/* The game's display font, shared with the TV (copied in by deploy.ps1). */
@font-face { font-family: Lilita; src: url(fonts/LilitaOne-Regular.ttf); font-display: swap; }

/* The background follows the TV's mood (category colors, stretch, last inning);
   registered so the gradient can fade between them. */
@property --bg { syntax: '<color>'; inherits: true; initial-value: #0f2147; }
@property --bg2 { syntax: '<color>'; inherits: true; initial-value: #1c3a6e; }
html { transition: --bg 1.2s, --bg2 1.2s; }

:root {
  --bg: #0f2147;
  --bg2: #1c3a6e;
  --panel: rgba(255, 255, 255, 0.08);
  --ink: #0f2147;
  --text: #fff;
  --muted: rgba(255, 255, 255, 0.7);
  --yellow: #ffd23f;
  --green: #3ddc84;
  --red: #ff5470;
  --accent: #ffd23f;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(160deg, var(--bg) 0%, var(--bg2) 100%) fixed;
  color: var(--text);
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
}

.screen { display: none; }
.screen.active { display: block; animation: pop-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); }
.screen.center.active { display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; }

@keyframes pop-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } }

#bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; font-weight: 800; letter-spacing: 0.02em;
  background: rgba(0, 0, 0, 0.25);
  border-bottom: 3px dashed #e03131; /* a row of red stitches, like a baseball seam */
}
#bar[hidden] { display: none; }
#bar-name { color: var(--accent); text-transform: uppercase; }
.bar-right, .bar-left { display: flex; align-items: center; gap: 12px; }
.bar-left { gap: 8px; }

/* ---------- Team picker ---------- */
.team-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.team-grid button {
  aspect-ratio: 1; padding: 3px; border-radius: 14px; border: 3px solid transparent;
  background: rgba(255, 255, 255, 0.08); display: grid; place-items: center;
}
.team-grid img { width: 100%; height: auto; display: block; }
.team-grid button[aria-checked="true"] { border-color: var(--yellow); background: rgba(255, 210, 63, 0.25); transform: scale(1.08); }
.team-grid button:disabled { opacity: 0.25; filter: grayscale(1); }
#lobby-logo { margin: 6px 0; filter: drop-shadow(0 6px 0 rgba(0, 0, 0, 0.25)); }
#lobby-team-grid { width: 100%; margin: 4px 0 10px; }
.team-line { margin: 0; font-weight: 700; color: var(--muted); }
.team-line b { color: #fff; }
.help-btn {
  width: 30px; height: 30px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.6);
  background: transparent; color: #fff; font-weight: 900; font-size: 16px; line-height: 1; padding: 0;
}
.quit-btn {
  height: 30px; padding: 0 10px; border-radius: 999px; border: 2px solid rgba(255, 255, 255, 0.6);
  background: transparent; color: #fff; font-weight: 800; font-size: 13px;
}

/* ---------- Yes/no dialog ---------- */
#confirm {
  width: min(380px, calc(100% - 32px)); padding: 24px 20px 20px; border: none; border-radius: 22px; text-align: center;
  background: #0a1730; color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
