/* ── Jeopardy Engine styles ──────────────────────────────────────────────────
   Generic visual design for the Jeopardy engine — nothing subject-specific.
   Theming hooks are the CSS custom properties in :root; override them after
   this stylesheet loads to reskin for a different app.

   CRITICAL: never use ID selectors in here. The engine prefixes every element
   id with a random per-mount uid so two instances can coexist, so `#board`
   can never match. Style by class only; ids are for JS lookups. */

:root {
  /* Surfaces — near-black navy, lit by the gradient mesh on <body>. */
  --bg-color: #05070f;
  --surface-1: #0a0f1e;
  --surface-2: #0e1526;
  --panel-bg: rgba(16, 22, 40, 0.62);
  --panel-border: rgba(255, 255, 255, 0.09);
  --hairline: rgba(255, 255, 255, 0.06);

  /* Accents — restrained console blue rather than saturated neon. */
  --primary: #6db6ff;
  --primary-deep: #2f6fd0;
  --secondary: #8a6cff;

  /* The board keeps Jeopardy's blue-and-gold identity. */
  --tile-top: #17356f;
  --tile-bottom: #0a1a3d;
  --gold: #f6cf6a;
  --gold-deep: #c99a2e;

  --correct: #34d399;
  --incorrect: #fb5779;

  --text-light: #f1f4fb;
  --text-muted: #94a1bd;

  --font-family: 'Inter Tight', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Archivo', 'Archivo Narrow', 'Helvetica Neue', Arial, sans-serif;

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;

  /* One shared easing curve keeps every transition feeling like one system. */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --tile-h: clamp(74px, 8.4vh, 108px);
}

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

html { color-scheme: dark; }

body {
  font-family: var(--font-family);
  font-optical-sizing: auto;
  background: var(--bg-color);
  color: var(--text-light);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Gradient mesh + vignette. Fixed, so it never scrolls or reflows; both
   pseudo-elements are flex children of <body> but position:fixed takes them
   out of flow, so the layout is unaffected. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(60% 55% at 12% 18%, rgba(58, 92, 200, 0.28) 0%, transparent 62%),
    radial-gradient(55% 50% at 88% 12%, rgba(122, 84, 255, 0.20) 0%, transparent 60%),
    radial-gradient(70% 60% at 50% 108%, rgba(30, 74, 160, 0.26) 0%, transparent 66%),
    linear-gradient(180deg, #070b16 0%, #05070f 55%, #04060d 100%);
}

/* Film grain + corner falloff — kills the flat "gradient poster" look and
   hides banding on the big dark areas of a projector or TV. */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

.jeopardy-engine-root {
  position: relative;
  z-index: 1;
  max-width: 1440px;
  margin: 0 auto;
  padding: clamp(1rem, 2.2vw, 2rem);
  width: 100%;
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: clamp(1rem, 2vw, 2rem);
  margin-bottom: clamp(1.2rem, 2.4vw, 2rem);
  animation: fadeInDown 0.7s var(--ease) both;
}

.logo { flex: 0 0 auto; }

.logo-img {
  max-height: 3rem;
  margin-bottom: 0.4rem;
}

.logo h1 {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 3.6vw, 3.6rem);
  font-weight: 900;
  font-stretch: 88%;
  letter-spacing: -0.015em;
  line-height: 0.98;
  color: var(--text-light); /* fallback if background-clip:text is unsupported */
  background: linear-gradient(100deg, #ffffff 0%, #cfe0ff 38%, var(--primary) 68%, var(--secondary) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 18px rgba(90, 140, 255, 0.28));
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  margin-top: 0.35rem;
}

/* ── Glass panels ─────────────────────────────────────────────────────────── */
.glass-panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(16px) saturate(1.15);
  -webkit-backdrop-filter: blur(16px) saturate(1.15);
  border-radius: var(--radius-lg);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 24px 60px -30px rgba(0, 0, 0, 0.95);
}

/* ── Board ────────────────────────────────────────────────────────────────── */
.board-container {
  flex: 1;
  display: flex;
  justify-content: center;
  animation: fadeInUp 0.7s var(--ease) 0.12s both;
}

