/* Trivia Night phone buzzer. Navy ground, gold accents, team color on the buzzer ring. */
:root {
  color-scheme: dark;
  --ink: #081126;
  --navy: #0d1a38;
  --navy-high: #1b3061;
  --forest: #164534;
  --oxblood: #6e1b27;
  --gold: #c9a24a;
  --gold-deep: #8a6a24;
  --champagne: #e8cf8f;
  --ivory: #f2ebdb;
  --muted: #a7adbf;
  --line: rgba(201, 162, 74, 0.25);
  --ok: #3fae7f;
  --bad: #d0505f;
  --team: #c9a24a;
  --display: Didot, "Bodoni 72", "Bodoni MT", "Playfair Display", Georgia, "Times New Roman", serif;
  --body: "Avenir Next", Avenir, "Segoe UI", Roboto, system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--ink);
  color: var(--ivory);
  font-family: var(--body);
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

body {
  background:
    radial-gradient(120% 70% at 50% 0%, var(--navy-high) 0%, var(--navy) 45%, var(--ink) 100%);
  background-attachment: fixed;
}

main {
  min-height: 100%;
  padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Deco frame */
main::before {
  content: "";
  position: fixed;
  inset: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom)) 10px;
  border: 1px solid var(--line);
  pointer-events: none;
}