#confirm::backdrop { background: rgba(3, 9, 22, 0.78); }
#confirm h2 { margin: 0 0 6px; font-size: 30px; color: var(--yellow); }
#confirm p { margin: 0 0 20px; font-size: 18px; font-weight: 700; }
.confirm-actions { display: flex; gap: 12px; }
.confirm-actions.reverse { flex-direction: row-reverse; }
.confirm-actions .big-btn { flex: 1; margin: 0; font-size: 18px; padding-left: 8px; padding-right: 8px; }
.big-btn.quiet { background: rgba(255, 255, 255, 0.14); color: var(--text); }
.big-btn.danger { background: var(--red); color: #fff; }
input::placeholder { color: rgba(15, 33, 71, 0.3); text-transform: none; letter-spacing: 0; font-size: 22px; }

/* ---------- How to play ---------- */
#help {
  width: min(480px, calc(100% - 24px)); max-height: calc(100% - 24px); padding: 0; border: none; border-radius: 22px;
  background: #0a1730; color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  flex-direction: column; overflow: hidden;
}
#help[open] { display: flex; }
#help::backdrop { background: rgba(3, 9, 22, 0.78); }
.help-body { overflow-y: auto; padding: 22px 20px 8px; -webkit-overflow-scrolling: touch; }
.help-body h2 { margin: 0 0 8px; font-size: 30px; font-weight: 900; color: var(--yellow); text-transform: uppercase; }
.help-body h3 { display: flex; align-items: center; gap: 10px; margin: 26px 0 6px; font-size: 20px; font-weight: 900; }
.help-body p, .help-body li { color: rgba(255, 255, 255, 0.85); line-height: 1.45; font-size: 15px; }
.help-body img {
  display: block; width: 62%; height: auto; margin: 12px auto; border-radius: 16px;
  border: 3px solid rgba(255, 255, 255, 0.15); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.help-body img.wide { width: 100%; }
.help-points { padding-left: 20px; margin: 8px 0; }
.step {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--yellow); color: var(--ink); font-size: 15px; flex: none;
}
.good { color: var(--green); font-weight: 800; }
.bad { color: var(--red); font-weight: 800; }
#help-close { flex: none; margin: 12px 20px 20px; width: auto; }

/* Demo mode (screenshots): no entrance animations. */
.demo *, .demo *::before { animation: none !important; transition: none !important; }

/* The site name over the join form (the same page joins every game). */
.brand { font-family: Lilita, system-ui, sans-serif; font-size: 30px; text-align: center; margin: 22px 0 0; color: #fff; letter-spacing: 0.02em; }

.logo {
  font-size: 56px; line-height: 0.95; text-align: center; margin: 10px 0 28px;
  text-transform: uppercase; font-weight: 900; color: var(--yellow);
  text-shadow: 0 5px 0 rgba(0, 0, 0, 0.3);
  transform: rotate(-3deg);
}

form { display: flex; flex-direction: column; gap: 16px; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 700; font-size: 14px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
input {
  font: inherit; font-size: 28px; font-weight: 800; letter-spacing: 0.05em;
  padding: 12px 14px; border-radius: 14px; border: 3px solid transparent;
  background: #fff; color: var(--ink); text-transform: uppercase; user-select: text; -webkit-user-select: text;
}
input:focus { outline: none; border-color: var(--yellow); }

button { font: inherit; cursor: pointer; touch-action: manipulation; }

.big-btn {
  width: 100%; padding: 18px; border: none; border-radius: 18px;
  background: var(--yellow); color: var(--ink);
  font-size: 24px; font-weight: 900; text-transform: uppercase; letter-spacing: 0.04em;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.3);
  transition: transform 0.08s, box-shadow 0.08s;
}
.big-btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3); }
.big-btn:disabled { opacity: 0.5; cursor: default; }
.big-btn[hidden] { display: none; }

.host-link { text-align: center; color: var(--muted); font-size: 14px; margin-top: 32px; }
.host-link a { color: var(--yellow); font-weight: 800; }

.error { color: var(--red); font-weight: 700; min-height: 1.2em; margin: 0; text-align: center; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.12em; font-weight: 800; color: var(--muted); margin: 0; }
.huge { font-size: 52px; font-weight: 900; margin: 0; color: var(--yellow); text-shadow: 0 4px 0 rgba(0, 0, 0, 0.3); word-break: break-word; }
.muted { color: var(--muted); }

/* ---------- Question ---------- */
.q-top { display: flex; justify-content: space-between; align-items: center; font-weight: 800; color: var(--muted); }
#q-timer {
  min-width: 56px; text-align: center; padding: 6px 12px; border-radius: 999px;
  background: rgba(0, 0, 0, 0.3); color: #fff; font-variant-numeric: tabular-nums;
}
#q-timer.urgent { background: var(--red); animation: pulse 0.5s infinite alternate; }
@keyframes pulse { to { transform: scale(1.12); } }

