/* DOORS — chamber aesthetic. Near-black ground, warm serif type, gold accents.
   Atmosphere through gradients only; no images, no saturated color. */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

:root {
  --bg:           rgb(5, 5, 8);
  --text:         rgba(255, 250, 240, 0.92);
  --text-dim:     rgba(255, 250, 240, 0.45);
  --text-faint:   rgba(255, 250, 240, 0.18);
  --surface:      rgba(38, 30, 20, 0.55);
  --surface-deep: rgba(22, 17, 10, 0.80);
  --gold:         rgba(210, 172, 50, 0.90);
  --gold-glow:    rgba(210, 172, 50, 0.30);
  --amber:        rgba(200, 130, 40, 0.70);
  --red-alert:    rgba(220, 95, 70, 0.95);
  --font: 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
}

html { background: var(--bg); }
html, body { height: 100%; }

body {
  font-family: var(--font);
  background:
    radial-gradient(ellipse 60% 40% at 50% 0%, rgba(255,248,230,0.035) 0%, transparent 70%),
    radial-gradient(ellipse at center, rgba(12,10,18,0) 0%, rgba(2,2,4,0.6) 100%),
    var(--bg);
  /* Per-room ambient overlay set by JS via --room-ambient */
  background-color: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Ambient overlay layer — composited above base background by JS */
body::after {
  content: '';
  position: fixed; inset: 0;
  background: radial-gradient(ellipse 80% 60% at 50% 20%, var(--room-ambient, transparent), transparent 70%);
  pointer-events: none;
  z-index: 0;
  transition: background 1.5s ease;
}

#app {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── Screens ─────────────────────────────────────────────────── */
.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  width: 100%;
  min-height: 100dvh;
  padding: 1.5rem 1.25rem;
  padding-top: max(1.5rem, env(safe-area-inset-top));
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
  padding-left: max(1.25rem, env(safe-area-inset-left));
  padding-right: max(1.25rem, env(safe-area-inset-right));
}
.screen.active { display: flex; }

/* ── Back / Leave button ────────────────────────────────────── */
.btn-home {
  position: fixed;
  top: max(0.75rem, env(safe-area-inset-top));
  left: max(0.75rem, env(safe-area-inset-left));
  z-index: 20;
  padding: 0.4rem 0.8rem;
  font: inherit;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  background: rgba(5, 5, 8, 0.7);
  border: 1px solid rgba(255, 250, 240, 0.12);
  border-radius: 999px;
  text-decoration: none;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: color 0.2s, border-color 0.2s;
}
.btn-home:hover, .btn-home:focus-visible {
  color: var(--gold);
  border-color: var(--gold);
  outline: none;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  font: inherit;
  font-weight: 500;
  letter-spacing: 0.1em;
  padding: 0.85rem 1.25rem;
  border-radius: 4px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.18s, color 0.18s, border-color 0.18s, opacity 0.18s;
  text-align: center;
}
.btn:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-primary {
  background: rgba(38, 30, 20, 0.80);
  color: var(--gold);
  border-color: rgba(210, 172, 50, 0.45);
}
.btn-primary:hover:not(:disabled), .btn-primary:focus-visible:not(:disabled) {
  background: rgba(50, 40, 25, 0.90);
  border-color: var(--gold);
  outline: none;
}

.btn-secondary {
  background: transparent;
  color: var(--text-dim);
  border-color: rgba(255, 250, 240, 0.2);
}
.btn-secondary:hover:not(:disabled), .btn-secondary:focus-visible:not(:disabled) {
  color: var(--text);
  border-color: rgba(255, 250, 240, 0.45);
  outline: none;
}

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border-color: rgba(255, 250, 240, 0.12);
  font-size: 0.8rem;
  letter-spacing: 0.12em;
}
.btn-ghost:hover:not(:disabled), .btn-ghost:focus-visible:not(:disabled) {
  color: var(--text);
  outline: none;
}

/* ── Inputs ──────────────────────────────────────────────────── */
.input {
  font: inherit;
  width: 100%;
  padding: 0.85rem 1rem;
  background: rgba(22, 17, 10, 0.60);
  color: var(--text);
  border: 1px solid rgba(255, 250, 240, 0.12);
  border-radius: 4px;
  outline: none;
  transition: border-color 0.18s;
}
.input:focus { border-color: rgba(210, 172, 50, 0.55); }
.input::placeholder { color: var(--text-faint); }

