:root {
  color-scheme: dark;
  --ink: #0b0d11;
  --ink-2: #12151b;
  --line: #222832;
  --text: #e8eef4;
  --muted: #8b99a8;
  --a: #5ac8e2;
  --b: #ec684e;
  --sand: #483d30;
}
* { box-sizing: border-box; }
/* .loading and .verdict set display, which beats the browser's own
   [hidden] { display: none }, so without this they never actually hide. */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font: 15px/1.5 Inter, system-ui, -apple-system, sans-serif;
  overflow: hidden;
}
.stage {
  display: grid;
  grid-template-columns: 70fr 30fr;
  height: 100%;
  gap: 1px;
  background: var(--line);
}
.arena-pane, .brain-pane { background: var(--ink); min-width: 0; min-height: 0; }
.arena-pane {
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 0 clamp(16px, 2vw, 28px);
}

/* --- scoreline ---------------------------------------------------------- */
.scoreline {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: clamp(16px, 3vw, 44px);
  padding: 18px 0 12px;
}
.fighter { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; }
.fighter .name {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: clamp(22px, 2.2vw, 34px);
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.05;
}
.fighter[data-side="0"] .name { color: var(--a); }
.fighter[data-side="1"] .name { color: var(--b); }
.fighter .class {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  align-self: end;
  padding-bottom: 4px;
}
.fighter .bar {
  grid-column: 1 / -1;
  height: 9px;
  border-radius: 5px;
  background: #1d232c;
  overflow: hidden;
}
.fighter .bar i {
  display: block; height: 100%; width: 100%;
  border-radius: 5px;
  transition: width 90ms linear;
}
.fighter[data-side="0"] .bar i { background: var(--a); }
.fighter[data-side="1"] .bar i { background: var(--b); }
.fighter .hp {
  grid-column: 1 / -1;
  font: 500 12px/1 'IBM Plex Mono', monospace;
  color: var(--muted);
}
/* The right-hand fighter is the same card mirrored. It swaps name and class in
   the markup rather than with `order`, because `order` only moved those two.
   the bar and the health number kept the default 0 and jumped above the name,
   which is what put the two bars on different lines. */
.fighter.right { text-align: right; grid-template-columns: auto 1fr; }
.fighter.right .class { text-align: left; }
.fighter.right .hp { text-align: right; }

.versus { display: grid; justify-items: center; gap: 4px; padding-top: 6px; }
.clock {
  font: 500 clamp(16px, 1.5vw, 22px)/1 'IBM Plex Mono', monospace;
  font-variant-numeric: tabular-nums;
}
.seedline {
  font: 400 11px/1 'IBM Plex Mono', monospace;
  color: var(--muted);
  letter-spacing: 0.08em;
}

/* --- canvas ------------------------------------------------------------- */
.canvas-wrap { position: relative; min-height: 0; }
#arena { display: block; width: 100%; height: 100%; }
.loading, .verdict, .countdown {
  position: absolute; inset: 0;
  display: grid; place-items: center; place-content: center;
  text-align: center;
}
/* The digits are centred on their cap-height box, which sits a little above
   the middle of the line box. Nudge so the number sits on the arena's centre
   rather than the text box's. */