.board {
  display: grid;
  --board-cols: 6;
  grid-template-columns: repeat(var(--board-cols), 1fr);
  /* Row 1 is the category strip (auto); clue rows share the leftover height, so
     the board fills the cabinet instead of stranding space under the last row.
     This must stay `1fr` — a definite cap like minmax(…, 190px) lets the tracks
     reach their growth limit in an indefinite-height flex parent and pushes the
     bottom row off screen on a full 5-row board. A Lite board simply gets
     taller, more readable tiles. */
  grid-template-rows: auto;
  grid-auto-rows: minmax(var(--tile-h), 1fr);
  gap: 10px;
  padding: clamp(12px, 1.2vw, 20px);
  width: 100%;
  /* The cabinet the tiles sit in: slightly darker than the page, gold hairline. */
  background: linear-gradient(180deg, rgba(12, 20, 42, 0.72), rgba(6, 10, 22, 0.72));
  border-color: rgba(246, 207, 106, 0.14);
}

/* Wide boards (7+ categories) — tighten spacing/text to fit; the exact
   column count comes from --board-cols, set in JS from category count. */
.board.cols-wide { gap: 6px; }
.board.cols-wide .category-header { font-size: clamp(0.7rem, 0.85vw, 0.95rem); padding: 0.6rem 0.3rem; }
.board.cols-wide .tile { font-size: clamp(1.15rem, 1.8vw, 1.7rem); }

.category-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0.9rem 0.5rem 1.1rem;
  font-family: var(--font-display);
  font-weight: 800;
  font-stretch: 82%;
  font-size: clamp(0.85rem, 1.05vw, 1.2rem);
  line-height: 1.15;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #dce7fb;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
  text-wrap: balance;
}

/* Gold rule under each category — fades out at both ends. */
.category-header::after {
  content: '';
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 0;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, rgba(246, 207, 106, 0.55), transparent);
}

.tile {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  min-height: var(--tile-h); /* the grid row stretch supplies the rest */
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: var(--radius-md);
  border: 1px solid rgba(140, 180, 255, 0.14);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0) 45%),
    linear-gradient(176deg, var(--tile-top) 0%, var(--tile-bottom) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 -1px 0 rgba(0, 0, 0, 0.4),
    0 12px 24px -16px rgba(0, 0, 0, 0.95);
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 2.1vw, 2.2rem);
  font-weight: 800;
  font-stretch: 86%;
  font-variant-numeric: tabular-nums lining-nums;
  letter-spacing: -0.01em;
  color: var(--gold);
  text-shadow: 0 2px 2px rgba(0, 0, 0, 0.55);
  cursor: pointer;
  transition:
    transform 0.28s var(--ease),
    box-shadow 0.28s var(--ease),
    border-color 0.28s var(--ease);
}

/* Warm pool of light that blooms up from the bottom on hover. */
.tile::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(85% 70% at 50% 118%, rgba(246, 207, 106, 0.30) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.28s var(--ease);
}

/* Specular sheen that sweeps across on hover. */
.tile::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: -60%;
  width: 45%;
  z-index: -1;
  transform: skewX(-18deg);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.13), transparent);
  transition: left 0.55s var(--ease);
}

.tile:hover {
  transform: translateY(-4px);
  border-color: rgba(246, 207, 106, 0.5);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    0 20px 34px -18px rgba(0, 0, 0, 1),
    0 0 26px -6px rgba(246, 207, 106, 0.35);
}

.tile:hover::before { opacity: 1; }
.tile:hover::after { left: 115%; }

.tile:active { transform: translateY(-1px) scale(0.985); }

.tile.answered {
  background: rgba(255, 255, 255, 0.018);
  border-color: rgba(255, 255, 255, 0.045);
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.5);
  color: transparent;
  text-shadow: none;
  cursor: default;
  pointer-events: none;
  transform: none;
}

.tile.answered::before,
.tile.answered::after { display: none; }

