:root {
  color-scheme: dark;
  --ground: #050606; --surface: #111413; --sunken: #1A1F1D; --ink: #EEF3F0; --muted: #8C9A92; --line: #232A27;
  --turf: #3DDC84; --turf-ink: #04140B; --turf-soft: rgba(61, 220, 132, .14);
  --goal: #FF7A45; --goal-soft: rgba(255, 122, 69, .16); --shot: #5AA9FF; --shot-soft: rgba(90, 169, 255, .15);
  --warn: #F5B94A; --warn-soft: rgba(245, 185, 74, .13);
  --display: "Barlow Condensed", "Arial Narrow", Arial, sans-serif;
  --body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --radius: 12px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ground); color: var(--ink); font: 15px/1.55 var(--body); }
h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.05; margin: 0; text-wrap: balance; }
h2 { font-size: 1.45rem; text-transform: uppercase; letter-spacing: .01em; }
h3 { font-size: 1.1rem; text-transform: uppercase; letter-spacing: .02em; }
p { margin: 0; }
a { color: var(--turf); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--turf); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.eyebrow { font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }

/* top bar */
.topbar { background: var(--ground); color: var(--ink); padding-inline: 16px; border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1120px; margin: 0 auto; display: flex; align-items: center; gap: 14px; padding-block: 14px; }
.crest { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--turf); color: var(--turf-ink); font-family: var(--display); font-weight: 700; font-size: 1.2rem; box-shadow: 0 0 0 4px var(--turf-soft); }
.topbar h1 { font-size: 1.9rem; text-transform: uppercase; }
.topbar .sub { font-size: .82rem; color: var(--muted); }
.topbar .spacer { flex: 1; }
.topbar a.switch { color: var(--turf); font-size: .82rem; text-decoration: none; border: 1px solid currentColor; border-radius: 999px; padding: 4px 12px; white-space: nowrap; }
.demo-banner { background: var(--ground); color: var(--muted); border-bottom: 1px solid var(--line); font-size: .8rem; text-align: center; padding: 6px 16px; }

/* tabs */
.tabs { background: var(--ground); border-bottom: 1px solid var(--line); padding-inline: 16px; position: sticky; top: 0; z-index: 5; }
.tabs-inner { max-width: 1120px; margin: 0 auto; display: flex; gap: 4px; overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 3px solid transparent; padding: 12px 12px 9px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--ink); border-color: var(--turf); }

