:root {
  --jeopardy-blue: #060CE9;
  --jeopardy-deep-blue: #0A1273;
  --jeopardy-border: #000080;
  --jeopardy-gold: #D69F4C;
  --jeopardy-yellow: #FFCC00;
  --jeopardy-bright-yellow: #FFE600;
  --jeopardy-dd-red: #A02020;
  --jeopardy-dd-red-2: #5B0000;
  --ink: #000000;
  --paper: #FFFFFF;
  --muted: #aaaaaa;

  --font-display: 'Anton', 'Oswald', 'Arial Narrow', 'Helvetica', sans-serif;
  --font-category: 'Oswald', 'Arial Narrow', sans-serif;
  --font-clue: 'Roboto Slab', Georgia, serif;
}

/* ============ RESET / BASE ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; width: 100%; overflow: hidden; }
body {
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-category);
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input { font-family: inherit; }

/* ============ SCREEN / OVERLAY ============ */
.screen, .overlay {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
}
.screen.active, .overlay.active {
  display: flex;
}
.overlay {
  background: var(--jeopardy-blue);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
.hidden { display: none !important; }

/* ============ LANDING SCREEN ============ */
#landing-screen {
  background: radial-gradient(ellipse at center, #1a1a4a 0%, var(--ink) 70%);
  align-items: center;
  justify-content: center;
}
.landing-enter-btn {
  font-family: var(--font-display);
  font-size: clamp(60px, 11vw, 132px);
  letter-spacing: 16px;
  padding: 36px 110px 32px;
  border-radius: 999px;
  background: linear-gradient(180deg, #FFE600 0%, #FFCC00 55%, #D69F4C 100%);
  color: var(--ink);
  text-shadow: 0 2px 0 rgba(255,255,255,0.45);
  transform: skewX(-3deg);
  transition: transform 0.15s ease, filter 0.2s ease;
  animation: landing-pulse 2.6s ease-in-out infinite;
  position: relative;
}
.landing-enter-btn:hover {
  transform: skewX(-3deg) scale(1.04);
  filter: brightness(1.08);
}
.landing-enter-btn:active {
  transform: skewX(-3deg) translateY(4px);
}
@keyframes landing-pulse {
  0%, 100% {
    box-shadow:
      0 8px 0 #8a6b20,
      0 16px 36px rgba(0,0,0,0.55),
      0 0 50px rgba(255,204,0,0.45),
      inset 0 -5px 0 rgba(0,0,0,0.18),
      inset 0 5px 0 rgba(255,255,255,0.45);
  }
  50% {
    box-shadow:
      0 8px 0 #8a6b20,
      0 16px 36px rgba(0,0,0,0.55),
      0 0 110px rgba(255,230,0,0.85),
      inset 0 -5px 0 rgba(0,0,0,0.18),
      inset 0 5px 0 rgba(255,255,255,0.55);
  }
}

/* ============ SETUP SCREEN ============ */
#setup-screen {
  background: radial-gradient(ellipse at center, #1a1a4a 0%, var(--ink) 70%);
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  overflow: hidden;
}
.setup-container {
  max-width: 600px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: relative;
  z-index: 2;
}

/* ============ PHOTO WALL (setup-screen background mosaic) ============ */
.photo-wall {
  position: absolute;
  inset: 0;
  display: grid;
  gap: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.photo-wall-tile {
  background-size: cover;
  background-position: center;
  opacity: 0;
  transform: scale(1.08);
  filter: saturate(0.92) brightness(0.85);
  transition:
    opacity 1.6s cubic-bezier(0.22, 0.7, 0.2, 1),
    transform 1.8s cubic-bezier(0.22, 0.7, 0.2, 1);
  transition-delay: var(--tile-delay, 0s);
}
.photo-wall.active .photo-wall-tile {
  opacity: 0.55;
  transform: scale(1);
}
/* Soft vignette so the centered setup card never gets crowded out. */
.photo-wall::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center,
    rgba(10,10,30,0.65) 0%,
    rgba(10,10,30,0.35) 45%,
    rgba(0,0,0,0.55) 100%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.4s ease-out;
}
.photo-wall.active::after { opacity: 1; }

/* When the wall is showing, give the setup boxes more weight so text stays legible. */
#setup-screen.wall-active .setup-box {
  background: rgba(0, 0, 20, 0.62);
  border-color: rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.title-logo {
  font-family: var(--font-display);
  font-size: clamp(44px, 8.2vw, 96px);
  color: var(--jeopardy-yellow);
  letter-spacing: 1px;
  text-shadow:
    0 2px 0 #8a6b20,
    0 4px 0 #654e17,
    0 6px 14px rgba(0,0,0,0.6);
  line-height: 0.95;
  transform: skewX(-6deg);
  transform-origin: center;
  text-transform: uppercase;
  white-space: nowrap;
}
.exclaim { color: var(--paper); }
.subtitle {
  font-size: 18px;
  color: var(--muted);
  margin-top: -12px;
  letter-spacing: 2px;
  text-transform: uppercase;
}
.setup-box {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  padding: 20px;
  text-align: left;
}
.setup-label {
  display: block;
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--jeopardy-yellow);
  margin-bottom: 10px;
}
.team-inputs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}
.team-inputs input,
.final-wager-block input,
#dd-wager-input {
  width: 100%;
  padding: 12px;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 6px;
  color: var(--paper);
  font-size: 18px;
  font-weight: 600;
}
.team-inputs input:focus,
.final-wager-block input:focus,
#dd-wager-input:focus {
  outline: none;
  border-color: var(--jeopardy-yellow);
  background: rgba(0,0,0,0.6);
}

