/* OffBranch — "European night": a floodlit board for branching stories.
   Single dark theme by deliberate choice. No framework. */
:root {
  --bg: #0b1020;          /* midnight navy, blue-biased */
  --surface: #111931;
  --surface-2: #172341;
  --border: #22304e;
  --border-2: #33456e;
  --text: #eef2fb;
  --muted: #93a0c0;
  --faint: #5f6d92;
  --accent: #3d8bff;      /* floodlight blue — structure & actions */
  --accent-soft: rgba(61, 139, 255, .15);
  --gold: #f5c451;        /* trophy — knockout, champion, twists */
  --up: #3ddc84;
  --down: #ff6b81;
  --radius: 14px;
  --shadow: 0 10px 34px rgba(0, 0, 0, .4);
  --display: "Barlow Semi Condensed", system-ui, sans-serif;
  --body: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0; color: var(--text); font-family: var(--body); line-height: 1.55;
  background:
    radial-gradient(1200px 520px at 78% -10%, rgba(61, 139, 255, .13), transparent 60%),
    linear-gradient(180deg, #0c1226, var(--bg));
  background-attachment: fixed; min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4, h5 { font-family: var(--display); font-weight: 800; line-height: 1.08;
  letter-spacing: -.005em; margin: 0 0 .4rem; text-wrap: balance; }
small { color: var(--muted); }
code { font-family: var(--mono); font-size: .84em; background: var(--surface-2);
  padding: .1em .4em; border-radius: 6px; color: #bcd0ff; }
pre { font-family: var(--mono); font-size: .8rem; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 12px; padding: 1rem; overflow: auto; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* layout */
.wrap { max-width: 1000px; margin: 0 auto; padding: 0 1.3rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; }
@media (max-width: 780px) { .grid-2 { grid-template-columns: 1fr; } }
.stack > * + * { margin-top: 1.1rem; }

/* header */
.top { position: sticky; top: 0; z-index: 20; backdrop-filter: blur(12px);
  background: rgba(11, 16, 32, .78); border-bottom: 1px solid var(--border); }
.top .wrap { display: flex; align-items: center; justify-content: space-between; height: 62px; }
.brand { display: flex; align-items: baseline; gap: .55rem; }
.brand a { font-family: var(--display); font-weight: 800; font-size: 1.35rem; color: var(--text);
  letter-spacing: -.01em; }
.brand a em { font-style: normal; color: var(--accent); }
.brand small { color: var(--muted); border-left: 1px solid var(--border-2); padding-left: .6rem; }
@media (max-width: 620px) { .brand small { display: none; } }

/* hero: the pitch, and a literal branch — one line forking into several */
.hero { padding: 2.6rem 0 1.2rem; display: grid; grid-template-columns: 1.15fr 1fr;
  gap: 2rem; align-items: center; }
@media (max-width: 860px) { .hero { grid-template-columns: 1fr; } }
.kicker { font-family: var(--display); font-weight: 700; text-transform: uppercase;
  letter-spacing: .14em; font-size: .74rem; color: var(--accent); margin: 0 0 .6rem; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.2rem); letter-spacing: -.02em; }
.hero h1 .em { color: var(--accent); }
.hero p { color: var(--muted); font-size: 1.05rem; max-width: 44rem; margin: .5rem 0 0; }

.branch-art { width: 100%; height: auto; max-width: 320px; justify-self: center; overflow: visible; }
@media (max-width: 860px) { .branch-art { max-width: 240px; } }
.bl { fill: none; stroke-width: 2.5; stroke-linecap: round; }
.bl.trunk { stroke: var(--border-2); }
.bl.b1, .bl.b2 { stroke: var(--accent); opacity: .55; }
.bl.b3 { stroke: var(--gold); }
.bn { fill: var(--surface); stroke: var(--border-2); stroke-width: 2; }
.bn.fork, .bn.end { stroke: var(--accent); }
.bn.end.gold { stroke: var(--gold); fill: var(--gold); }
@media (prefers-reduced-motion: no-preference) {
  .bl { stroke-dasharray: 320; stroke-dashoffset: 320; animation: branch-draw 1s ease forwards; }
  .bl.trunk { animation-delay: .1s; }
  .bl.b1 { animation-delay: .6s; }
  .bl.b2 { animation-delay: .7s; }
  .bl.b3 { animation-delay: .8s; }
  .bn { opacity: 0; animation: branch-in .35s ease forwards; }
  .bn.fork { animation-delay: .55s; }
  .bn.end { animation-delay: 1.5s; }
}
@keyframes branch-draw { to { stroke-dashoffset: 0; } }
@keyframes branch-in { to { opacity: 1; } }

/* how it works: the three moves, in order */
.how { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.1rem; margin: 1.6rem 0 1rem; }
@media (max-width: 780px) { .how { grid-template-columns: 1fr; } }
.how-step { padding: 1.1rem 1.2rem; border: 1px solid var(--border); border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(23, 35, 65, .5), transparent); }
.how-step .hn { font-family: var(--mono); color: var(--accent); font-size: .8rem; letter-spacing: .08em; }
.how-step h3 { font-size: 1.08rem; margin: .35rem 0 .25rem; }
.how-step p { color: var(--muted); font-size: .9rem; margin: 0; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.3rem 1.4rem; box-shadow: var(--shadow); }
.card h2 { font-size: 1.35rem; } .card h3 { font-size: 1.2rem; } .card h4 { font-size: 1.05rem; }
.card .sub, .sub { color: var(--muted); font-size: .9rem; }
.card h2 + .sub, .card h3 + .sub { margin-top: -.15rem; }

/* forms */
label { display: block; font-family: var(--display); font-size: .8rem; color: var(--muted);
  font-weight: 700; text-transform: uppercase; letter-spacing: .06em; margin: 0 0 .35rem; }
input, select, textarea { width: 100%; font: inherit; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border-2); border-radius: 9px; padding: .58rem .7rem; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft); }
.field + .field { margin-top: .85rem; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: .5rem; justify-content: center; font: inherit;
  font-family: var(--display); font-weight: 700; letter-spacing: .01em; cursor: pointer; border-radius: 9px;
  padding: .58rem 1rem; border: 1px solid transparent; background: var(--surface-2); color: var(--text);
  min-height: 44px; transition: transform .1s, background .12s, border-color .12s; }
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-primary { background: var(--accent); color: #06122e; box-shadow: 0 6px 18px rgba(61, 139, 255, .3); width: 100%; }
.btn-primary:hover { background: #5a9dff; }
.btn-ghost { background: transparent; border-color: var(--border-2); color: var(--text); }
.btn-ghost:hover { border-color: var(--accent); }
.btn-sm { padding: .3rem .7rem; font-size: .82rem; min-height: 34px; }

/* pills */
.pill { display: inline-flex; align-items: center; gap: .35rem; font-family: var(--display); font-size: .74rem;
  font-weight: 700; padding: .16rem .6rem; border-radius: 999px; text-transform: uppercase; letter-spacing: .05em; }
.s-done { background: rgba(61, 220, 132, .15); color: var(--up); }
.s-running, .s-queued { background: var(--accent-soft); color: var(--accent); }
.s-choosing { background: rgba(245, 196, 81, .16); color: var(--gold); }
.s-error { background: rgba(255, 107, 129, .16); color: var(--down); }

/* setups: which story you're telling — one live, others visibly on the way */
.setups { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .9rem; }
.setup { display: inline-flex; align-items: center; gap: .45rem; font: inherit; font-family: var(--display);
  background: transparent; color: var(--text); cursor: default;
  font-weight: 700; font-size: .85rem; padding: .5rem .8rem; border-radius: 9px; border: 1px solid var(--border-2); }
.setup i { font-style: normal; text-transform: uppercase; letter-spacing: .05em; font-size: .66rem; font-weight: 700; }
.setup.active { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.setup.active i { color: var(--up); }
.setup.disabled { color: var(--faint); border-style: dashed; }
.setup.disabled i { color: var(--faint); }

/* about the selected setup */
.about h3 { font-size: 1.05rem; margin: .9rem 0 .3rem; color: var(--accent); }
.about p { color: var(--muted); font-size: .93rem; margin: 0 0 .6rem; max-width: 34rem; }

/* story page header */
.story-top { margin: .9rem 0 .8rem; }
.story-top .back { margin-bottom: .4rem; }
.story-title { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; }
.story-title h1 { font-size: 1.55rem; margin: 0; }

/* the reader: one chapter in view, snap between them */
.steps { height: calc(100vh - 300px); height: calc(100dvh - 300px); min-height: 420px;
  overflow-y: auto; scroll-snap-type: y mandatory; overscroll-behavior: contain;
  scrollbar-width: none; }
.steps::-webkit-scrollbar { display: none; }
.step { height: 100%; padding-bottom: .8rem; scroll-snap-align: start; scroll-snap-stop: always; }
.chapter { height: 100%; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.5rem 1.6rem; }

.ch-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.ch-kicker { font-family: var(--display); font-weight: 700; text-transform: uppercase;
  letter-spacing: .1em; font-size: .72rem; color: var(--accent); }
.ch-date { font-family: var(--mono); color: var(--faint); font-size: .76rem; }
.ch-title { font-size: clamp(1.5rem, 3vw, 2rem); margin: .3rem 0 .7rem; }
.ch-title.gold { color: var(--gold); }
.ch-narrative { font-size: 1.02rem; max-width: 46rem; margin: 0; }
.ch-meta { color: var(--muted); font-size: .88rem; margin: .6rem 0 0; }
.ch-twist { display: flex; gap: .6rem; align-items: baseline; margin: 0 0 .8rem; padding: .55rem .8rem;
  border: 1px solid rgba(245, 196, 81, .35); border-radius: 10px; background: rgba(245, 196, 81, .07); }
.ch-twist span { font-family: var(--display); font-weight: 700; font-size: .68rem; text-transform: uppercase;
  letter-spacing: .07em; color: var(--gold); white-space: nowrap; }

.chapter.wait { display: flex; flex-direction: column; justify-content: center; align-items: center;
  text-align: center; gap: .5rem; }

/* press, quotes, matches inside a chapter */
.tl-press { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .8rem; }
.tl-headline { font-family: var(--display); font-weight: 700; text-transform: uppercase; font-size: .7rem;
  letter-spacing: .04em; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
  padding: .28rem .6rem; border-radius: 6px; }
.tl-quotes { margin-top: .7rem; display: flex; flex-direction: column; gap: .45rem; }
.quote { margin: 0; padding-left: .9rem; border-left: 2px solid var(--accent); color: var(--muted);
  font-style: italic; font-size: .92rem; }
.tl-matches { margin-top: 1rem; background: var(--surface-2); border-color: var(--border); }
.tl-matches summary { font-family: var(--display); font-weight: 700; font-size: .78rem; text-transform: uppercase;
  letter-spacing: .05em; color: var(--accent); }
.tl-matches[open] summary { margin-bottom: .3rem; }

.mrow { display: grid; grid-template-columns: 10px 1fr auto 1fr; align-items: center; gap: .7rem;
  padding: .5rem .25rem; border-bottom: 1px solid var(--border); color: var(--text); }
.mrow:last-child { border-bottom: none; }
.mrow:hover { background: var(--surface); text-decoration: none; }
.mrow .sig { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); }
.mrow .tm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mrow .tm.home { text-align: right; } .mrow .tm.away { text-align: left; }
.mrow .sc { font-family: var(--display); font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mrow .sc i { color: var(--faint); font-style: normal; margin: 0 .12rem; }
.mrow .hl { grid-column: 2 / 5; color: var(--muted); font-size: .82rem; margin-top: -.1rem; }

/* the choice: 2-3 branch points, or let it play out */
.chapter.choice .sub { font-size: .95rem; }
.cands { display: grid; gap: .6rem; margin-top: 1.1rem; }
@media (min-width: 781px) { .cands { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); } }
.cand { text-align: left; font: inherit; color: var(--text); cursor: pointer; border: 1px solid var(--border-2);
  border-radius: 12px; background: var(--surface-2); padding: .95rem 1rem; display: flex; flex-direction: column;
  gap: .35rem; transition: border-color .12s, transform .1s; }
.cand:hover { border-color: var(--accent); transform: translateY(-1px); }
.cand:disabled { opacity: .55; cursor: default; transform: none; }
.cand-tag { align-self: flex-start; font-family: var(--display); font-weight: 700; font-size: .66rem;
  text-transform: uppercase; letter-spacing: .07em; color: var(--gold); border: 1px solid rgba(245, 196, 81, .4);
  padding: .12rem .5rem; border-radius: 999px; }
.cand.plain .cand-tag { color: var(--muted); border-color: var(--border-2); }
.cand-h { font-family: var(--display); font-weight: 800; font-size: 1.05rem; line-height: 1.15; }
.cand-d { color: var(--muted); font-size: .88rem; }
.cand-custom { margin-top: 1rem; padding-top: 1rem; border-top: 1px dashed var(--border-2); display: grid; gap: .5rem; }
.cand-custom .btn { justify-self: start; min-height: 38px; }

/* chapter navigation */
.story-nav { display: flex; align-items: center; justify-content: center; gap: .55rem; margin: 0 0 .7rem; }
.snav { font: inherit; font-family: var(--display); font-weight: 700; font-size: .9rem; color: var(--text);
  cursor: pointer; background: var(--surface-2); border: 1px solid var(--border-2); border-radius: 999px;
  min-width: 38px; height: 38px; padding: 0 .8rem; }
.snav:hover { border-color: var(--accent); }
.snav[hidden] { display: none; }
.snav.wide { color: var(--accent); }
.scount { font-family: var(--mono); color: var(--muted); font-size: .85rem; min-width: 3.6rem; text-align: center;
  font-variant-numeric: tabular-nums; }
.scount i { font-style: normal; color: var(--faint); margin: 0 .18rem; }

/* epilogue: champion, key moments, the fork */
.champ { text-align: center; padding: 2rem 1.4rem; }
.champ.bare { padding: .6rem 0 1.2rem; border-bottom: 1px solid var(--border); margin-bottom: .4rem;
  background: radial-gradient(600px 200px at 50% -20%, rgba(245, 196, 81, .1), transparent); }
.champ .ct { color: var(--muted); font-family: var(--display); text-transform: uppercase; letter-spacing: .12em; font-size: .78rem; }
.champ .crown { font-family: var(--display); font-weight: 800; font-size: clamp(1.9rem, 5vw, 2.9rem); color: var(--gold); margin: .35rem 0; }
.champ .cvs { display: flex; align-items: center; justify-content: center; gap: 1.6rem; margin: .9rem 0; flex-wrap: wrap; }
.champ .side { display: flex; flex-direction: column; gap: .2rem; }
.champ .side .lbl { color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; }
.champ .side .who { font-family: var(--display); font-weight: 800; font-size: 1.45rem; }
.champ .side.win .who { color: var(--gold); }
.champ .arrow { color: var(--faint); font-size: 1.6rem; }
.ep-h { font-size: 1.15rem; margin: 1.3rem 0 .2rem; }

/* key-moment cards */
.moments { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .7rem; margin-top: .8rem; }
.moment { display: block; background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px;
  padding: .8rem .9rem; color: var(--text); transition: .1s; }
.moment:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-1px); }
.moment .mh { color: var(--muted); font-family: var(--display); text-transform: uppercase; letter-spacing: .05em; font-size: .7rem; }
.moment .ms { margin: .3rem 0; } .moment .ms b { color: var(--gold); font-family: var(--display); }
.moment .mt { color: var(--muted); font-size: .85rem; }

