:root {
  --jeopardy-blue: #060ce9;
  --jeopardy-blue-dark: #02024d;
  --jeopardy-gold: #ffcc00;
  --jeopardy-white: #ffffff;
  --answered-gray: #1a1a3d;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Arial Narrow', Arial, sans-serif;
  background: var(--jeopardy-blue-dark);
  color: var(--jeopardy-white);
  display: flex;
  flex-direction: column;
  align-items: center;
}

h1, h2, h3 {
  font-family: Georgia, 'Times New Roman', serif;
  text-align: center;
}

.hidden {
  display: none !important;
}

button {
  font-family: inherit;
  font-weight: bold;
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 0.75em 1.25em;
  background: var(--jeopardy-gold);
  color: var(--jeopardy-blue-dark);
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

input[type="text"], input[type="number"], input[type="password"] {
  font-size: 1.1em;
  padding: 0.5em;
  border-radius: 6px;
  border: 2px solid var(--jeopardy-gold);
  background: var(--jeopardy-white);
  color: #000;
}

/* ---- Player / join page ---- */

.player-wrap {
  width: 100%;
  max-width: 480px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.buzz-btn {
  width: min(70vw, 300px);
  height: min(70vw, 300px);
  border-radius: 50%;
  font-size: 2rem;
  background: radial-gradient(circle at 35% 30%, #ff3333, #b30000);
  color: white;
  box-shadow: 0 8px 0 #7a0000;
}

.buzz-btn:active:not(:disabled) {
  transform: translateY(6px);
  box-shadow: 0 2px 0 #7a0000;
}

.buzz-btn:disabled {
  background: #444;
  box-shadow: 0 8px 0 #222;
}

.buzz-btn.buzzed-in {
  background: radial-gradient(circle at 35% 30%, #33dd33, #1a8f1a);
  box-shadow: 0 8px 0 #0d5c0d;
}

.status-line {
  font-size: 1.2rem;
  text-align: center;
  min-height: 1.6em;
}

.player-clue-text {
  background: var(--jeopardy-blue);
  border-radius: 12px;
  padding: 1.25rem 1rem;
  font-size: clamp(1.1rem, 5vw, 1.5rem);
  text-align: center;
  width: 100%;
}

.score-line {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--jeopardy-gold);
}

/* ---- Player clue picker ---- */

#picker-board {
  width: 100%;
}

.picker-grid {
  display: grid;
  gap: 0.35rem;
  width: 100%;
}

.picker-category-name {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--jeopardy-white);
  font-weight: bold;
  text-align: center;
  padding: 0.2rem 0.1rem;
  overflow-wrap: break-word;
  hyphens: auto;
}

.picker-chip {
  min-width: 0;
  width: 100%;
  padding: 0.6em 0;
  text-align: center;
  border-radius: 8px;
  background: var(--jeopardy-blue);
  color: var(--jeopardy-gold);
  font-weight: bold;
  border: none;
  font-size: clamp(0.7rem, 4.5vw, 1rem);
}

.picker-chip:disabled {
  background: var(--answered-gray);
  color: #555;
  opacity: 0.6;
}

/* ---- Board / projector page ---- */

.board-wrap {
  width: 100%;
  max-width: 1400px;
  padding: 1rem;
}

.board-grid {
  display: grid;
  gap: 6px;
  margin: 1rem 0;
}

.cell {
  background: var(--jeopardy-blue);
  border: 2px solid var(--jeopardy-blue-dark);
  border-radius: 4px;
  padding: 1rem 0.5rem;
  text-align: center;
  font-weight: bold;
}

.cell.category {
  text-transform: uppercase;
  font-size: clamp(0.7rem, 1.4vw, 1.1rem);
  background: transparent;
  padding: 0;
  height: 4.5rem;
  perspective: 800px;
}

.cell.category .flip-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.7s cubic-bezier(0.4, 0.2, 0.2, 1);
}

.cell.category.revealed .flip-inner {
  transform: rotateY(180deg);
}

.cell.category .flip-face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem 0.5rem;
  border-radius: 4px;
  background: var(--jeopardy-blue-dark);
  backface-visibility: hidden;
}

.cell.category .flip-face-front {
  color: var(--jeopardy-gold);
}

.cell.category .flip-face-back {
  transform: rotateY(180deg);
}

.cell.value {
  color: var(--jeopardy-gold);
  font-size: clamp(1.2rem, 2.5vw, 2rem);
}

.cell.value.answered {
  background: var(--answered-gray);
  color: #555;
}

.clue-display {
  background: var(--jeopardy-blue);
  border-radius: 12px;
  padding: 2rem;
  font-size: clamp(1.5rem, 3vw, 2.5rem);
  text-align: center;
  margin: 1rem 0;
}