/* ============ BUTTONS ============ */
.btn {
  padding: 14px 22px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  border-radius: 6px;
  font-size: 15px;
  transition: transform 0.05s ease, filter 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; filter: none; transform: none; }
.btn-primary { background: var(--jeopardy-blue); color: var(--paper); box-shadow: 0 3px 0 var(--jeopardy-deep-blue); }
.btn-gold { background: var(--jeopardy-yellow); color: var(--ink); box-shadow: 0 3px 0 #8a6b20; }
.btn-correct { background: #1f7a33; color: var(--paper); box-shadow: 0 3px 0 #0c3e18; }
.btn-wrong { background: #8b2020; color: var(--paper); box-shadow: 0 3px 0 #410909; }
.btn-neutral { background: #555; color: var(--paper); box-shadow: 0 3px 0 #222; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid rgba(255,255,255,0.2); }
.btn-ghost:hover { color: var(--paper); border-color: var(--paper); }
.btn-small { padding: 8px 14px; font-size: 12px; letter-spacing: 1px; }
.kbd-hint {
  font-size: 11px;
  opacity: 0.7;
  margin-left: 4px;
  font-weight: 400;
}
kbd {
  background: rgba(255,255,255,0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 12px;
}
.hint {
  font-size: 13px;
  color: var(--muted);
  margin-top: 10px;
}

/* ============ BOARD SCREEN ============ */
#board-screen {
  background: var(--ink);
  padding: 0;
}
.round-header {
  background: var(--ink);
  padding: 10px 20px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 60px;
  position: relative;
}
/* Both live in the flow rather than pinned to the corner — the next-round
   button is now always visible, so an absolutely-positioned one would sit on
   top of it. */
.round-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.round-label {
  font-family: var(--font-display);
  font-size: clamp(28px, 4vw, 42px);
  color: var(--jeopardy-yellow);
  letter-spacing: 2px;
  text-transform: uppercase;
  text-shadow: 2px 2px 0 #8a6b20;
  flex: 1;
  text-align: center;
}
.board {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: minmax(60px, 1.1fr) repeat(5, 1fr);
  gap: 6px;
  padding: 6px 10px 10px;
  background: var(--ink);
}
.category-cell {
  background: var(--jeopardy-blue);
  color: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: var(--font-category);
  font-weight: 700;
  font-size: clamp(12px, 1.3vw, 22px);
  letter-spacing: 1px;
  text-transform: uppercase;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.6);
  padding: 6px;
  line-height: 1.1;
  border: 2px solid var(--jeopardy-border);
  border-radius: 3px;
}
.clue-cell {
  background: var(--jeopardy-blue);
  color: var(--jeopardy-yellow);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: clamp(28px, 4.2vw, 64px);
  letter-spacing: 1px;
  text-shadow: 3px 3px 0 #000, 5px 5px 0 rgba(0,0,0,0.5);
  cursor: pointer;
  border: 2px solid var(--jeopardy-border);
  border-radius: 3px;
  transition: background 0.15s ease, transform 0.08s ease;
}
.clue-cell:hover:not(.used) {
  background: #2a30ee;
}
.clue-cell:active:not(.used) { transform: scale(0.98); }
.clue-cell.used {
  background: #050826;
  color: transparent;
  cursor: default;
}

/* Board-fill cascade animation. Each tile fades+scales in with a stagger.
   --tile-stagger is set in JS so the total duration matches board-fill.mp3. */
.board.board-filling .category-cell,
.board.board-filling .clue-cell {
  animation: tile-in 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
  animation-delay: calc(var(--tile-idx, 0) * var(--tile-stagger, 40ms));
}
@keyframes tile-in {
  from { opacity: 0; transform: scale(0.6); }
  to   { opacity: 1; transform: scale(1); }
}

/* ============ SCORES ============ */
.scores {
  display: grid;
  /* Team count is set by the renderer, so a solo game and a six-team game
     both fill the bar evenly. */
  grid-template-columns: repeat(var(--team-count, 2), 1fr);
  gap: 6px;
  padding: 6px 10px 10px;
  background: var(--ink);
}
@media (max-width: 700px) {
  .scores { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
}
.team-card {
  background: var(--jeopardy-blue);
  border: 2px solid var(--jeopardy-border);
  border-radius: 4px;
  padding: 10px 14px;
  text-align: center;
}
.team-name {
  font-family: var(--font-category);
  font-size: clamp(14px, 1.6vw, 22px);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--paper);
  margin-bottom: 4px;
  font-weight: 600;
}
.team-score-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.team-score {
  font-family: var(--font-display);
  font-size: clamp(28px, 3.5vw, 50px);
  color: var(--jeopardy-yellow);
  letter-spacing: 1px;
  min-width: 100px;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.6);
  outline: none;
  padding: 0 10px;
  border-radius: 4px;
}
.team-score.negative { color: #ff6b6b; }
.team-score:focus { background: rgba(0,0,0,0.3); }
.score-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(0,0,0,0.35);
  color: var(--paper);
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
}
.score-btn:hover { background: rgba(0,0,0,0.6); }

/* ============ CLUE OVERLAY ============ */
.clue-inner {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px 40px;
  gap: 20px;
  /* Centred flex children overflow in BOTH directions once the content is
     taller than the box, which put tall photos over the header. */
  overflow: hidden;
}
.clue-meta {
  font-family: var(--font-category);
  font-size: 18px;
  text-transform: uppercase;
  letter-spacing: 3px;
  color: var(--jeopardy-yellow);
  opacity: 0.85;
}
.clue-text {
  font-family: var(--font-clue);
  font-weight: 700;
  text-transform: uppercase;
  color: var(--paper);
  text-align: center;
  font-size: clamp(28px, 4.5vw, 64px);
  line-height: 1.25;
  max-width: 1400px;
  text-shadow: 3px 3px 0 rgba(0,0,0,0.6);
  letter-spacing: 1px;
}

/* Picture-question image: scales to fit any dimensions, never overflows. */
/* The image takes whatever vertical space the text and controls leave, rather
   than a fixed share of the viewport. A tall portrait photo used to overflow
   the flex column and ride up over the category header. */
.clue-image-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 1100px;
  flex: 1 1 0;
  min-height: 0;
  padding: 8px 0;
}
.clue-image-wrap.hidden { display: none; }
#clue-image, #final-clue-image, #final-response-image {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.6), 0 0 0 4px rgba(0,0,0,0.4);
  background: #000;
}
/* When showing an image, dial down the question text size so both fit. */
.clue-image-wrap:not(.hidden) ~ .clue-text {
  font-size: clamp(20px, 2.6vw, 36px);
  max-width: 1100px;
}

