@import url("tokens.css");

*, *::before, *::after { box-sizing: border-box; margin: 0; }
html, body { overflow-x: clip; }
html { scroll-behavior: smooth; scroll-padding-top: 16px; }
body {
  background: var(--void);
  color: var(--text);
  font: 400 16px/1.6 var(--font-display);
  -webkit-font-smoothing: antialiased;
  --stage-color: var(--stage-probe);
  --tension: 0;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; }
button { font: inherit; }
:focus-visible { outline: 2px solid var(--shield); outline-offset: 3px; }
.mono { font-family: var(--font-mono); }
.wrap { max-width: 1120px; margin-inline: auto; padding-inline: 24px; }

/* Top bar */
.top { display: flex; align-items: center; gap: 32px; padding-block: 22px; }
.brand img { height: 26px; width: auto; }
.top nav { display: flex; gap: 24px; margin-left: auto; font-size: 14px; color: var(--muted); }
.top nav a { text-decoration: none; }
.top nav a:hover { color: var(--text); }
.ticker {
  padding: 7px 16px; border-radius: var(--radius-s);
  background: var(--breach); color: var(--void);
  font: 700 15px var(--font-mono); text-decoration: none;
  box-shadow: 0 0 24px color-mix(in srgb, var(--breach) 40%, transparent);
}
a.ticker[href]:hover { background: color-mix(in srgb, var(--breach) 84%, var(--text)); }
.ca { display: inline-flex; align-items: center; gap: 8px; font: 600 13px var(--font-mono); color: var(--muted); }
.ca .btn.mini { margin-left: 0; }
.hdr-link { font-size: 14px; color: var(--muted); text-decoration: none; }
.hdr-link:hover { color: var(--text); }
.hl-short { display: none; }
[hidden] { display: none !important; }

/* Page-wide tension: a vignette that thickens as the gauge climbs */
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: radial-gradient(ellipse 85% 75% at 50% 28%, transparent 35%, color-mix(in srgb, var(--stage-color) 40%, transparent) 135%);
  opacity: var(--tension);
  transition: opacity 1.2s ease;
}
.top, main, footer { position: relative; z-index: 1; }

/* Hero */
.hero { padding-block: 40px 88px; }
h1 {
  max-width: 15ch;
  font-size: clamp(40px, 7.2vw, 88px);
  line-height: 1;
  font-weight: 800;
  font-stretch: 112%;
  letter-spacing: -0.02em;
  overflow-wrap: break-word;
  min-width: 0;
}
.sub { margin-top: 20px; max-width: 46ch; font-size: clamp(17px, 2vw, 21px); color: var(--muted); }

