:root {
  --bg: #12060a;
  --bg2: #24101a;
  --card: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.12);
  --text: #fff4f4;
  --muted: #c9a9b1;
  --red: #e5172f;
  --red-dark: #7a0b1c;
  --red-glow: rgba(229, 23, 47, 0.55);
  --green: #2ecc71;
  --amber: #ffb020;
  --blue: #4ea3ff;
  --radius: 18px;
  font-family: ui-rounded, 'SF Pro Rounded', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: radial-gradient(1200px 800px at 20% -10%, var(--bg2), var(--bg));
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
h1, h2 { margin: 0 0 0.4em; letter-spacing: -0.01em; }
p { margin: 0.4em 0; }
[hidden] { display: none !important; }
a { color: var(--blue); }

.dot {
  display: inline-block; width: 0.8em; height: 0.8em; border-radius: 50%;
  background: var(--red); box-shadow: 0 0 12px var(--red-glow); vertical-align: -0.05em; margin-right: 0.2em;
}
.badge {
  display: inline-block; padding: 0.1em 0.6em; border-radius: 999px; font-size: 0.8em;
  background: var(--card); border: 1px solid var(--line); color: var(--muted);
}
.status { font-size: 0.85em; color: var(--muted); }
.status::before { content: '●'; margin-right: 0.35em; color: var(--amber); }
.status[data-state='open']::before { color: var(--green); }
.status[data-state='closed']::before { color: var(--red); }
.error { color: #ff8c9a; min-height: 1.4em; font-weight: 600; }
.hint { color: var(--muted); font-size: 0.9em; }
button.sound { padding: 0.3em 0.6em; font-size: 1em; }
button.sound.locked { color: var(--amber); border-color: var(--amber); animation: nudge 1.2s ease-in-out infinite; }
@keyframes nudge { 50% { box-shadow: 0 0 0 6px rgba(255, 176, 32, 0); } 0% { box-shadow: 0 0 0 0 rgba(255, 176, 32, 0.5); } }

button {
  font: inherit; font-weight: 700; color: var(--text); cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 0.7em 1.2em;
  transition: transform 0.08s ease, filter 0.15s ease;
}
button:hover:not(:disabled):not(.buzzer) { filter: brightness(1.15); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.primary { background: var(--red); border-color: transparent; box-shadow: 0 6px 20px var(--red-glow); }
button.good { background: #1f8f4c; border-color: transparent; }
button.bad { background: #8a1a2b; border-color: transparent; }
button.ghost { background: transparent; }
button.big { font-size: 1.15em; padding: 0.9em 1.4em; }
input {
  font: inherit; color: var(--text); background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line);
  border-radius: 12px; padding: 0.75em 1em; width: 100%; outline: none;
}
input:focus { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-glow); }
input::placeholder { color: var(--muted); }
.row { display: flex; gap: 0.6em; }
.col { display: flex; flex-direction: column; gap: 0.8em; }
#code { text-transform: uppercase; letter-spacing: 0.3em; font-weight: 800; font-size: 1.2em; text-align: center; }

.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 1em; flex-wrap: wrap;
  padding: 0.7em 1.2em; border-bottom: 1px solid var(--line); font-size: 0.95em;
  background: rgba(0, 0, 0, 0.25); backdrop-filter: blur(8px);
}
.bar strong { letter-spacing: 0.15em; }

/* ---------- home ---------- */
.home .card {
  max-width: 460px; margin: 8vh auto; padding: 2em 1.6em; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--line); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}
.home h1 { font-size: 2.4em; }
.home .tagline { color: var(--muted); margin-bottom: 1.6em; }
.home section h2 { font-size: 1.05em; color: var(--muted); font-weight: 600; }
.home .primary { width: 100%; font-size: 1.15em; padding: 0.9em; }
.home .or { text-align: center; color: var(--muted); margin: 1.4em 0; text-transform: uppercase; font-size: 0.8em; letter-spacing: 0.2em; }
.home .row button { white-space: nowrap; }