.input-code {
  text-align: center;
  letter-spacing: 0.6em;
  text-transform: uppercase;
  font-weight: 600;
  font-size: 1.15rem;
}

/* ── Landing ─────────────────────────────────────────────────── */
#landing-screen { align-items: center; justify-content: center; }

.landing-inner {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.landing-header { text-align: center; }

.game-title {
  font-size: 3rem;
  font-weight: 400;
  letter-spacing: 0.35em;
  color: var(--text);
  text-shadow: 0 0 40px rgba(210,172,50,0.15);
}
.game-subtitle {
  font-size: 0.78rem;
  letter-spacing: 0.15em;
  color: var(--text-dim);
  margin-top: 0.35rem;
}

.form-stack { display: flex; flex-direction: column; gap: 0.75rem; }

.divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-faint);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255, 250, 240, 0.08);
}

.join-row { display: flex; gap: 0.6rem; }
.join-row .input-code { flex: 1; }
.join-row .btn { white-space: nowrap; padding-left: 1rem; padding-right: 1rem; }

.error-text { color: rgba(200, 130, 40, 0.85); font-size: 0.78rem; min-height: 1.2em; text-align: center; letter-spacing: 0.04em; }

/* ── ? button ────────────────────────────────────────────────── */
.btn-rules {
  background: none;
  border: 1px solid rgba(255, 250, 240, 0.14);
  border-radius: 50%;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  font: inherit;
  font-size: 0.72rem;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.btn-rules:hover, .btn-rules:focus-visible {
  color: var(--gold);
  border-color: rgba(210, 172, 50, 0.4);
  outline: none;
}

.lobby-rules-btn {
  position: fixed;
  top: max(0.75rem, env(safe-area-inset-top));
  right: max(0.75rem, env(safe-area-inset-right));
  z-index: 20;
}

.game-rules-btn {
  position: absolute;
  right: max(0.5rem, env(safe-area-inset-right));
}

/* ── Lobby ───────────────────────────────────────────────────── */
#lobby-screen { align-items: center; justify-content: center; }

.lobby-inner {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
  padding-top: 3rem;
}

.lobby-mode-hint {
  font-size: 0.60rem;
  letter-spacing: 0.13em;
  color: var(--text-faint);
  text-transform: uppercase;
  text-align: center;
  margin-top: -0.5rem;
}

.room-code-btn {
  font: inherit;
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: 0.5em;
  color: var(--text);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  transition: color 0.18s;
}
.room-code-btn:hover { color: var(--gold); }

.lobby-players {
  width: 100%;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.lobby-player-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem 0.9rem;
  background: var(--surface);
  border-radius: 3px;
  font-size: 0.9rem;
  letter-spacing: 0.06em;
  color: var(--text);
}
.lobby-player-item.empty {
  color: var(--text-faint);
  font-style: italic;
  background: rgba(22, 17, 10, 0.30);
}
.lobby-player-item.optional-seat {
  background: transparent;
  border: 1px dashed rgba(255, 250, 240, 0.08);
  font-size: 0.78rem;
}
.lobby-player-item.optional-seat .lobby-player-dot {
  background: transparent;
  border: 1px solid rgba(255, 250, 240, 0.18);
}
.lobby-player-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--gold);
  flex-shrink: 0;
}
.lobby-player-item.empty .lobby-player-dot { background: var(--text-faint); }
.lobby-host-badge {
  margin-left: auto;
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  color: var(--gold);
  opacity: 0.7;
}

.muted-text { color: var(--text-dim); font-size: 0.78rem; letter-spacing: 0.06em; }

/* ── Game screen ─────────────────────────────────────────────── */
#game-screen {
  display: none;
  flex-direction: column;
  padding: 0;
  position: relative;
  overflow: hidden;
}
#game-screen.active { display: flex; }

/* Player bar */
#player-bar {
  display: flex;
  justify-content: center;
  gap: 0;
  padding: max(0.6rem, env(safe-area-inset-top)) 0.5rem 0.5rem;
  background: rgba(5, 5, 8, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  position: relative;
  z-index: 10;
  flex-shrink: 0;
}