@keyframes clue-reveal-normal {
  from { opacity: 0; transform: perspective(1000px) rotateX(-90deg); }
  to   { opacity: 1; transform: perspective(1000px) rotateX(0deg); }
}

@keyframes clue-reveal-daily-double {
  0%   { opacity: 0; transform: perspective(1000px) rotateY(0deg) scale(0.7); }
  20%  { opacity: 1; }
  100% { opacity: 1; transform: perspective(1000px) rotateY(720deg) scale(1); }
}

.clue-display.reveal-normal {
  animation: clue-reveal-normal 0.5s ease-out;
}

.clue-display.reveal-daily-double {
  animation: clue-reveal-daily-double 1.1s ease-in-out;
}

@media (prefers-reduced-motion: reduce) {
  .cell.category .flip-inner {
    transition: none;
  }
  .clue-display.reveal-normal,
  .clue-display.reveal-daily-double {
    animation: none;
  }
}

.buzzer-banner {
  text-align: center;
  font-size: 1.5rem;
  font-weight: bold;
  padding: 0.5rem;
  border-radius: 8px;
  margin: 0.5rem 0;
}

.buzzer-banner.open {
  background: #1a8f1a;
}

.buzzer-banner.locked {
  background: #b30000;
}

.buzzer-banner.closed {
  background: #444;
}

.scoreboard {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 1.5rem;
}

.score-card {
  position: relative;
  background: var(--jeopardy-blue);
  border-radius: 8px;
  padding: 0.75rem 1.25rem;
  text-align: center;
  min-width: 120px;
}

.remove-player-btn {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 22px;
  height: 22px;
  padding: 0;
  line-height: 1;
  border-radius: 50%;
  background: #b30000;
  color: var(--jeopardy-white);
  font-size: 0.75rem;
}

.score-card .name {
  font-weight: bold;
}

.score-card .score {
  color: var(--jeopardy-gold);
  font-size: 1.4rem;
}

.score-card.disconnected {
  opacity: 0.4;
}

/* ---- Host panel ---- */

.host-wrap {
  width: 100%;
  max-width: 1200px;
  padding: 1rem;
}

.host-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  margin: 1rem 0;
}

#fairness-controls {
  font-size: 0.85rem;
  gap: 0.5rem 1rem;
  align-items: center;
  margin-top: 0;
  opacity: 0.9;
}

#fairness-controls input[type='number'] {
  font-size: 0.85rem;
}

.score-card .status-line {
  font-size: 0.7rem;
  margin: 0.15rem 0 0;
  opacity: 0.8;
}

.player-judge-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
  background: var(--jeopardy-blue);
  border-radius: 8px;
  padding: 0.75rem;
  margin: 0.5rem 0;
}

.answer-reveal {
  background: #1a8f1a;
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
  font-size: 1.3rem;
  margin: 1rem 0;
}

.login-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin-top: 4rem;
}

/* Board lobby: join instructions + QR on one side, the player list on the
   other, so both are on screen at once without scrolling. Stacks on a
   narrow display. */
.lobby-view {
  display: flex;
  flex-wrap: wrap;
  gap: 2.5rem 3rem;
  align-items: center;
  justify-content: center;
  margin-top: 2.5rem;
}

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

/* Scan-to-play code — the join URL stays above it as text for anyone
   typing it in. The PNG already carries a white quiet zone. */
.join-qr {
  width: min(340px, 38vw);
  height: auto;
  border-radius: 8px;
  display: block;
}

.lobby-players {
  flex: 1 1 260px;
  max-width: 520px;
}

.lobby-players .scoreboard {
  margin-top: 0;
}

/* Full-screen black wipe for the lobby -> game-start transition: the music
   fades down and the screen fades to black over ~5s, then the board swaps
   in behind it and it fades back out. Sits under the sound-unlock overlay
   (z-index 10) but over everything on the board. */
#fade-black {
  position: fixed;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  z-index: 9;
  transition: opacity 800ms ease;
}

#fade-black.to-black {
  opacity: 1;
  transition: opacity 5000ms linear;
}

.error-text {
  color: #ff6666;
  font-weight: bold;
}

/* ---- Pronunciation review ---- */