/* ── Modals ───────────────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 1;
  transition: opacity 0.28s var(--ease);
}

.modal.hidden {
  opacity: 0;
  pointer-events: none;
}

/* These elements are toggled with a bare `hidden` class by the engine and are
   NOT modals, so they need their own display rule. Without this the feedback
   box (and its "Back to Board" button) stays on screen during a live question. */
.feedback-box.hidden,
.picker-score-btns.hidden,
.btn.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background:
    radial-gradient(60% 55% at 50% 38%, rgba(28, 52, 110, 0.5) 0%, transparent 70%),
    rgba(2, 4, 10, 0.82);
  backdrop-filter: blur(14px) saturate(0.85);
  -webkit-backdrop-filter: blur(14px) saturate(0.85);
}

.modal-content {
  position: relative;
  width: 90%;
  max-width: 860px;
  padding: clamp(1.6rem, 3vw, 3rem);
  text-align: center;
  transform: scale(1);
  transition: transform 0.42s cubic-bezier(0.16, 1.1, 0.3, 1);
  /* 1px gradient border: painted in the border box, panel fill in the padding
     box, so the rim catches light at the top and fades toward the bottom. */
  border: 1px solid transparent;
  background:
    linear-gradient(180deg, rgba(17, 24, 44, 0.94), rgba(9, 13, 26, 0.94)) padding-box,
    linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.04) 45%, rgba(255, 255, 255, 0.02)) border-box;
}

.modal.hidden .modal-content {
  transform: scale(0.94) translateY(8px);
}

.modal-content.glow {
  box-shadow:
    0 40px 120px -40px rgba(0, 0, 0, 1),
    0 0 90px -30px rgba(109, 182, 255, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1.8rem;
  border-bottom: 1px solid var(--hairline);
  padding-bottom: 1rem;
}

.modal-header h2 {
  font-family: var(--font-display);
  font-size: clamp(0.95rem, 1.3vw, 1.35rem);
  font-weight: 700;
  font-stretch: 84%;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  text-align: left;
}

.neon-text {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 2.2vw, 2.1rem);
  font-weight: 800;
  font-stretch: 88%;
  font-variant-numeric: tabular-nums lining-nums;
  letter-spacing: -0.01em;
  color: var(--gold);
  text-shadow: 0 2px 14px rgba(246, 207, 106, 0.28);
}

.modal-body p {
  font-size: clamp(1.35rem, 2.5vw, 2.4rem);
  font-weight: 500;
  line-height: 1.28;
  letter-spacing: -0.015em;
  margin-bottom: clamp(1.5rem, 2.6vw, 2.5rem);
  text-wrap: balance;
}

.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.option-btn {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.03));
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 1.15rem 1.3rem;
  border-radius: var(--radius-md);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  color: var(--text-light);
  font-size: clamp(1rem, 1.35vw, 1.35rem);
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.005em;
  font-family: inherit;
  cursor: pointer;
  transition:
    transform 0.2s var(--ease),
    border-color 0.2s var(--ease),
    background 0.2s var(--ease),
    box-shadow 0.2s var(--ease);
  text-align: left;
  display: flex;
  align-items: center;
  gap: 0.1rem;
}

.option-btn strong {
  font-family: var(--font-display);
  font-weight: 800;
  font-stretch: 84%;
  color: var(--primary);
  transition: color 0.2s var(--ease);
}

.option-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, rgba(109, 182, 255, 0.16), rgba(109, 182, 255, 0.06));
  border-color: rgba(109, 182, 255, 0.55);
  transform: translateY(-2px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 14px 28px -18px rgba(0, 0, 0, 1);
}

.option-btn:active:not(:disabled) { transform: translateY(0) scale(0.99); }

.option-btn.correct-reveal {
  background: linear-gradient(180deg, rgba(52, 211, 153, 0.26), rgba(52, 211, 153, 0.1));
  border-color: var(--correct);
  color: #d7fff0;
  box-shadow: 0 0 34px -10px rgba(52, 211, 153, 0.7);
  animation: revealPop 0.42s var(--ease);
}
.option-btn.correct-reveal strong { color: var(--correct); }