/* Panels and gauge */
.panel {
  position: relative;
  background: var(--panel);
  border: 1px solid color-mix(in srgb, var(--stage-color) 40%, var(--line));
  border-radius: var(--radius-m);
}
.gauge-panel { margin-top: 36px; padding: 32px 32px 26px; display: grid; gap: 26px; }
.gauge-panel::before {
  content: ""; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none;
  box-shadow:
    0 0 calc(18px + 70px * var(--tension)) color-mix(in srgb, var(--stage-color) 55%, transparent),
    inset 0 0 calc(10px + 50px * var(--tension)) color-mix(in srgb, var(--stage-color) 18%, transparent);
  opacity: 0.3;
  animation: beat var(--beat, 3.4s) ease-in-out infinite;
}
@keyframes beat { 0%, 100% { opacity: 0.25; } 10% { opacity: 1; } 22% { opacity: 0.4; } 34% { opacity: 0.85; } 60% { opacity: 0.25; } }
.panel-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 32px; flex-wrap: wrap; }
.pct-block { position: relative; }
.pct {
  font: 700 clamp(72px, 12vw, 148px)/0.9 var(--font-mono); letter-spacing: -0.04em; color: var(--stage-color);
  text-shadow: 0 0 calc(8px + 44px * var(--tension)) color-mix(in srgb, var(--stage-color) 65%, transparent);
}
.pct small { font-size: 0.4em; letter-spacing: 0; color: var(--muted); margin-left: 4px; text-shadow: none; }
.pct .dp { margin-inline: -0.14em; }
body[data-stage="3"] .pct { animation: jitter 0.14s steps(1) infinite; }
@keyframes jitter { 0% { translate: 0 0; } 25% { translate: 1px -1px; } 50% { translate: -1px 1px; } 75% { translate: 1px 1px; } }
.ring {
  position: absolute; left: 20px; top: 50%; width: 140px; height: 140px; margin-top: -70px;
  border: 2px solid var(--stage-color); border-radius: 50%; opacity: 0; pointer-events: none;
}
.ring.go { animation: ring 1.3s ease-out; }
@keyframes ring { from { opacity: 0.9; transform: scale(0.3); } to { opacity: 0; transform: scale(5.5); } }
.state { margin-top: 12px; font-size: clamp(20px, 2.6vw, 30px); font-weight: 800; font-stretch: 108%; color: var(--stage-color); }
.chrono { display: grid; gap: 10px; }
.chrono-label { font-size: 14px; color: var(--muted); }
.chrono-digits { display: flex; gap: 22px; align-items: flex-end; }
.t-cell { display: grid; gap: 2px; text-align: left; }
.t-cell strong { font: 600 clamp(28px, 4.2vw, 46px)/1 var(--font-mono); letter-spacing: -0.02em; }
.t-cell span { font-size: 13px; color: var(--muted); }