/* Subtle question timer in top-right of the clue overlay. */
.clue-timer {
  position: absolute;
  top: 16px;
  right: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-category);
  font-size: 13px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.65);
}
.timer-start {
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.25);
  color: rgba(255,255,255,0.8);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.timer-start:hover {
  background: rgba(0,0,0,0.5);
  color: var(--jeopardy-yellow);
  border-color: var(--jeopardy-yellow);
}
.timer-readout {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 2px;
  color: var(--jeopardy-yellow);
  min-width: 56px;
  text-align: center;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,204,0,0.4);
}
.timer-readout.running { animation: timer-pulse 1s ease-in-out infinite; }
.timer-readout.expired {
  color: #ff6b6b;
  border-color: #ff6b6b;
  animation: none;
}
@keyframes timer-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.6; }
}

.time-up-flash {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-size: clamp(80px, 14vw, 200px);
  color: #ff6b6b;
  letter-spacing: 6px;
  text-shadow: 4px 4px 0 #000, 0 0 30px rgba(255,80,80,0.6);
  pointer-events: none;
  animation: flash-time-up 1.4s ease-out;
  z-index: 10;
}
@keyframes flash-time-up {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.7); }
  20%  { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
  80%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1); }
}
.clue-response {
  font-family: var(--font-clue);
  font-weight: 900;
  color: var(--jeopardy-bright-yellow);
  font-size: clamp(32px, 5vw, 72px);
  text-align: center;
  text-shadow: 3px 3px 0 rgba(0,0,0,0.7);
  letter-spacing: 2px;
  margin-top: 10px;
  padding: 20px;
  border-top: 3px dashed rgba(255,230,0,0.4);
  animation: fadeIn 0.4s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.clue-controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
  margin-top: 20px;
}
.judging-controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}
.judging-controls .btn { font-size: 13px; padding: 12px 18px; }