.player-slot {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.35rem 0.2rem;
  border-radius: 3px;
  transition: background 0.3s, opacity 0.3s;
}
.player-slot.eliminated {
  opacity: 0.28;
}
.player-slot.deliverer {
  background: rgba(210, 172, 50, 0.22);
  box-shadow:
    inset 0 0 0 1px rgba(210, 172, 50, 0.55),
    0 0 14px -2px rgba(210, 172, 50, 0.35);
  animation: deliverer-pulse 1.8s ease-in-out infinite;
}
@keyframes deliverer-pulse {
  0%, 100% {
    box-shadow:
      inset 0 0 0 1px rgba(210, 172, 50, 0.55),
      0 0 14px -2px rgba(210, 172, 50, 0.35);
  }
  50% {
    box-shadow:
      inset 0 0 0 1px rgba(210, 172, 50, 0.85),
      0 0 22px -1px rgba(210, 172, 50, 0.55);
  }
}
.player-slot.me { border-bottom: 1px solid rgba(255,250,240,0.15); }

.player-slot-name {
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.player-slot.deliverer .player-slot-name { color: var(--gold); }

.player-slot-points {
  font-size: 1.0rem;
  color: var(--text);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  position: relative;
  overflow: hidden;
  height: 1.3em;
}
.player-slot.eliminated .player-slot-points { visibility: hidden; }

/* Point-change slide animation */
.points-slide-out {
  animation: pts-out 0.25s ease-in forwards;
}
.points-slide-in {
  animation: pts-in 0.25s ease-out forwards;
}
@keyframes pts-out {
  to { transform: translateY(-100%); opacity: 0; }
}
@keyframes pts-in {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Amber flicker on point loss */
@keyframes amber-flicker {
  0%, 100% { color: var(--text); }
  30% { color: rgba(220, 150, 50, 0.95); }
  60% { color: rgba(230, 165, 60, 0.80); }
}
.player-slot.points-lost .player-slot-name {
  animation: amber-flicker 0.6s ease;
}

/* Room numeral overlay */
.room-numeral {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(4rem, 25vw, 14rem);
  font-weight: 300;
  letter-spacing: 0.05em;
  color: rgba(255, 250, 240, 0.28);
  pointer-events: none;
  z-index: 15;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.room-numeral.visible { opacity: 1; }

/* ── Game area (center) ──────────────────────────────────────── */
#game-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 1.5rem 1.25rem 0;
  gap: 1.5rem;
  overflow-y: auto;
  padding-left: max(1.25rem, env(safe-area-inset-left));
  padding-right: max(1.25rem, env(safe-area-inset-right));
}

/* ── Puzzle wrap + door transition ──────────────────────────── */
#puzzle-wrap {
  position: relative;
  width: 100%;
  max-width: 640px;
  min-height: 120px;
  background: var(--surface);
  border-radius: 4px;
  overflow: hidden;
}

/* The two door panels — initially off-screen (outside the container),
   pulled in to cover it before opening. JS controls via .door-closing / .door-opening. */
.door-half {
  position: absolute;
  top: 0; bottom: 0;
  width: 51%; /* slight overlap at center to avoid gap */
  background: rgba(20, 15, 8, 0.97);
  z-index: 5;
  pointer-events: none;
  will-change: transform;
}
.door-left  { left: 0;  transform: translateX(-101%); }
.door-right { right: 0; transform: translateX(101%); }

/* Doors close (slide in from edges, covering puzzle) */
#puzzle-wrap.door-closing .door-left {
  animation: door-close-l 0.3s ease-in forwards;
}
#puzzle-wrap.door-closing .door-right {
  animation: door-close-r 0.3s ease-in forwards;
}
@keyframes door-close-l { to { transform: translateX(0); } }
@keyframes door-close-r { to { transform: translateX(0); } }

/* Doors open (pull apart, revealing new content) */
#puzzle-wrap.door-opening .door-left {
  transform: translateX(0);
  animation: door-open-l 0.6s ease-out 0.1s forwards;
}
#puzzle-wrap.door-opening .door-right {
  transform: translateX(0);
  animation: door-open-r 0.6s ease-out 0.1s forwards;
}
@keyframes door-open-l { to { transform: translateX(-101%); } }
@keyframes door-open-r { to { transform: translateX(101%); } }

