/* ============================================================
   BIG BOARD — game-show design system
   Fonts: Big Shoulders Display (display) + Archivo (body)
   All colors flow through theme tokens so holiday themes and
   AI-generated themes restyle every surface at once.
   ============================================================ */

:root {
  --bg-a: #0a0f2e;
  --bg-b: #050818;
  --board-bg: #030616;
  --cell-a: #1c2fd6;
  --cell-b: #101fa8;
  --cell-border: #04061c;
  --value: #e8b34b;
  --ink: #f4f6ff;
  --accent: #e8b34b;
  --accent-ink: #1a1300;
  --clue-a: #1c2fd6;
  --clue-b: #0a1470;
  --gold: #ffd977;

  --font-display: 'Big Shoulders Display', 'Arial Narrow', sans-serif;
  --font-body: 'Archivo', 'Helvetica Neue', sans-serif;
  --radius: 14px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.55);
}

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

html, body { height: 100%; }

body {
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(1200px 700px at 20% -10%, color-mix(in srgb, var(--cell-a) 24%, transparent), transparent 60%),
    radial-gradient(1000px 600px at 110% 110%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 55%),
    linear-gradient(160deg, var(--bg-a), var(--bg-b));
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* subtle scanline/grain atmosphere */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.015) 0 1px, transparent 1px 3px);
  z-index: 1;
}

h1, h2, h3, .display {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

button {
  font-family: var(--font-body);
  font-weight: 700;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}
button:active { transform: translateY(1px) scale(0.99); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

.btn {
  padding: 0.7rem 1.3rem;
  font-size: 1rem;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.15);
}
.btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.14); }

.btn-accent {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 100%, white 12%), var(--accent));
  color: var(--accent-ink);
  border: none;
  box-shadow: 0 4px 18px color-mix(in srgb, var(--accent) 45%, transparent);
}
.btn-accent:hover:not(:disabled) { filter: brightness(1.08); }

.btn-ghost { background: transparent; border: 1px dashed rgba(255,255,255,0.3); color: var(--ink); }

.btn-danger { background: #a4243b; color: #fff; }
.btn-good { background: #2d8a4e; color: #fff; }

input, select, textarea {
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 0.65rem 0.8rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.35);
  color: var(--ink);
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: rgba(255, 255, 255, 0.4); }

.card {
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: var(--radius);
  padding: 1.2rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
  position: relative;
  z-index: 2;
}

.muted { color: color-mix(in srgb, var(--ink) 55%, transparent); }
.gold { color: var(--gold); }
.row { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }

/* ---------- particles ---------- */

#particle-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}
.particle {
  position: absolute;
  top: -50px;
  animation: fall linear forwards;
  opacity: 0.8;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.4));
}
@keyframes fall {
  0% { transform: translateY(-60px) rotate(0deg); opacity: 0; }
  8% { opacity: 0.85; }
  100% { transform: translateY(110vh) rotate(340deg); opacity: 0.5; }
}

.confetti-canvas { position: fixed; inset: 0; pointer-events: none; z-index: 50; }

/* ---------- toast ---------- */