.eyebrow {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--gold);
}
.display { font-family: var(--display); font-weight: 400; font-size: 38px; line-height: 1.1; margin: 10px 0; }
.small-display { font-size: 28px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Screens */
.panel, .buzz-screen { display: none; }
.screen-connecting #message-panel,
.screen-error #message-panel,
.screen-ended #ended-panel { display: flex; }
.screen-live .buzz-screen { display: flex; }

.panel {
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 4px;
  max-width: 420px;
  margin: 0 auto;
}
.panel p { margin: 4px 0; line-height: 1.5; }

.spinner {
  width: 44px; height: 44px; margin-top: 22px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--gold);
  animation: spin 1s linear infinite;
}
.screen-error .spinner { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Live screen */
.buzz-screen {
  flex: 1;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.top { width: 100%; display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.team-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 14px; font-weight: 600;
  max-width: 75%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.swatch { width: 14px; height: 14px; border-radius: 50%; background: var(--team); box-shadow: 0 0 0 2px rgba(255,255,255,0.12); flex: none; }
.signal { display: flex; gap: 3px; align-items: flex-end; height: 14px; }
.signal i { width: 4px; background: var(--muted); opacity: 0.35; border-radius: 1px; }
.signal i:nth-child(1) { height: 5px; } .signal i:nth-child(2) { height: 9px; } .signal i:nth-child(3) { height: 14px; }
.signal[data-level="3"] i, .signal[data-level="2"] i:nth-child(-n+2), .signal[data-level="1"] i:nth-child(1) { background: var(--ok); opacity: 1; }
.signal[data-level="0"] i { background: var(--bad); opacity: 0.8; }

.player { font-family: var(--display); font-size: 30px; margin: 6px 0 0; }

.banner {
  margin-top: 14px;
  padding: 8px 14px;
  border: 1px solid var(--gold);
  color: var(--champagne);
  font-size: 13px;
  letter-spacing: 0.04em;
}

/* The buzzer */
.buzzer {
  --size: min(72vw, 46vh, 340px);
  position: relative;
  width: var(--size); height: var(--size);
  margin: auto 0;
  border-radius: 50%;
  border: none;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
  color: var(--ink);
  font: inherit;
  background: radial-gradient(circle at 35% 28%, var(--champagne) 0%, var(--gold) 42%, var(--gold-deep) 100%);
  box-shadow:
    0 0 0 calc(var(--size) * 0.035) color-mix(in srgb, var(--team) 85%, black),
    0 0 0 calc(var(--size) * 0.06) rgba(201, 162, 74, 0.25),
    0 18px 50px rgba(0, 0, 0, 0.55),
    inset 0 -10px 30px rgba(0, 0, 0, 0.25);
  transition: transform 80ms ease, filter 200ms ease, opacity 200ms ease;
}
.buzzer .label {
  font-family: var(--display);
  font-weight: 700;
  font-size: calc(var(--size) * 0.17);
  letter-spacing: 0.12em;
}
.buzzer .ring {
  position: absolute; inset: -14px;
  border-radius: 50%;
  border: 2px solid var(--team);
  opacity: 0;
}
.buzzer:active, .buzzer.pressed { transform: scale(0.96); }

/* Buzzer states */
[data-buzzer="armed"] .buzzer .ring,
[data-buzzer="lobby"] .buzzer .ring { animation: pulse 1.6s ease-out infinite; }
@keyframes pulse { 0% { opacity: 0.8; transform: scale(0.96); } 100% { opacity: 0; transform: scale(1.18); } }

[data-buzzer="waiting"] .buzzer,
[data-buzzer="closed"] .buzzer,
[data-buzzer="off"] .buzzer,
[data-buzzer="queued"] .buzzer { filter: grayscale(0.85) brightness(0.55); }
[data-buzzer="locked"] .buzzer,
[data-buzzer="used"] .buzzer,
[data-buzzer="penalty"] .buzzer { filter: grayscale(1) brightness(0.35); }
[data-buzzer="active"] .buzzer {
  background: radial-gradient(circle at 35% 28%, #ffffff 0%, var(--champagne) 30%, var(--gold) 70%);
  box-shadow: 0 0 0 calc(var(--size) * 0.05) var(--team), 0 0 80px rgba(232, 207, 143, 0.75);
  animation: glow 0.9s ease-in-out infinite alternate;
}
[data-buzzer="correct"] .buzzer {
  background: radial-gradient(circle at 35% 28%, #8fe0bb 0%, var(--ok) 45%, var(--forest) 100%);
}
@keyframes glow { to { box-shadow: 0 0 0 calc(var(--size) * 0.07) var(--team), 0 0 120px rgba(232, 207, 143, 0.95); } }

@media (prefers-reduced-motion: reduce) {
  .buzzer .ring, [data-buzzer="active"] .buzzer, .spinner { animation: none !important; }
}

.status { font-family: var(--display); font-size: 26px; margin: 18px 0 2px; min-height: 1.2em; }
[data-buzzer="active"] .status { color: var(--champagne); }
[data-buzzer="correct"] .status { color: #8fe0bb; }
[data-buzzer="locked"] .status, [data-buzzer="penalty"] .status { color: #eba2ab; }
.substatus { margin: 0; font-size: 14px; min-height: 1.3em; }

.bottom { width: 100%; margin-top: 18px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.score { display: flex; align-items: baseline; gap: 10px; }
.score-value { font-family: var(--display); font-size: 30px; color: var(--champagne); }
.members { font-size: 12px; margin: 0; }

/* Ended */
.rule { display: flex; align-items: center; gap: 10px; width: 200px; margin: 6px 0 16px; }
.rule span { flex: 1; height: 1px; background: linear-gradient(90deg, transparent, var(--gold)); }
.rule span:last-child { background: linear-gradient(270deg, transparent, var(--gold)); }
.rule i { width: 7px; height: 7px; border: 1px solid var(--gold); transform: rotate(45deg); }
.standings { list-style: none; padding: 0; margin: 0 0 18px; width: 100%; }
.standings li {
  display: grid; grid-template-columns: 36px 1fr auto; align-items: baseline; gap: 10px;
  padding: 10px 6px; border-bottom: 1px solid var(--line); text-align: left;
}
.standings li.mine { background: rgba(201, 162, 74, 0.1); }
.standings .pos { font-family: var(--display); font-size: 24px; color: var(--gold); text-align: center; }
.standings .name { font-size: 16px; font-weight: 600; }
.standings .pts { font-variant-numeric: tabular-nums; color: var(--champagne); }

.overlay {
  position: fixed; inset: 0;
  background: rgba(8, 17, 38, 0.92);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 24px; gap: 6px;
}
.overlay[hidden] { display: none; }
[hidden] { display: none !important; }

/* Input requests: answers, guesses, wagers, votes */
.input-panel {
  width: 100%; max-width: 440px;
  margin: 22px auto auto;
  display: flex; flex-direction: column; gap: 12px; align-items: stretch;
  text-align: left;
}
[data-mode="input"] .buzzer, [data-mode="input"] .status, [data-mode="input"] .substatus { display: none; }
.input-prompt { font-family: var(--display); font-size: 24px; line-height: 1.25; margin: 0; }
.input-body { display: flex; flex-direction: column; gap: 10px; }
.choice {
  display: flex; align-items: center; gap: 14px;
  width: 100%; padding: 14px 16px;
  font: inherit; font-size: 17px; text-align: left;
  color: var(--ivory); background: rgba(8, 17, 38, 0.7);
  border: 1px solid var(--line); border-radius: 6px;
  touch-action: manipulation;
}
.choice b { font-family: var(--display); font-size: 22px; color: var(--gold); min-width: 22px; }
.choice.selected { background: linear-gradient(180deg, var(--champagne), var(--gold)); color: var(--ink); border-color: var(--champagne); }
.choice.selected b { color: var(--ink); }
.choice:disabled { opacity: 0.55; }
.field {
  width: 100%; padding: 14px 16px; font: inherit; font-size: 22px;
  color: var(--ivory); background: rgba(8, 17, 38, 0.8);
  border: 1px solid var(--gold); border-radius: 6px;
  -webkit-user-select: text; user-select: text;
}
.field::placeholder { color: var(--muted); }
.wager-value { font-family: var(--display); font-size: 54px; color: var(--champagne); text-align: center; font-variant-numeric: tabular-nums; }
.wager-range { width: 100%; accent-color: var(--gold); }
.quick { display: flex; gap: 8px; }
.quick button, .order-row button {
  flex: 1; padding: 10px; font: inherit; color: var(--ivory);
  background: rgba(8, 17, 38, 0.7); border: 1px solid var(--line); border-radius: 6px;
}
.order-row { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: rgba(8, 17, 38, 0.7); border: 1px solid var(--line); border-radius: 6px; }
.order-row span { flex: 1; font-size: 17px; }
.order-row b { font-family: var(--display); color: var(--gold); width: 22px; }
.order-row button { flex: none; width: 44px; }
.submit {
  margin-top: 4px; padding: 16px; font: inherit; font-size: 18px; font-weight: 600; letter-spacing: 0.04em;
  color: var(--ink); background: linear-gradient(180deg, var(--champagne), var(--gold));
  border: none; border-radius: 6px; touch-action: manipulation;
}
.submit:disabled { opacity: 0.4; }
.submit[hidden] { display: none; }
.joker {
  padding: 26px; font-family: var(--display); font-size: 30px; color: var(--ink);
  background: radial-gradient(circle at 35% 28%, var(--champagne), var(--gold) 60%, var(--gold-deep));
  border: none; border-radius: 10px;
}
.input-status { font-size: 14px; margin: 0; min-height: 1.3em; }
.input-status.locked { color: var(--champagne); }