.countdown { padding-bottom: 0.1em; }
.loading { color: var(--muted); font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase; }
.countdown {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: clamp(150px, 27vw, 430px);
  /* Cormorant defaults to old-style figures, where 1 sits at x-height and
     reads as a Roman I, and 3 hangs below the baseline. Lining figures give
     every digit the same cap-height box, which fixes both the shape and the
     way they jumped about between numbers. */
  font-variant-numeric: lining-nums tabular-nums;
  font-feature-settings: 'lnum' 1, 'tnum' 1;
  font-weight: 700; line-height: 1; color: #f7ecd6;
  text-shadow: 0 0 80px rgba(0, 0, 0, 0.9), 0 0 24px rgba(0, 0, 0, 0.7);
  pointer-events: none;
  animation: countPop 700ms ease-out;
}
.countdown[data-go] {
  font-size: clamp(64px, 11vw, 168px);
  letter-spacing: 0.08em;
  color: #ffe9b8;
}
@keyframes countPop {
  0%   { transform: scale(1.5); opacity: 0; }
  18%  { transform: scale(1);   opacity: 1; }
  70%  { transform: scale(1);   opacity: 1; }
  100% { transform: scale(0.92); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .countdown { animation: none; } }

.verdict {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: clamp(30px, 4vw, 58px);
  font-weight: 700;
  letter-spacing: 0.04em;
  background: radial-gradient(ellipse at center, rgba(11,13,17,0.82), rgba(11,13,17,0.15) 72%);
  pointer-events: none;
}

/* --- transport ---------------------------------------------------------- */
.transport {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 0 20px;
}
.icon {
  width: 38px; height: 38px;
  border: 1px solid var(--line);
  background: var(--ink-2);
  color: var(--text);
  border-radius: 9px;
  font-size: 14px;
  cursor: pointer;
}
.icon:hover { border-color: #37404e; }
.icon:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid var(--a); outline-offset: 2px;
}
.icon[disabled] { opacity: 0.4; cursor: not-allowed; }
#scrub { flex: 1; accent-color: var(--a); }
.speed { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.speed select {
  background: var(--ink-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 8px; font: inherit;
}

/* --- brain pane --------------------------------------------------------- */
.brain-pane {
  padding: 18px clamp(12px, 1.2vw, 20px) 16px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto auto;
  gap: 8px;
  min-height: 0;
}
.brain-pane h2 {
  margin: 0;
  font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--muted); font-weight: 600;
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
}
.brain-pane h2 small {
  font-size: 10px; letter-spacing: 0.04em; text-transform: none;
  color: #5d6b7a; font-weight: 400;
}

.brains { display: grid; grid-template-rows: 1fr 1fr; gap: 8px; min-height: 0; }
.brains figure {
  margin: 0; position: relative; min-height: 0;
  background: #0d1016;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.brains canvas { display: block; width: 100%; height: 100%; }
.brains figcaption {
  position: absolute; top: 7px; left: 10px; z-index: 1;
  font: 600 10px/1 'IBM Plex Mono', monospace;
  letter-spacing: 0.14em;
}
figure:nth-child(1) figcaption { color: var(--a); }
figure:nth-child(2) figcaption { color: var(--b); }

/* --- meters: both fighters diverging from a shared centre --------------- */
.meters { display: grid; gap: 5px; }
.meter { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.meter .cap {
  grid-column: 1 / -1;
  display: flex; justify-content: space-between; align-items: baseline;
  font: 400 10px/1.4 'IBM Plex Mono', monospace;
  color: #6f7d8c;
}
.meter .cap b { color: #93a2b1; font-weight: 500; }
.meter .cap em {
  font-style: normal; letter-spacing: 0.12em; text-transform: uppercase;
  font-size: 9px; color: #55636f;
}
.meter .track {
  height: 7px; background: #171c24; border-radius: 4px; overflow: hidden;
  display: flex;
}
.meter .track.left { justify-content: flex-end; }
.meter .track i { display: block; height: 100%; width: 0%; }
.meter .track.left i { background: var(--a); border-radius: 4px 0 0 4px; }
.meter .track.right i { background: var(--b); border-radius: 0 4px 4px 0; }

.legend {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px;
  font-size: 10px; color: #6f7d8c;
}
.legend li { display: flex; align-items: center; gap: 6px; }
.legend i { width: 7px; height: 7px; border-radius: 50%; flex: none; }

@media (max-width: 880px) {
  body { overflow: auto; }
  .stage { grid-template-columns: 1fr; height: auto; }
  .canvas-wrap { aspect-ratio: 1 / 1; }
}

/* --- fighter picker ----------------------------------------------------- */
.picker {
  position: fixed; inset: 0; z-index: 10;
  overflow: auto;
  background:
    radial-gradient(ellipse 80% 55% at 50% 0%, rgba(124, 96, 60, 0.20), transparent 70%),
    radial-gradient(ellipse 60% 50% at 50% 100%, rgba(40, 60, 78, 0.22), transparent 70%),
    #08090c;
}
.picker-inner {
  min-height: 100%;
  display: grid; align-content: center; justify-items: center;
  gap: clamp(9px, 1.2vh, 15px);
  padding: clamp(16px, 2.6vh, 32px) clamp(18px, 4vw, 48px);
  max-width: 1080px; margin: 0 auto;
}

.hero { display: grid; justify-items: center; gap: 5px; text-align: center; }
.eyebrow {
  margin: 0;
  font: 500 11px/1 'IBM Plex Mono', monospace;
  letter-spacing: 0.24em; text-transform: uppercase;
  color: #b08d4f;
}
.hero h1 {
  margin: 0;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: clamp(34px, 5.2vw, 64px);
  /* Room for the descender on the y: background-clip crops to the text box,
     and at line-height 1 that box cuts the tail off. */
  font-weight: 700; line-height: 1.12; letter-spacing: 0.01em;
  padding-bottom: 0.04em;
  text-wrap: balance;
  background: linear-gradient(180deg, #f6efe2 0%, #cdb890 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.blurb {
  margin: 0; max-width: 96ch;
  color: #8b99a8; font-size: clamp(12.5px, 1vw, 14px); line-height: 1.55;
}
.blurb strong { color: #e6d9bd; font-weight: 600; }
.blurb em { color: #cdb890; font-style: italic; }

/* --- roster ------------------------------------------------------------- */
.roster {
  display: grid; gap: 10px; width: 100%;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
@media (max-width: 900px) { .roster { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .roster { grid-template-columns: minmax(0, 1fr); } }
.card {
  position: relative;
  display: grid; gap: 0; text-align: left;
  grid-template-rows: auto auto auto 1fr auto;
  padding: 0 0 9px;
  background: linear-gradient(180deg, #141820 0%, #0f1319 100%);
  border: 1px solid #232a34; border-radius: 14px;
  color: var(--text); font: inherit; cursor: pointer;
  overflow: hidden;
  transition: border-color 140ms, transform 140ms, box-shadow 140ms;
}
.card:hover { border-color: #3d4756; transform: translateY(-2px); }
.card:focus-visible { outline: 2px solid var(--a); outline-offset: 2px; }

.card .portrait {
  display: block; width: 100%; height: 66px;
  background:
    radial-gradient(ellipse 70% 90% at 50% 120%, rgba(150,120,78,0.16), transparent 70%),
    #0c0f14;
  border-bottom: 1px solid #1c222b;
}
.card .n {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 25px; font-weight: 700; line-height: 1.1;
  padding: 9px 13px 0;
}
.card .c {
  font: 500 10px/1.5 'IBM Plex Mono', monospace;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: #b08d4f; padding: 0 13px 5px;
}
/* No clamp. Cards in a grid row share a height anyway, so a description that
   runs long makes the row taller rather than getting its tail cut off. */
.card .note {
  font-size: 11.5px; line-height: 1.4; color: #7d8a99;
  padding: 0 13px 9px;
}
.card .stats { display: grid; gap: 4px; padding: 0 13px; align-self: end; }
.card .stat { display: grid; grid-template-columns: 62px 1fr; align-items: center; gap: 8px; }
.card .stat b {
  font: 500 8.5px/1 'IBM Plex Mono', monospace;
  letter-spacing: 0.08em; color: #6f7d8c; font-weight: 500;
}
.card .stat i { display: block; height: 4px; border-radius: 2px; background: #1b2029; }
.card .stat u {
  display: block; height: 100%; border-radius: 2px;
  background: var(--own); text-decoration: none;
}

.card[data-pick] { border-color: var(--own); }
.card[data-pick] .n { color: var(--own); }
.card[data-pick]::after {
  content: attr(data-side); position: absolute; top: 10px; right: 12px;
  font: 600 9px/1 'IBM Plex Mono', monospace; letter-spacing: 0.16em;
  padding: 5px 7px; border-radius: 5px; color: #08090c;
}
.card[data-pick]::after { background: var(--own); }
.card[disabled] { opacity: 0.32; cursor: not-allowed; transform: none; }
.card[disabled]:hover { border-color: #232a34; }

/* --- matchup line ------------------------------------------------------- */
.matchup {
  display: flex; align-items: center; justify-content: center; gap: 18px;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: clamp(19px, 1.9vw, 26px); font-weight: 700;
  min-height: 1.5em;
}
.matchup .slot { min-width: 7ch; text-align: center; }
.matchup .slot:nth-of-type(1) { color: var(--a); text-align: right; }
.matchup .slot:last-of-type { color: var(--b); text-align: left; }
.matchup .slot em {
  font-family: Inter, sans-serif; font-style: normal;
  font-size: 12px; letter-spacing: 0.06em; color: #4d5967;
}
.matchup .vs { color: #4d5967; font-size: 0.6em; }

.picker-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: center; }
.fight {
  padding: 13px 38px; border-radius: 10px; border: 1px solid transparent;
  background: linear-gradient(180deg, #f0e3c6, #cdb183);
  color: #17120a;
  font: 600 14px/1 Inter, sans-serif; letter-spacing: 0.06em;
  text-transform: uppercase; cursor: pointer;
  transition: filter 140ms;
}
.fight:hover:not([disabled]) { filter: brightness(1.08); }
.fight[disabled] {
  background: #161b22; color: #4d5967;
  border-color: #232a34; cursor: not-allowed; text-transform: none;
  letter-spacing: 0.02em; font-weight: 500;
}
.ghost {
  padding: 13px 20px; border-radius: 10px;
  border: 1px solid #232a34; background: transparent; color: #8b99a8;
  font: 500 13px/1 Inter, sans-serif; cursor: pointer;
}
.ghost:hover { border-color: #3d4756; color: var(--text); }

.provenance {
  display: grid; gap: 5px; max-width: 68ch; text-align: center;
  font-size: 11px; line-height: 1.5; color: #5d6b7a;
}
.provenance p { margin: 0; }
.provenance strong { color: #8b99a8; font-weight: 500; }
.provenance .credit {
  font-size: 12.5px; color: #8b99a8; margin-bottom: 2px;
}
.provenance .credit a { color: #d9c396; font-weight: 500; }
.provenance a { color: #b08d4f; text-decoration: none; }
.provenance a:hover { text-decoration: underline; }

.icon.wide { width: auto; padding: 0 14px; font-size: 12px; }

@media (max-width: 620px) { .card .portrait { height: 72px; } }