.option-btn.wrong-reveal {
  background: linear-gradient(180deg, rgba(251, 87, 121, 0.22), rgba(251, 87, 121, 0.08));
  border-color: var(--incorrect);
  color: #ffdbe3;
  opacity: 0.85;
}
.option-btn.wrong-reveal strong { color: var(--incorrect); }

/* Options that were neither picked nor correct recede once the answer lands. */
.option-btn:disabled { cursor: default; }
.option-btn:disabled:not(.correct-reveal):not(.wrong-reveal) { opacity: 0.42; }

.feedback-box {
  margin-top: 1.8rem;
  padding: clamp(1rem, 1.6vw, 1.5rem);
  border-radius: var(--radius-md);
  animation: fadeInUp 0.4s var(--ease);
}

.feedback-box.correct {
  background: linear-gradient(180deg, rgba(52, 211, 153, 0.12), rgba(52, 211, 153, 0.04));
  border: 1px solid rgba(52, 211, 153, 0.32);
}

.feedback-box.incorrect {
  background: linear-gradient(180deg, rgba(251, 87, 121, 0.12), rgba(251, 87, 121, 0.04));
  border: 1px solid rgba(251, 87, 121, 0.32);
}

.feedback-title {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 2.2vw, 2.1rem);
  font-weight: 800;
  font-stretch: 88%;
  letter-spacing: -0.01em;
  margin-bottom: 0.5rem;
}

.correct .feedback-title { color: var(--correct); }
.incorrect .feedback-title { color: var(--incorrect); }

.feedback-remark {
  font-size: clamp(1rem, 1.35vw, 1.35rem);
  line-height: 1.5;
  color: var(--text-light);
  margin-bottom: 1.4rem;
  text-wrap: pretty;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  position: relative;
  overflow: hidden;
  padding: 0.95rem 2rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 800;
  font-stretch: 86%;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  border: none;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), filter 0.2s var(--ease);
}

.primary-btn {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-deep) 55%, var(--secondary) 100%);
  color: #061021;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 14px 30px -14px rgba(72, 116, 255, 0.85);
}

/* Sheen that sweeps the button on hover. */
.primary-btn::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: -70%;
  width: 45%;
  transform: skewX(-18deg);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  transition: left 0.6s var(--ease);
}

.primary-btn:hover {
  transform: translateY(-2px);
  filter: saturate(1.1);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    0 18px 38px -14px rgba(72, 116, 255, 1);
}

.primary-btn:hover::after { left: 130%; }
.primary-btn:active { transform: translateY(0) scale(0.985); }

/* Keyboard users get a visible ring; mouse users never see it. */
.btn:focus-visible,
.option-btn:focus-visible,
.hdr-btn:focus-visible,
.setup-count-btn:focus-visible,
.setup-mode-btn:focus-visible,
.setup-name:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

/* ── Animations ───────────────────────────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeInDown { from { opacity: 0; transform: translateY(-16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes revealPop { 0% { transform: scale(1); } 45% { transform: scale(1.035); } 100% { transform: scale(1); } }

/* ── Scrollbars ───────────────────────────────────────────────────────────── */
.teams-bar::-webkit-scrollbar,
.setup-names::-webkit-scrollbar,
.flags-list::-webkit-scrollbar,
.learn-content::-webkit-scrollbar { width: 8px; }

.teams-bar::-webkit-scrollbar-thumb,
.setup-names::-webkit-scrollbar-thumb,
.flags-list::-webkit-scrollbar-thumb,
.learn-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 99px;
}

.teams-bar::-webkit-scrollbar-track,
.setup-names::-webkit-scrollbar-track,
.flags-list::-webkit-scrollbar-track,
.learn-content::-webkit-scrollbar-track { background: transparent; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .board { grid-template-columns: repeat(3, 1fr); }
  .board.cols-wide { grid-template-columns: repeat(4, 1fr); }
  header { flex-wrap: wrap; justify-content: center; text-align: center; }
  .logo h1 { text-align: center; }
}

@media (max-width: 600px) {
  .board { grid-template-columns: repeat(2, 1fr); }
  .board.cols-wide { grid-template-columns: repeat(2, 1fr); }
  .options-grid { grid-template-columns: 1fr; }
  .modal-content { padding: 1.5rem 1.2rem; }
  .modal-header { flex-direction: column; align-items: center; gap: 0.4rem; }
  .modal-header h2 { text-align: center; }
}