/* ============ DAILY DOUBLE ============ */
#dd-overlay {
  background: radial-gradient(ellipse at center, #d16a1b 0%, #6a2b0a 80%, #2a1000 100%);
}
.dd-splash {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: ddFlash 0.6s ease-out;
}
.dd-text {
  font-family: var(--font-display);
  font-size: clamp(80px, 15vw, 220px);
  color: var(--jeopardy-yellow);
  text-align: center;
  letter-spacing: 4px;
  line-height: 0.95;
  text-shadow:
    4px 4px 0 #000,
    8px 8px 0 rgba(0,0,0,0.5),
    0 0 40px rgba(255,230,0,0.3);
  transform: skewX(-6deg);
  text-transform: uppercase;
}
@keyframes ddFlash {
  0% { opacity: 0; transform: scale(0.6); }
  50% { opacity: 1; transform: scale(1.1); }
  100% { opacity: 1; transform: scale(1); }
}
.dd-wager {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 30px;
  text-align: center;
}
.dd-wager.visible { display: flex; }
.dd-header {
  font-family: var(--font-display);
  font-size: clamp(40px, 6vw, 80px);
  color: var(--jeopardy-yellow);
  letter-spacing: 3px;
  text-shadow: 3px 3px 0 #000;
  text-transform: uppercase;
}
.dd-instruct {
  font-size: 20px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--paper);
}
.dd-team-pick {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
}
#dd-wager-input {
  font-size: 28px;
  text-align: center;
  max-width: 260px;
}

