:root {
  /* Forkbomb palette: terminal black, cream text, signal orange (forks, kills), green only for exit 0 */
  --bg: #0a0a0b;
  --panel: #131315;
  --panel-2: #19191c;
  --line: #232327;
  --line-2: #2f2f34;
  --text: #ece4d4;
  --muted: #8a847a;
  --dim: #5c5851;
  --alive: #3cf2b4;
  --alive-dim: rgba(60, 242, 180, 0.12);
  --signal: #ff4d1f;
  --signal-ink: #ff7a55;
  --signal-dim: rgba(255, 77, 31, 0.1);
  --judge: #f5b83d;
  --dead: #ff7a55;
  --dead-dim: rgba(255, 77, 31, 0.1);
  --info: #8fb8ff;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
  --card-w: 248px;
  --card-h: 104px;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--sans); }
body { min-height: 100vh; display: flex; flex-direction: column; }
code, pre, .mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.label { font: 600 10.5px/1 var(--mono); letter-spacing: 0.14em; color: var(--muted); margin-right: 10px; }
[hidden] { display: none !important; }
a { color: inherit; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; border-radius: 4px; }
#treeWrap:focus-visible { outline-offset: -2px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: fixed; top: 8px; left: 8px; z-index: 20; padding: 8px 14px; border-radius: 999px; background: var(--signal); color: #0a0a0b; font: 600 13px/1.2 var(--mono); text-decoration: none; transform: translateY(-200%); }
.skip:focus, .skip:focus-visible { transform: none; }
.nojs { margin: 16px 24px 0; padding: 16px 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); display: grid; gap: 10px; }
.nojsTree { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; font: 13px/1.4 var(--mono); }
.nojsTree li { padding: 8px 10px; border: 1px solid var(--line-2); border-radius: 6px; }
.nojsTree li + li { margin-left: 24px; }
.nojsTree .cut { color: var(--muted); }
.nojsTree .won { border-color: var(--alive); color: var(--text); }
.nojs a { color: var(--signal-ink); }