/* Honour the OS "reduce motion" setting: keep state changes, drop the travel. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .tile:hover { transform: none; }
  .primary-btn:hover { transform: none; }
}

/* ── Teams mode ───────────────────────────────────────────────────────────── */
.teams-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  align-content: center;
  flex: 1;
  max-height: 190px;
  overflow-y: auto;
  padding: 2px;
}

.team-card {
  position: relative;
  background: linear-gradient(180deg, rgba(24, 32, 55, 0.75), rgba(12, 17, 32, 0.75));
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  padding: 8px 14px;
  text-align: center;
  cursor: pointer;
  min-width: 104px;
  transition: border-color 0.2s var(--ease), transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.team-card:hover { transform: translateY(-2px); border-color: rgba(255, 255, 255, 0.18); }

.team-card.active {
  border-color: rgba(109, 182, 255, 0.75);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 0 26px -6px rgba(109, 182, 255, 0.65);
}

.team-name {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
  cursor: text;
}

.team-card.active .team-name { color: var(--primary); }

.team-name-edit {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-light);
  max-width: 180px;
  width: 100%;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--primary);
  border-radius: 6px;
  padding: 2px 6px;
  font-family: inherit;
  text-align: center;
}

.team-score {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 800;
  font-stretch: 86%;
  font-variant-numeric: tabular-nums lining-nums;
  letter-spacing: -0.01em;
  color: var(--correct);
  transition: filter 0.35s var(--ease), opacity 0.35s var(--ease);
}

.team-score.neg { color: var(--incorrect); }

.team-turn {
  font-family: var(--font-display);
  font-size: 0.66rem;
  font-weight: 800;
  font-stretch: 84%;
  color: var(--primary);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* Show/hide scores toggle — blur+fade the numbers, keep names visible so the
   board stays usable while scores are hidden for suspense. */
.teams-bar.scores-hidden .team-score { filter: blur(7px); opacity: 0.3; }

/* Many-player layout: tighten cards so 10+ names/scores still read cleanly */
.teams-bar.compact .team-card { min-width: 76px; padding: 6px 8px; }
.teams-bar.compact .team-name, .teams-bar.compact .team-name-edit { font-size: 0.78rem; max-width: 120px; }
.teams-bar.compact .team-score { font-size: 1.2rem; }
.teams-bar.compact .team-turn { font-size: 0.6rem; }

.header-btns { display: flex; gap: 8px; flex: 0 0 auto; }

.hdr-btn {
  background: linear-gradient(180deg, rgba(24, 32, 55, 0.8), rgba(12, 17, 32, 0.8));
  border: 1px solid var(--panel-border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  color: var(--text-light);
  border-radius: var(--radius-sm);
  padding: 10px 15px;
  font-family: var(--font-family);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), transform 0.2s var(--ease);
}

.hdr-btn:hover { border-color: rgba(109, 182, 255, 0.6); transform: translateY(-1px); }
.hdr-btn:active { transform: translateY(0); }

.modal-team {
  text-align: center;
  color: var(--primary);
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  margin-top: 4px;
  margin-bottom: 1rem;
}

.skip-btn {
  display: block;
  margin: 14px auto 0;
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 0.8rem 1.4rem;
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 700;
  font-stretch: 86%;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease);
}

.skip-btn:hover { border-color: var(--incorrect); color: var(--text-light); }
.skip-btn.hidden { display: none; }

/* ── Setup + results ──────────────────────────────────────────────────────── */
.setup-content { max-width: 500px; text-align: center; }

.setup-sub {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin: 18px 0 10px;
}

.setup-counts { display: flex; gap: 8px; justify-content: center; margin-bottom: 14px; flex-wrap: wrap; }