.track { position: relative; height: 36px; background: var(--line); border-radius: 18px; }
.fill {
  position: absolute; inset: 0; border-radius: 18px;
  background: var(--gauge);
  clip-path: inset(0 calc(100% - var(--p, 0%)) 0 0 round 18px);
  transition: clip-path 900ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.track::after {
  content: ""; position: absolute; inset: 0; border-radius: 18px; pointer-events: none; z-index: 1;
  background: repeating-linear-gradient(90deg, transparent 0 calc(25% - 4px), var(--panel) calc(25% - 4px) 25%);
}
.spark {
  position: absolute; inset: 0; pointer-events: none; z-index: 2;
  transform: translateX(calc(var(--p, 0%) - 100%));
  transition: transform 900ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.spark::before {
  content: ""; position: absolute; right: -3px; top: -9px; bottom: -9px; width: 6px; border-radius: 3px;
  background: var(--text); box-shadow: 0 0 20px 5px var(--stage-color);
}
.spark::after {
  content: ""; position: absolute; right: -52px; top: 50%; width: 104px; height: 104px; margin-top: -52px;
  background: radial-gradient(circle, color-mix(in srgb, var(--stage-color) 70%, transparent), transparent 65%);
  animation: flick 1.5s ease-in-out infinite;
}
@keyframes flick { 0%, 100% { opacity: 0.45; } 50% { opacity: 1; } }
body[data-broken] .spark { display: none; }
body[data-broken] .fill { background: var(--stage-broken); }
body[data-broken] .track { box-shadow: 0 0 60px color-mix(in srgb, var(--stage-broken) 70%, transparent); }
.marks { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: -16px; font: 400 12px var(--font-mono); color: var(--muted); }
.marks span { text-align: right; padding-right: 4px; }
.marks span.hit { color: var(--stage-color); font-weight: 700; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.stats dt { font-size: 14px; color: var(--muted); }
.stats dd { margin-top: 2px; font: 600 18px/1.3 var(--font-mono); overflow-wrap: anywhere; }
.btn.mini { padding: 3px 10px; font-size: 12px; margin-left: 8px; vertical-align: 2px; }

/* Stage crossing: flash, title card, shake */
.flash { position: fixed; inset: 0; pointer-events: none; z-index: 50; background: var(--stage-color); opacity: 0; }
.flash.go { animation: flash 1.1s ease-out; }
@keyframes flash { from { opacity: 0.55; } to { opacity: 0; } }
.toast { position: fixed; left: 50%; top: 40%; z-index: 60; transform: translate(-50%, -50%); text-align: center; pointer-events: none; opacity: 0; width: min(92vw, 1000px); }
.toast strong {
  display: block; font: 800 clamp(64px, 15vw, 180px)/1 var(--font-display); font-stretch: 125%; letter-spacing: -0.03em; color: var(--stage-color);
  text-shadow: 0 0 70px color-mix(in srgb, var(--stage-color) 70%, transparent);
}
.toast span { display: block; margin-top: 10px; font-size: clamp(20px, 3.2vw, 36px); font-weight: 700; text-shadow: 0 2px 24px var(--void), 0 0 8px var(--void); }
.toast.go { animation: toast 3.4s ease both; }
@keyframes toast {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(1.3); }
  7% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  78% { opacity: 1; }
  100% { opacity: 0; }
}
main.shake { animation: shake 0.8s cubic-bezier(0.36, 0.07, 0.19, 0.97); }
@keyframes shake {
  10%, 90% { translate: -2px 0; } 20%, 80% { translate: 5px 0; } 30%, 50%, 70% { translate: -9px 2px; } 40%, 60% { translate: 9px -2px; }
}

/* Sections */
section { padding-block: 72px; border-top: 1px solid var(--line); }
.hero { border-top: 0; }
h2 { font-size: 32px; line-height: 1.15; font-weight: 700; font-stretch: 108%; letter-spacing: -0.01em; }
h3 { font-size: 18px; line-height: 1.3; font-weight: 700; }
.lede { margin-top: 12px; max-width: 62ch; color: var(--muted); }
.section-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; flex-wrap: wrap; }

.btn {
  padding: 10px 18px; border-radius: var(--radius-s);
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  cursor: pointer; font-size: 14px; font-weight: 600;
  transition: background-color 150ms ease, border-color 150ms ease;
}
.btn:hover { background: var(--raised); border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn[aria-pressed="true"] { border-color: var(--breach); color: var(--breach); }

/* Leaderboard */
.board { list-style: none; padding: 0; margin-top: 36px; border-top: 1px solid var(--line); }
.row {
  display: grid;
  grid-template-columns: 36px minmax(150px, 1.1fr) minmax(0, 2.6fr) 64px 110px;
  align-items: center; gap: 20px;
  padding: 16px 0; border-bottom: 1px solid var(--line);
}
.rank { font: 600 15px var(--font-mono); color: var(--muted); }
.who b { display: block; font-weight: 700; }
.who small { color: var(--muted); font-size: 14px; }
.bar { position: relative; height: 10px; border-radius: 5px; background: var(--line); overflow: hidden; }
.bar i { position: absolute; inset: 0; background: var(--gauge); clip-path: inset(0 calc(100% - var(--p, 0%)) 0 0); }
.val { font: 600 16px var(--font-mono); text-align: right; }
.tgt { font-size: 13px; color: var(--muted); text-align: right; }

/* VMs */
.vm-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 36px; }
.vm { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-m); display: grid; grid-template-rows: auto 1fr auto; min-width: 0; }
.vm header { display: flex; align-items: baseline; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.vm header .id { font: 600 13px var(--font-mono); color: var(--muted); }
.vm header b { font-weight: 700; }
.vm header small { color: var(--muted); font-size: 14px; }
.vm header .score { margin-left: auto; font: 600 14px var(--font-mono); color: var(--stage-color, var(--text)); }
.log { font: 400 12px/1.7 var(--font-mono); padding: 12px 16px; min-height: 226px; overflow: hidden; color: var(--muted); background: var(--void); }
.log .ln { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.log i { font-style: normal; }
.log .t { opacity: 0.55; margin-right: 10px; }
.log .lv { display: inline-block; width: 4.5ch; margin-right: 8px; font-weight: 700; }
.log .src { display: inline-block; width: 9.5ch; margin-right: 8px; color: var(--text); opacity: 0.7; }
.log .warn .lv, .log .warn .msg { color: var(--stage-crack); }
.log .hit .lv, .log .hit .msg { color: var(--breach); }
.log .err .lv, .log .err .msg { color: var(--stage-onebreak); }
.vm footer { display: flex; flex-wrap: wrap; gap: 6px 20px; padding: 10px 18px; border-top: 1px solid var(--line); font: 400 12.5px var(--font-mono); color: var(--muted); }
.vm footer .sp { margin-left: auto; color: var(--text); }

/* Method table */
table { width: 100%; margin-top: 32px; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 14px 16px 14px 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-weight: 400; font-size: 14px; color: var(--muted); }
td.range { font-family: var(--font-mono); font-size: 14px; white-space: nowrap; }
.stage-cell { font-weight: 700; white-space: nowrap; }
.chip { display: inline-block; width: 36px; height: 12px; margin-right: 12px; border-radius: 6px; vertical-align: middle; }
.c-probe { background: var(--stage-probe); } .c-crack { background: var(--stage-crack); }
.c-giving { background: var(--stage-giving); } .c-onebreak { background: var(--stage-onebreak); }
.c-broken { background: var(--stage-broken); }

/* Context */
.refs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 36px; }
.ref {
  display: grid; gap: 10px; align-content: start; padding: 28px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-m);
  text-decoration: none;
  transition: border-color 150ms ease, transform 150ms ease;
}
.ref:hover { border-color: var(--shield); transform: translateY(-2px); }
.ref p { color: var(--muted); font-size: 15px; }
.ref-link { color: var(--shield); font-weight: 600; font-size: 15px; }
.ref-link::after { content: " \2192"; }