/* ============ FINAL JEOPARDY ============ */
#final-screen {
  background: var(--jeopardy-blue);
  align-items: center;
  justify-content: center;
  padding: 40px 30px;
  overflow: auto;
}
.final-step {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  max-width: 1400px;
  width: 100%;
  text-align: center;
}
.final-step.active { display: flex; }
.final-category-label {
  font-family: var(--font-category);
  font-size: 20px;
  text-transform: uppercase;
  letter-spacing: 3px;
  color: var(--jeopardy-yellow);
  opacity: 0.85;
}
.final-category {
  font-family: var(--font-display);
  font-size: clamp(48px, 8vw, 110px);
  color: var(--jeopardy-yellow);
  letter-spacing: 3px;
  text-shadow: 4px 4px 0 #000;
  text-transform: uppercase;
  line-height: 1.05;
}
.final-wagers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 24px;
  width: 100%;
  max-width: 900px;
  margin-top: 20px;
}
.final-wager-block {
  background: rgba(0,0,0,0.35);
  padding: 20px;
  border-radius: 10px;
  text-align: center;
  border: 1px solid rgba(255,255,255,0.2);
}
.final-wager-block label {
  display: block;
  font-size: 18px;
  color: var(--paper);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 700;
}
.final-max {
  font-size: 13px;
  color: var(--jeopardy-yellow);
  margin-bottom: 12px;
  letter-spacing: 1px;
}
.final-instruct {
  color: var(--paper);
  font-size: 16px;
  letter-spacing: 2px;
  text-transform: uppercase;
  opacity: 0.8;
}
.final-small-clue {
  font-family: var(--font-clue);
  font-weight: 700;
  color: var(--paper);
  font-size: clamp(20px, 3vw, 36px);
  text-align: center;
  max-width: 1000px;
  text-transform: uppercase;
  opacity: 0.85;
}
.final-judge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 30px;
  width: 100%;
  max-width: 1100px;
  margin-top: 20px;
}
.final-judge-block {
  background: rgba(0,0,0,0.35);
  padding: 24px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid rgba(255,255,255,0.2);
}
.final-team-name {
  font-family: var(--font-display);
  font-size: 36px;
  color: var(--jeopardy-yellow);
  letter-spacing: 2px;
}
.final-wager-display {
  font-size: 20px;
  color: var(--paper);
  opacity: 0.8;
  margin-bottom: 10px;
}
.final-result {
  font-weight: 800;
  font-size: 18px;
  min-height: 24px;
  text-transform: uppercase;
  letter-spacing: 2px;
}
.final-result.correct { color: #9df596; }
.final-result.wrong { color: #ff8a8a; }

.winner-announce {
  font-family: var(--font-display);
  font-size: clamp(40px, 6vw, 80px);
  color: var(--jeopardy-yellow);
  letter-spacing: 3px;
  text-shadow: 4px 4px 0 #000;
  text-transform: uppercase;
}
.final-scoreboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 30px;
  width: 100%;
  max-width: 1000px;
  margin-top: 20px;
}
.final-score-card {
  background: rgba(0,0,0,0.4);
  padding: 30px;
  border-radius: 10px;
  text-align: center;
}
.final-score-card.winner {
  background: linear-gradient(135deg, rgba(255,204,0,0.3), rgba(255,204,0,0.1));
  border: 2px solid var(--jeopardy-yellow);
}
.final-score-card .team-name { font-size: 22px; margin-bottom: 10px; }
.final-score-card .team-score { font-size: 56px; }

/* ============ RESPONSIVENESS ============ */
@media (max-width: 700px) {
  .board { padding: 4px; gap: 3px; }
  .scores { grid-template-columns: 1fr; }
  .judging-controls { grid-template-columns: 1fr 1fr; }
  .final-wagers, .final-judge-grid, .final-scoreboard { grid-template-columns: 1fr; }
}

/* ============================================================
   LIBRARY
   ============================================================ */

#library-screen {
  overflow-y: auto;
  align-items: flex-start;
  padding: 40px 20px 60px;
}
.library-container {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.library-head { text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.library-head .subtitle { margin-top: 0; letter-spacing: 1px; text-transform: none; font-size: 15px; }

.library-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.library-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--muted);
  border-bottom: 1px solid rgba(255,255,255,0.12);
  padding-bottom: 10px;
}
.storage-health { display: flex; align-items: center; gap: 10px; }
.storage-badge {
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: help;
}
.storage-badge.ok   { background: rgba(60,170,100,0.18); color: #7fdca4; }
.storage-badge.warn { background: rgba(220,150,40,0.18); color: #ffc46b; }

.library-list { display: flex; flex-direction: column; gap: 12px; }
.library-empty { text-align: center; color: var(--muted); padding: 40px 0; }
.library-empty .muted { font-size: 13px; margin-top: 6px; opacity: 0.75; }

.game-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  padding: 16px 18px;
}
.game-card-head { flex: 1 1 240px; min-width: 0; }
.game-card-title {
  font-family: var(--font-category);
  font-size: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.game-card-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.game-card-warn { font-size: 12px; color: #ffc46b; margin-top: 6px; }
.game-card-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-danger { color: #ff9a9a; border-color: rgba(255,120,120,0.4); }
.btn-danger:hover { background: rgba(180,40,40,0.25); }

/* ============================================================
   ISSUE BANNERS
   ============================================================ */

.setup-issues, .builder-issues { display: flex; flex-direction: column; gap: 8px; }
.issue {
  font-size: 13px;
  border-radius: 6px;
  padding: 8px 12px;
  text-align: left;
}
.issue.error { background: rgba(180,40,40,0.22); color: #ffb3b3; }
.issue.warn  { background: rgba(220,150,40,0.16); color: #ffcf8f; cursor: pointer; }
.issue.ok    { background: rgba(60,170,100,0.16); color: #8fe0ac; }
.issue ul { margin: 8px 0 2px 18px; display: flex; flex-direction: column; gap: 4px; }
.issue summary { cursor: pointer; }

.setup-footer { display: flex; gap: 10px; justify-content: center; }

/* ============================================================
   BUILDER
   ============================================================ */

#builder-screen {
  display: none;
  padding: 0;
  align-items: stretch;
  justify-content: flex-start;
  flex-direction: column;
  background: #0a0f2e;
}
#builder-screen.active { display: flex; }

.flex-spacer { flex: 1; }

.builder-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(0,0,0,0.4);
  border-bottom: 1px solid rgba(255,255,255,0.12);
  flex-wrap: wrap;
}
.builder-title {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--jeopardy-yellow);
  font-family: var(--font-category);
  font-size: 20px;
  text-transform: uppercase;
  padding: 6px 10px;
  min-width: 200px;
}
.builder-title:hover { border-color: rgba(255,255,255,0.2); }
.builder-title:focus { outline: none; border-color: var(--jeopardy-yellow); background: rgba(0,0,0,0.4); }
.builder-status { font-size: 12px; color: var(--muted); min-width: 60px; }
.builder-issues { max-width: 320px; }
.builder-issues .issue { padding: 4px 10px; font-size: 12px; }

.builder-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 14px 0;
  overflow-x: auto;
  border-bottom: 1px solid rgba(255,255,255,0.12);
}
.builder-tab {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  color: var(--paper);
  font-family: var(--font-category);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 9px 16px;
  cursor: pointer;
  white-space: nowrap;
}
.builder-tab:hover { background: rgba(255,255,255,0.12); }
.builder-tab.active { background: var(--jeopardy-blue); border-color: var(--jeopardy-yellow); color: var(--jeopardy-yellow); }
.builder-tab.final { font-style: italic; }
.builder-tab.add { background: transparent; color: var(--muted); }

.builder-body {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 0;
  min-height: 0;
}
.builder-board { padding: 16px; overflow: auto; }
.builder-empty { color: var(--muted); text-align: center; padding: 40px; }

.builder-inspector {
  background: rgba(0,0,0,0.35);
  border-left: 1px solid rgba(255,255,255,0.12);
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.inspector-head {
  font-family: var(--font-category);
  text-transform: uppercase;
  color: var(--jeopardy-yellow);
  font-size: 14px;
  letter-spacing: 0.05em;
}
.inspector-hint { color: var(--muted); font-size: 13px; }

@media (max-width: 900px) {
  .builder-body { grid-template-columns: 1fr; }
  .builder-inspector { border-left: none; border-top: 1px solid rgba(255,255,255,0.12); }
}

/* ===== Round toolbar ===== */

.round-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.round-title-input {
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  color: var(--paper);
  font-family: var(--font-category);
  font-size: 15px;
  text-transform: uppercase;
  padding: 8px 12px;
  min-width: 200px;
}
.round-field { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.round-field input {
  width: 60px;
  padding: 6px 8px;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  color: var(--paper);
}
.round-note { font-size: 12px; color: var(--muted); }

/* ===== Editable grid ===== */

.builder-grid-wrap { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.builder-grid { display: grid; gap: 4px; width: 100%; }

.builder-corner { }
.builder-cat {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--jeopardy-blue);
  border: 2px solid var(--jeopardy-border);
  border-radius: 4px;
  padding: 4px;
}
.builder-cat input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  color: var(--paper);
  font-family: var(--font-category);
  font-size: 12px;
  text-transform: uppercase;
  text-align: center;
  padding: 6px 2px;
}
.builder-cat input:focus { outline: 1px solid var(--jeopardy-yellow); border-radius: 3px; }

.builder-add-col, .icon-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 4px 6px;
}
.builder-add-col:hover, .icon-btn:hover { background: rgba(255,255,255,0.2); color: var(--paper); }
.icon-btn { align-self: center; }

.builder-value { display: flex; align-items: center; }
.builder-value input {
  width: 100%;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  color: var(--jeopardy-yellow);
  font-family: var(--font-display);
  font-size: 13px;
  text-align: center;
  padding: 6px 2px;
}

.builder-tile {
  position: relative;
  min-height: 72px;
  background: rgba(255,255,255,0.05);
  border: 2px dashed rgba(255,255,255,0.18);
  border-radius: 4px;
  padding: 6px;
  cursor: pointer;
  overflow: hidden;
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.builder-tile:hover { border-color: var(--jeopardy-yellow); }
.builder-tile.filled { background-color: var(--jeopardy-blue); border-style: solid; border-color: var(--jeopardy-border); }
.builder-tile.selected { outline: 2px solid var(--jeopardy-yellow); outline-offset: 1px; }
.builder-tile.has-photo .builder-tile-text {
  background: rgba(0,0,0,0.6);
  padding: 3px 5px;
  border-radius: 3px;
}
.builder-tile-text {
  font-size: 11px;
  line-height: 1.25;
  color: var(--paper);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.builder-tile-badge {
  position: absolute;
  top: 3px;
  right: 5px;
  font-size: 8px;
  color: var(--jeopardy-yellow);
}

/* ===== Fields ===== */

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.field input, .field textarea {
  width: 100%;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  color: var(--paper);
  font-family: var(--font-clue);
  font-size: 14px;
  padding: 9px 11px;
  resize: vertical;
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--jeopardy-yellow); }
.field-inline { flex-direction: row; align-items: center; gap: 8px; }
.field-inline input { width: auto; }

.final-editor { display: flex; flex-direction: column; gap: 14px; max-width: 620px; }

.photo-zone {
  border: 2px dashed rgba(255,255,255,0.25);
  border-radius: 8px;
  padding: 14px;
  text-align: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transition: border-color 0.15s, background 0.15s;
}
.photo-zone:hover, .photo-zone.drag { border-color: var(--jeopardy-yellow); background: rgba(255,204,0,0.08); }
.photo-zone.busy { opacity: 0.6; pointer-events: none; }
.photo-zone-hint { font-size: 12px; color: var(--muted); }
.photo-preview { max-width: 100%; max-height: 160px; border-radius: 6px; }

.attract-strip { display: flex; gap: 8px; flex-wrap: wrap; }
.attract-thumb {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 5px;
  background-size: cover;
  background-position: center;
}
.attract-thumb .icon-btn { position: absolute; top: -6px; right: -6px; padding: 1px 5px; }

/* ===== Settings drawer ===== */

.builder-settings {
  position: fixed;
  top: 0;
  right: 0;
  width: 340px;
  max-width: 90vw;
  height: 100%;
  background: #0d1440;
  border-left: 1px solid rgba(255,255,255,0.15);
  padding: 20px;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.22s ease;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.builder-settings.open { transform: translateX(0); }
.builder-settings h2 {
  font-family: var(--font-category);
  font-size: 16px;
  text-transform: uppercase;
  color: var(--jeopardy-yellow);
}
#builder-settings-body { display: flex; flex-direction: column; gap: 16px; }

/* ============================================================
   EMPTY BOARD TILES
   ============================================================ */

/* A tile nobody wrote a clue for. Reads as spent rather than clickable, so a
   half-finished board is still playable without dead ends. */
.clue-cell.empty { opacity: 0.35; }

/* ============================================================
   TOAST + DIALOG
   ============================================================ */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 20px);
  max-width: min(560px, 92vw);
  background: #12193f;
  border: 1px solid rgba(255,255,255,0.2);
  border-left: 4px solid var(--jeopardy-yellow);
  border-radius: 8px;
  color: var(--paper);
  font-size: 14px;
  padding: 12px 18px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
  z-index: 200;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast.ok    { border-left-color: #5fd18c; }
.toast.error { border-left-color: #ff7a7a; }
.toast.warn  { border-left-color: #ffb14d; }

.dialog-host {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 20px;
}
.dialog-host.active { display: flex; }
.dialog {
  background: #12193f;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 10px;
  padding: 24px;
  max-width: 460px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.dialog-message { font-size: 15px; line-height: 1.5; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

/* Game titles are user text and can be long, so the setup wordmark wraps
   rather than running off the screen the way the fixed logo could. */
#setup-title {
  white-space: normal;
  font-size: clamp(32px, 6vw, 72px);
  overflow-wrap: anywhere;
}