/* A pointer to the TV (or, in the stretch, the instruction): the controls are the star here. */
#q-text { font-size: 17px; font-weight: 700; line-height: 1.3; margin: 12px 0 8px; color: var(--muted); }
#q-round { text-transform: uppercase; letter-spacing: 0.06em; }
.pinch-note { margin: 0 0 10px; padding: 8px 12px; border-radius: 12px; background: rgba(255, 210, 63, 0.16); border: 2px solid rgba(255, 210, 63, 0.6); font-weight: 700; font-size: 15px; }
.pinch-note b { color: var(--yellow); }
.pinch-note[hidden] { display: none; }

/* Numbers you can tap to type, instead of dragging. */
.tap-edit { font: inherit; color: inherit; background: none; border: none; padding: 0 2px; border-bottom: 3px dotted rgba(255, 255, 255, 0.35); line-height: 1.05; }
.tap-edit:active { color: var(--yellow); }
#number { width: min(380px, calc(100% - 32px)); padding: 24px 20px 20px; border: none; border-radius: 22px; text-align: center; background: #0a1730; color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); }
#number::backdrop { background: rgba(3, 9, 22, 0.78); }
#number h2 { margin: 0 0 12px; font-size: 26px; color: var(--yellow); }
#number input { width: 100%; text-align: center; font-size: 36px; }
#number .hint { margin: 8px 0 16px; }
.exact-btn { margin: 0; background: var(--green); color: var(--ink); }
#number-form .confirm-actions { order: 1; } /* below the Set exact button */
.exact-btn[hidden] { display: none; }
.result-extra { margin: 0; font-weight: 800; color: var(--yellow); min-height: 1.2em; }

#range-display {
  display: flex; justify-content: center; align-items: baseline; gap: 12px;
  font-size: 44px; font-weight: 900; font-variant-numeric: tabular-nums; margin: 6px 0 14px;
}
#range-display .dash { font-size: 18px; color: var(--muted); text-transform: uppercase; }

.round-ui { display: none; }
.round-ui.active { display: block; }
.hint { color: var(--muted); font-size: 14px; font-weight: 700; margin: 0 0 10px; }
.hint b { color: var(--yellow); }