footer { padding-block: 48px 64px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.foot { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.foot-left, .foot-right { display: flex; align-items: center; gap: 14px; }
.x-icon {
  display: grid; place-items: center; width: 36px; height: 36px;
  border: 1px solid var(--line); border-radius: var(--radius-s); color: var(--text);
  transition: border-color 150ms ease, background-color 150ms ease;
}
.x-icon:hover { border-color: var(--muted); background: var(--panel); }
.note { margin-top: 20px; }

/* How it works */
.how-lead { max-width: 60ch; font-size: clamp(18px, 2.2vw, 24px); line-height: 1.45; font-weight: 600; letter-spacing: -0.01em; }
.how-lead + .how-lead { margin-top: 16px; font-size: clamp(16px, 1.8vw, 19px); font-weight: 400; color: var(--muted); }
.how-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 40px; margin-top: 48px; padding-top: 40px; border-top: 1px solid var(--line); }
.how-grid h2 { font-size: 22px; }
.how-grid p { margin-top: 12px; color: var(--muted); }
.how-grid p strong { color: var(--text); }

/* VM full-screen view */
.vm-open {
  display: grid; place-items: center; width: 28px; height: 28px; margin-left: 8px; align-self: center;
  border: 1px solid var(--line); border-radius: var(--radius-s); background: transparent; color: var(--muted); cursor: pointer;
}
.vm-open:hover { color: var(--text); border-color: var(--muted); background: var(--raised); }
.row { position: relative; }
.row-open { position: absolute; inset: 0; border: 0; border-radius: inherit; background: transparent; cursor: pointer; }
.row-open:hover { background: color-mix(in srgb, var(--text) 4%, transparent); }
.row-open:focus-visible { outline-offset: -2px; }
html.vv-open { overflow: hidden; }
.vmview { position: fixed; inset: 0; z-index: 50; display: grid; grid-template-rows: auto minmax(0, 1fr); background: var(--void); }
.vv-bar { position: relative; display: flex; align-items: center; gap: 16px; padding: 14px 24px; background: var(--panel); border-bottom: 1px solid var(--line); }
.vv-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.vv-title .id { font: 600 13px var(--font-mono); color: var(--muted); }
.vv-title b { font-size: 18px; }
.vv-title small { color: var(--muted); font-size: 14px; }
.vv-score { margin-left: auto; font: 700 20px var(--font-mono); color: var(--stage-color, var(--text)); }
.vv-nav { display: flex; gap: 8px; }
.vv-meter { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; }
.vv-meter i { display: block; height: 100%; width: var(--p, 0%); background: var(--stage-color, var(--text)); }
.vv-body { display: grid; grid-template-columns: minmax(0, 1fr) 340px; min-height: 0; }
.vv-term { display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; min-width: 0; padding: 0; border-top: 0; }
.vv-tools { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 24px; border-bottom: 1px solid var(--line); }
.vv-tools .btn.mini { margin-left: 0; }
.vv-filters { display: flex; gap: 8px; }
.vv-log { min-height: 0; overflow-y: auto; padding: 14px 24px; font-size: 13px; line-height: 1.75; }
.vv-log .ln { white-space: normal; overflow: visible; padding-left: 31ch; text-indent: -31ch; overflow-wrap: anywhere; }
.vv-log .ln i { text-indent: 0; }
.vv-log:empty::before { content: "Nothing matches yet."; }
.vv-side { padding: 20px 24px; overflow-y: auto; background: var(--panel); border-left: 1px solid var(--line); }
.vv-stats div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.vv-stats dt { color: var(--muted); font-size: 13px; }
.vv-stats dd { margin: 0; font: 600 13px var(--font-mono); text-align: right; }
.vv-side h3 { margin: 24px 0 10px; font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.vv-gpus { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; font: 400 12px var(--font-mono); color: var(--muted); }
.vv-gpus li { display: grid; grid-template-columns: 36px minmax(0, 1fr) 34px 66px 34px; align-items: center; gap: 8px; }
.vv-gpus .gb { height: 6px; border-radius: 3px; background: var(--raised); overflow: hidden; }
.vv-gpus .gb i { display: block; height: 100%; background: var(--stage-color, var(--shield)); }
.vv-gpus .u, .vv-gpus .g, .vv-gpus .c { text-align: right; color: var(--text); }
@media (max-width: 900px) {
  .vv-bar { gap: 8px; padding: 10px 12px; }
  .vv-bar .btn { padding: 6px 10px; }
  .vv-title { flex: 1 1 auto; overflow: hidden; }
  .vv-title b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .vv-title .id, .vv-title small { display: none; }
  .vv-score { margin-left: 0; font-size: 16px; }
  .vv-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .vv-side { max-height: 36vh; border-left: 0; border-top: 1px solid var(--line); padding: 14px 16px; }
  .vv-tools, .vv-log { padding-inline: 16px; }
  .vv-log .ln { padding-left: 0; text-indent: 0; }
}

@media (max-width: 900px) {
  .row { grid-template-columns: 28px minmax(0, 1fr) 64px; row-gap: 8px; }
  .row .bar { grid-column: 2 / 4; grid-row: 2; }
  .row .tgt { display: none; }
  .vm-grid, .refs { grid-template-columns: minmax(0, 1fr); }
  .top nav { display: none; }
  .top { justify-content: space-between; }
  .hdr-link { margin-left: auto; }
  .how-grid { grid-template-columns: minmax(0, 1fr); gap: 32px; }
}
@media (max-width: 560px) {
  .ca .js-ca { display: none; }
  .top { gap: 16px; }
  .hl-full { display: none; }
  .hl-short { display: inline; }
  .gauge-panel { padding: 20px; }
  .chrono-digits { gap: 14px; }
  .stats { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .stage-cell { white-space: normal; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .fill, .spark, .btn, .ref, body::before { transition: none; }
  .ref:hover { transform: none; }
  .gauge-panel::before, .spark::after, .pct, .ring, main.shake { animation: none !important; }
  .gauge-panel::before { opacity: 0.6; }
  .flash { display: none; }
  .toast.go { animation: none; opacity: 1; }
}