.pron-card {
  background: var(--jeopardy-blue);
  border-radius: 8px;
  padding: 0.9rem 1rem;
  margin-bottom: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.pron-card-top {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.pron-label {
  font-size: 0.8rem;
  opacity: 0.75;
}

.pron-text {
  font-size: 1.05rem;
}

.pron-text mark {
  background: var(--jeopardy-gold);
  color: var(--jeopardy-blue-dark);
  border-radius: 3px;
  padding: 0 0.15em;
}

.pron-note {
  font-size: 0.85rem;
  opacity: 0.8;
  font-style: italic;
}

.pron-compare {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.pron-audio-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.7;
  margin-bottom: 0.15rem;
}

.pron-status {
  font-size: 0.7rem;
  font-weight: bold;
  text-transform: uppercase;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

.pron-status-pending {
  background: #664400;
  color: var(--jeopardy-gold);
}

.pron-status-resolved {
  background: #1a8f1a;
  color: white;
}

.pron-status-resolving {
  background: #664400;
  color: var(--jeopardy-gold);
  opacity: 0.7;
}

.pron-status-no_change {
  background: #8f6a1a;
  color: white;
}

.pron-status-dismissed {
  background: #555;
  color: #ccc;
  text-decoration: line-through;
}

.pron-status-failed {
  background: #8f1a1a;
  color: white;
}

.pron-flag-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.pron-flag-form {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.pron-flag-form input[type="text"] {
  flex: 1;
  min-width: 8rem;
  font-size: 0.9rem;
  padding: 0.4em;
}

.pron-flag-status {
  font-size: 0.85rem;
  opacity: 0.85;
}

.pron-status-applied {
  background: #1a5f8f;
  color: white;
}

.pron-status-archived {
  background: #444;
  color: #bbb;
}

.pron-hint {
  font-size: 0.85rem;
  opacity: 0.8;
  margin: 0 0 0.75rem;
  max-width: 70ch;
}

.pron-status-open {
  background: #664400;
  color: var(--jeopardy-gold);
}

.pron-status-decided {
  background: #1a8f1a;
  color: white;
}

.pron-status-waiting {
  background: #444;
  color: #ddd;
}

.pron-takes {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.pron-take {
  display: grid;
  grid-template-columns: 2.2rem minmax(9rem, 14rem) 1fr auto;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.18);
}

.pron-take.chosen {
  outline: 2px solid var(--jeopardy-gold);
}

.pron-take-label {
  font-weight: bold;
  text-align: center;
}

.pron-take-desc {
  min-width: 0;
  font-size: 0.92rem;
}

.pron-take-desc code {
  display: block;
  font-size: 0.75rem;
  opacity: 0.65;
  overflow-wrap: anywhere;
}

.pron-take-neither {
  grid-template-columns: 2.2rem 1fr auto;
}

.pron-take-neither input {
  min-width: 0;
  font-size: 0.9rem;
  padding: 0.4em;
}

@media (max-width: 640px) {
  .pron-take {
    grid-template-columns: 2.2rem 1fr;
  }
  .pron-take .pron-take-desc,
  .pron-take button,
  .pron-take-neither input {
    grid-column: 2;
    justify-self: start;
  }
}

.pron-archive-btn {
  background: #1a8f1a;
  color: white;
  border: none;
  border-radius: 4px;
  font-weight: bold;
  font-size: 0.85rem;
  padding: 0.35em 0.7em;
}

.pron-note code {
  background: var(--jeopardy-blue-dark);
  padding: 0.1em 0.3em;
  border-radius: 3px;
  font-size: 0.9em;
}

.pron-fix {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.6rem;
  background: var(--jeopardy-blue-dark);
  border-radius: 6px;
}

.pron-fix-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.pron-fix-row input[type="text"] {
  flex: 1;
  min-width: 9rem;
  font-size: 0.9rem;
  padding: 0.4em;
}

.pron-fix-row .fix-word {
  flex: 0 0 8rem;
}

.fix-msg,
.fix-apply-msg,
.fix-convert-msg {
  font-size: 0.8rem;
  opacity: 0.85;
}

.fix-candidates {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.fix-cand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  background: var(--jeopardy-blue);
  border-radius: 4px;
  border: 1px solid transparent;
}

.fix-cand.picked {
  border-color: var(--jeopardy-gold);
}

.fix-cand-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.fix-cand-respell {
  font-weight: bold;
}

.fix-cand-differs {
  font-size: 0.8rem;
  opacity: 0.8;
}

.fix-cand button,
.pron-fix button,
.pron-accept-btn {
  font-size: 0.85rem;
  padding: 0.35em 0.7em;
  white-space: nowrap;
}

.pron-accept-btn {
  background: #1a8f1a;
  color: white;
  border: none;
  border-radius: 4px;
  font-weight: bold;
}

/* ---- Daily Double / round transition / Final reveal (feature: dd-transitions-final) ---- */

.daily-double-splash {
  font-size: clamp(2.5rem, 9vw, 6rem);
  font-weight: bold;
  letter-spacing: 0.08em;
  text-align: center;
  color: var(--jeopardy-gold);
  text-shadow: 3px 3px 0 var(--jeopardy-blue-dark);
  padding: 2rem 1rem;
}

/* The "do this next" call-to-action highlight on host buttons. */
.cta {
  outline: 3px solid var(--jeopardy-gold);
  outline-offset: 2px;
  animation: cta-pulse 1.2s ease-in-out infinite;
}

@keyframes cta-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 204, 0, 0.6); }
  50% { box-shadow: 0 0 0 10px rgba(255, 204, 0, 0); }
}

#round-complete-view {
  text-align: center;
  margin: 2.5rem auto;
}