/* side drawers: the match (right), the branch DAG (left) */
.scrim { position: fixed; inset: 0; background: rgba(5, 8, 18, .55); backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 30; }
.scrim.show { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; bottom: 0; width: min(440px, 94vw); background: var(--surface);
  z-index: 40; display: flex; flex-direction: column; transition: transform .28s ease;
  box-shadow: var(--shadow); }
.drawer.right { right: 0; border-left: 1px solid var(--border-2); transform: translateX(105%); }
.drawer.left { left: 0; border-right: 1px solid var(--border-2); transform: translateX(-105%); }
.drawer.open { transform: none; }
.drawer header { display: flex; justify-content: space-between; align-items: center;
  padding: .85rem 1.1rem; border-bottom: 1px solid var(--border); }
.drawer header h3 { margin: 0; font-size: 1.05rem; }
.dclose { background: none; border: none; color: var(--muted); font-size: 1.5rem; cursor: pointer;
  line-height: 1; padding: .1rem .4rem; }
.dclose:hover { color: var(--text); }
.dbody { padding: 1.1rem; overflow-y: auto; }
@media (prefers-reduced-motion: reduce) { .drawer, .scrim { transition: none; } }

/* the branch DAG: trunk first, forks indented under the moment they split */
.lineage, .lineage ul { list-style: none; margin: 0; padding: 0; }
.lineage ul { margin-left: .55rem; padding-left: 1rem; border-left: 2px solid var(--border-2); }
.ln { margin: .55rem 0; position: relative; }
.lineage ul .ln::before { content: ""; position: absolute; left: -1rem; top: .8rem;
  width: .7rem; height: 2px; background: var(--border-2); }