/* layout */
main { max-width: 1120px; margin: 0 auto; padding: 20px 16px 120px; display: flex; flex-direction: column; gap: 18px; }
.grid { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .grid.two { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); align-items: start; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
[hidden] { display: none !important; }

/* buttons & chips */
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 14px; font-weight: 600; font-size: .88rem; }
.btn.primary { background: var(--turf); border-color: var(--turf); color: var(--turf-ink); }
.btn:disabled { opacity: .5; cursor: default; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 11px; font-size: .8rem; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.pill { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 1px 9px; font-size: .72rem; font-weight: 600; white-space: nowrap; }
.pill.goal { background: var(--goal-soft); color: var(--goal); }
.pill.shot { background: var(--shot-soft); color: var(--shot); }
.pill.turf { background: var(--turf-soft); color: var(--turf); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }

/* video */
.player { background: #000; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; aspect-ratio: 16 / 9; max-width: 100%; }
.player video { width: 100%; height: 100%; display: block; }
.now-playing { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* match timeline */
.timeline { position: relative; height: 46px; background: var(--sunken); border-radius: 8px; margin-top: 4px; }
.timeline .half { position: absolute; top: 0; bottom: 0; left: 50%; border-left: 1px dashed var(--line); }
.timeline .tick { position: absolute; bottom: 2px; font-size: .62rem; color: var(--muted); transform: translateX(-50%); font-family: var(--mono); }
.marker { position: absolute; top: 8px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; border: 2px solid var(--shot); background: var(--surface); padding: 0; }
.marker.goal { border-color: var(--goal); background: var(--goal); }
.marker.comment { top: 24px; width: 10px; height: 10px; margin-left: -5px; border-radius: 2px; border-color: var(--ink); background: var(--ink); }
.marker.mine { box-shadow: 0 0 0 3px var(--turf); }
.marker[aria-current="true"] { transform: scale(1.35); }

/* event list */
.events { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; max-height: 420px; overflow-y: auto; border-top: 1px solid var(--line); }
.events li { display: grid; grid-template-columns: 78px auto 1fr auto; gap: 10px; align-items: center; padding: 8px 2px; border-bottom: 1px solid var(--line); }
.events li[aria-current="true"] { background: var(--turf-soft); }
.events .play { border: 0; background: none; text-align: left; padding: 0; font-weight: 600; white-space: nowrap; }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--muted); white-space: nowrap; }
.toggle input { width: 18px; height: 18px; accent-color: var(--turf); }

/* forms */
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: .8rem; color: var(--muted); }
.input { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 9px 11px; width: 100%; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* upload slots */
.slots { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.slot { border: 1.5px dashed var(--line); border-radius: 8px; aspect-ratio: 4 / 5; display: grid; place-items: center; text-align: center;
  color: var(--muted); font-size: .8rem; position: relative; overflow: hidden; background: var(--sunken); }
.slot input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.slot img { width: 100%; height: 100%; object-fit: cover; }
.swatch { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line); display: inline-block; vertical-align: middle; }

/* tables */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; background: var(--sunken); border: 1px solid var(--line); }
.dot.done { background: var(--turf); border-color: var(--turf); }
.dot.today { border: 2px solid var(--turf); }