/* Gold glow on puzzle area for correct answer */
#puzzle-wrap.gold-glow {
  box-shadow: 0 0 32px 8px rgba(210, 172, 50, 0.28), 0 0 4px 1px rgba(210, 172, 50, 0.4);
  transition: box-shadow 0.15s ease;
}

#puzzle-content {
  padding: 2rem 2rem 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  position: relative;
  /* Above doors (z-index 5) so flash/grid stimuli are never hidden by a stuck
     or in-flight door animation. Doors still slide visibly at the edges. */
  z-index: 6;
}

/* Flash sequence */
.flash-display {
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: 400;
  letter-spacing: 0.15em;
  text-align: center;
  color: var(--text);
  min-height: 2.5em;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s ease;
}

/* Stimulus text */
.stimulus-text {
  font-size: clamp(0.95rem, 2.5vw, 1.2rem);
  line-height: 1.7;
  color: var(--text);
  text-align: center;
  letter-spacing: 0.02em;
  white-space: pre-line;
}
.stimulus-text:empty { display: none; }

/* Question */
.question-text {
  font-size: clamp(0.9rem, 2.2vw, 1.05rem);
  line-height: 1.6;
  color: var(--text-dim);
  text-align: center;
  letter-spacing: 0.03em;
  font-style: italic;
}
.question-text:empty { display: none; }

/* Grid stimulus (e.g. 4x4 letter grid) */
.grid-display {
  display: grid;
  gap: clamp(6px, 1.5vw, 12px);
  justify-content: center;
  align-content: center;
  margin: 0 auto;
  padding: 0.5rem;
  opacity: 0;
  transition: opacity 0.18s ease;
}
.grid-display.visible { opacity: 1; }
.grid-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  width: clamp(34px, 9vw, 56px);
  height: clamp(34px, 9vw, 56px);
  font-size: clamp(1.1rem, 3vw, 1.5rem);
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text);
  background: rgba(255, 250, 240, 0.04);
  border: 1px solid rgba(255, 250, 240, 0.08);
  border-radius: 3px;
  font-variant-numeric: tabular-nums;
}

/* Flash progress bar — thin horizontal line that drains during stimulus display */
.flash-progress {
  width: clamp(120px, 40vw, 280px);
  height: 1px;
  background: rgba(255, 250, 240, 0.06);
  margin: 0.75rem auto 0;
  overflow: hidden;
}
.flash-progress-fill {
  height: 100%;
  width: 100%;
  background: rgba(210, 172, 50, 0.40);
  transform-origin: left center;
}
.flash-progress-fill.draining {
  animation: drain linear forwards;
}
@keyframes drain {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}

/* ── Vote area ───────────────────────────────────────────────── */
.vote-area {
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}
.vote-hint {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  color: var(--text-dim);
  text-transform: uppercase;
}
.vote-threshold-hint {
  font-size: 0.62rem;
  letter-spacing: 0.10em;
  color: var(--text-faint);
}
.vote-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.7rem;
  width: 100%;
}

.vote-btn {
  flex: 1 1 120px;
  max-width: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.9rem 1rem;
  background: var(--surface);
  border: 1px solid rgba(255, 250, 240, 0.08);
  border-radius: 3px;
  color: var(--text-dim);
  font: inherit;
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, color 0.18s, opacity 0.18s;
}
.vote-btn:hover:not(:disabled), .vote-btn:focus-visible:not(:disabled) {
  background: rgba(50, 38, 22, 0.70);
  color: var(--text);
  outline: none;
}
.vote-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.vote-btn.my-vote {
  border-color: rgba(210, 172, 50, 0.50);
  color: var(--text);
  background: rgba(45, 35, 18, 0.70);
}
/* Brighten as vote count increases */
.vote-btn[data-votes="1"] { border-color: rgba(255,250,240,0.18); color: rgba(255,250,240,0.72); }
.vote-btn[data-votes="2"] { border-color: rgba(255,250,240,0.30); color: rgba(255,250,240,0.85); }
.vote-btn[data-votes="3"] { border-color: rgba(210,172,50,0.55); color: var(--text); background: rgba(45,35,18,0.70); }
.vote-btn[data-votes="4"],
.vote-btn[data-votes="5"] { border-color: var(--gold); color: var(--gold); background: rgba(50,40,18,0.80); }

