/* Same palette as the app: navy board, ball yellow for lit numbers, stitch red for outs. */
:root {
  --navy: #14213D;
  --navy-2: #1C2D52;
  --navy-line: #2E4170;
  --ball: #E8E21A;
  --ball-soft: #F6F3B5;
  --stitch: #C8102E;
  --stitch-soft: #F8D7DC;
  --field: #2E7D32;
  --field-soft: #DCEFDD;
  --paper: #F4F4EE;
  --card: #FFFFFF;
  --ink: #141A26;
  --muted: #5B6375;
  --line: #E1E2DA;
  --shadow: 0 1px 2px rgba(20, 33, 61, .06), 0 4px 16px rgba(20, 33, 61, .06);
  --cond: "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;
  --body: "Roboto", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0B1222;
    --card: #131C30;
    --ink: #E9ECF3;
    --muted: #9AA3B5;
    --line: #26314A;
    --field-soft: #183A22;
    --stitch-soft: #46141D;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.45 var(--body);
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--navy); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; font: 700 20px/1 var(--cond); letter-spacing: .3px; }
.brand b { color: var(--ball); font-weight: 800; }
.ball { width: 28px; height: 28px; }
.ball-fill { fill: var(--ball); }
.ball-stitch { fill: none; stroke: var(--stitch); stroke-width: 1.8; stroke-dasharray: 2.2 1.6; }

.status {
  display: inline-flex; align-items: center; gap: 7px;
  font: 700 13px/1 var(--cond); letter-spacing: 1px; text-transform: uppercase;
  padding: 6px 10px; border-radius: 99px; background: var(--navy-2);
}
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status.live { color: #FF5A6E; }
.status.live::before { animation: pulse 1.6s ease-in-out infinite; }
.status.final { color: var(--ball); }
.status.offline { color: #9AA3B5; }
@keyframes pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .status.live::before { animation: none; } }

main { max-width: 640px; margin: 0 auto; padding: 16px; }
#game { display: grid; gap: 14px; }

/* Join */
.join { padding: 40px 4px; text-align: center; }
.join h1 { font: 800 34px/1.1 var(--cond); margin: 0 0 8px; }
.lede { color: var(--muted); margin: 0 auto 24px; max-width: 32ch; }
#join-form { display: flex; gap: 10px; max-width: 360px; margin: 0 auto; }
#code-input {
  flex: 1; min-width: 0; height: 56px; padding: 0 14px; border-radius: 14px;
  border: 2px solid var(--line); background: var(--card); color: var(--ink);
  font: 800 28px/1 var(--cond); letter-spacing: 6px; text-align: center; text-transform: uppercase;
}
#code-input:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px var(--ball); }
.error { color: var(--stitch); min-height: 1.4em; margin-top: 12px; }