.slider { position: relative; height: 56px; margin: 0 22px; touch-action: none; }
.slider .track { position: absolute; left: 0; right: 0; top: 22px; height: 12px; border-radius: 6px; background: rgba(0, 0, 0, 0.35); }
.slider .fill { position: absolute; top: 16px; height: 24px; border-radius: 12px; background: var(--yellow); min-width: 6px; box-shadow: 0 0 0 3px rgba(255, 210, 63, 0.25); }
.thumb {
  position: absolute; top: 0; width: 44px; height: 56px; margin-left: -22px;
  display: flex; align-items: center; justify-content: center;
}
.thumb span { width: 30px; height: 30px; border-radius: 50%; background: #fff; border: 4px solid var(--ink); box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3); pointer-events: none; }

.scale { display: flex; justify-content: space-between; font-size: 13px; font-weight: 700; color: var(--muted); margin: 4px 0 14px; font-variant-numeric: tabular-nums; }

.nudges { display: flex; justify-content: space-between; gap: 8px; }
.nudge-group { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; background: var(--panel); border-radius: 14px; padding: 8px 4px; }
.nudge-label { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.nudge-group div { display: flex; gap: 6px; }
.nudge-group button {
  width: 44px; height: 44px; border-radius: 12px; border: none;
  background: rgba(255, 255, 255, 0.9); color: var(--ink); font-size: 22px; font-weight: 900;
}
.nudge-group button:active { background: var(--yellow); }

#stakes { display: flex; gap: 10px; margin: 16px 0; }
#stakes > div { flex: 1; border-radius: 14px; padding: 10px; text-align: center; font-weight: 800; text-transform: uppercase; font-size: 13px; letter-spacing: 0.08em; }
#stakes b { display: block; font-size: 30px; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.worth { background: rgba(61, 220, 132, 0.18); color: var(--green); }
.risk { background: rgba(255, 84, 112, 0.18); color: var(--red); }

.nudge-group.wide { flex: 1; }
.nudge-group.wide button { width: auto; flex: 1; font-size: 18px; }
.nudge-group.wide div { width: 100%; padding: 0 4px; }

#screen-question.locked .slider,
#screen-question.locked .nudges,
#screen-question.locked #tl-list { opacity: 0.4; pointer-events: none; }
#screen-question.locked #lock-btn { background: var(--green); }
#lock-btn { margin-top: 16px; }
.center-text { text-align: center; margin-top: 12px; }

/* ---------- Intro ---------- */
.intro-label { font-size: 64px; transform: rotate(-3deg); animation: slam 0.5s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes slam { from { transform: scale(2.2) rotate(-12deg); opacity: 0; } }

/* ---------- Timeline ---------- */
#tl-list { position: relative; list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.tl-card {
  display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 12px;
  background: #fff; color: var(--ink); border-radius: 14px; box-shadow: 0 4px 0 rgba(0, 0, 0, 0.3);
  touch-action: none; user-select: none; -webkit-user-select: none; position: relative;
  transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.2s;
}
/* The dragged card tracks the finger exactly, so no easing on its movement. */
.tl-card.dragging { transition: box-shadow 0.2s; box-shadow: 0 12px 24px rgba(0, 0, 0, 0.45); z-index: 2; }
@media (prefers-reduced-motion: reduce) { .tl-card { transition: none; } }
.tl-letter {
  flex: none; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: var(--ink); color: var(--yellow); font-weight: 900; font-size: 20px;
}
.tl-text { flex: 1; font-weight: 800; font-size: 17px; line-height: 1.2; }
.tl-arrows { display: flex; flex-direction: column; gap: 4px; }
.tl-arrows button {
  width: 40px; height: 30px; border: none; border-radius: 8px; background: rgba(15, 33, 71, 0.12);
  color: var(--ink); font-size: 14px; font-weight: 900;
}
.tl-arrows button:disabled { opacity: 0.25; }
.tl-slot { flex: none; font-size: 12px; font-weight: 900; color: rgba(15, 33, 71, 0.45); width: 18px; text-align: center; }

/* ---------- Final ---------- */
.big-value { text-align: center; font-size: 56px; font-weight: 900; font-variant-numeric: tabular-nums; margin: 4px 0 10px; }

/* ---------- Result ---------- */
.delta { font-size: 48px; font-weight: 900; margin: 8px 0; }
.delta.good { color: var(--green); }
.delta.bad { color: var(--red); }
#result-rank { font-weight: 800; font-size: 20px; }
.final-score { font-size: 30px; margin: 0; }

#final-awards { list-style: none; padding: 0; margin: 10px 0; width: 100%; display: flex; flex-direction: column; gap: 8px; }
#final-awards li { background: rgba(255, 210, 63, 0.14); border: 2px solid rgba(255, 210, 63, 0.5); border-radius: 14px; padding: 10px 14px; }
#final-awards b { display: block; color: var(--yellow); font-weight: 900; text-transform: uppercase; letter-spacing: 0.05em; }
#final-awards span { color: var(--muted); font-size: 14px; }

/* ---------- Status ---------- */
.spinner { width: 48px; height: 48px; border-radius: 50%; border: 6px solid rgba(255, 255, 255, 0.2); border-top-color: var(--yellow); animation: spin 0.8s linear infinite; }
.spinner[hidden] { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

#toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: #111; color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 700;
  max-width: calc(100% - 32px); transition: transform 0.25s, opacity 0.25s; pointer-events: none;
  opacity: 0; visibility: hidden;
}
#toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; }

/* Big game type in the TV's font (it has one weight, so no faux bold); body
   text stays in the system font. Last, so it wins over the rules above. */
.huge, .delta, .big-btn, .big-value, #range-display, #stakes b, #confirm h2, #number h2, .help-body h2, .final-score {
  font-family: Lilita, system-ui, sans-serif; font-weight: 400;
}
