/* ===========================================================
   Cluedo en ligne — styles
   Mobile-first, compatible iOS Safari / Android Chrome & Firefox
   =========================================================== */

:root {
  --bg-1: #f4f1fb; --bg-2: #e6def6; --surface: #ffffff; --surface-alt: #f5f2fb;
  --text: #241c38; --text-dim: #6d6284; --primary: #5a3aa8; --primary-dark: #432b80;
  --primary-contrast: #ffffff; --accent: #c99b3a; --success: #2c9d63; --success-bg: #e2f5ea;
  --danger: #b8342f; --danger-bg: #fbe8e6; --border: #e4defa; --shadow: 0 8px 24px rgba(60, 30, 100, .14);
  --radius: 18px; --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-1: #150f22; --bg-2: #1c1430; --surface: #211a38; --surface-alt: #271f42;
    --text: #f1ecfb; --text-dim: #b3a6cf; --primary: #a685f0; --primary-dark: #c3a8ff;
    --primary-contrast: #170f28; --accent: #e0b559; --success: #57c98a; --success-bg: #133a26;
    --danger: #ff8f7a; --danger-bg: #3a1c1a; --border: #362a5c; --shadow: 0 8px 28px rgba(0,0,0,.5);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; min-height: 100dvh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text); background: radial-gradient(circle at 20% -10%, var(--bg-2), var(--bg-1) 60%);
  -webkit-font-smoothing: antialiased; touch-action: manipulation; overscroll-behavior-y: contain;
}
button, input, select { font-family: inherit; font-size: 16px; }

.app { max-width: 560px; margin: 0 auto; padding: calc(14px + var(--safe-top)) 12px calc(100px + var(--safe-bottom)); min-height: 100dvh; }
.view { display: none; animation: fade-in .25s ease; }
.view.active { display: flex; flex-direction: column; gap: 12px; }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.hidden { display: none !important; }

.brand { text-align: center; margin-top: 8px; }
.brand-emoji { font-size: 48px; line-height: 1; }
.brand h1 { margin: 4px 0 2px; font-size: 32px; letter-spacing: -0.02em; }
.subtitle { margin: 0; color: var(--text-dim); font-size: 15px; }

.card { background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); border: 1px solid var(--border); }
.card h2 { margin: 0 0 12px; font-size: 15px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }
.field > span { font-size: 13px; color: var(--text-dim); font-weight: 600; }

/* Case à cocher inline (Mode Bénéficiaire AAH, voir public/shared/AAH_MODE.md
   — motif dupliqué depuis games/petit-bac/public/style.css, chaque jeu de
   cette plateforme restant autonome pour son propre CSS). */
.field-inline { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-dim); margin: 12px 0; }
.field-inline input { width: 20px; height: 20px; flex-shrink: 0; }
input[type="text"], input[type="number"], select {
  padding: 12px 13px; border-radius: 12px; border: 1.5px solid var(--border);
  background: var(--surface-alt); color: var(--text); outline: none; transition: border-color .15s ease; width: 100%;
}
input:focus, select:focus { border-color: var(--primary); }
#input-code { text-transform: uppercase; letter-spacing: 0.15em; font-weight: 700; }

.btn {
  border: none; border-radius: 14px; padding: 12px 16px; font-weight: 700; font-size: 15px;
  cursor: pointer; transition: transform .08s ease, opacity .15s ease; -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }
.btn[disabled] { opacity: .45; cursor: default; transform: none; }
.btn-primary { background: var(--primary); color: var(--primary-contrast); box-shadow: 0 6px 16px rgba(90,58,168,.35); }
.btn-primary.danger { background: var(--danger); box-shadow: 0 6px 16px rgba(184,52,47,.35); }
.btn-secondary { background: var(--surface-alt); color: var(--primary); border: 1.5px solid var(--primary); }
.btn-ghost { background: transparent; color: var(--text-dim); border: 1.5px solid var(--border); }
.btn-ghost.danger { color: var(--danger); border-color: var(--danger); }
.btn-big { width: 100%; padding: 15px; font-size: 16px; }
.action-row { display: flex; gap: 10px; flex-wrap: wrap; }
.action-row .btn { flex: 1; min-width: 110px; }

