/* SimpleMarbles: venue race screen. Night-track indigo, glossy marbles, gold for money. */
:root {
  --sm-bg: #10122a;
  --sm-bg-deep: #0a0b1d;
  --sm-surface: #191c3a;
  --sm-surface-2: #22264a;
  --sm-line: #30366a;
  --sm-text: #eeedf7;
  --sm-muted: #9b9ec4;
  --sm-gold: #f4c95d;
  --sm-mint: #6ee7b7;
  --sm-rose: #ff7a93;
  --sm-sky: #8fb4ff;
  --sm-display: "Bahnschrift SemiCondensed", "Bahnschrift", "DIN Alternate", "Barlow Semi Condensed",
                "Arial Narrow", system-ui, sans-serif;
  --sm-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --sm-mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --sm-radius: 14px;
  --sm-gap: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { background: var(--sm-bg-deep); }
body {
  min-height: 100vh;
  background:
    radial-gradient(1100px 600px at 50% -220px, #2a2f6b 0%, transparent 70%),
    linear-gradient(180deg, var(--sm-bg) 0%, var(--sm-bg-deep) 100%);
  background-attachment: fixed;
  color: var(--sm-text);
  font: 15px/1.5 var(--sm-body);
  -webkit-font-smoothing: antialiased;
}
#app { width: 100%; max-width: 1280px; margin: 0 auto; padding: 12px 16px 40px; }
[hidden] { display: none !important; }
h1, h2 { font-family: var(--sm-display); font-weight: 600; margin: 0; }
code { font-family: var(--sm-mono); font-size: 13px; }
:focus-visible { outline: 2px solid var(--sm-sky); outline-offset: 2px; border-radius: 6px; }

/* ---------- marbles (the one decorative idea, used everywhere) ---------- */
.marble {
  --c: #8a8fb8;
  display: inline-block; flex: 0 0 auto;
  width: 14px; height: 14px; border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, rgba(255,255,255,.85) 0 10%, rgba(255,255,255,0) 32%),
    radial-gradient(circle at 50% 50%, var(--c) 0 55%, color-mix(in srgb, var(--c) 55%, #000) 100%);
  box-shadow: 0 1px 2px rgba(0,0,0,.45), inset 0 -1px 2px rgba(0,0,0,.35);
}
.marble.blank {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--sm-line);
}
.marble-xl { width: 64px; height: 64px; box-shadow: 0 6px 20px rgba(0,0,0,.5), inset 0 -4px 8px rgba(0,0,0,.3); }

/* ---------- buttons ---------- */
.btn {
  font: 600 15px/1 var(--sm-display); letter-spacing: .02em;
  background: var(--sm-gold); color: #2a1d00; border: 0; border-radius: 10px;
  padding: 12px 18px; cursor: pointer;
}
.btn:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; color: var(--sm-text); box-shadow: inset 0 0 0 1px var(--sm-line); }
.btn.ghost:hover { box-shadow: inset 0 0 0 1px var(--sm-muted); }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0 14px; }
.wordmark {
  font-family: var(--sm-display); font-weight: 700; letter-spacing: .01em;
  color: var(--sm-text); text-decoration: none;
}
.wordmark.small { font-size: 20px; }
.status-pill {
  font: 600 13px/1 var(--sm-display); letter-spacing: .03em;
  padding: 7px 12px; border-radius: 999px;
  background: var(--sm-surface-2); color: var(--sm-muted);
  display: inline-flex; align-items: center; gap: 8px;
}
.status-pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status-pill[data-status="entries_open"] { color: var(--sm-mint); }
.status-pill[data-status="entries_closed"],
.status-pill[data-status="starting"] { color: var(--sm-gold); }
.status-pill[data-status="racing"] { color: var(--sm-sky); }
.status-pill[data-status="racing"]::before { animation: sm-pulse 1.2s ease-in-out infinite; }
.status-pill[data-status="finished"] { color: var(--sm-gold); }
.status-pill[data-status="cancelled"],
.status-pill[data-status="ended"] { color: var(--sm-rose); }
@keyframes sm-pulse { 50% { opacity: .25; } }

