/* ═══════════════════════════════════════════════════════════
   GAMIFY — Player Join Page (play.html)
   Mobile-first. Dark theme. Touch-friendly.
   ═══════════════════════════════════════════════════════════ */

:root {
  --play-bg: var(--bg-dark, #0F172A);
  --play-surface: #1E293B;
  --play-text: #F1F5F9;
  --play-muted: #CBD5E1;
  --play-accent: #F43F5E;           /* brighter rose — AA (4.5:1) on #0F172A and #1E293B */
  --play-accent-hover: #E11D48;
  --play-success: var(--text-success, #10B981); /* brighter green for dark bg AA */
  --play-error-text: #FCA5A5;       /* AA-friendly error text on dark bg */
  --play-border: rgba(255,255,255,.08);
  --play-focus: #22D3EE;
  --play-radius: 12px;
}

body {
  background: var(--play-bg);
  color: var(--play-text);
  font-family: "DM Sans", system-ui, -apple-system, sans-serif;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── Focus styles (keyboard accessibility) ── */
button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid var(--play-focus);
  outline-offset: 2px;
}

/* ── Join screen ─────────────────────── */
.play-join { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; }
.play-join-card {
  background: var(--play-surface);
  border-radius: var(--play-radius);
  padding: 32px 24px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.play-brand { font-size: 28px; font-weight: 800; color: var(--play-accent); margin-bottom: 4px; letter-spacing: -0.5px; }
.play-tagline { font-size: 13px; color: var(--play-muted); margin-bottom: 28px; }

.play-field { margin-bottom: 16px; text-align: left; }
.play-field label { display: block; font-size: 11px; font-weight: 700; color: var(--play-muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px; }
.play-field input {
  width: 100%; padding: 14px 16px;
  border: 2px solid var(--play-border);
  border-radius: 10px;
  background: var(--play-bg);
  color: var(--play-text);
  font-size: 18px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
  min-height: 48px;
}
.play-field input:focus { border-color: var(--play-accent); }
.play-field input:focus-visible { outline: 3px solid var(--play-focus); outline-offset: 2px; }
.play-field input.code-input { text-align: center; font-size: 28px; font-weight: 800; letter-spacing: 8px; text-transform: uppercase; }

.play-btn {
  width: 100%; padding: 16px; min-height: 48px;
  border: none; border-radius: 10px;
  background: var(--play-accent); color: #fff;
  font-size: 18px; font-weight: 700;
  cursor: pointer; font-family: inherit;
  transition: background .15s;
  margin-top: 8px;
}
.play-btn:hover { background: var(--play-accent-hover); }
.play-btn:focus-visible { outline: 3px solid var(--play-focus); outline-offset: 3px; }
.play-btn:disabled { opacity: .5; cursor: default; }

.play-error {
  color: var(--play-error-text);
  font-size: 14px;
  font-weight: 600;
  margin-top: 12px;
  min-height: 20px;
}

/* ── Lobby ────────────────────────────── */
.play-lobby { flex: 1; display: none; flex-direction: column; align-items: center; padding: 24px; text-align: center; }
.play-lobby.active { display: flex; }
.play-room-code { font-size: 14px; color: var(--play-muted); margin-bottom: 8px; }
.play-room-code span { font-weight: 800; color: var(--play-accent); font-size: 18px; letter-spacing: 2px; }
.play-your-name { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.play-waiting { font-size: 15px; color: var(--play-muted); margin-bottom: 24px; }
.play-waiting .dot { animation: dot-pulse 1.4s infinite both; }
.play-waiting .dot:nth-child(2) { animation-delay: .2s; }
.play-waiting .dot:nth-child(3) { animation-delay: .4s; }
@keyframes dot-pulse { 0%, 80%, 100% { opacity: .3 } 40% { opacity: 1 } }
@media (prefers-reduced-motion: reduce) {
  .play-waiting .dot { animation: none; opacity: 0.6; }
}

/* Team picker */
.play-teams { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; width: 100%; max-width: 400px; margin-bottom: 20px; }
.play-team-btn {
  padding: 14px 12px; min-height: 48px;
  border-radius: 10px;
  border: 3px solid transparent;
  background: var(--play-surface);
  font-size: 15px; font-weight: 700;
  cursor: pointer; font-family: inherit;
  color: #fff;
  transition: all .15s;
}
.play-team-btn:hover { transform: scale(1.03); }
.play-team-btn:focus-visible { outline: 3px solid var(--play-focus); outline-offset: 3px; }
.play-team-btn.picked { border-color: #fff; box-shadow: 0 0 20px rgba(255,255,255,.15); }
.play-player-count { font-size: 13px; color: var(--play-muted); margin-top: auto; padding: 12px; }

/* ── Game screen ─────────────────────── */
.play-game { flex: 1; display: none; flex-direction: column; padding: 16px; }
.play-game.active { display: flex; }
.play-game-header { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; margin-bottom: 12px; border-bottom: 1px solid var(--play-border); }
.play-game-type { font-size: 12px; font-weight: 700; color: var(--play-muted); text-transform: uppercase; letter-spacing: 1px; }
.play-game-score { font-size: 20px; font-weight: 800; color: var(--play-accent); }

/* Question display */
.play-question { font-size: 20px; font-weight: 700; line-height: 1.4; margin-bottom: 20px; text-align: center; padding: 0 8px; }
.play-options { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.play-opt {
  padding: 16px; min-height: 48px;
  border-radius: 10px;
  border: 2px solid var(--play-border);
  background: var(--play-surface);
  font-size: 16px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  color: var(--play-text);
  text-align: left;
  transition: all .15s;
  -webkit-tap-highlight-color: transparent;
}
.play-opt:active { transform: scale(0.98); }
.play-opt:focus-visible { outline: 3px solid var(--play-focus); outline-offset: 2px; }
.play-opt.selected { border-color: var(--play-accent); background: rgba(244,63,94,.15); }
.play-opt.correct { border-color: var(--play-success); background: rgba(16,185,129,.2); color: #6EE7B7; }
.play-opt.wrong { border-color: var(--play-accent); background: rgba(244,63,94,.2); color: #FDA4AF; }
.play-opt:disabled { pointer-events: none; opacity: 0.85; }

.play-timer { height: 4px; background: var(--play-border); border-radius: 2px; margin-bottom: 16px; overflow: hidden; }
.play-timer-fill { height: 100%; background: var(--play-accent); border-radius: 2px; transition: width .1s linear; width: 100%; }

/* Buzz button */
.play-buzz { flex: 1; display: none; align-items: center; justify-content: center; padding: 24px; }
.play-buzz.active { display: flex; }
.play-buzz-btn {
  width: 200px; height: 200px;
  border-radius: 50%;
  border: none;
  background: var(--play-accent);
  color: #fff;
  font-size: 32px; font-weight: 900;
  cursor: pointer; font-family: inherit;
  box-shadow: 0 8px 32px rgba(244,63,94,.4);
  transition: all .1s;
  -webkit-tap-highlight-color: transparent;
}
.play-buzz-btn:active { transform: scale(0.92); box-shadow: 0 4px 16px rgba(244,63,94,.3); }
.play-buzz-btn:focus-visible { outline: 4px solid var(--play-focus); outline-offset: 6px; }
.play-buzz-btn:disabled { opacity: .3; transform: none; box-shadow: none; cursor: default; }

/* Explanation / result */
.play-result { text-align: center; padding: 16px; margin-top: auto; }
.play-result-text { font-size: 16px; color: var(--play-muted); font-style: italic; }
.play-points { font-size: 36px; font-weight: 900; color: var(--play-success); margin-bottom: 4px; }
.play-points.zero { color: var(--play-muted); }

/* ── Game over ────────────────────────── */
.play-gameover { flex: 1; display: none; align-items: center; justify-content: center; flex-direction: column; text-align: center; padding: 24px; }
.play-gameover.active { display: flex; }
.play-gameover-title { font-size: 28px; font-weight: 900; margin-bottom: 8px; }
.play-gameover-score { font-size: 56px; font-weight: 900; color: var(--play-accent); }
.play-gameover-rank { font-size: 18px; color: var(--play-muted); margin-top: 8px; }
.play-gameover-btn {
  margin-top: 32px; padding: 14px 32px; min-height: 48px;
  border: 2px solid var(--play-border);
  border-radius: 10px;
  background: transparent;
  color: var(--play-text);
  font-size: 15px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.play-gameover-btn:focus-visible { outline: 3px solid var(--play-focus); outline-offset: 3px; }

/* Host disconnected banner */
.play-disconnected {
  display: none;
  background: rgba(244,63,94,.15);
  border: 1px solid var(--play-accent);
  border-radius: 8px;
  padding: 10px 16px;
  text-align: center;
  font-size: 13px;
  color: var(--play-error-text);
  margin-bottom: 12px;
  font-weight: 600;
}
.play-disconnected.active { display: block; }