.landing-actions { display: flex; flex-direction: column; }
.landing-actions .btn-primary { margin-bottom: 4px; }
.divider { text-align: center; color: var(--text-dim); font-size: 13px; margin: 14px 0; position: relative; }
.divider::before, .divider::after { content: ""; position: absolute; top: 50%; width: 40%; height: 1px; background: var(--border); }
.divider::before { left: 0; } .divider::after { right: 0; }
.hint { color: var(--text-dim); font-size: 13px; text-align: center; line-height: 1.5; margin: 0; }
.hint.tight { text-align: left; margin-top: 4px; }
.hint.center { text-align: center; padding: 10px; }

.topbar { display: flex; align-items: center; justify-content: space-between; }
.icon-btn { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; width: 40px; height: 40px; font-size: 17px; cursor: pointer; display: flex; align-items: center; justify-content: center; text-decoration: none; color: var(--text); }
.icon-btn.small { width: 30px; height: 30px; font-size: 13px; }
.room-code-badge { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 7px 11px; }
.room-code-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; }
.room-code-value { font-weight: 800; letter-spacing: 0.15em; font-size: 17px; color: var(--primary); }

.player-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.player-row { display: flex; align-items: center; gap: 9px; padding: 9px 11px; border-radius: 12px; background: var(--surface-alt); }
.player-row .dot { width: 9px; height: 9px; border-radius: 50%; background: #bbb; flex-shrink: 0; }
.player-row .dot.online { background: var(--success); }
.player-row .name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-row .host-tag { font-size: 11px; background: var(--primary); color: var(--primary-contrast); padding: 2px 7px; border-radius: 20px; }
.player-row .wins-tag { font-size: 12px; color: var(--text-dim); white-space: nowrap; }
.player-row .suspect-tag { font-size: 11px; color: var(--primary); font-weight: 700; white-space: nowrap; }

.suspect-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.suspect-choice {
  padding: 10px 12px; border-radius: 12px; border: 1.5px solid var(--border);
  background: var(--surface-alt); color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer;
}
.suspect-choice.selected { border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 3px rgba(90,58,168,.15); color: var(--primary); }
.suspect-choice:disabled { opacity: .3; cursor: not-allowed; }

.section-title { margin: 4px 0 0; font-size: 20px; }
.section-title.center { text-align: center; }
.results-list { display: flex; flex-direction: column; gap: 10px; }
.result-row { display: flex; align-items: center; gap: 10px; background: var(--surface); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); border: 1px solid var(--border); }
.result-row .rank { font-weight: 800; color: var(--text-dim); width: 22px; text-align: center; flex-shrink: 0; }
.result-row.first { border-color: var(--primary); }
.result-row .name { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-row .wins-tag { font-size: 12px; color: var(--text-dim); white-space: nowrap; }
.confetti-emoji { text-align: center; font-size: 52px; }
.round-footer { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }

.solution-reveal {
  background: var(--surface); border-radius: 16px; padding: 16px; box-shadow: var(--shadow);
  border: 1.5px solid var(--accent); text-align: center; font-weight: 700; font-size: 14px; line-height: 1.6;
}

/* ---------- Bande de joueurs ---------- */

.players-strip { display: flex; gap: 8px; overflow-x: auto; padding: 2px; scrollbar-width: none; }
.players-strip::-webkit-scrollbar { display: none; }
.player-chip {
  flex-shrink: 0; display: flex; align-items: center; gap: 6px; padding: 7px 11px; border-radius: 14px;
  background: var(--surface); border: 2px solid var(--border); font-size: 12px; font-weight: 700;
}
.player-chip.current-turn { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(90,58,168,.15); }
.player-chip.eliminated { opacity: .4; text-decoration: line-through; }
.player-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: #bbb; }
.player-chip .dot.online { background: var(--success); }

/* ---------- Onglets ---------- */

.tabs { display: flex; gap: 6px; background: var(--surface); border-radius: 14px; padding: 4px; border: 1px solid var(--border); }
.tab-btn { position: relative; flex: 1; border: none; background: transparent; border-radius: 10px; padding: 9px 6px; font-weight: 700; font-size: 12.5px; color: var(--text-dim); cursor: pointer; }
.tab-btn.active { background: var(--primary); color: var(--primary-contrast); }
.tab-badge {
  position: absolute; top: 2px; right: 6px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--danger); box-shadow: 0 0 0 2px var(--surface); animation: badgePulse 1.4s ease-in-out infinite;
}
@keyframes badgePulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.3); } }
.tab-panel { display: none; flex-direction: column; gap: 10px; }
.tab-panel.active { display: flex; }