#round-complete-view h2 {
  font-size: clamp(1.8rem, 5vw, 3rem);
  color: var(--jeopardy-gold);
}

/* While the round-complete screen is up, give the standing scoreboard more presence. */
#round-complete-view:not(.hidden) ~ .scoreboard .score-card {
  transform: scale(1.15);
}

#final-reveal-panel {
  margin-top: 1.5rem;
  text-align: center;
}

.final-reveal-player {
  font-size: clamp(1.4rem, 4vw, 2.2rem);
  font-weight: bold;
  color: var(--jeopardy-gold);
  margin-bottom: 0.5rem;
}

.final-reveal-verdict {
  font-size: clamp(1.5rem, 5vw, 2.5rem);
  font-weight: bold;
  border-radius: 10px;
  padding: 0.6rem 1rem;
  margin: 1rem auto;
  max-width: 20ch;
}

.final-reveal-verdict.correct { background: #1a8f1a; color: #fff; }
.final-reveal-verdict.incorrect { background: #b30000; color: #fff; }

.final-reveal-delta {
  font-size: clamp(1rem, 3vw, 1.6rem);
  font-weight: bold;
}

@media (prefers-reduced-motion: reduce) {
  .cta { animation: none; }
}

/* ---- Clue selection caption (feature: first-run-feedback) ---- */

.clue-context {
  text-align: center;
  font-family: Georgia, 'Times New Roman', serif;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: bold;
  color: var(--jeopardy-gold);
  font-size: clamp(0.9rem, 2vw, 1.4rem);
  margin: 0.25rem 0 0.5rem;
}

/* ---- Buzz-in countdown bar ---- */

.buzz-countdown {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
  margin: -0.25rem 0 0.5rem;
}

.buzz-countdown-bar {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: #1a8f1a;
}

.buzz-countdown-bar.urgent {
  background: #b30000;
  animation: cta-pulse 0.7s ease-in-out infinite;
}

/* ---- Winner splash ---- */

#winner-view {
  text-align: center;
  margin: 2rem auto 0;
  color: var(--jeopardy-gold);
}

.winner-trophy {
  width: clamp(120px, 22vw, 220px);
  height: auto;
  color: var(--jeopardy-gold);
  filter: drop-shadow(0 6px 0 var(--jeopardy-blue-dark));
}

.winner-trophy.spin {
  animation: clue-reveal-daily-double 1.1s ease-in-out;
}

.winner-label {
  font-family: Georgia, 'Times New Roman', serif;
  text-transform: uppercase;
  letter-spacing: 0.3em;
  font-size: clamp(1rem, 2.5vw, 1.6rem);
  margin: 0.5rem 0 0;
  opacity: 0.85;
}

.winner-name {
  font-family: Georgia, 'Times New Roman', serif;
  font-weight: bold;
  font-size: clamp(2.5rem, 9vw, 6rem);
  line-height: 1.05;
  text-shadow: 3px 3px 0 var(--jeopardy-blue-dark);
  margin: 0.25rem 0 1rem;
  animation: cta-pulse 1.6s ease-in-out infinite;
}

#winner-view.is-tie .winner-name {
  font-size: clamp(1.8rem, 6vw, 4rem);
}

#winner-view .scoreboard {
  margin-top: 1.5rem;
}

@media (prefers-reduced-motion: reduce) {
  .buzz-countdown-bar.urgent,
  .winner-trophy.spin,
  .winner-name {
    animation: none;
  }
}

.clip-player {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  max-width: 420px;
  padding: 0.3rem 0.6rem 0.3rem 0.3rem;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 999px;
}

.clip-player .clip-play {
  flex: none;
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  border-radius: 50%;
  font-size: 0.9rem;
  line-height: 1;
}

.clip-player[data-state='error'] .clip-play {
  background: #8f1a1a;
  color: white;
}

.clip-player .clip-seek {
  flex: 1;
  min-width: 0;
  accent-color: var(--jeopardy-gold);
  border: none;
  padding: 0;
  background: transparent;
}

.clip-player .clip-time {
  flex: none;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
  min-width: 5.5em;
  text-align: right;
}
