/* ===========================================================
   Slam Duel — styles
   Mobile-first, compatible iOS Safari / Android Chrome & Firefox
   Palette violette (distincte du Slam coopératif, orange) pour bien
   signaler qu'il s'agit d'un jeu différent, même famille.
   =========================================================== */

:root {
  --bg-1: #f3ecfb; --bg-2: #e6d7f7; --surface: #ffffff; --surface-alt: #f7f1fc;
  --text: #241a30; --text-dim: #715a86; --primary: #7a1fb0; --primary-dark: #5c1786;
  --primary-contrast: #ffffff; --accent: #d9a441; --success: #2c9d63; --success-bg: #e2f5ea;
  --danger: #d13a3a; --danger-bg: #fdeaea; --border: #ddc7f0; --shadow: 0 8px 24px rgba(90, 20, 140, .14);
  --radius: 18px; --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
  --cell-empty: #ebdcf8; --me: #7a1fb0; --opp: #c2410c;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-1: #1b1024; --bg-2: #241430; --surface: #271a34; --surface-alt: #2f2040;
    --text: #f1e6fb; --text-dim: #c1a9d9; --primary: #b565f0; --primary-dark: #d494ff;
    --primary-contrast: #1b1024; --accent: #e8bd6a; --success: #57c98a; --success-bg: #133a26;
    --danger: #ff7a7a; --danger-bg: #3a1c1c; --border: #402a56; --shadow: 0 8px 28px rgba(0,0,0,.5);
    --cell-empty: #362447; --me: #c98aff; --opp: #ff9a5e;
  }
}

* { 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(40px + 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"], 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: 14.5px;
  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(122,31,176,.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-big { width: 100%; padding: 15px; font-size: 16px; }

.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; }

.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; }

.settings-row { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }
.section-title { margin: 4px 0 0; font-size: 20px; }
.section-title.center { text-align: center; }
.confetti-emoji { text-align: center; font-size: 52px; }
.round-footer { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }

.event-log { font-size: 12px; color: var(--text-dim); line-height: 1.7; max-height: 130px; overflow-y: auto; }
.log-entry:first-child { color: var(--text); font-weight: 600; }

/* ---------- En-tête duel (scores + chrono) ---------- */

.duel-header { display: flex; align-items: center; gap: 8px; }
.duel-header-mid { flex: 1; display: flex; flex-direction: column; gap: 4px; align-items: center; min-width: 0; }
.score-panel {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 12px; border-radius: 14px;
  background: var(--surface); border: 2px solid var(--border); min-width: 64px; flex-shrink: 0;
}
.score-panel.me { border-color: var(--me); }
.score-panel.opp { border-color: var(--opp); }
.score-panel-name { font-size: 10.5px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 80px; }
.score-panel-value { font-size: 20px; font-weight: 900; }
.score-panel.me .score-panel-value { color: var(--me); }
.score-panel.opp .score-panel-value { color: var(--opp); }
.score-panel.winning { animation: score-pop .5s ease; }
@keyframes score-pop { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }

.game-progress { font-size: 12px; font-weight: 700; color: var(--text-dim); }
.timer-bar-wrap { width: 100%; height: 8px; border-radius: 6px; background: var(--surface-alt); overflow: hidden; border: 1px solid var(--border); }
.timer-bar { height: 100%; background: var(--primary); width: 100%; transition: width .2s linear; }
.timer-bar.low { background: var(--danger); }
.game-timer-text { font-size: 11.5px; color: var(--text-dim); }

/* ---------- Grille ---------- */

.slam-grid-wrap { display: flex; justify-content: center; overflow-x: auto; padding: 6px 0; }
.slam-grid { display: grid; gap: 4px; background: transparent; }
.slam-cell {
  width: 38px; height: 38px; background: var(--surface); border: 1.5px solid var(--border); border-radius: 7px;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 17px; position: relative;
  transition: box-shadow .15s ease, border-color .15s ease, transform .1s ease;
}
.slam-cell.empty { background: var(--cell-empty); color: transparent; border-color: transparent; }
.slam-cell.filled { background: var(--success-bg); border-color: var(--success); color: var(--success); }
.slam-cell.active-word { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(122,31,176,.25); }
.slam-cell.has-number { cursor: pointer; }
.slam-cell.selectable { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(217,164,65,.35); animation: cell-pulse 1.8s ease-in-out infinite; }
.slam-cell.selectable:active { transform: scale(0.92); }
@keyframes cell-pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(217,164,65,.35); }
  50% { box-shadow: 0 0 0 5px rgba(217,164,65,.15); }
}
.slam-cell .cell-number { position: absolute; top: 1px; left: 2px; font-size: 8px; font-weight: 800; color: var(--text-dim); line-height: 1; }
.slam-cell .cell-arrow { position: absolute; font-size: 9px; font-weight: 900; color: var(--border); line-height: 1; }
.slam-cell .cell-arrow.dir-h { top: 2px; right: 2px; }
.slam-cell .cell-arrow.dir-v { bottom: 2px; right: 2px; }
.slam-cell .cell-arrow.ready { color: var(--primary); }

/* ---------- Panneau de phase ---------- */

#phase-panel h3 { margin: 0 0 8px; font-size: 15.5px; }
.question-text { font-size: 16px; font-weight: 600; margin: 0 0 14px; line-height: 1.4; }