.action-panel { background: var(--surface); border-radius: 14px; padding: 14px; box-shadow: var(--shadow); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.action-panel p { margin: 0; font-size: 14px; }
.turn-banner { text-align: center; font-weight: 800; font-size: 14.5px; padding: 9px 12px; background: var(--surface); border-radius: 14px; border: 1px solid var(--border); box-shadow: var(--shadow); }
.turn-banner.my-turn { background: var(--primary); color: var(--primary-contrast); }

.dice-display { display: flex; justify-content: center; gap: 14px; font-size: 42px; }
.die { display: inline-block; }
.die.rolling { animation: dieShake .14s ease-in-out infinite; }
@keyframes dieShake { 0%, 100% { transform: rotate(-8deg) scale(1); } 50% { transform: rotate(8deg) scale(1.12); } }

.chip-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-choice {
  padding: 10px 14px; border-radius: 20px; border: 1.5px solid var(--primary);
  background: var(--surface-alt); color: var(--primary); font-weight: 700; font-size: 13px; cursor: pointer;
}
.chip-choice:active { background: var(--primary); color: var(--primary-contrast); }

.event-log { font-size: 12px; color: var(--text-dim); line-height: 1.7; max-height: 140px; overflow-y: auto; background: var(--surface); border-radius: 12px; padding: 10px 12px; border: 1px solid var(--border); }
.log-entry:first-child { color: var(--text); font-weight: 600; }
.log-entry-enter { animation: logIn .32s cubic-bezier(.22,1,.36,1); }
@keyframes logIn { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* ---------- Plateau (grille 3x3 des pièces) ---------- */

.board-wrap { width: 100%; }
.cluedo-board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.room-cell {
  aspect-ratio: 1 / 1; background: var(--surface); border: 1.5px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; padding: 6px; cursor: pointer; text-align: center; position: relative;
}
.room-cell.reachable { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(90,58,168,.18); }
.room-cell.current { background: var(--surface-alt); border-color: var(--accent); }
.room-cell .room-name { font-size: 10.5px; font-weight: 700; line-height: 1.2; }
.room-cell .room-tokens { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; }
.room-token { font-size: 15px; }

/* ---------- Modales ---------- */

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; z-index: 70; padding: 20px; }
.modal-card { background: var(--surface); border-radius: 18px; padding: 18px; max-width: 340px; width: 100%; box-shadow: var(--shadow); }
.modal-card h3 { margin: 0 0 8px; }
.modal-card table { width: 100%; font-size: 12.5px; border-collapse: collapse; margin: 8px 0; }
.modal-card td { padding: 3px 0; border-bottom: 1px dashed var(--border); }
.modal-card .close-btn, .modal-card .close-modal { margin-top: 4px; width: 100%; }

/* ---------- Carnet d'enquête ---------- */

.my-hand { display: flex; flex-wrap: wrap; gap: 8px; }
.hand-card {
  padding: 10px 12px; border-radius: 12px; background: var(--surface-alt); border: 1px solid var(--border);
  font-size: 12px; font-weight: 600; text-align: center;
}
.hand-card .hc-type { display: block; font-size: 9px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }

.my-reveals { display: flex; flex-direction: column; gap: 8px; }
.reveal-row { padding: 9px 10px; border-radius: 12px; background: var(--surface-alt); font-size: 12.5px; }
.reveal-row strong { color: var(--primary); }

.notebook { display: flex; flex-direction: column; gap: 14px; }
.notebook-group h4 { margin: 0 0 8px; font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em; }
.notebook-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.notebook-item {
  padding: 8px 11px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--surface-alt);
  font-size: 12px; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 5px;
}
.notebook-item.state-out { opacity: .5; text-decoration: line-through; border-color: var(--text-dim); }
.notebook-item.state-suspect { border-color: var(--accent); background: rgba(201,155,58,.15); }
.notebook-item.state-mine { border-color: var(--success); }