.conn-banner {
  margin: 0 0 12px; padding: 10px 14px; border-radius: 10px;
  background: color-mix(in srgb, var(--sm-rose) 16%, transparent); color: var(--sm-rose);
  font-size: 14px;
}

/* ---------- race heading ---------- */
.race-head { margin: 0 0 14px; }
.race-title { font-size: clamp(30px, 8vw, 52px); line-height: 1; letter-spacing: -.01em; }
.race-sub { margin: 6px 0 0; color: var(--sm-muted); }

/* ---------- layout: one column on phones, stage + sidebar on wide screens ---------- */
.layout { display: grid; gap: var(--sm-gap); grid-template-columns: minmax(0, 1fr); }
.col-main, .col-side { display: grid; gap: var(--sm-gap); align-content: start; min-width: 0; }
@media (min-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr) 360px; grid-template-rows: auto 1fr; }
  .col-side { grid-column: 2; grid-row: 1 / span 2; }
  .history { grid-column: 1; grid-row: 2; align-self: start; }
}

.panel {
  background: var(--sm-surface); border-radius: var(--sm-radius); padding: 16px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.04);
}
.panel h2 { font-size: 18px; margin: 0 0 10px; }
.empty { color: var(--sm-muted); margin: 0; font-size: 14px; }

/* ---------- stage ---------- */
.stage {
  position: relative; overflow: hidden; border-radius: var(--sm-radius);
  aspect-ratio: 4 / 5; max-height: 78vh; width: 100%;
  background: #0a0c12;
  box-shadow: inset 0 0 0 1px var(--sm-line);
}
@media (min-width: 720px) { .stage { aspect-ratio: 16 / 10; } }
.stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; }
.stage-idle {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 22px; padding: 24px; text-align: center;
  background:
    repeating-linear-gradient(90deg, transparent 0 46px, rgba(255,255,255,.025) 46px 48px),
    radial-gradient(500px 260px at 50% 60%, #1b1f45 0%, transparent 70%);
}
.grid-line {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 10px;
  max-width: 460px; padding: 14px 18px; border-bottom: 3px dashed rgba(255,255,255,.18);
}
.grid-line:empty { display: none; }
.grid-line .marble { width: 26px; height: 26px; }
.stage-msg { margin: 0; max-width: 34ch; color: var(--sm-muted); font-size: 16px; }

/* ---------- winner banner ---------- */
.winner {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 2px 12px; align-items: center;
  padding: 10px 14px; border-radius: var(--sm-radius);
  background: linear-gradient(135deg, color-mix(in srgb, var(--sm-gold) 22%, var(--sm-surface)), var(--sm-surface) 70%);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--sm-gold) 45%, transparent);
  animation: sm-win .5s cubic-bezier(.2, .9, .3, 1.2) both;
}
.winner .marble-xl { width: 40px; height: 40px; }
.winner-text { min-width: 0; }
.winner-kicker { margin: 0; color: var(--sm-gold); font: 600 12px/1.2 var(--sm-display); }
.winner-label { margin: 1px 0 0; font: 700 clamp(18px, 4.5vw, 24px)/1.1 var(--sm-display); overflow-wrap: anywhere; }
.winner-who { margin: 1px 0 0; color: var(--sm-muted); font-size: 13px; overflow-wrap: anywhere; }
.winner-pot { display: flex; align-items: baseline; gap: 4px; }
.winner-pot .gil { font: 700 24px/1 var(--sm-display); color: var(--sm-gold); font-variant-numeric: tabular-nums; }
.winner-pot .unit { color: var(--sm-muted); font-size: 13px; }
@keyframes sm-win { from { transform: scale(.96); opacity: 0; } }

/* ---------- pot strip ---------- */
.pot-strip {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 20px;
  padding: 4px 2px;
}
.pot { display: flex; align-items: baseline; gap: 8px; }
.pot .gil { font: 700 clamp(34px, 9vw, 48px)/1 var(--sm-display); color: var(--sm-gold); font-variant-numeric: tabular-nums; }
.pot .unit { color: var(--sm-muted); }
.pot-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--sm-muted); font-size: 14px; }