.ln > a { display: flex; align-items: center; gap: .5rem; color: var(--text);
  padding: .32rem .5rem; border-radius: 8px; border: 1px solid transparent; }
.ln > a:hover { text-decoration: none; border-color: var(--border-2); }
.ln.here > a { border-color: var(--accent); background: var(--accent-soft); }
.ln-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--faint); }
.ln-dot.s-done { background: var(--up); }
.ln-dot.s-running, .ln-dot.s-queued { background: var(--accent); }
.ln-dot.s-choosing { background: var(--gold); }
.ln-dot.s-error { background: var(--down); }
.ln-label { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ln-at { color: var(--faint); font-size: .76rem; font-family: var(--mono); white-space: nowrap; }
.ln-tw { color: var(--muted); font-size: .82rem; margin: .1rem 0 0 1.4rem; font-style: italic; }

/* single match */
.m-kicker { color: var(--muted); font-family: var(--display); text-transform: uppercase;
  letter-spacing: .06em; font-size: .78rem; }
.scoreline { display: flex; align-items: center; justify-content: center; gap: 1.6rem; margin-top: 1.2rem; flex-wrap: wrap; }
.scoreline .team { font-family: var(--display); font-weight: 700; font-size: 1.25rem; }
.scoreline .big { font-family: var(--display); font-weight: 800; font-size: 2.6rem; color: var(--gold); font-variant-numeric: tabular-nums; }
.scoreline .big i { color: var(--faint); font-style: normal; }
.mlabel { font-family: var(--display); text-transform: uppercase; letter-spacing: .06em; font-size: .74rem;
  color: var(--muted); border-bottom: 1px solid var(--border); padding-bottom: .3rem; margin-bottom: .5rem; }
.mlist { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .3rem; }
.mlist li { font-variant-numeric: tabular-nums; }

/* misc */
details { border: 1px solid var(--border); border-radius: 11px; padding: .3rem .9rem; background: var(--surface-2); }
details + details { margin-top: .5rem; }
summary { cursor: pointer; padding: .5rem 0; font-weight: 600; }
.busy { display: flex; align-items: center; gap: .7rem; color: var(--muted); font-family: var(--display); font-weight: 600; }
.spinner { width: 18px; height: 18px; border: 2.5px solid var(--border-2); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } .btn:hover, .cand:hover, .moment:hover { transform: none; } }
.foot { color: var(--faint); font-size: .82rem; padding: 2.6rem 0 2rem; text-align: center; }
.back { display: inline-block; color: var(--muted); }

/* small screens: the reader turns sideways — swipe between chapters */
@media (max-width: 780px) {
  .steps { display: flex; scroll-snap-type: x mandatory; overflow-x: auto; overflow-y: hidden;
    height: calc(100vh - 250px); height: calc(100dvh - 250px); min-height: 400px; }
  .step { flex: 0 0 100%; width: 100%; height: 100%; padding: 0 .7rem 0 0; }
  .chapter { padding: 1.15rem 1.05rem; }
}
@media (max-width: 480px) {
  .wrap { padding: 0 .9rem; }
  .brand a { font-size: 1.15rem; }
  .top .wrap { height: 56px; }
  .card { padding: 1.05rem 1rem; }
  .story-title h1 { font-size: 1.3rem; }
  .mrow { grid-template-columns: 8px 1fr auto 1fr; gap: .45rem; font-size: .92rem; }
  .champ .cvs { gap: 1rem; }
  .scoreline { gap: 1rem; }
  .scoreline .big { font-size: 2.1rem; }
}