.buzz-row { display: flex; gap: 10px; }
.buzz-side { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.buzz-side .who { font-size: 11.5px; font-weight: 700; text-transform: uppercase; color: var(--text-dim); text-align: center; }
.btn-buzz {
  width: 100%; padding: 18px 10px; border-radius: 16px; border: none; font-weight: 900; font-size: 15px;
  color: #fff; cursor: pointer; transition: transform .08s ease, opacity .2s ease;
  background: linear-gradient(135deg, var(--me), #a24bd9);
  box-shadow: 0 6px 18px rgba(122,31,176,.4);
}
.btn-buzz:active { transform: scale(0.95); }
.btn-buzz[disabled] { opacity: .4; cursor: default; transform: none; animation: none; }
.btn-buzz.locked { background: var(--danger); animation: none; }
.lock-countdown { text-align: center; font-size: 12.5px; font-weight: 700; color: var(--danger); }
.buzz-input { width: 100%; text-align: center; text-transform: uppercase; font-weight: 700; letter-spacing: .04em; margin-bottom: 6px; }
.opp-status { text-align: center; font-size: 12.5px; color: var(--text-dim); padding: 12px 0; }

.choose-list { display: flex; flex-direction: column; gap: 8px; }
.choose-option {
  display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-radius: 12px;
  border: 1.5px solid var(--border); background: var(--surface-alt); cursor: pointer; font-weight: 700;
}
.choose-option:active { transform: scale(0.98); }
.choose-option .len { font-size: 12px; color: var(--text-dim); font-weight: 600; }

.fill-clue { font-size: 15px; font-weight: 700; margin: 0 0 4px; }
.fill-meta { font-size: 12.5px; color: var(--text-dim); margin: 0 0 10px; }
.fill-input-row { display: flex; gap: 8px; }
.fill-input-row input { flex: 1; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }
.turn-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 800; padding: 4px 10px; border-radius: 20px; margin-bottom: 10px; }
.turn-badge.me { background: rgba(122,31,176,.15); color: var(--me); }
.turn-badge.opp { background: rgba(194,65,12,.15); color: var(--opp); }

/* ---------- Fin de partie ---------- */

.summary-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.summary-row:last-child { border-bottom: none; }
.summary-row b { font-size: 16px; }
.summary-row.winner b { color: var(--success); }

/* ---------- Retour visuel bonne/mauvaise réponse + victoire ---------- */

.flash-overlay { position: fixed; inset: 0; pointer-events: none; z-index: 70; opacity: 0; }
.flash-overlay.flash-correct { background: radial-gradient(circle, rgba(44,157,99,.28), transparent 70%); animation: flash-pop .55s ease-out; }
.flash-overlay.flash-wrong { background: radial-gradient(circle, rgba(209,58,58,.3), transparent 70%); animation: flash-pop .5s ease-out; }
@keyframes flash-pop { 0% { opacity: 0; } 20% { opacity: 1; } 100% { opacity: 0; } }

.confetti-layer { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 71; }
.confetti-piece { position: absolute; top: -20px; width: 9px; height: 14px; opacity: 0; animation: confetti-fall 2.4s ease-in forwards; }
@keyframes confetti-fall {
  0% { opacity: 1; transform: translateY(0) rotate(0deg); }
  100% { opacity: 0.9; transform: translateY(110vh) rotate(540deg); }
}
.firework-particle { position: absolute; width: 6px; height: 6px; border-radius: 50%; opacity: 0; animation: firework-burst 1s ease-out forwards; }
@keyframes firework-burst {
  0% { opacity: 1; transform: translate(0, 0) scale(1); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(.3); }
}

.toast { position: fixed; top: calc(14px + var(--safe-top)); left: 50%; transform: translateX(-50%) translateY(-140%); 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.toast-danger { background: var(--danger); }
.toast.toast-success { background: var(--success); }
.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); }

/* ---------- Pop-up de révélation (personne n'a trouvé la lettre) ----------
   Même mécanique que le Slam coopératif (voir ../slam/public/style.css) :
   plus visible qu'un toast, durée réglable par l'hôte (`revealPopupMs`). */
/* pointer-events: none en permanence — une nouvelle question démarre
   souvent tout de suite après (question-timeout) : le pop-up ne doit
   jamais bloquer la saisie du tour déjà en cours en dessous. */
.reveal-popup {
  position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: rgba(0, 0, 0, .45); opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.reveal-popup.show { opacity: 1; }
.reveal-popup-card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px 24px; max-width: 420px; width: 100%; text-align: center;
  border-top: 6px solid var(--danger); transform: scale(.92); transition: transform .2s ease;
}
.reveal-popup.show .reveal-popup-card { transform: scale(1); }
.reveal-popup.reveal-success .reveal-popup-card { border-top-color: var(--success); }
.reveal-popup-title { font-size: 15px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; }
.reveal-popup-answer { font-size: 22px; font-weight: 800; color: var(--text); margin-bottom: 6px; }
.reveal-popup-explanation { font-size: 15px; color: var(--text-dim); line-height: 1.4; }

@media (min-width: 640px) {
  .brand h1 { font-size: 38px; }
  .slam-cell { width: 36px; height: 36px; font-size: 16px; }
}

/* Salon d'attente unifié visuellement sur le modèle du 8-américain */
.lobby-card { text-align: center; }
.lobby-card h2 { text-transform: none; font-size: 20px; color: var(--text); letter-spacing: normal; }
.lobby-card .room-code-label {
  text-align: center; color: var(--text-dim); margin: 10px 0 6px;
  font-size: 13px; text-transform: none;
}
.lobby-card .room-code-badge { justify-content: center; margin: 0 auto 4px; width: fit-content; }
.players-title {
  margin: 20px 0 10px; font-size: 13px; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .04em; text-align: left;
}
.lobby-card .player-list,
.lobby-card #host-settings,
.lobby-card #guest-waiting,
.lobby-card #path-picker { text-align: left; }
.lobby-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }
.lobby-actions .icon-btn {
  width: auto; height: auto; padding: 13px 18px; border-radius: 14px;
  font-size: 15px; font-weight: 700; background: transparent; color: var(--text-dim);
  border: 1.5px solid var(--border);
}