/* ---------- entries ---------- */
.entries, .order, .history-list { list-style: none; margin: 0; padding: 0; }
.entry {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "who count" "dots dots";
  gap: 6px 12px; padding: 10px 0; border-top: 1px solid var(--sm-line);
}
.entry:first-child { border-top: 0; padding-top: 2px; }
.entry .dots { grid-area: dots; display: flex; gap: 6px; }
.entry .who { grid-area: who; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; }
.entry .name { font-weight: 600; overflow-wrap: anywhere; }
.entry .world { color: var(--sm-muted); font-size: 13px; }
.entry .count { grid-area: count; color: var(--sm-muted); font-variant-numeric: tabular-nums; }
.entry.won .name { color: var(--sm-gold); }

/* ---------- finishing order ---------- */
.order li { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.order .place { width: 2ch; text-align: right; color: var(--sm-muted); font: 600 15px/1 var(--sm-display); font-variant-numeric: tabular-nums; }
.order .label { min-width: 0; overflow-wrap: anywhere; }
.order li.first .label { color: var(--sm-gold); font-weight: 600; }
.order li.first .place { color: var(--sm-gold); }

/* ---------- live standings ---------- */
.live-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.stopwatch { font: 600 22px/1 var(--sm-display); font-variant-numeric: tabular-nums; color: var(--sm-gold); }
.standings { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.standing { display: grid; grid-template-columns: 2ch auto minmax(0, 1fr) auto; align-items: center; gap: 10px; }
.standing .place { text-align: right; color: var(--sm-muted); font: 600 15px/1 var(--sm-display); font-variant-numeric: tabular-nums; }
.standing .label { min-width: 0; overflow-wrap: anywhere; }
.standing .time { color: var(--sm-mint); font-size: 13px; font-variant-numeric: tabular-nums; }
.standing.first .place, .standing.first .label { color: var(--sm-gold); font-weight: 600; }
.standing.done .label { opacity: .85; }

/* ---------- history ---------- */
.hist { display: grid; grid-template-columns: 4.5em minmax(0, 1fr); align-items: baseline; gap: 10px;
  padding: 9px 0; border-top: 1px solid var(--sm-line); }
.hist:first-child { border-top: 0; padding-top: 2px; }
.hist-num { color: var(--sm-muted); font: 600 14px/1.2 var(--sm-display); }
.hist-body { min-width: 0; display: flex; flex-wrap: wrap; gap: 0 10px; align-items: baseline; }
.hist-winner { font-weight: 600; overflow-wrap: anywhere; }
.hist.cancelled .hist-winner { color: var(--sm-rose); font-weight: 500; }
.hist-meta { color: var(--sm-muted); font-size: 13px; }

/* ---------- landing ---------- */
body.landing #app { min-height: 100vh; display: grid; place-items: center; }
.landing-card { width: 100%; max-width: 460px; text-align: left; }
.landing-marbles { display: flex; gap: 10px; margin-bottom: 18px; }
.landing-marbles .marble { width: 30px; height: 30px; }
.landing-card .wordmark { font-size: clamp(40px, 11vw, 56px); line-height: 1; }
.landing-lead { font-size: 17px; margin: 14px 0 0; max-width: 40ch; }
.landing-note { color: var(--sm-muted); margin: 8px 0 0; }
.landing-form { margin-top: 28px; }
.landing-form label { display: block; color: var(--sm-muted); font-size: 14px; margin-bottom: 6px; }
.landing-row { display: flex; gap: 8px; }
.landing-row input {
  flex: 1; min-width: 0; font: 16px/1 var(--sm-body); color: var(--sm-text);
  background: var(--sm-surface); border: 0; border-radius: 10px; padding: 12px 14px;
  box-shadow: inset 0 0 0 1px var(--sm-line);
}
.landing-row input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--sm-sky); }

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