.setup-count-btn, .setup-mode-btn {
  background: linear-gradient(180deg, rgba(24, 32, 55, 0.8), rgba(12, 17, 32, 0.8));
  border: 1px solid var(--panel-border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  color: var(--text-light);
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-family: var(--font-family);
  font-weight: 600;
  font-size: 0.98rem;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.setup-count-btn.active, .setup-mode-btn.active {
  border-color: rgba(109, 182, 255, 0.75);
  color: var(--primary);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 0 22px -6px rgba(109, 182, 255, 0.7);
}

.setup-modes, .setup-lengths { display: flex; gap: 8px; justify-content: center; margin-bottom: 16px; }
.setup-mode-btn { flex: 1; font-size: 1rem; padding: 12px; }

/* Game-length picker (Lite / Full). Same chrome as the mode buttons, but a
   separate class — the engine reads each group's `.active` button by class. */
.setup-length-btn {
  flex: 1;
  background: linear-gradient(180deg, rgba(24, 32, 55, 0.8), rgba(12, 17, 32, 0.8));
  border: 1px solid var(--panel-border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  color: var(--text-light);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: var(--font-family);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.setup-length-btn.active {
  border-color: rgba(246, 207, 106, 0.75);
  color: var(--gold);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 0 22px -6px rgba(246, 207, 106, 0.7);
}

.setup-length-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }

.setup-keys {
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.5;
  margin-top: 16px;
  text-wrap: pretty;
}

/* Two columns of name inputs; scrolls internally once the roster gets big
   (classroom-sized rosters) instead of pushing the Start button off-screen. */
.setup-names { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; max-height: 42vh; overflow-y: auto; padding: 2px; }
.setup-names input:only-child { grid-column: 1 / -1; }

.setup-name {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--panel-border);
  color: var(--text-light);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: var(--font-family);
  font-size: 1.05rem;
  font-weight: 500;
  text-align: center;
  transition: border-color 0.2s var(--ease);
}

.setup-name:focus { outline: none; border-color: var(--primary); }

.results-list { margin: 18px 0; display: flex; flex-direction: column; gap: 8px; }

.result-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(180deg, rgba(24, 32, 55, 0.7), rgba(12, 17, 32, 0.7));
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  font-size: 1.2rem;
}

.result-row.winner {
  border-color: rgba(246, 207, 106, 0.6);
  background: linear-gradient(180deg, rgba(246, 207, 106, 0.14), rgba(246, 207, 106, 0.03));
  box-shadow: 0 0 30px -8px rgba(246, 207, 106, 0.6);
  font-size: 1.45rem;
}

.result-medal { width: 2rem; }
.result-name { flex: 1; text-align: left; font-weight: 600; }

.result-score {
  font-family: var(--font-display);
  font-weight: 800;
  font-stretch: 86%;
  font-variant-numeric: tabular-nums lining-nums;
  color: var(--correct);
}

.result-row.winner .result-score { color: var(--gold); }

/* ── Secret fact-check flags ─────────────────────────────────────────────── */
.modal-value { user-select: none; cursor: default; }
.modal-value.flagged { text-decoration: underline dotted rgba(255, 165, 0, 0.6); text-underline-offset: 6px; }
.modal-value.flag-pulse { animation: flagPulse 0.6s ease; }
@keyframes flagPulse {
  0% { color: inherit; }
  30% { color: #ffa500; text-shadow: 0 0 12px rgba(255, 165, 0, 0.8); }
  100% { color: inherit; }
}

.flags-list {
  max-height: 50vh;
  overflow-y: auto;
  text-align: left;
  margin: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.flags-empty { color: var(--text-muted); text-align: center; padding: 20px 0; }
.flag-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.flag-info { flex: 1; min-width: 0; }
.flag-meta { color: var(--primary); font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; }
.flag-text { margin: 4px 0; }
.flag-answer { color: var(--correct); font-size: 0.85rem; }
.flag-unflag {
  background: none;
  border: 1px solid var(--panel-border);
  color: var(--text-muted);
  border-radius: 8px;
  padding: 4px 10px;
  cursor: pointer;
  font-family: inherit;
}
.flag-unflag:hover { border-color: var(--incorrect); color: var(--incorrect); }
.flags-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ── Secret name picker ───────────────────────────────────────────────────── */
.picker-name {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4.5vw, 3.4rem);
  font-weight: 900;
  font-stretch: 88%;
  letter-spacing: -0.02em;
  margin: 30px 0;
  min-height: 1.3em;
  color: var(--text-light);
}

.picker-name.picker-final {
  color: var(--correct);
  text-shadow: 0 0 40px rgba(52, 211, 153, 0.55);
  animation: pickerPop 0.4s var(--ease);
}

@keyframes pickerPop {
  0% { transform: scale(0.7); }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.picker-score-btns { display: flex; gap: 12px; justify-content: center; align-items: stretch; margin-bottom: 16px; animation: fadeIn 0.3s ease; }

/* The incorrect button is also a .skip-btn, whose `margin: 14px auto 0` would
   otherwise shove it below its sibling inside this flex row. */
.picker-score-btns .btn {
  margin: 0;
  font-size: 0.85rem;
  padding: 0.85rem 1.5rem;
}

.picker-correct-btn {
  background: linear-gradient(180deg, rgba(52, 211, 153, 0.22), rgba(52, 211, 153, 0.08));
  border: 1px solid var(--correct);
  color: var(--correct);
  box-shadow: none;
}
.picker-correct-btn::after { content: none; }
.picker-correct-btn:hover {
  background: linear-gradient(180deg, rgba(52, 211, 153, 0.32), rgba(52, 211, 153, 0.14));
  transform: translateY(-2px);
  box-shadow: 0 0 30px -8px rgba(52, 211, 153, 0.7);
  filter: none;
}

.picker-incorrect-btn { border-color: var(--incorrect); color: var(--incorrect); }
.picker-incorrect-btn:hover { border-color: var(--incorrect); color: var(--text-light); background: rgba(251, 87, 121, 0.16); }

/* ── Learn / reference panel (optional, config.learn) ────────────────────── */
.learn-link {
  display: block;
  margin: 16px auto 0;
  background: none;
  border: none;
  color: var(--primary);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.2s var(--ease);
}
.learn-link:hover { color: var(--text-light); }

.learn-content {
  max-width: 760px;
  max-height: 85vh;
  overflow-y: auto;
  text-align: left;
}
.learn-content .modal-header h2 {
  font-family: var(--font-display);
  text-transform: none;
  letter-spacing: -0.01em;
  font-stretch: 92%;
  color: var(--text-light);
  font-size: clamp(1.25rem, 1.8vw, 1.6rem);
}
.learn-body h3 {
  font-family: var(--font-display);
  font-stretch: 88%;
  color: var(--primary);
  font-size: 1.15rem;
  letter-spacing: -0.005em;
  margin: 24px 0 10px;
}
.learn-body h3:first-child { margin-top: 0; }
.learn-body p {
  color: var(--text-light);
  line-height: 1.62;
  margin-bottom: 12px;
  text-wrap: pretty;
}
.learn-body ul {
  margin: 0 0 12px 1.2em;
  line-height: 1.62;
}
.learn-body strong { color: var(--primary); font-weight: 600; }

/* Wraps wide tables so they scroll horizontally on narrow screens instead of
   being silently clipped by body's overflow-x: hidden. */
.table-scroll {
  overflow-x: auto;
  margin: 12px 0 20px;
  border-radius: var(--radius-sm);
}

.value-table {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  margin: 0;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums lining-nums;
}
.value-table th, .value-table td {
  border: 1px solid var(--hairline);
  padding: 9px 11px;
  text-align: center;
}
.value-table th {
  background: rgba(255, 255, 255, 0.04);
  color: var(--primary);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
}
.value-table td:first-child, .value-table td:last-child { text-align: left; }
.value-table tr.this-game td {
  background: rgba(109, 182, 255, 0.1);
  color: var(--text-light);
  font-weight: 600;
}
.learn-footnote {
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.5;
  margin-top: 4px;
}

/* ── Optional visual clue slot ────────────────────────────────────────────────
   Rendered only when the host app supplies config.renderClue (e.g. PuzzlePardy
   draws a chess position here). Hidden and zero-cost for text-only apps. */
.clue-media { display: flex; justify-content: center; margin: 0 0 18px; }
.clue-media.hidden { display: none; }
