:root {
  --ground: #f1f4ee;
  --surface: #ffffff;
  --ink: #13201a;
  --muted: #47564f;
  --rule: #c9d2c9;
  --action: #1c3fd0;
  --action-ink: #ffffff;
  --action-hover: #1632a8;
  --sold: #1c6a4c;
  --step: #dfe5dc;
  --warn: #9a3a0b;
  --lp: #1c6a4c;
  --arena: #1c3fd0;
  --burn: #b4551a;
  --dev: #6b7a72;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #0e1513;
    --surface: #161f1c;
    --ink: #e7ede6;
    --muted: #a3b2aa;
    --rule: #2b3732;
    --action: #8ea6ff;
    --action-ink: #0a1030;
    --action-hover: #a9bbff;
    --sold: #5fc79c;
    --step: #222d29;
    --warn: #f0a070;
    --lp: #5fc79c;
    --arena: #8ea6ff;
    --burn: #e89a5e;
    --dev: #8a9990;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scrollbar-color: var(--rule) var(--ground); }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 1rem/1.55 var(--sans);
  caret-color: var(--action);
}

::selection { background: var(--action); color: var(--action-ink); }

:focus-visible { outline: 2px solid var(--action); outline-offset: 3px; border-radius: 2px; }

a { color: var(--action); text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }

h1, h2 { text-wrap: balance; margin: 0; }
h1 { font-size: clamp(2rem, 1.2rem + 3.6vw, 3.5rem); line-height: 1.04; letter-spacing: -0.025em; font-weight: 750; }
h2 { font-size: 1.25rem; line-height: 1.2; letter-spacing: -0.01em; font-weight: 700; }
p { margin: 0; }

.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: var(--ground); padding: 0.5rem 0.75rem; z-index: 10; }
.skip:focus { left: 0.5rem; top: 0.5rem; }

/* ------------------------------------------------------------------ header */

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  max-width: 72rem; margin: 0 auto; padding: 1rem clamp(1rem, 4vw, 2.5rem);
}
.wordmark { font-weight: 800; font-size: 1.25rem; letter-spacing: -0.03em; color: var(--ink); text-decoration: none; }
.wordmark span { color: var(--action); }
.top-right { display: flex; align-items: center; gap: 0.75rem; min-width: 0; margin-left: auto; }
.nav { display: flex; gap: 0.25rem; }
.nav a {
  color: var(--muted); text-decoration: none; font-weight: 600;
  padding: 0.5rem 0.75rem; border-radius: 0.5rem; min-height: 2.75rem; display: inline-flex; align-items: center;
  transition: color 160ms var(--ease), background-color 160ms var(--ease);
}
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--step); }
@media (max-width: 34rem) {
  .top { flex-wrap: wrap; row-gap: 0.25rem; }
  .nav { order: 3; width: 100%; margin: 0 -0.75rem; }
}
.network { font-size: 0.875rem; color: var(--warn); }

/* ----------------------------------------------------------------- buttons */

.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border-radius: 0.5rem; border: 1px solid transparent;
  padding: 0.6rem 1rem; min-height: 2.75rem;
  transition: background-color 160ms var(--ease), border-color 160ms var(--ease), transform 160ms var(--ease);
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { cursor: not-allowed; opacity: 0.55; }
.btn-primary { background: var(--action); color: var(--action-ink); width: 100%; font-size: 1.0625rem; padding: 0.85rem 1rem; }
.btn-primary:hover:not(:disabled) { background: var(--action-hover); }
.btn-quiet { background: transparent; color: var(--ink); border-color: var(--rule); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-quiet:hover:not(:disabled) { border-color: var(--ink); }

/* ------------------------------------------------------------------ layout */

.page {
  max-width: 72rem; margin: 0 auto;
  padding: clamp(1.5rem, 5vw, 3.5rem) clamp(1rem, 4vw, 2.5rem) 4rem;
  display: grid; gap: 3.5rem 4rem;
  grid-template-columns: minmax(0, 1fr);
}
.page > section > h2 { margin-bottom: 0.75rem; }
.page > section > p { max-width: 62ch; color: var(--muted); }
.lede { margin-top: 1.25rem; font-size: 1.125rem; max-width: 52ch; color: var(--muted); }

@media (min-width: 60rem) {
  .page { grid-template-columns: minmax(0, 1fr) 24rem; align-items: start; }
  .page > * { grid-column: 1; }
  .panel { grid-column: 2; grid-row: 1 / span 8; position: sticky; top: 1.5rem; max-height: calc(100vh - 3rem); overflow-y: auto; }
}

/* ------------------------------------------------------------------- panel */

.panel {
  background: var(--surface); border: 1px solid var(--rule); border-radius: 0.75rem;
  padding: 1.5rem; display: grid; gap: 1.25rem;
}
.panel > h2 { margin: 0; }
.phase { color: var(--ink); font-weight: 600; }
.phase.is-warn { color: var(--warn); }

.facts { margin: 0; display: grid; gap: 0; border-top: 1px solid var(--rule); }
.facts > div { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: 0.6rem 0; border-bottom: 1px solid var(--rule); }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }

