/* Big Board Trivia. Colors come from the game's theme (set as CSS variables by app.js). */
:root {
  --bg: #1b110b; --bg2: #3a2312; --head: #3d2516; --head-text: #f6e8cf;
  --tile: #8c381b; --tile-hi: #b44e28; --value: #f8d68f; --accent: #eaa33c;
  --clue: #5e2412; --clue-2: #24100a; --ink: #f6e8cf;
  --good: #3e9b58; --bad: #c4473b;
  --display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --ui: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: radial-gradient(ellipse 120% 80% at 50% 0%, var(--bg2), var(--bg) 70%) fixed;
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--ui);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.loading { text-align: center; padding: 30vh 16px; opacity: .6; }
.muted { opacity: .65; }
.small { font-size: .85rem; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
code { background: #ffffff14; padding: 1px 6px; border-radius: 4px; font-size: .9em; }

/* ----- Buttons ----- */
.btn {
  border: 0; border-radius: 999px; padding: .65em 1.25em;
  background: #ffffff16; font-weight: 650; letter-spacing: .01em;
  transition: background .15s, transform .1s, opacity .15s;
}
.btn:hover:not(:disabled) { background: #ffffff26; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .3; cursor: default; }
.btn.primary { background: var(--accent); color: #17100a; }
.btn.primary:hover:not(:disabled) { background: var(--value); }
.btn.ghost { background: transparent; box-shadow: inset 0 0 0 1px #ffffff38; }
.btn.ghost:hover:not(:disabled) { background: #ffffff12; }
.btn.good { background: var(--good); color: #fff; }
.btn.bad { background: var(--bad); color: #fff; }
.btn.small { padding: .45em 1em; font-size: .9rem; }
.btn.big { padding: .8em 1.8em; font-size: 1.15rem; }
.btn.wide { display: block; width: 100%; text-align: center; margin-top: 10px; }
.btn.pulse { animation: pulse 1.4s ease-in-out infinite; }
.btn:focus-visible, .tile:focus-visible, .game-card:focus-visible { outline: 3px solid var(--value); outline-offset: 2px; }
.mini { border: 0; background: #ffffff18; border-radius: 6px; padding: 3px 9px; font-size: .8rem; }
.mini:hover { background: #ffffff2e; }
.mini.danger:hover { background: var(--bad); }

/* ----- Home ----- */
.home { max-width: 1160px; margin: 0 auto; padding: 36px 16px 48px; }
.home-head { margin-bottom: 26px; }
.logo {
  font-family: var(--display); font-weight: 900; margin: 0;
  font-size: clamp(2.8rem, 8vw, 5.4rem); line-height: .9; letter-spacing: -.03em; color: var(--value);
}
.logo span { display: block; color: var(--accent); font-style: italic; font-weight: 500; }
.tag { font-size: 1.1rem; opacity: .75; margin: 14px 0 0; }
.resume {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  background: #ffffff10; border-left: 4px solid var(--accent); border-radius: 12px; padding: 14px 18px; margin-bottom: 20px;
}
.home-grid { display: grid; grid-template-columns: 1.35fr 1fr; gap: 20px; align-items: start; }
.panel { background: #00000038; border: 1px solid #ffffff12; border-radius: 18px; padding: 20px; }
.panel h2 { font-family: var(--display); font-weight: 700; font-size: 1.3rem; margin: 0 0 12px; color: var(--value); }
.panel h2:not(:first-child) { margin-top: 24px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; }
.game-card {
  display: flex; gap: 14px; align-items: stretch; width: 100%; text-align: left;
  background: #ffffff09; border: 2px solid transparent; border-radius: 14px; padding: 12px 14px; margin-bottom: 10px;
  transition: background .15s, border-color .15s;
}
.game-card:hover { background: #ffffff12; }
.game-card.sel { border-color: var(--accent); background: #ffffff14; }
.gc-swatch { flex: 0 0 10px; border-radius: 6px; background: linear-gradient(var(--sw1) 60%, var(--sw2) 60%); }
.mix-swatch { background: repeating-linear-gradient(180deg, #ff8a5b 0 8px, #5ec8e5 8px 16px, #c9dc6b 16px 24px, #d39bf2 24px 32px); }
.gc-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.gc-title { font-weight: 700; font-size: 1.08rem; }
.gc-sub { opacity: .75; font-size: .92rem; }
.gc-meta { opacity: .55; font-size: .82rem; }
.badge { margin-left: 8px; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; background: var(--accent); color: #17100a; padding: 2px 7px; border-radius: 99px; vertical-align: 2px; }
.mix { padding: 4px 4px 0; }
.mix-group { margin: 12px 0; }
.mix-game { font-weight: 700; font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; opacity: .6; margin-bottom: 4px; }
.mix-cat { display: flex; gap: 8px; align-items: center; padding: 5px 4px; cursor: pointer; border-radius: 6px; }
.mix-cat:hover { background: #ffffff0c; }
.mix-cat small { opacity: .45; }
.seg { display: inline-flex; background: #00000040; border-radius: 999px; padding: 4px; gap: 2px; }
.seg button { white-space: nowrap; border: 0; background: transparent; padding: .45em 1.1em; border-radius: 999px; font-weight: 600; }
.seg button.on { background: var(--accent); color: #17100a; }
.team-inputs { display: grid; gap: 8px; margin-top: 12px; }
.team-input {
  width: 100%; background: #00000035; border: 1px solid #ffffff1c; border-left: 6px solid var(--team);
  border-radius: 10px; padding: 10px 12px; font-weight: 600; font-size: 1.05rem;
}
.team-input:focus { outline: none; border-color: var(--team); background: #00000050; }
.opts { display: grid; gap: 4px; margin-bottom: 20px; }
.opt { display: flex; gap: 10px; align-items: flex-start; padding: 7px 2px; cursor: pointer; }
.opt input[type=checkbox] { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); flex: none; }
.opt small { display: block; opacity: .55; font-size: .82rem; }
.sel-opt { justify-content: space-between; align-items: center; }
.sel-opt select { background: #00000040; border: 1px solid #ffffff22; border-radius: 8px; padding: 6px 8px; max-width: 62%; }
.sel-opt option { background: #222; }
.home-foot { margin-top: 26px; text-align: center; font-size: .9rem; }

/* ----- Board ----- */
.screen-board, .screen-final { min-height: 100vh; height: 100vh; display: grid; grid-template-rows: auto 1fr auto; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; flex-wrap: wrap; }
.tb-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tb-name { font-family: var(--display); font-weight: 700; font-size: 1.25rem; color: var(--value); }
.chip { background: var(--accent); color: #17100a; font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; padding: 3px 10px; border-radius: 99px; }
.tb-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.board {
  display: grid; gap: 8px; padding: 0 16px 12px; min-height: 0;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  grid-template-rows: minmax(64px, .8fr) repeat(var(--rows), minmax(0, 1fr));
}
.cat {
  display: grid; place-items: center; text-align: center; padding: 8px 10px; border-radius: 10px;
  background: var(--head); color: var(--head-text); border-bottom: 4px solid var(--accent);
  font-family: var(--display); font-weight: 700; line-height: 1.08; letter-spacing: .01em;
  font-size: clamp(.85rem, min(1.7vw, 2.6vh), 1.7rem); overflow: hidden;
}
.tile {
  border: 0; border-radius: 10px; min-height: 0;
  background: linear-gradient(180deg, var(--tile-hi), var(--tile));
  box-shadow: inset 0 -5px 0 #00000038, inset 0 1px 0 #ffffff26, 0 2px 0 #0005;
  color: var(--value); font-family: var(--display); font-weight: 900;
  font-size: clamp(1.3rem, min(4.2vw, 6vh), 4rem); letter-spacing: -.01em;
  text-shadow: 0 2px 0 #0004;
  transition: transform .12s, filter .12s;
}
.tile:hover:not(.used) { transform: translateY(-2px); filter: brightness(1.13); }
.tile.used { background: #ffffff07; box-shadow: inset 0 0 0 1px #ffffff0d; cursor: pointer; }
.tile.empty { background: transparent; box-shadow: none; }
.scores { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 8px; padding: 0 16px 14px; }
.team {
  position: relative; text-align: center; padding: 8px 10px 6px; border-radius: 14px;
  background: #00000045; border-top: 5px solid var(--team); transition: background .2s;
}
.team.control { background: #ffffff12; }
.team.control::before {
  content: '▶ picks next'; position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
  background: var(--team); color: #111; font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em;
  padding: 2px 8px; border-radius: 99px; white-space: nowrap;
}
.team-name { font-weight: 700; font-size: clamp(.9rem, 1.6vw, 1.3rem); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.team-score { font-family: var(--display); font-weight: 900; line-height: 1.05; color: var(--team); font-size: clamp(1.6rem, min(4vw, 6vh), 3.2rem); }
.team-score.neg { color: #ff7b6b; }
.team-adj { display: flex; gap: 4px; justify-content: center; opacity: .25; transition: opacity .15s; margin-top: 2px; }
.team:hover .team-adj, .team:focus-within .team-adj { opacity: 1; }

/* ----- Overlays (clue, daily double, splash) ----- */
#overlay[hidden] { display: none; }
.overlay {
  position: fixed; inset: 0; z-index: 10; overflow: auto;
  display: flex; flex-direction: column; padding: 24px clamp(16px, 4vw, 48px);
  background: radial-gradient(ellipse at center, var(--clue), var(--clue-2));
  animation: pop .22s ease-out;
}
.clue-meta { display: flex; justify-content: space-between; gap: 16px; font-family: var(--display); font-weight: 700; color: var(--value); font-size: clamp(1rem, 2.4vw, 2rem); text-transform: uppercase; letter-spacing: .03em; }
.clue-value { color: var(--accent); white-space: nowrap; }
.clue-text {
  flex: 1; display: grid; place-items: center; text-align: center; margin: 0 auto; max-width: 1500px; padding: 3vh 1vw;
  font-family: var(--display); font-weight: 500; line-height: 1.16; text-wrap: balance;
  font-size: clamp(2rem, min(6vw, 9vh), 6rem);
}
.clue-text.mid { font-size: clamp(1.8rem, min(4.8vw, 7.5vh), 4.8rem); }
.clue-text.long { font-size: clamp(1.6rem, min(4vw, 6.4vh), 4rem); }
.clue-text.xlong { font-size: clamp(1.4rem, min(3.2vw, 5.2vh), 3.2rem); }
.answer {
  text-align: center; font-family: var(--display); font-weight: 900; color: var(--value); line-height: 1.1;
  font-size: clamp(1.8rem, min(5vw, 8vh), 5rem); min-height: 1.2em; visibility: hidden; text-wrap: balance;
}
.answer.long, .answer.xlong { font-size: clamp(1.4rem, min(3.4vw, 5.5vh), 3.4rem); }
.answer.show { visibility: visible; animation: pop .3s ease-out; }
.judge { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 18px 0 14px; }
.judge[hidden] { display: none; }
.judge-team {
  display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 16px; border-radius: 999px;
  background: #00000045; border-left: 6px solid var(--team); transition: opacity .2s;
}
.jt-name { font-weight: 700; margin-right: 4px; }
.judge-team .btn { padding: .5em 1em; }
.judge-team.tried { opacity: .4; }
.judge-team.won { box-shadow: 0 0 0 3px var(--value); }
.final-judge .btn:not(.on) { opacity: .6; }
.final-judge .btn.on { box-shadow: 0 0 0 3px #fff; }
.clue-actions { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.hint { text-align: center; opacity: .45; font-size: .85rem; margin: 12px 0 0; }
.timer { display: flex; align-items: center; gap: 12px; width: 100%; max-width: 900px; margin: 0 auto 14px; }
.timer-track { flex: 1; height: 10px; background: #00000050; border-radius: 99px; overflow: hidden; }
.timer-track i { display: block; height: 100%; width: 100%; background: var(--accent); border-radius: 99px; }
.timer-num { font-family: var(--display); font-weight: 900; font-size: 1.6rem; min-width: 2ch; text-align: right; color: var(--value); }
.timer.done .timer-track i { background: var(--bad); }
.timer.done .timer-num { color: #ff7b6b; animation: pulse .6s 3; }

.splash, .dd { justify-content: center; align-items: center; text-align: center; gap: 14px; cursor: default; }
.splash { cursor: pointer; }
.splash-title, .dd-burst {
  font-family: var(--display); font-weight: 900; color: var(--value); line-height: .95; letter-spacing: -.02em;
  font-size: clamp(3rem, 11vw, 9rem); text-wrap: balance;
}
.dd-burst { color: var(--accent); animation: burst .6s cubic-bezier(.2, 1.6, .4, 1); font-style: italic; }
.splash-sub { font-size: clamp(1.1rem, 2.4vw, 1.8rem); opacity: .85; max-width: 900px; margin: 0; }
.dd-cat { font-family: var(--display); font-weight: 700; font-size: clamp(1.4rem, 3.4vw, 2.6rem); text-transform: uppercase; }
.dd-help { opacity: .75; margin: 0; }
.team-picks { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.team-pick {
  display: flex; flex-direction: column; align-items: center; min-width: 130px; padding: 10px 18px;
  border: 2px solid #ffffff26; border-top: 5px solid var(--team); border-radius: 12px; background: #00000040; font-weight: 700;
}
.team-pick small { opacity: .6; font-weight: 500; }
.team-pick.sel { border-color: var(--team); background: #ffffff1c; }
.wager { display: flex; align-items: center; gap: 12px; font-weight: 700; flex-wrap: wrap; justify-content: center; }
.wager-input {
  width: 9ch; background: #00000050; border: 2px solid #ffffff30; border-radius: 10px; padding: 8px 10px;
  font-family: var(--display); font-weight: 900; font-size: 1.8rem; text-align: center;
}
.wager-input:focus { outline: none; border-color: var(--accent); }

/* ----- Final round + results ----- */
.final { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 12px 16px; text-align: center; min-height: 0; overflow: auto; }
.final .clue-text { flex: 0 1 auto; }
.final-kicker { font-weight: 800; text-transform: uppercase; letter-spacing: .12em; opacity: .7; }
.final-cat { font-family: var(--display); font-weight: 900; color: var(--value); font-size: clamp(2.4rem, 7vw, 5.5rem); line-height: 1; text-wrap: balance; }
.final-help { max-width: 640px; opacity: .8; margin: 0; }
.final-wagers { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.fw { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 16px; border-radius: 14px; background: #00000040; border-top: 5px solid var(--team); }
.fw-name { font-weight: 800; }
.results { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 32px 16px; text-align: center; }
.results-title { font-family: var(--display); font-weight: 900; color: var(--value); font-size: clamp(2.6rem, 9vw, 7rem); line-height: .95; margin: 0; text-wrap: balance; animation: burst .7s cubic-bezier(.2, 1.6, .4, 1); }
.standings { list-style: none; padding: 0; margin: 8px 0 16px; width: min(560px, 100%); counter-reset: place; }
.standings li {
  counter-increment: place; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 18px; margin: 8px 0; border-radius: 12px; background: #00000040; border-left: 6px solid var(--team); font-size: 1.25rem; font-weight: 700;
}
.standings li::before { content: counter(place); font-family: var(--display); opacity: .5; margin-right: 4px; }
.standings li span { flex: 1; text-align: left; }
.standings li b { font-family: var(--display); color: var(--team); font-size: 1.6rem; }
.standings li:first-child { background: #ffffff16; transform: scale(1.04); }

/* ----- Editor ----- */
.editor { max-width: 1300px; margin: 0 auto; padding: 20px 16px 40px; }
.ed-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.ed-head h1 { font-family: var(--display); color: var(--value); margin: 0; flex: 1; font-size: 1.8rem; }
.saved-msg { color: var(--value); font-weight: 600; font-size: .9rem; }
.ed-grid { display: grid; grid-template-columns: 290px 1fr; gap: 18px; align-items: start; }
.ed-list h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; opacity: .6; margin: 20px 0 8px; }
.file-btn { cursor: pointer; }
.ed-item { padding: 10px; border-radius: 10px; background: #ffffff08; margin-bottom: 8px; border: 1px solid transparent; }
.ed-item.sel { border-color: var(--accent); }
.ed-title { font-weight: 650; display: flex; flex-direction: column; gap: 2px; }
.ed-title small { font-weight: 400; opacity: .55; font-size: .8rem; }
.ed-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.editor-text {
  width: 100%; min-height: 62vh; resize: vertical; padding: 16px; border-radius: 14px;
  background: #00000055; border: 1px solid #ffffff20; line-height: 1.55; tab-size: 4;
  font-family: ui-monospace, 'Cascadia Code', 'SF Mono', Menlo, Consolas, monospace; font-size: .92rem;
}
.editor-text:focus { outline: none; border-color: var(--accent); }
.editor-status { margin-top: 10px; font-size: .92rem; display: grid; gap: 4px; }
.es-summary { font-weight: 650; }
.es-err { color: #ff8b7e; }
.es-warn { color: var(--value); opacity: .85; }
.ed-help { margin-top: 14px; background: #00000030; border-radius: 12px; padding: 12px 16px; }
.ed-help summary { cursor: pointer; font-weight: 650; }
.ed-help li { margin: 6px 0; line-height: 1.45; }

/* ----- Confetti + animation ----- */
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 30; }
.confetti i { position: absolute; top: -24px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(112vh) rotate(800deg); } }
@keyframes pop { from { transform: scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes burst { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pulse { 50% { transform: scale(1.06); } }
@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important; } .confetti { display: none; } }

/* ----- Narrow screens (setup on a phone) ----- */
@media (max-width: 860px) {
  .home-grid, .ed-grid { grid-template-columns: 1fr; }
  .screen-board, .screen-final { height: auto; }
  .board { min-height: 70vh; gap: 5px; }
  .scores { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 18px; }
}