.vote-btn-name { font-size: 0.85rem; }
.vote-btn-count { font-size: 0.7rem; color: inherit; opacity: 0.65; min-height: 0.9em; }

/* Local click confirmation. Server echo of the vote tally can lag on a
   flaky network — this brief squish makes sure the button always feels
   like it registered the press. JS toggles the class on each click. */
.vote-btn.just-clicked { animation: vote-click 0.22s ease-out; }
@keyframes vote-click {
  0%   { transform: scale(1); }
  40%  { transform: scale(0.94); }
  100% { transform: scale(1); }
}

/* ── Deliver area ────────────────────────────────────────────── */
.deliver-area {
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
}

.deliverer-label {
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  color: var(--gold);
  text-transform: uppercase;
}

/* Answer input — carved-in look via inner shadow */
.text-input-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.answer-input {
  font: inherit;
  font-size: 1.2rem;
  letter-spacing: 0.04em;
  width: 100%;
  padding: 1rem 1.25rem;
  background: rgba(15, 11, 6, 0.80);
  color: var(--text);
  border: 1px solid rgba(210, 172, 50, 0.30);
  border-radius: 3px;
  outline: none;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.5);
  transition: border-color 0.18s;
  text-align: center;
}
.answer-input:focus { border-color: rgba(210, 172, 50, 0.70); }

/* Live answer mirror for non-deliverers */
.live-answer {
  width: 100%;
  padding: 1rem 1.25rem;
  background: rgba(15, 11, 6, 0.60);
  border: 1px solid rgba(255, 250, 240, 0.10);
  border-radius: 3px;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.4);
  font-size: 1.1rem;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  text-align: center;
  min-height: 3.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.live-answer::after {
  content: '▋';
  opacity: 0.5;
  animation: blink 1s step-end infinite;
  margin-left: 2px;
}
@keyframes blink { 50% { opacity: 0; } }