#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(10, 10, 14, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  padding: 0.8rem 1.4rem;
  border-radius: 12px;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 100;
  max-width: 90vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { border-color: #ff5d73; color: #ffd9de; }

/* ---------- the board ---------- */

.board {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: clamp(4px, 0.6vw, 10px);
  background: var(--board-bg);
  padding: clamp(6px, 0.8vw, 14px);
  border-radius: var(--radius);
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.board .cat, .board .cell {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  border-radius: 6px;
  background: linear-gradient(180deg, var(--cell-a), var(--cell-b));
  border: 1px solid var(--cell-border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), inset 0 -8px 18px rgba(0, 0, 0, 0.25);
}

.board .cat {
  font-family: var(--font-display);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: clamp(0.7rem, 1.5vw, 1.5rem);
  line-height: 1.1;
  padding: 0.4em 0.3em;
  min-height: 3.2em;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

.board .cell {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.1rem, 3.2vw, 3rem);
  color: var(--value);
  text-shadow: 0 3px 8px rgba(0, 0, 0, 0.65);
  min-height: 2.1em;
  user-select: none;
}
.board .cell.done {
  background: color-mix(in srgb, var(--board-bg) 80%, black);
  color: transparent;
  text-shadow: none;
  box-shadow: none;
  border-color: transparent;
}
button.cell:hover:not(.done):not(:disabled) {
  filter: brightness(1.25);
  transform: scale(1.02);
}

/* ---------- fullscreen clue (TV) ---------- */

.clue-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2.5vh;
  padding: 5vh 6vw;
  background: radial-gradient(1000px 600px at 50% 15%, color-mix(in srgb, var(--clue-a) 80%, white 6%), transparent 70%), linear-gradient(170deg, var(--clue-a), var(--clue-b));
  text-align: center;
  z-index: 10;
  animation: clue-in 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}
@keyframes clue-in {
  from { transform: scale(0.12); opacity: 0.2; border-radius: 20px; }
  to { transform: scale(1); opacity: 1; }
}
.clue-screen .kicker {
  font-family: var(--font-display);
  font-size: clamp(1rem, 2.4vw, 2rem);
  letter-spacing: 0.2em;
  color: var(--gold);
  text-transform: uppercase;
}
.clue-screen .clue-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.6rem, 5vw, 4.6rem);
  line-height: 1.18;
  text-transform: uppercase;
  text-shadow: 0 4px 14px rgba(0, 0, 0, 0.7);
  max-width: 22ch;
}
.clue-screen .answer-text {
  font-size: clamp(1.2rem, 3vw, 2.6rem);
  color: var(--gold);
  font-family: var(--font-display);
  animation: rise 0.4s ease;
}
@keyframes rise { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }

.clue-screen.buzzing { animation: none; }
.clue-screen.buzzing::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 10px solid var(--gold);
  pointer-events: none;
  animation: pulse-border 0.8s ease-in-out infinite;
}
@keyframes pulse-border { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }

.team-banner {
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 3.4vw, 3rem);
  padding: 0.3em 1em;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.4);
  border: 3px solid var(--team-color, var(--gold));
  color: var(--team-color, var(--gold));
  animation: rise 0.3s ease;
  text-transform: uppercase;
}

.dd-splash {
  font-family: var(--font-display);
  font-size: clamp(3rem, 10vw, 9rem);
  color: var(--gold);
  text-shadow: 0 0 40px color-mix(in srgb, var(--gold) 60%, transparent), 0 6px 0 rgba(0,0,0,0.4);
  animation: dd-zoom 0.8s cubic-bezier(0.2, 1.4, 0.4, 1);
  text-align: center;
  line-height: 1;
}
@keyframes dd-zoom { from { transform: scale(0.2) rotate(-8deg); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- scoreboard ---------- */

.scoreboard {
  display: flex;
  gap: clamp(6px, 1vw, 16px);
  justify-content: center;
  flex-wrap: wrap;
}
.score-tile {
  min-width: clamp(110px, 14vw, 210px);
  text-align: center;
  padding: 0.5rem 0.9rem;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.45);
  border-top: 4px solid var(--team-color, var(--accent));
  box-shadow: var(--shadow);
}
.score-tile .tname {
  font-family: var(--font-display);
  font-size: clamp(0.85rem, 1.4vw, 1.25rem);
  letter-spacing: 0.05em;
  color: var(--team-color, var(--ink));
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: clamp(110px, 14vw, 210px);
}
.score-tile .tscore {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.3rem, 2.6vw, 2.4rem);
  color: var(--value);
}
.score-tile .tscore.negative { color: #ff8797; }
.score-tile.control { outline: 2px solid var(--gold); outline-offset: 2px; }
.score-tile.buzzed { animation: pulse-tile 0.7s ease infinite alternate; }
@keyframes pulse-tile { from { transform: scale(1); } to { transform: scale(1.06); } }

/* ---------- utility ---------- */

.code-chip {
  font-family: var(--font-display);
  font-size: 1.5rem;
  letter-spacing: 0.35em;
  padding: 0.2em 0.5em 0.2em 0.75em;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--accent);
  color: var(--gold);
  border-radius: 10px;
}

.swatch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 0.6rem; }
.swatch {
  border-radius: 10px;
  padding: 0.6rem;
  text-align: center;
  cursor: pointer;
  border: 2px solid transparent;
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}
.swatch.selected { border-color: var(--gold); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 40%, transparent); }

.spinner {
  width: 20px; height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  display: inline-block;
  vertical-align: middle;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