/* Site nav: the floating pill bar from the Next.js site (globals.css "Site nav"), with the same links */
.sitenav { padding: 10px clamp(8px, 4vw - 8px, 24px) 6px; }
.sitenav__inner { display: flex; align-items: center; gap: 16px; max-width: 1376px; height: 48px; margin: 0 auto; padding: 0 7px 0 16px; border: 1px solid var(--line-2); border-radius: 999px; background: rgba(16, 16, 18, 0.8); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45), 0 1px 0 rgba(255, 245, 225, 0.04) inset; }
.sitenav__links { display: flex; align-items: center; gap: 2px; margin: 0 auto; padding: 0; list-style: none; }
.sitenav__links a { display: inline-flex; align-items: center; height: 34px; padding: 0 12px; border-radius: 999px; font: 14px/1 var(--sans); color: #b0a999; text-decoration: none; transition: color .15s, background-color .15s; }
.sitenav__links a:hover { color: var(--text); background: var(--panel-2); }
.sitenav__links .sitenav__token { font: 500 12px/1 var(--mono); letter-spacing: 0.04em; color: var(--signal-ink); }
.sitenav__links .sitenav__token:hover { color: var(--signal); }
.sitenav__cta { flex: none; display: inline-flex; align-items: center; height: 34px; padding: 0 16px; border-radius: 999px; background: var(--signal); color: #0a0a0b; font: 600 12px/1 var(--sans); text-decoration: none; box-shadow: 0 1px 0 rgba(255, 255, 255, 0.3) inset, 0 6px 22px rgba(255, 77, 31, 0.25); transition: background-color .15s; }
.sitenav__cta:hover { background: #ff6a42; }
.sitenav__cta:focus-visible { border-radius: 999px; }

/* Site footer: minimal, same links */
.sitefoot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 24px; padding: 20px 24px calc(20px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); background: #0e0e10; font: 12px/1.5 var(--mono); color: var(--muted); }
.sitefoot nav { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.sitefoot a { font: 13px/1.4 var(--sans); color: #b0a999; text-decoration: none; }
.sitefoot a:hover { color: var(--text); }
.sitefoot p { margin: 0; }

/* Run bar: live status of the replay */
.top { display: flex; align-items: center; gap: 20px; padding: 14px 24px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, #111012, var(--bg)); position: sticky; top: 0; z-index: 5; }
.top::after { content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 3px; background: repeating-linear-gradient(-45deg, var(--signal) 0 8px, #141414 8px 16px); opacity: .9; }
.brand { flex: none; display: flex; align-items: center; gap: 10px; color: var(--signal); text-decoration: none; border-radius: 999px; }
.mark { width: 22px; height: 22px; }
.word { height: 16px; width: auto; color: var(--text); }
.status { flex: 1; }
.pill { font: 600 11px/1 var(--mono); letter-spacing: 0.12em; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--muted); }
.pill.live { color: var(--signal-ink); border-color: rgba(255,77,31,.4); background: var(--signal-dim); }
.pill.live::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--signal); margin-right: 8px; vertical-align: 1px; animation: pulse 1.2s steps(2, end) infinite; }
.pill.won { box-shadow: 0 0 18px rgba(60,242,180,.35); color: #06110d; background: var(--alive); border-color: var(--alive); }
.pill.lost { color: var(--dead); border-color: rgba(255,77,31,.4); background: var(--dead-dim); }
.meta { display: flex; flex-wrap: wrap; gap: 8px 18px; font: 12px/1 var(--mono); color: var(--muted); }
.meta > span { white-space: nowrap; }
.meta b { color: var(--text); font-weight: 600; }

/* Task line */
.task { padding: 14px 24px 4px; display: grid; gap: 8px; }
.task > div { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px; }
.taskText { font-size: 15px; color: var(--text); }
.task code { font-size: 12.5px; color: var(--info); background: var(--panel); border: 1px solid var(--line); padding: 2px 7px; border-radius: 4px; margin-right: 10px; }

/* Tiles */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; margin: 14px 24px; background: var(--line); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.tile { background: var(--panel); padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.tile .k { font: 600 10.5px/1 var(--mono); letter-spacing: 0.14em; color: var(--muted); }
.tile .v { font: 600 22px/1.1 var(--mono); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .s { font-size: 12px; color: var(--muted); }
.tile .v.hot { color: var(--signal); text-shadow: 0 0 .45em rgba(255,77,31,.5); }

/* Stage */
.stage { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; padding: 0 24px 24px; min-height: 0; }
.treeWrap { position: relative; overflow: auto; border: 1px solid var(--line); border-radius: 8px; background:
  repeating-linear-gradient(to bottom, transparent 0 2px, rgba(0,0,0,.18) 2px 3px), radial-gradient(circle at 1px 1px, #1d1c1a 1px, transparent 0) 0 0 / 22px 22px, var(--bg); min-height: 420px; }
.tree { position: relative; min-width: 100%; }
/* Sized in px by layout() so wire coordinates match the absolutely positioned cards. */
.wires { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }

.wire { fill: none; stroke: var(--line-2); stroke-width: 1.6; stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: draw .6s cubic-bezier(.2,.7,.2,1) forwards; }
.wire.live { stroke: rgba(255,77,31,.55); }
.wire.judging { stroke: rgba(244,183,64,.6); }
.wire.dead { stroke: rgba(255,77,31,.4); stroke-dasharray: 4 5; animation: none; stroke-dashoffset: 0; }
.wire.done { stroke: #3a3732; }
.wire.won { stroke: var(--alive); stroke-width: 3; filter: drop-shadow(0 0 6px rgba(60,242,180,.7)); }
.cut { stroke: var(--signal); stroke-width: 2.2; stroke-linecap: round; }

.card { position: absolute; width: var(--card-w); height: var(--card-h); background: var(--panel); border: 1px solid var(--line-2); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; transition: opacity .5s, filter .5s, border-color .3s, box-shadow .3s, transform .3s; animation: rise .45s cubic-bezier(.2,.7,.2,1) both; }
.card .row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.card .id { font: 700 12px/1 var(--mono); color: var(--text); }
.card .strat { font: 12px/1 var(--mono); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.card .chip { font: 600 9.5px/1 var(--mono); letter-spacing: .1em; padding: 4px 6px; border-radius: 4px; color: var(--muted); border: 1px solid var(--line-2); }
.card .tick { font: 11.5px/1.35 var(--mono); color: #b0a999; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 16px; }
.card .tick.flash { animation: flash .5s ease-out; }
.card .tick.note { color: #c9c1b1; font-style: italic; font-family: var(--sans); }
.card .foot { margin-top: auto; display: flex; align-items: center; gap: 10px; font: 11px/1 var(--mono); color: var(--muted); }
.card .bar { flex: 1; height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.card .bar i { display: block; height: 100%; width: 0; background: var(--judge); transition: width .6s; }

.card.body { border-style: dashed; }
.card.body .chip { color: var(--text); border-color: var(--line-2); }
.card.running { border-color: rgba(255,77,31,.35); }
.card.running .chip { color: var(--signal-ink); border-color: rgba(255,77,31,.4); }
.card.running .id::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--signal); margin-right: 7px; vertical-align: 1px; animation: pulse 1.1s steps(2, end) infinite; }
.card.judging { border-color: rgba(244,183,64,.55); }
.card.judging .chip { color: var(--judge); border-color: rgba(244,183,64,.45); }
.card.failed .chip { color: var(--muted); }
.card.failed .bar i { background: #8a6a2c; }
.card.passed .bar i, .card.won .bar i { background: var(--alive); }
.card.severed { opacity: .38; filter: grayscale(.9); transform: scale(.97); }
.card.severed .chip { color: var(--dead); border-color: rgba(255,77,31,.45); }
.card.won { border-color: var(--alive); box-shadow: 0 0 0 1px var(--alive), 0 0 28px rgba(60,242,180,.28); }
.card.won .chip { color: #06110d; background: var(--alive); border-color: var(--alive); }
.card.best { border-color: rgba(244,183,64,.6); }
.card .tamper { color: var(--dead); }

/* Side panels */
.side { display: flex; flex-direction: column; gap: 16px; min-height: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; display: flex; flex-direction: column; min-height: 0; }
.panelHead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font: 12px/1 var(--mono); }
.log { list-style: none; margin: 0; padding: 0; overflow: auto; max-height: 520px; font: 11.5px/1.5 var(--mono); }
.log li { display: grid; grid-template-columns: 52px 46px minmax(0,1fr); gap: 8px; padding: 3px 0; border-bottom: 1px solid #1a1918; color: #b0a999; }
.log li .t { color: var(--dim); }
.log li .h { color: var(--muted); }
.log li .m { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log li.good .m { color: var(--alive); }
.log li.hot .m { color: var(--signal-ink); }
.log li.bad .m { color: var(--dead); }
.log li.warn .m { color: var(--judge); }
.winnerSummary { margin: 0 0 10px; color: var(--text); font-size: 13px; }
.diff { margin: 0; max-height: 340px; overflow: auto; font: 11.5px/1.45 var(--mono); background: #0c0c0d; border: 1px solid var(--line); border-radius: 6px; padding: 10px; white-space: pre; }
.diff .add { color: var(--alive); }
.diff .del { color: var(--dead); }
.diff .hunk { color: var(--info); }
.diff .file { color: var(--text); font-weight: 600; }

/* Replay bar */
.replay { position: sticky; bottom: 0; flex-wrap: wrap; display: flex; align-items: center; gap: 12px; padding: 10px 24px; background: rgba(10,10,11,.92); backdrop-filter: blur(8px); border-top: 1px solid var(--line); font: 12px/1 var(--mono); }
.replay button, .replay select { font: 12px/1 var(--mono); color: var(--text); background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 999px; padding: 7px 14px; cursor: pointer; }
.replay button:hover { border-color: var(--signal); }

@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes rise { from { opacity: 0; transform: translateX(-10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
@keyframes flash { from { color: #fff; } }

@media (max-width: 899px) {
  /* Phones and small tablets: brand + Open app only. Every link is in the footer. */
  .sitenav__links { display: none; }
  .sitenav__inner { justify-content: space-between; }
}
@media (max-width: 1000px) {
  .stage { grid-template-columns: minmax(0, 1fr); }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .top { padding: 12px 16px; gap: 10px 12px; flex-wrap: wrap; }
  .meta { flex-basis: 100%; gap: 8px 14px; }
  .sitefoot { padding-left: 16px; padding-right: 16px; }
  .replay { padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px)); gap: 8px 10px; }
  .replay .muted { flex-basis: 100%; }
  .task, .stage { padding-left: 16px; padding-right: 16px; }
  .tiles { margin: 12px 16px; }
  .tile .v { font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before { animation: none !important; transition: none !important; }
  .wire { stroke-dashoffset: 0; }
}