/* ---------- player ---------- */
.player .card { max-width: 420px; margin: 12vh auto; padding: 1.6em; }
.player .me { font-weight: 600; cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.stage { display: flex; align-items: center; justify-content: center; min-height: calc(100dvh - 60px); padding: 1em; }
.stage-inner { text-align: center; width: 100%; max-width: 520px; }
.stage-inner h1 { font-size: clamp(1.4em, 6vw, 2.2em); min-height: 1.3em; }
.stage-inner p { color: var(--muted); min-height: 2.6em; }
.buzzer {
  --size: min(78vw, 60vh, 420px);
  width: var(--size); height: var(--size); border-radius: 50%; margin: 1em auto; display: grid; place-items: center;
  font-size: clamp(1.6em, 9vw, 3.2em); font-weight: 900; letter-spacing: 0.05em; color: #fff;
  border: none; touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
  background: radial-gradient(circle at 35% 30%, #ff6b7a, var(--red) 45%, #b3101f 100%);
  box-shadow: 0 18px 0 var(--red-dark), 0 28px 50px rgba(0, 0, 0, 0.55), inset 0 -10px 30px rgba(0, 0, 0, 0.25);
  transition: transform 0.06s ease, box-shadow 0.06s ease, filter 0.2s ease;
}
.buzzer:disabled { opacity: 1; cursor: default; }
.buzzer[data-mode='live'] { animation: pulse 1.1s ease-in-out infinite; }
.buzzer[data-mode='live']:active, .buzzer.pressed {
  transform: translateY(14px);
  box-shadow: 0 4px 0 var(--red-dark), 0 10px 20px rgba(0, 0, 0, 0.5), inset 0 -4px 12px rgba(0, 0, 0, 0.3);
  animation: none;
}
.buzzer[data-mode='wait'], .buzzer[data-mode='off'] { filter: grayscale(0.85) brightness(0.55); }
.buzzer[data-mode='late'] { filter: grayscale(0.9) brightness(0.7); cursor: pointer; }
.buzzer[data-mode='late']:active, .buzzer[data-mode='late'].pressed {
  transform: translateY(14px);
  box-shadow: 0 4px 0 var(--red-dark), 0 10px 20px rgba(0, 0, 0, 0.5), inset 0 -4px 12px rgba(0, 0, 0, 0.3);
}
.buzzer[data-mode='done'] { filter: grayscale(0.6) brightness(0.7); }
.buzzer[data-mode='mine'] {
  background: radial-gradient(circle at 35% 30%, #8ff5b7, var(--green) 45%, #178c4a 100%);
  box-shadow: 0 18px 0 #0d5a2f, 0 0 60px rgba(46, 204, 113, 0.6);
  animation: bounce 0.5s ease-out;
}
@keyframes pulse {
  0%, 100% { filter: brightness(1); box-shadow: 0 18px 0 var(--red-dark), 0 28px 50px rgba(0, 0, 0, 0.55), 0 0 0 0 var(--red-glow); }
  50% { filter: brightness(1.12); box-shadow: 0 18px 0 var(--red-dark), 0 28px 50px rgba(0, 0, 0, 0.55), 0 0 0 22px rgba(229, 23, 47, 0); }
}
@keyframes bounce { 0% { transform: scale(0.92); } 60% { transform: scale(1.05); } 100% { transform: scale(1); } }
.mini-scores { list-style: none; padding: 0; margin: 1em auto 0; max-width: 320px; font-size: 0.95em; }
.mini-scores li { display: flex; justify-content: space-between; padding: 0.3em 0.6em; border-bottom: 1px solid var(--line); color: var(--muted); }
.mini-scores li.me { color: var(--text); font-weight: 700; }

/* ---------- dashboard ---------- */
.dashboard .grid {
  display: grid; grid-template-columns: 320px 1fr 300px; gap: 1.2em; padding: 1.2em;
  min-height: calc(100dvh - 56px);
}
.dashboard aside, .dashboard .main { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2em; }
.join-box { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 0.3em; }
.join-box .label { color: var(--muted); text-transform: uppercase; letter-spacing: 0.15em; font-size: 0.75em; margin-top: 0.8em; }
.join-box .url { font-weight: 700; font-size: 1.05em; word-break: break-all; }
.join-box .code { font-size: 3.2em; font-weight: 900; letter-spacing: 0.25em; margin: 0; line-height: 1; padding-left: 0.25em; }
.qr { width: 100%; max-width: 260px; height: auto; background: #fff; padding: 10px; border-radius: 14px; }
.dashboard .main { display: flex; flex-direction: column; gap: 1em; }
.banner {
  flex: 1; display: flex; flex-direction: column; justify-content: center; text-align: center; padding: 2em 1em;
  border-radius: var(--radius); background: rgba(0, 0, 0, 0.3); border: 2px solid var(--line); transition: background 0.3s, border-color 0.3s;
}
.banner h1 { font-size: clamp(1.8em, 4.5vw, 3.6em); }
.banner p { color: var(--muted); font-size: 1.2em; }
.banner[data-phase='armed'] { border-color: var(--red); background: rgba(229, 23, 47, 0.12); animation: glow 1.2s ease-in-out infinite; }
.banner[data-phase='buzzed'] { border-color: var(--amber); background: rgba(255, 176, 32, 0.14); }
.banner[data-phase='idle'] { border-color: var(--green); background: rgba(46, 204, 113, 0.12); }
@keyframes glow { 50% { box-shadow: 0 0 40px var(--red-glow); } }
.buzz-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.4em; }
.buzz-list li {
  display: grid; grid-template-columns: 2.4em 1fr auto 1.6em; align-items: center; gap: 0.8em;
  padding: 0.6em 0.9em; border-radius: 12px; background: rgba(0, 0, 0, 0.25); font-size: 1.15em;
}
.buzz-list li.current { outline: 2px solid var(--amber); }
.buzz-list li[data-verdict='correct'] { background: rgba(46, 204, 113, 0.2); }
.buzz-list li[data-verdict='wrong'] { opacity: 0.55; text-decoration: line-through; }
.buzz-list .ms { font-variant-numeric: tabular-nums; color: var(--muted); }
.buzz-list .rank { font-size: 1.2em; text-align: center; }
.controls { display: flex; flex-wrap: wrap; gap: 0.6em; align-items: center; }
.controls .hint { flex-basis: 100%; margin: 0; }
.players h2 { display: flex; justify-content: space-between; align-items: center; font-size: 1.1em; }
.player-list { list-style: none; padding: 0; margin: 0; }
.player-list li { display: flex; align-items: center; gap: 0.6em; padding: 0.45em 0.2em; border-bottom: 1px solid var(--line); }
.player-list li .who { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-list li[data-connected='false'] .who { opacity: 0.45; }
.player-list li[data-connected='false'] .who::after { content: ' (away)'; font-size: 0.8em; }
.player-list .score { font-weight: 800; min-width: 1.6em; text-align: right; }
.player-list .kick { padding: 0 0.5em; line-height: 1.4; border-radius: 8px; font-size: 0.9em; }
.fastest { color: var(--amber); font-weight: 600; }

@media (max-width: 960px) {
  .dashboard .grid { grid-template-columns: 1fr; }
  .join-box { order: 2; }
  .players { order: 3; }
}
