:root {
  color-scheme: dark;
  --bg: #07110f;
  --panel: #0d1916;
  --panel-2: #10201c;
  --line: #20332d;
  --line-bright: #345248;
  --ink: #edf7f2;
  --muted: #89a39a;
  --acid: #a7f46a;
  --mint: #51d8a5;
  --orange: #ff9d66;
  --red: #ff6f78;
  --blue: #64b5f6;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-width: 320px; background: radial-gradient(circle at 80% -10%, #17382d 0, transparent 30rem), var(--bg); color: var(--ink); font-family: var(--sans); }
button, select, input { font: inherit; }
button, select, label { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
code { color: var(--acid); font-family: var(--mono); }

.topbar { height: 64px; padding: 0 clamp(18px, 4vw, 54px); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: rgba(7, 17, 15, .86); backdrop-filter: blur(18px); position: sticky; top: 0; z-index: 20; }
.brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; font: 700 12px/1 var(--mono); letter-spacing: .11em; }
.brand b { color: var(--acid); }
.brand-mark { display: grid; place-items: center; width: 31px; height: 31px; border: 1px solid var(--acid); border-radius: 50%; color: var(--acid); font-size: 10px; letter-spacing: 0; }
.load-actions { display: flex; gap: 9px; align-items: center; }
#file { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.file-button, .quiet-button, .primary-button { border-radius: 999px; cursor: pointer; font-weight: 700; transition: .18s ease; }
.file-button, .quiet-button { padding: 9px 14px; font-size: 12px; }
.file-button { background: var(--acid); color: #0a160f; border: 1px solid var(--acid); }
.quiet-button { color: var(--ink); background: transparent; border: 1px solid var(--line-bright); }
.quiet-button:disabled { opacity: .35; cursor: default; }
.file-button:hover, .primary-button:hover { filter: brightness(1.1); transform: translateY(-1px); }
.quiet-button:not(:disabled):hover { border-color: var(--acid); color: var(--acid); }

.shell { width: min(1600px, 100%); margin: 0 auto; padding: 42px clamp(14px, 3vw, 42px) 116px; }
.hero-row { display: flex; align-items: end; justify-content: space-between; gap: 30px; margin: 0 0 28px; }
.eyebrow, .panel-kicker { margin: 0 0 8px; color: var(--acid); font: 700 10px/1.2 var(--mono); letter-spacing: .16em; text-transform: uppercase; }
h1 { margin: 0; max-width: 920px; font-size: clamp(28px, 4.5vw, 60px); letter-spacing: -.055em; line-height: .98; }
.meta { margin: 13px 0 0; color: var(--muted); font: 12px/1.6 var(--mono); }
.league { min-width: 118px; padding: 13px 18px; border: 1px solid var(--acid); border-radius: 999px; color: var(--acid); text-align: center; font: 800 12px/1 var(--mono); letter-spacing: .12em; box-shadow: 0 0 36px rgba(167, 244, 106, .08); }

.empty-state { min-height: 530px; position: relative; display: grid; align-content: center; justify-items: start; overflow: hidden; padding: clamp(30px, 8vw, 90px); border: 1px solid var(--line); border-radius: 20px; background: linear-gradient(135deg, rgba(16,32,28,.9), rgba(7,17,15,.94)); }
.empty-state > *:not(.empty-grid) { position: relative; z-index: 1; }
.empty-state h2 { max-width: 720px; margin: 0; font-size: clamp(34px, 6vw, 76px); line-height: .96; letter-spacing: -.06em; }
.empty-state p:not(.eyebrow) { max-width: 550px; margin: 23px 0 32px; color: var(--muted); font-size: 17px; line-height: 1.6; }
.empty-grid { position: absolute; inset: 0; opacity: .46; background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px); background-size: 46px 46px; mask-image: linear-gradient(90deg, transparent 16%, black 100%); transform: perspective(600px) rotateY(-13deg) scale(1.25); transform-origin: right; }
.primary-button { padding: 13px 20px; color: #0a160f; background: var(--acid); }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; }
.main-column, .side-column { display: grid; gap: 16px; align-content: start; min-width: 0; }
.side-column { position: sticky; top: 80px; }
.panel { min-width: 0; overflow: hidden; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: linear-gradient(145deg, rgba(16,32,28,.96), rgba(11,24,20,.96)); box-shadow: 0 20px 45px rgba(0,0,0,.13); }
.panel-head { min-height: 42px; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: start; gap: 20px; }
.panel h2 { margin: 0; font-size: 16px; letter-spacing: -.015em; }
.segmented { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: #081410; }
.segmented button { min-width: 43px; padding: 6px 9px; border: 0; border-radius: 6px; color: var(--muted); background: transparent; font: 700 10px/1 var(--mono); cursor: pointer; }
.segmented button.active { color: #08130f; background: var(--acid); }
select { padding: 7px 28px 7px 10px; color: var(--ink); border: 1px solid var(--line-bright); border-radius: 8px; background: #0a1713; font: 11px/1 var(--mono); }
.canvas-wrap { position: relative; width: 100%; overflow: hidden; border: 1px solid rgba(52,82,72,.5); border-radius: 9px; background: #07110f; }
canvas { display: block; width: 100%; height: 330px; }
.race-panel canvas { height: 240px; }
.chart-tooltip { position: absolute; z-index: 4; width: max-content; max-width: 280px; pointer-events: none; padding: 9px 11px; border: 1px solid var(--line-bright); border-radius: 7px; background: rgba(4,12,9,.96); box-shadow: 0 12px 35px rgba(0,0,0,.35); color: var(--ink); font: 10px/1.55 var(--mono); white-space: pre-line; }
.chart-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 13px; min-height: 25px; margin-top: 10px; color: var(--muted); font: 10px/1.3 var(--mono); }
.chart-legend label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.chart-legend input { accent-color: var(--acid); }
.dot { display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; }
.dot.bid { background: var(--mint); }.dot.ask { background: var(--red); }.dot.trade { background: white; }
.note { color: var(--muted); font: 10px/1.55 var(--mono); }

.tape-head { align-items: center; }
.tape-filters { display: flex; gap: 8px; }
.tape-labels, .tape-row { display: grid; grid-template-columns: 72px 100px minmax(130px,.8fr) minmax(210px,1.4fr); gap: 8px; align-items: center; }
.tape-labels { padding: 8px 10px; color: var(--muted); border-bottom: 1px solid var(--line); font: 9px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; }
.tape { height: 275px; overflow: auto; scrollbar-color: var(--line-bright) transparent; }
.tape-row { min-height: 36px; padding: 6px 10px; border-bottom: 1px solid rgba(32,51,45,.65); font: 11px/1.3 var(--mono); }
.tape-row:hover { background: rgba(167,244,106,.035); }
.tape-row .inst { color: var(--acid); font-weight: 800; }
.tape-row .side-buy { color: var(--mint); }.tape-row .side-sell { color: var(--red); }
.tape-empty { display: grid; place-items: center; height: 100%; color: var(--muted); font: 11px/1.6 var(--mono); text-align: center; }

.fundamental-readout { display: grid; grid-template-columns: repeat(3,1fr); gap: 7px; margin: 14px 0; }
.fundamental-value { padding: 11px 8px; border: 1px solid var(--line); border-radius: 8px; background: #091511; }
.fundamental-value span { display: block; color: var(--muted); font: 9px/1 var(--mono); }
.fundamental-value b { display: block; margin-top: 7px; color: var(--acid); font: 700 16px/1 var(--mono); }
.standings { margin-top: 14px; }
.standing { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 8px; min-height: 39px; border-bottom: 1px solid var(--line); font: 11px/1 var(--mono); }
.standing:last-child { border-bottom: 0; }
.standing .rank { color: var(--muted); }.standing .score { font-weight: 700; }
.seat-name { display: inline-flex; align-items: center; gap: 7px; }
.seat-color { width: 7px; height: 7px; border-radius: 50%; }
.match-card dl { margin: 13px 0 0; }
.match-card dl div { display: grid; grid-template-columns: 86px 1fr; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); font: 10px/1.4 var(--mono); }
.match-card dt { color: var(--muted); }.match-card dd { margin: 0; overflow-wrap: anywhere; }

.playback { position: fixed; z-index: 30; left: 50%; bottom: 16px; width: min(920px, calc(100% - 28px)); min-height: 70px; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; padding: 11px 14px; border: 1px solid var(--line-bright); border-radius: 16px; background: rgba(7,17,15,.92); backdrop-filter: blur(22px); box-shadow: 0 22px 70px rgba(0,0,0,.55); }
.play-button, .step-button { flex: 0 0 auto; display: grid; place-items: center; border: 1px solid var(--line-bright); color: var(--ink); background: #10201c; cursor: pointer; }
.play-button { width: 42px; height: 42px; border-color: var(--acid); border-radius: 50%; color: #08130f; background: var(--acid); }
.step-button { width: 35px; height: 31px; border-radius: 7px; font: 700 10px/1 var(--mono); }
.scrub-group { flex: 1; min-width: 100px; }
#scrub { width: 100%; accent-color: var(--acid); cursor: pointer; }
.scrub-meta { display: flex; justify-content: space-between; color: var(--muted); font: 9px/1 var(--mono); }
.speed-label { display: grid; gap: 4px; color: var(--muted); font: 8px/1 var(--mono); text-transform: uppercase; }

body.embed .topbar, body.embed .hero-row, body.embed .side-column { display: none; }
body.embed .shell { padding: 8px 8px 88px; }
body.embed .workspace { grid-template-columns: 1fr; }
body.embed .tape-panel { display: none; }

@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .side-column { position: static; grid-template-columns: repeat(3, minmax(0,1fr)); }
}
@media (max-width: 700px) {
  .topbar { padding: 0 14px; }.brand > span:last-child { display: none; }.quiet-button { display: none; }
  .shell { padding-top: 26px; }.hero-row { align-items: start; }.league { min-width: auto; padding: 10px 12px; }
  .panel { padding: 13px; border-radius: 10px; }.panel-head { gap: 8px; }
  canvas { height: 270px; }.race-panel canvas { height: 220px; }
  .side-column { grid-template-columns: 1fr; }
  .tape-head { align-items: start; }.tape-filters { flex-direction: column; }
  .tape-labels, .tape-row { grid-template-columns: 45px 68px 1fr; }.tape-labels span:last-child, .tape-row span:last-child { grid-column: 3; }.tape-row span:last-child { color: var(--muted); }
  .playback { bottom: 8px; min-height: 62px; padding: 8px; }.step-button { display: none; }.speed-label { display: none; }
}

:focus-visible { outline: 2px solid var(--acid); outline-offset: 3px; }
[hidden] { display: none !important; }