.you { display: grid; gap: 0.5rem; }
.you-id { font-weight: 600; overflow-wrap: anywhere; }
.you-id small { display: block; font-weight: 400; color: var(--muted); font-size: 0.875rem; }
.you-id .handle { color: var(--sold); }

.order { display: grid; gap: 0.6rem; }
.order label { font-weight: 600; }
.stepper { display: grid; grid-template-columns: 2.75rem minmax(0, 1fr) 2.75rem auto; gap: 0.5rem; }
.step {
  display: grid; place-items: center; min-height: 2.75rem; cursor: pointer;
  background: transparent; color: var(--ink); border: 1px solid var(--rule); border-radius: 0.5rem;
  transition: border-color 160ms var(--ease);
}
.step:hover:not(:disabled) { border-color: var(--ink); }
.step:disabled { opacity: 0.4; cursor: not-allowed; }
.step svg { width: 1rem; height: 1rem; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; }
.stepper input {
  font: inherit; font-size: 1.125rem; font-weight: 600; font-variant-numeric: tabular-nums; text-align: center;
  color: var(--ink); background: var(--ground); border: 1px solid var(--rule); border-radius: 0.5rem;
  min-height: 2.75rem; width: 100%; padding: 0 0.5rem; -moz-appearance: textfield; appearance: textfield;
}
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper input:focus-visible { outline-offset: 1px; }

.quote { margin: 0.25rem 0 0; display: grid; gap: 0.25rem; }
.quote > div { display: flex; justify-content: space-between; gap: 1rem; }
.quote dt { color: var(--muted); }
.quote dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 600; }

.status { min-height: 1.5em; color: var(--muted); font-size: 0.9375rem; overflow-wrap: anywhere; }
.status.is-error { color: var(--warn); }
.status.is-ok { color: var(--sold); }

/* ------------------------------------------------------------------ ladder */

.ladder { margin-top: 1.25rem; display: grid; grid-template-columns: repeat(25, minmax(0, 1fr)); gap: 3px; }
.ladder i {
  display: block; aspect-ratio: 1 / 1.6; border-radius: 2px; background: var(--step);
  background-image: linear-gradient(to top, var(--sold) var(--fill, 0%), transparent var(--fill, 0%));
}
.ladder i.is-now { outline: 2px solid var(--ink); outline-offset: 1px; }
.ladder.is-live i.is-sold { animation: climb 520ms var(--ease) both; animation-delay: calc(var(--i) * 9ms); }
@keyframes climb { from { clip-path: inset(100% 0 0 0); } to { clip-path: inset(0 0 0 0); } }
.ladder-ends { display: flex; justify-content: space-between; margin-top: 0.5rem; font-size: 0.875rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.ladder-note { margin-top: 0.75rem; font-weight: 600; color: var(--ink) !important; font-variant-numeric: tabular-nums; }
@media (min-width: 40rem) { .ladder { grid-template-columns: repeat(50, minmax(0, 1fr)); } .ladder i { aspect-ratio: 1 / 2.4; } }

/* ------------------------------------------------------------------- split */

.bar { display: flex; height: 0.875rem; border-radius: 0.25rem; overflow: hidden; gap: 2px; margin: 1.25rem 0 0.5rem; }
.seg-lp { background: var(--lp); } .seg-arena { background: var(--arena); } .seg-burn { background: var(--burn); } .seg-dev { background: var(--dev); }
.ledger { width: 100%; border-collapse: collapse; }
.ledger th, .ledger td { text-align: left; vertical-align: top; padding: 0.85rem 0; border-bottom: 1px solid var(--rule); }
.ledger th { font-weight: 600; white-space: nowrap; padding-right: 1rem; }
.ledger .num { font-variant-numeric: tabular-nums; font-weight: 700; padding-right: 1.25rem; }
.ledger td:last-child { color: var(--muted); }
.key { display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 2px; margin-right: 0.55rem; }
.fine { margin-top: 1rem; font-size: 0.9375rem; }
@media (max-width: 34rem) {
  .ledger tr { display: grid; grid-template-columns: 1fr auto; padding: 0.85rem 0; border-bottom: 1px solid var(--rule); }
  .ledger th, .ledger td { border: 0; padding: 0; }
  .ledger .num { padding: 0; }
  .ledger td:last-child { grid-column: 1 / -1; margin-top: 0.3rem; }
}

/* ------------------------------------------------------------------- rules */

.rules ul { margin: 0.5rem 0 0; padding: 0; list-style: none; max-width: 62ch; }
.rules li { padding: 0.85rem 0; border-bottom: 1px solid var(--rule); color: var(--muted); }
.rules li strong { color: var(--ink); }
.contracts { margin: 1.5rem 0 0; display: grid; gap: 0.4rem; font-size: 0.9375rem; }
.contracts > div { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: 0.75rem; }
.contracts dt { color: var(--muted); }
.contracts dd { margin: 0; font-family: var(--mono); font-size: 0.875rem; overflow-wrap: anywhere; }

/* ------------------------------------------------------------------ agents */

.prompt {
  margin: 1rem 0 0; padding: 1rem; background: var(--surface); border: 1px solid var(--rule); border-radius: 0.5rem;
  font: 0.875rem/1.55 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; max-width: 72ch; color: var(--ink);
}
.agents-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 1.25rem; margin-top: 1rem; }