/* comments */
.comments { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.comments li { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; }
.comments .time { border: 0; background: var(--sunken); border-radius: 6px; padding: 2px 7px; font-family: var(--mono); font-size: .78rem; height: fit-content; }
.comments .who { font-weight: 600; font-size: .85rem; }

/* chat dock (player dashboard) */
.chat-dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; padding: 0 12px calc(12px + env(safe-area-inset-bottom)); pointer-events: none; }
.chat-inner { max-width: 760px; margin: 0 auto; pointer-events: auto; background: rgba(17, 20, 19, .96); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: 0 -8px 40px rgba(0,0,0,.7), 0 0 0 1px var(--turf-soft); overflow: hidden; }
.chat-log { max-height: min(55vh, 460px); overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; border-bottom: 1px solid var(--line); }
.msg { max-width: 88%; padding: 9px 12px; border-radius: 14px; font-size: .92rem; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--turf); color: var(--turf-ink); border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; background: var(--sunken); border-bottom-left-radius: 4px; }
.msg .ts { border: 0; background: var(--turf-soft); color: var(--turf); border-radius: 5px; padding: 0 5px; font-family: var(--mono); font-size: .82rem; }
.chat-suggest { display: flex; gap: 6px; overflow-x: auto; padding: 10px 12px 0; }
.chat-suggest .chip { white-space: nowrap; }
.chat-form { display: flex; gap: 8px; padding: 10px 12px; align-items: center; }
.chat-form input { flex: 1; border: 1px solid var(--line); border-radius: 999px; padding: 10px 14px; background: var(--ground); min-width: 0; }
.chat-toggle { border: 0; background: none; color: var(--muted); font-size: .8rem; padding: 4px 8px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* stat tiles */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 720px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat .label { font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.stat .value { font-family: var(--display); font-weight: 700; font-size: 2.3rem; line-height: 1; font-variant-numeric: tabular-nums; }
.stat .value.accent { color: var(--turf); }
.stat .hint { font-size: .75rem; color: var(--muted); }
.stat .bar { height: 4px; border-radius: 2px; background: var(--sunken); overflow: hidden; margin-top: 6px; }
.stat .bar span { display: block; height: 100%; background: var(--turf); }
.card { box-shadow: inset 0 1px 0 rgba(255,255,255,.03); }
.btn { background: var(--sunken); }
.btn.primary { box-shadow: 0 0 18px rgba(61, 220, 132, .25); }

/* box editor */
.editor { display: flex; flex-direction: column; gap: 10px; border: 1px solid var(--turf); border-radius: var(--radius); padding: 12px; background: var(--sunken); box-shadow: 0 0 0 3px var(--turf-soft); }
.editor-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.editor-stage { position: relative; }
.editor-stage video { pointer-events: none; }
.editor-canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.editor-slider { width: 100%; accent-color: var(--turf); }
.editor-controls { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.editor-controls .spacer { flex: 1; }
.editor-controls .btn[aria-pressed="true"] { background: #FFD400; color: #1a1400; border-color: #FFD400; }
.editor-panel { display: flex; flex-direction: column; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.editor-empty { border: 1px dashed var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.cov-row { display: flex; flex-direction: column; gap: 6px; }
.cov { position: relative; display: flex; height: 14px; border-radius: 4px; overflow: hidden; cursor: pointer; background: var(--sunken); }
.cov .on { background: var(--turf); }
.cov .off { background: rgba(255, 90, 90, .55); }
.cov .cov-now { position: absolute; top: -2px; bottom: -2px; width: 2px; background: #FFD400; }
.edit-btn { margin-left: auto; }

/* full-screen box editor */
body.editor-open { overflow: hidden; }
body.editor-open .chat-dock { display: none; }
.editor.fullscreen { position: fixed; inset: 0; z-index: 100; border: 0; border-radius: 0; box-shadow: none; background: #000;
  padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  display: flex; flex-direction: column; gap: 8px; }
.editor.fullscreen .editor-head { flex-wrap: nowrap; align-items: center; }
.editor.fullscreen .editor-head .spacer { flex: 1; }
.editor.fullscreen .editor-hint { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.editor-main { flex: 1; min-height: 0; display: grid; place-items: center; }
.editor.fullscreen .editor-stage { width: min(100%, calc((100dvh - 210px) * 16 / 9)); aspect-ratio: 16 / 9; height: auto; border-radius: 10px; }
.editor-bottom { display: flex; flex-direction: column; gap: 8px; width: min(100%, 1200px); margin: 0 auto; }
.editor.fullscreen .editor-panel { position: absolute; left: 50%; transform: translateX(-50%); bottom: max(10px, env(safe-area-inset-bottom));
  width: min(calc(100% - 24px), 760px); max-height: 48dvh; overflow-y: auto; z-index: 2; box-shadow: 0 -10px 40px rgba(0,0,0,.8); }
@media (max-width: 600px) {
  .editor-hint { display: none; }
  .editor.fullscreen .editor-stage { width: min(100%, calc((100dvh - 240px) * 16 / 9)); }
  .editor-controls .btn { padding: 6px 10px; }
  .editor-tools .toggle { font-size: .75rem; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .editor.fullscreen .editor-stage { width: min(100%, calc((100dvh - 120px) * 16 / 9)); }
  .editor.fullscreen .editor-head .editor-hint { display: none; }
}
.editor-stage .add-ball { position: absolute; top: 10px; right: 10px; z-index: 3; }
.editor-stage .ball-hint { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 3; background: #FFD400; color: #1a1400;
  font-weight: 600; font-size: .85rem; padding: 6px 12px; border-radius: 999px; pointer-events: none; }
.sync-label { white-space: nowrap; }
.editor-stage .del-ball { position: absolute; top: 10px; right: 10px; z-index: 3; background: rgba(0,0,0,.65); border-color: #FF6B6B; color: #FFB3B3; }
.editor-toast { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); z-index: 3; background: rgba(0,0,0,.8); color: #fff;
  border: 1px solid var(--line); padding: 6px 12px; border-radius: 999px; font-size: .85rem; pointer-events: none; white-space: nowrap; }
@media (min-width: 900px) { .grid.pair { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; } }