/* ---------- Emoji / réactions / toast ---------- */

.react-fab {
  position: fixed; right: calc(14px + env(safe-area-inset-right, 0px)); bottom: calc(14px + var(--safe-bottom));
  width: 46px; height: 46px; border-radius: 50%; border: none;
  background: var(--primary); color: var(--primary-contrast); font-size: 20px;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  box-shadow: 0 6px 18px rgba(0,0,0,.3); z-index: 45;
}
.react-fab:active { transform: scale(0.92); }

.reaction-picker {
  position: fixed; right: calc(14px + env(safe-area-inset-right, 0px)); bottom: calc(68px + var(--safe-bottom));
  background: rgba(20, 20, 30, 0.92); border-radius: 22px; padding: 8px;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 4px;
  max-width: min(80vw, 230px); z-index: 46; box-shadow: var(--shadow);
}
.reaction-choice { border: none; background: none; font-size: 20px; padding: 6px; cursor: pointer; border-radius: 50%; line-height: 1; }
.reaction-choice:active { background: rgba(255,255,255,0.18); transform: scale(1.15); }

#reaction-layer { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 60; }
.floating-reaction { position: absolute; bottom: 90px; display: flex; flex-direction: column; align-items: center; animation: float-up 2.6s ease-out forwards; }
.floating-reaction .emoji { font-size: 40px; filter: drop-shadow(0 4px 8px rgba(0,0,0,.25)); }
.floating-reaction .who { font-size: 11px; font-weight: 700; color: var(--text-dim); background: var(--surface); padding: 2px 8px; border-radius: 20px; margin-top: 2px; }
@keyframes float-up {
  0% { opacity: 0; transform: translateY(20px) scale(.6) rotate(-6deg); }
  15% { opacity: 1; transform: translateY(-10px) scale(1.05) rotate(3deg); }
  85% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-260px) scale(1) rotate(-4deg); }
}

.toast { position: fixed; top: calc(14px + var(--safe-top)); left: 50%; transform: translateX(-50%) translateY(-140%); background: var(--danger); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 600; font-size: 14px; box-shadow: var(--shadow); z-index: 80; transition: transform .25s ease; max-width: 90%; text-align: center; }
.toast.show { transform: translateX(-50%) translateY(0); }
.connection-banner { position: fixed; top: calc(14px + var(--safe-top)); left: 50%; transform: translateX(-50%); background: #333; color: #fff; padding: 8px 16px; border-radius: 20px; font-size: 13px; z-index: 80; box-shadow: var(--shadow); }

#action-banner-layer {
  position: fixed; top: calc(14px + var(--safe-top)); left: 50%; transform: translateX(-50%);
  z-index: 75; display: flex; flex-direction: column; align-items: center; gap: 6px;
  pointer-events: none; width: 90%; max-width: 380px;
}
.action-banner {
  display: flex; align-items: center; gap: 10px; background: var(--surface); color: var(--text);
  border: 1.5px solid var(--primary); border-radius: 14px; padding: 10px 16px;
  box-shadow: var(--shadow); font-size: 13.5px; font-weight: 600;
  opacity: 0; transform: translateY(-16px) scale(.95); transition: opacity .25s ease, transform .25s ease;
}
.action-banner.show { opacity: 1; transform: translateY(0) scale(1); }
.action-banner-icon { font-size: 20px; flex-shrink: 0; }

@media (min-width: 640px) {
  .brand h1 { font-size: 38px; }
}