.foot { border-top: 1px solid var(--rule); }
.foot p { max-width: 72rem; margin: 0 auto; padding: 1.5rem clamp(1rem, 4vw, 2.5rem) 2.5rem; color: var(--muted); font-size: 0.875rem; }

.btn-wide { width: 100%; }
.btn-small { min-height: 2.25rem; padding: 0.3rem 0.8rem; font-size: 0.9375rem; }

/* ------------------------------------------------------- stake and arena */

.seg-control { display: grid; grid-template-columns: 1fr 1fr; gap: 0.25rem; padding: 0.25rem; background: var(--ground); border: 1px solid var(--rule); border-radius: 0.6rem; }
.seg-control label { position: relative; font-weight: 600; }
.seg-control input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.seg-control span { display: grid; place-items: center; min-height: 2.5rem; border-radius: 0.4rem; color: var(--muted); transition: background-color 160ms var(--ease), color 160ms var(--ease); }
.seg-control input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--rule); }
.seg-control input:focus-visible + span { outline: 2px solid var(--action); outline-offset: 2px; }

.amount { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.5rem; }
.amount input, .field {
  font: inherit; font-size: 1.0625rem; font-weight: 600; font-variant-numeric: tabular-nums;
  color: var(--ink); background: var(--ground); border: 1px solid var(--rule); border-radius: 0.5rem;
  min-height: 2.75rem; width: 100%; padding: 0 0.75rem;
}
.amount input::placeholder, .field::placeholder { color: var(--muted); font-weight: 400; opacity: 1; }
.amount input:focus-visible, .field:focus-visible { outline-offset: 1px; }
.amount input[readonly] { font: 0.875rem var(--mono); font-weight: 400; }
.hint { font-size: 0.9375rem; color: var(--muted); overflow-wrap: anywhere; }
.hint:empty { display: none; }
.hint.is-warn { color: var(--warn); }

.more-actions, .claims { display: grid; gap: 0.5rem; }

.entrants { display: grid; gap: 0.5rem; }
.entrants h3 { margin: 0; font-size: 1rem; font-weight: 700; }
.entrants ul { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.entrants ul:empty { display: none; }
.entrants li { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.6rem 0; border-bottom: 1px solid var(--rule); }
.who { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.1rem 0.5rem; min-width: 0; overflow-wrap: anywhere; }
.who small { flex-basis: 100%; color: var(--muted); font-size: 0.875rem; font-variant-numeric: tabular-nums; }

.tag { font-size: 0.8125rem; font-weight: 700; color: var(--muted); }
.tag-entries { color: var(--action); }
.tag-running, .tag-settled { color: var(--sold); }
.tag-awaiting, .tag-cancelled { color: var(--warn); }

.rounds { list-style: none; margin: 1.25rem 0 0; padding: 0; display: grid; gap: 0.5rem; max-width: 40rem; }
.rounds:empty { display: none; }
.round {
  font: inherit; text-align: left; cursor: pointer; width: 100%;
  display: grid; gap: 0.2rem; padding: 0.85rem 1rem;
  background: var(--surface); color: var(--ink); border: 1px solid var(--rule); border-radius: 0.6rem;
  transition: border-color 160ms var(--ease);
}
.round:hover { border-color: var(--ink); }
.round[aria-pressed="true"] { border-color: var(--action); box-shadow: inset 0 0 0 1px var(--action); }
.round-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.round-sub { color: var(--muted); font-variant-numeric: tabular-nums; }
.round-due { color: var(--sold); font-weight: 600; font-size: 0.9375rem; }

.steps { margin: 0.5rem 0 0; padding: 0; list-style: none; counter-reset: step; max-width: 62ch; }
.steps li { counter-increment: step; position: relative; padding: 0.85rem 0 0.85rem 2.5rem; border-bottom: 1px solid var(--rule); color: var(--muted); }
.steps li::before { content: counter(step); position: absolute; left: 0; top: 0.85rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); }
.steps li strong { color: var(--ink); }

.ref { display: grid; gap: 0.5rem; margin-top: 1.25rem; max-width: 40rem; }
.ref label { font-weight: 600; }
.agents .contracts { margin-top: 2rem; }

[hidden] { display: none !important; }

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