.btn {
  height: 56px; padding: 0 22px; border: 0; border-radius: 14px; cursor: pointer;
  font: 800 18px/1 var(--cond); letter-spacing: .5px;
}
.btn.primary { background: var(--navy); color: var(--ball); }
.btn.secondary { height: 46px; background: var(--navy); color: #fff; margin-top: 12px; width: 100%; }
.btn:focus-visible, .link:focus-visible, .chip:focus-visible { outline: 3px solid var(--ball); outline-offset: 2px; }

/* Scoreboard */
.eyebrow { font: 700 13px/1 var(--cond); letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.board {
  background: var(--navy); color: #fff; border-radius: 20px; padding: 14px 18px 12px;
  box-shadow: 0 8px 28px rgba(20, 33, 61, .28);
}
.board-head { display: flex; justify-content: space-between; align-items: center; color: rgba(255,255,255,.65); font: 500 14px/1 var(--body); }
.link { background: none; border: 0; color: #fff; font: 500 14px/1 var(--body); padding: 6px 8px; margin-right: -8px; border-radius: 8px; cursor: pointer; }
.team-row { display: flex; align-items: center; height: 54px; gap: 12px; }
.team-name { flex: 1; min-width: 0; font: 700 24px/1.1 var(--cond); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.team-runs { font: 800 46px/1 var(--cond); font-variant-numeric: tabular-nums; }
.team-row.us .team-runs { color: var(--ball); }
.team-row.trailing .team-name, .team-row.trailing .team-runs { opacity: .72; }
.linescore-wrap { overflow-x: auto; margin-top: 6px; background: var(--navy-2); border-radius: 12px; }
.linescore { border-collapse: collapse; width: 100%; font: 700 15px/1 var(--cond); font-variant-numeric: tabular-nums; }
.linescore th, .linescore td { text-align: center; padding: 6px 0; min-width: 30px; }
.linescore th { font-weight: 500; font-size: 12px; color: rgba(255,255,255,.5); }
.linescore th.now { color: var(--ball); }
.linescore tr.us td { color: var(--ball); }
/* After the row rule, and as specific, so an unplayed inning stays a dim dot on our row too. */
.linescore tr td.empty { color: rgba(255,255,255,.25); }
.linescore .total { border-left: 1px solid var(--navy-line); min-width: 40px; }
.linescore th.rowlabel, .linescore td.rowlabel { text-align: left; padding-left: 10px; min-width: 44px; color: rgba(255,255,255,.6); font-weight: 500; }

/* Cards */
.card { background: var(--card); border-radius: 18px; padding: 16px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.card h2 { font: 800 20px/1.1 var(--cond); margin: 0; letter-spacing: .2px; }
.hint { color: var(--muted); margin: 0 0 12px; font-size: 14px; }
.hint.small { font-size: 13px; margin: 10px 0 0; }
.pill { font: 700 12px/1 var(--cond); letter-spacing: .8px; text-transform: uppercase; padding: 5px 9px; border-radius: 99px; background: var(--field-soft); color: var(--field); }

/* Situation */
.situation { display: grid; grid-template-columns: 132px 1fr; gap: 14px; align-items: center; }
.diamond { width: 132px; height: 132px; }
.infield { fill: var(--field-soft); stroke: var(--line); stroke-width: 2; }
.plate { fill: var(--card); stroke: var(--muted); stroke-width: 1.5; }
.base { fill: var(--card); stroke: var(--muted); stroke-width: 2; transition: fill .2s; }
.diamond g.on .base { fill: var(--navy); stroke: var(--navy); }
.diamond text { font: 800 12px/1 var(--cond); fill: var(--ball); text-anchor: middle; pointer-events: none; }
.inning-outs { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.inning { font: 800 20px/1 var(--cond); }
.outs { display: inline-flex; gap: 6px; }
.outs i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); }
.outs i.on { background: var(--stitch); border-color: var(--stitch); }
.label { font: 500 12px/1 var(--body); letter-spacing: .6px; text-transform: uppercase; color: var(--muted); }
.batter { font: 800 26px/1.15 var(--cond); margin-top: 3px; overflow-wrap: anywhere; }
.batter-line { color: var(--field); font-weight: 500; font-size: 14px; min-height: 1em; }
.ondeck, .runlimit { color: var(--muted); font-size: 14px; }

/* Follow */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 14px;
  border-radius: 99px; border: 1.5px solid var(--line); background: var(--card); color: var(--ink);
  font: 700 15px/1 var(--cond); cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--ball); border-color: var(--ball); color: var(--navy); }
.chip[aria-pressed="true"]::before { content: "★"; font-size: 13px; }
.toggle { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-weight: 500; cursor: pointer; }
.toggle input { width: 20px; height: 20px; accent-color: var(--navy); }

/* Plays */
.plays { list-style: none; margin: 0; padding: 0; }
.plays li { display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.plays li:first-child { border-top: 0; }
.plays li.inning-end { display: block; margin: 4px 0; padding: 8px 12px; border-radius: 10px; border-top: 0; background: var(--line); font-weight: 700; color: var(--navy); }
.plays .inn { font: 700 13px/1 var(--cond); color: var(--muted); }
.plays .txt { font-weight: 500; }
.plays .tag { font: 800 12px/1 var(--cond); letter-spacing: .6px; padding: 5px 8px; border-radius: 8px; text-transform: uppercase; }
.tag.hit { background: var(--field-soft); color: var(--field); }
.tag.hr { background: var(--ball); color: var(--navy); }
.tag.out { background: var(--stitch-soft); color: var(--stitch); }
.tag.walk { background: var(--line); color: var(--ink); }
.plays li.followed .txt::after { content: " ★"; color: #B8A800; }
.plays li.fresh { animation: fresh 2.4s ease-out; }
@keyframes fresh { from { background: var(--ball-soft); } to { background: transparent; } }

/* Box */
.box-wrap { overflow-x: auto; }
.box { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.box th, .box td { padding: 8px 6px; text-align: right; border-top: 1px solid var(--line); }
.box th { font: 700 12px/1 var(--cond); color: var(--muted); letter-spacing: .6px; border-top: 0; }
.box th:first-child, .box td:first-child { text-align: left; }
.box td:first-child { font-weight: 500; }

.footer { text-align: center; font-size: 14px; }
.footer a { color: var(--muted); }

/* Toasts */
.toasts { position: fixed; left: 0; right: 0; bottom: calc(16px + env(safe-area-inset-bottom)); display: grid; gap: 8px; justify-items: center; padding: 0 16px; pointer-events: none; z-index: 10; }
.toast {
  pointer-events: auto; max-width: 480px; width: 100%;
  background: var(--navy); color: #fff; border-radius: 14px; padding: 12px 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25); display: flex; gap: 10px; align-items: center;
  animation: up .25s ease-out;
}
.toast b { color: var(--ball); font: 800 17px/1.2 var(--cond); }
.toast small { display: block; color: rgba(255,255,255,.7); }
.toast.followed { border-left: 5px solid var(--ball); }
@keyframes up { from { transform: translateY(16px); opacity: 0; } }

@media (max-width: 380px) {
  .situation { grid-template-columns: 108px 1fr; }
  .diamond { width: 108px; height: 108px; }
  .team-runs { font-size: 40px; }
}