/* Choice options */
.choice-options {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.choice-btn {
  width: 100%;
  padding: 0.85rem 1.25rem;
  background: var(--surface);
  border: 1px solid rgba(255, 250, 240, 0.10);
  border-radius: 3px;
  color: var(--text-dim);
  font: inherit;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.choice-btn:hover:not(:disabled), .choice-btn:focus-visible:not(:disabled) {
  background: rgba(50, 38, 22, 0.80);
  color: var(--text);
  border-color: rgba(255, 250, 240, 0.25);
  outline: none;
}
.choice-btn.hovered { background: rgba(50, 40, 22, 0.80); color: var(--text); border-color: rgba(255,250,240,0.28); }
.choice-btn:disabled { opacity: 0.40; cursor: not-allowed; }

/* ── Resolve message ─────────────────────────────────────────── */
.resolve-msg {
  width: 100%;
  max-width: 640px;
  padding: 0.75rem 1.25rem;
  text-align: center;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  opacity: 0;
  transition: opacity 0.3s;
}
.resolve-msg.visible { opacity: 1; }
.resolve-msg.correct { color: var(--gold); }
.resolve-msg.wrong { color: var(--amber); }

/* ── Disconnect notices ──────────────────────────────────────── */
.disconnect-notices {
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.disconnect-notice {
  padding: 0.55rem 0.9rem;
  background: rgba(22, 17, 10, 0.70);
  border-left: 2px solid var(--amber);
  border-radius: 2px;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  animation: notice-fade-in 0.25s ease;
}
@keyframes notice-fade-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.disconnect-notice.distribution { border-color: var(--gold); color: var(--gold); }

/* ── Bottom bar ──────────────────────────────────────────────── */
#bottom-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.25rem max(0.75rem, env(safe-area-inset-bottom));
  gap: 1rem;
  flex-shrink: 0;
  position: relative;
}

/* Progress indicator — 10 thin vertical marks */
#progress-indicator {
  display: flex;
  gap: clamp(8px, 2.5vw, 18px);
  align-items: center;
}
.progress-mark {
  width: 2px;
  height: 20px;
  background: var(--text);
  border-radius: 1px;
  opacity: 0.32;
  transition: opacity 0.4s, box-shadow 0.4s, background 0.4s;
  flex-shrink: 0;
}
.progress-mark.cleared {
  opacity: 0.65;
  background: rgba(210, 172, 50, 0.65);
}
.progress-mark.current {
  opacity: 0.95;
  box-shadow: 0 0 8px 1px rgba(210, 172, 50, 0.55);
  background: rgba(210, 172, 50, 0.95);
}

/* Game timer */
.game-timer {
  position: absolute;
  right: max(3rem, calc(2.5rem + env(safe-area-inset-right)));
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.game-timer.warning { color: var(--amber); }
/* Critical (<5 min) — red, slightly larger, pulsing so the eye keeps
   being drawn back. .critical is applied on top of .warning so the
   pulse + colour here override the amber from the earlier threshold. */
.game-timer.critical {
  color: var(--red-alert);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  animation: timer-pulse 1.1s ease-in-out infinite;
}
@keyframes timer-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

/* ── Game Over ────────────────────────────────────────────────── */
#gameover-screen { align-items: center; justify-content: center; }

.over-inner {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
  padding-top: 2rem;
  text-align: center;
}

.over-title {
  font-size: clamp(2rem, 8vw, 3.5rem);
  font-weight: 300;
  letter-spacing: 0.3em;
  color: var(--text);
}
.over-title.cleared { color: var(--gold); text-shadow: 0 0 30px rgba(210,172,50,0.3); }

.over-subtitle {
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}

.over-summary {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.over-player-row {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: var(--surface);
  border-radius: 3px;
}
.over-player-name {
  flex: 1;
  font-size: 0.88rem;
  letter-spacing: 0.06em;
  color: var(--text);
  text-align: left;
}
.over-player-pts {
  font-size: 0.85rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.over-player-result {
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.over-player-row.won .over-player-result { color: var(--gold); }
.over-player-row.won .over-player-name  { color: var(--gold); }
.over-player-row.eliminated { opacity: 0.55; }

.over-hub-link {
  text-decoration: none;
  display: block;
  width: 100%;
}

/* ── Toast ────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: max(1.5rem, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  padding: 0.6rem 1.2rem;
  background: rgba(25, 20, 12, 0.92);
  border: 1px solid rgba(255,250,240,0.15);
  border-radius: 3px;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  white-space: nowrap;
  animation: toast-in 0.2s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translateX(-50%) translateY(8px); } }

/* ── Mobile ───────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .vote-btn { flex: 1 1 90px; padding: 0.75rem 0.6rem; }
  .vote-btn-name { font-size: 0.78rem; }
  #puzzle-content { padding: 1.25rem; }
  .game-title { font-size: 2.4rem; }
  .player-slot-name { font-size: 0.58rem; }
  .player-slot-points { font-size: 0.9rem; }
}

@media (min-width: 640px) {
  .vote-buttons { gap: 1rem; }
  .vote-btn { padding: 1rem 1.25rem; }
  #puzzle-content { padding: 2.5rem; }
}

/* ── Rules modal ─────────────────────────────────────────────── */
.rules-overlay {
  position: fixed; inset: 0;
  background: rgba(2, 2, 4, 0.88);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.rules-card {
  width: 100%;
  max-width: 400px;
  background: rgb(16, 12, 7);
  border: 1px solid rgba(210, 172, 50, 0.22);
  border-radius: 6px;
  padding: 2rem 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.rules-heading {
  font-size: 0.7rem;
  font-weight: 400;
  letter-spacing: 0.28em;
  color: var(--gold);
  text-transform: uppercase;
}

.rules-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.rules-list li {
  font-size: 0.82rem;
  line-height: 1.65;
  color: var(--text-dim);
  letter-spacing: 0.03em;
  padding-left: 1rem;
  position: relative;
}

.rules-list li::before {
  content: '—';
  position: absolute;
  left: 0;
  color: var(--text-faint);
}

.rules-list li strong {
  color: var(--text);
}

.rules-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.rules-countdown {
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  color: var(--text-faint);
  text-align: center;
}

.rules-ready-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.rules-ready-status {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  text-align: center;
}
