:root {
  --bg: #090e14;
  --panel: #131f28;
  --panel-low: #0c151b;
  --panel-high: #19262e;
  --line: #2b424c;
  --ink: #eaf4f2;
  --dim: #9aafb2;
  --a: #80f6e7;
  --a-hover: #37e0ff;
  --a-ink: #04121a;
  --b: #fa9587;
  --b-ink: #22060d;
  --gold: #edc17e;
  --good: #52e0a0;
  --warn: #edc17e;
  --outline: #05070f;
  --display: Impact, "Arial Narrow", sans-serif;
  --body: system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 14px;
  line-height: 1.5;
}

.shell {
  max-width: 1020px;
  margin: 0 auto;
  padding: 16px 24px 32px;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
}

h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 38px;
  font-weight: 700;
  letter-spacing: 1px;
  line-height: 1;
}

h2 {
  font-family: var(--body);
  font-size: 15px;
  font-weight: 800;
  margin: 0 0 8px;
}

.sub { margin: 8px 0 0; color: var(--dim); }

.panel {
  background: linear-gradient(140deg, #19262e, #101920);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 16px;
  margin-top: 24px;
}

.row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
  flex-wrap: wrap;
}

button {
  font-family: var(--body);
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  border-radius: 2px;
  padding: 11px 15px;
  min-height: 43px;
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--a);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--a);
  color: var(--a-ink);
  border: 2px solid var(--outline);
}

.btn-primary:hover { background: #7df0ff; }

.btn-primary:disabled { opacity: 0.35; cursor: default; }

.btn-ghost {
  background: transparent;
  color: var(--a);
  border: 1px solid var(--a);
}

.btn-ghost:hover { background: #80f6e722; border-color: var(--a); }

.btn-ghost:disabled { opacity: 0.35; cursor: default; }

input {
  background: #0a141b;
  color: var(--ink);
  border: 1px solid #435c65;
  border-radius: 2px;
  padding: 12px;
  min-height: 44px;
  font-size: 14px;
}

textarea {
  background: #0a141b;
  color: var(--ink);
  border: 1px solid #435c65;
  border-radius: 2px;
  padding: 12px;
  min-height: 44px;
  font-size: 14px;
  font-family: inherit;
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
}

.pills { display: flex; gap: 8px; flex-wrap: wrap; }

.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  color: var(--dim);
  background: var(--panel-low);
  font-variant-numeric: tabular-nums;
}

.hud {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.bar-block.right { text-align: right; }
.name { font-family: var(--body); font-weight: 800; }
.tag-a { color: var(--a); }
.tag-b { color: var(--b); }

.bar {
  height: 12px;
  border: 1px solid var(--outline);
  border-radius: 2px;
  background: var(--panel-low);
  overflow: hidden;
  margin-top: 4px;
}

.bar.thin { height: 6px; }
.fill { height: 100%; width: 100%; }
.hp-a { background: var(--a); }
.en-a { background: var(--good); }
.hp-b { background: var(--b); }
.en-b { background: var(--good); }

/* Short flash when a unit takes a hit. */
.fill.hit { background: #ffffff; }

.stage { position: relative; }

#arena {
  display: block;
  width: 100%;
  height: auto;
  border: 2px solid var(--outline);
  border-radius: 3px;
  background: #070b18;
}

.endcard {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #05070fd9;
  text-align: center;
}

.endcard[hidden] { display: none; }

.endcard h2 {
  font-family: var(--display);
  font-size: 40px;
  margin: 0;
  letter-spacing: 1px;
}

.endcard p { color: var(--dim); margin: 0 0 8px; }

#feed {
  margin: 8px 0 0;
  padding-left: 20px;
  max-height: 160px;
  overflow: auto;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

.ladder {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-top: 12px;
}

.ladder figure { margin: 0; text-align: center; }

.ladder img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--panel-low);
}

.ladder figcaption {
  margin-top: 6px;
  font-family: var(--body);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.02em;
}

.ladder figcaption small {
  display: block;
  font-family: var(--body);
  font-weight: 400;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

.pill.live { border-color: var(--good); color: var(--good); }

.hero { display: flex; gap: 16px; align-items: start; margin-top: 12px; }

#hero-img {
  width: 160px;
  height: 160px;
  object-fit: cover;
  border: 2px solid var(--outline);
  border-radius: 3px;
  background: var(--panel-low);
}

#lobby-img {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border: 2px solid var(--outline);
  border-radius: 3px;
  background: var(--panel-low);
}

#hero-img,
#lobby-img {
  animation: paint-in 0.5s ease-out;
}

@keyframes paint-in {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: none; }
}

.hero-name { font-family: var(--body); font-weight: 700; font-size: 20px; margin: 0; }

#hero-shield { width: 56px; height: 56px; object-fit: contain; }

.hero-ap { font-family: var(--body); font-weight: 600; margin: 0; }
/* Agent forge: portrait frame left, unit readout right. */
.forge { display: grid; grid-template-columns: minmax(220px, 300px) 1fr; gap: 20px; margin-top: 14px; align-items: start; }
.forge-frame { position: relative; border: 1px solid var(--line); background: var(--panel-low); padding: 10px; }
.forge-frame::before, .forge-frame::after { content: ""; position: absolute; width: 22px; height: 22px; pointer-events: none; }
.forge-frame::before { left: -1px; top: -1px; border-left: 3px solid var(--gold); border-top: 3px solid var(--gold); }
.forge-frame::after { right: -1px; bottom: -1px; border-right: 3px solid var(--gold); border-bottom: 3px solid var(--gold); }
.forge-frame:has(img[hidden]) { border-style: dashed; min-height: 220px; display: flex; align-items: center; justify-content: center; }
.forge-frame:has(img[hidden])::before { content: "AWAITING UNIT"; width: auto; height: auto; position: static; border: 0; font-size: 11px; letter-spacing: 0.2em; color: var(--dim); }
.forge-frame:has(img[hidden])::after { display: none; }
#hero-card #hero-img { width: 100%; height: auto; aspect-ratio: 4 / 5; border: 0; border-radius: 2px; }
.forge-name { font-family: var(--display); font-size: 44px; line-height: 1; margin: 0; letter-spacing: 0.02em; }
.forge-concept { margin-top: 4px; }
.forge-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.stat-tile { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 3px; background: var(--panel-low); padding: 12px 14px; min-width: 0; }
.stat-rank { grid-column: 1 / -1; border-color: #edc17e66; }
.stat-rank img { width: 44px; height: 44px; object-fit: contain; }
.stat-ic { flex: none; }
.stat-text { display: flex; flex-direction: column; min-width: 0; }
.stat-value { font-family: var(--body); font-weight: 800; font-size: 17px; white-space: nowrap; }
.stat-sub { font-size: 12px; color: var(--dim); }
.pips { margin-left: auto; display: flex; gap: 3px; flex: none; }
.pip { width: 8px; height: 18px; transform: skewX(-12deg); background: #22333c; }
.pip.on { background: var(--a); }
.forge-chip { width: 100%; margin-top: 14px; padding: 14px 16px; font-size: 13px; justify-content: flex-start; }
.forge-status { margin-top: 10px; }
.forge-cta { display: flex; gap: 10px; margin-top: 14px; }
.forge-cta #hero-next { margin: 0; flex: 1; display: flex; }
.forge-cta #hero-next-link { flex: 1; text-align: center; }
.forge-cta #share-btn { flex: 1; }

.ver { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
.ver-head { margin: 0 0 8px; font-variant-numeric: tabular-nums; }

table.chips { border-collapse: collapse; width: 100%; font-size: 14px; }
table.chips th, table.chips td {
  border: 1px solid var(--line);
  padding: 6px 10px;
  text-align: left;
  font-variant-numeric: tabular-nums;
}
table.chips th { font-family: var(--body); color: var(--dim); font-weight: 700; }

@media (max-width: 700px) {
  h1 { font-size: 32px; }
  #home-hero, #barracks-hero { min-height: 300px; }
  #home-hero .hero-copy, #barracks-hero .hero-copy { padding: 20px; }
  #home-hero .hero-copy h2, #barracks-hero .hero-copy h2 { font-size: 43px; }
  #home-hero .bot, #barracks-hero .bot { width: 58%; right: -8%; }
  .shell { padding: 12px 16px 24px; }
  .row { flex-direction: column; align-items: stretch; }
  .hero { flex-direction: column; }
  #hero-img, #lobby-img { width: 120px; height: auto; }
  #arena { width: 100%; height: auto; }
  .ladder { grid-template-columns: repeat(2, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none; animation: none; }
}

/* Command center: one primary act per screen. */
.command { border-color: var(--line); background: linear-gradient(180deg, var(--panel-high), var(--panel)); }
.command-grid { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 12px; margin-top: 12px; }
.command-card { background: var(--panel-low); border: 1px solid var(--line); border-radius: 3px; padding: 12px; }
.command-card h3 { margin: 0 0 8px; font-family: var(--body); font-size: 14px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }
.agent-face { width: 120px; height: 120px; object-fit: cover; border: 2px solid var(--gold); border-radius: 3px; background: var(--panel-low); }
.agent-face.empty { border-style: dashed; border-color: var(--line); }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.step { border: 1px solid var(--line); border-radius: 3px; padding: 10px; background: var(--panel-low); }
.step b { display: block; font-family: var(--body); font-weight: 800; font-size: 14px; }
.step.done { border-color: var(--good); }
.step.next { border-color: var(--a); }
.step.claimed { border-color: var(--gold); }
.path-head { display: flex; justify-content: space-between; align-items: end; gap: 12px; flex-wrap: wrap; }
.step .prize { display: block; margin-top: 8px; font-family: var(--body); font-weight: 800; font-size: 12px; letter-spacing: 0.08em; color: var(--gold); text-transform: uppercase; }
.step.claimed .prize { color: var(--good); }
.claim-btn { margin-top: 8px; width: 100%; }
.step.paid { animation: paid-flash 1.6s ease-out; }
@keyframes paid-flash { 0% { box-shadow: 0 0 0 3px var(--gold); } 100% { box-shadow: none; } }
@media (prefers-reduced-motion: reduce) { .step.paid { animation: none; } }
/* Guided tour: veil bands, highlight ring, step card. */
.tour-root { position: fixed; inset: 0; z-index: 60; }
.tour-band { position: fixed; background: #04080cd9; }
.tour-ring { position: fixed; border: 2px solid var(--a); border-radius: 4px; box-shadow: 0 0 0 4px #80f6e722, 0 0 28px #80f6e744; pointer-events: none; }
.tour-card { position: fixed; width: min(360px, calc(100vw - 24px)); background: var(--panel-high); border: 1px solid var(--a); border-radius: 4px; padding: 16px; z-index: 62; }
.tour-card.center { left: 50%; top: 50%; transform: translate(-50%, -50%); }
.tour-card h3 { margin: 4px 0 8px; font-family: var(--display); font-size: 22px; letter-spacing: 0.04em; }
.tour-cta { margin-top: 12px; }
.tour-cta:empty { display: none; }
.tour-foot { display: flex; align-items: center; gap: 10px; margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.tour-dots { display: flex; gap: 5px; font-size: 8px; color: var(--dim); }
.tour-dots .on { color: var(--a); }
.tour-count { font-size: 11px; color: var(--dim); font-variant-numeric: tabular-nums; }
.tour-nav { margin-left: auto; display: flex; gap: 6px; }
.tour-btn { padding: 8px 12px; font-size: 10px; }
.tour-btn:disabled { opacity: 0.35; cursor: default; }
.rank-emblem { display: flex; gap: 12px; align-items: center; }
.rank-emblem img { width: 64px; height: 64px; object-fit: contain; }
.rank-bar { height: 8px; border: 1px solid var(--outline); border-radius: 2px; background: var(--panel-low); overflow: hidden; margin-top: 8px; }
.rank-bar i { display: block; height: 100%; background: var(--gold); }
.score { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; margin-bottom: 12px; }
.score .side { display: flex; gap: 8px; align-items: center; }
.score .side.right { justify-content: end; text-align: right; }
.score img { width: 48px; height: 48px; object-fit: cover; border: 1px solid var(--line); border-radius: 3px; }
.score .clock { font-family: var(--body); font-weight: 800; font-size: 20px; font-variant-numeric: tabular-nums; }
.breed-frame { border: 2px solid var(--gold); border-radius: 3px; background: var(--panel-low); padding: 8px; max-width: 240px; }
details.diag { border: 1px dashed var(--line); border-radius: 3px; padding: 8px 12px; margin-top: 12px; }
details.diag summary { cursor: pointer; font-family: var(--body); font-weight: 700; color: var(--dim); }
.admin-note { border: 1px solid var(--warn); border-radius: 3px; padding: 10px 12px; background: #ffcf5d14; }
.next-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.why { margin: 12px 0 0; padding-left: 22px; display: grid; gap: 8px; color: var(--dim); }
.why li::marker { color: #8affec; }
#handle-input { width: 100%; max-width: 340px; box-sizing: border-box; }
#handle-input.ok { border-color: #3dff7a; }
#handle-input.bad { border-color: #ff5d7a; }
/* Arena: lobby views fade between queue and battle. */
.view { transition: opacity 0.45s ease; }
.view.fade-out { opacity: 0; }
@media (prefers-reduced-motion: reduce) { .view { transition: none; } }
.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.mode-card { border: 1px solid var(--line); border-radius: 3px; background: var(--panel-low); padding: 16px; }
.mode-card h3 { margin: 4px 0 8px; font-family: var(--display); font-size: 30px; letter-spacing: 0.04em; }
.mode-card.active { border-color: var(--a); }
.mode-card .btn-primary { margin-top: 12px; width: 100%; }
/* Single call to act per panel. Ghost links stay quiet. */
a.btn-ghost { text-decoration: none; display: inline-block; font-family: var(--body); font-weight: 800; font-size: 11px; letter-spacing: 0.8px; text-transform: uppercase; padding: 11px 15px; }
a.btn-primary { text-decoration: none; display: inline-block; font-family: var(--body); font-weight: 800; font-size: 11px; letter-spacing: 0.8px; text-transform: uppercase; padding: 11px 15px; }
.eyebrow { color: var(--a); font-size: 10px; letter-spacing: 2px; font-weight: 900; text-transform: uppercase; margin: 0; }
#home-hero, #barracks-hero { min-height: 345px; overflow: hidden; padding: 0; position: relative; background: radial-gradient(ellipse at 73% 45%, #31575b, #162d35 40%, #101c24 75%); }
#home-hero:before, #barracks-hero:before { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, #111d25ef, transparent 85%), repeating-linear-gradient(90deg, transparent 0 59px, #ffffff0a 60px), repeating-linear-gradient(0deg, transparent 0 59px, #ffffff08 60px); }
#home-hero .hero-copy, #barracks-hero .hero-copy { position: relative; z-index: 2; padding: 28px; display: flex; flex-direction: column; align-items: flex-start; width: 60%; height: 100%; }
#home-hero .hero-copy h2, #barracks-hero .hero-copy h2 { font-family: var(--display); font-size: 56px; line-height: 1; letter-spacing: 1px; margin: 28px 0 7px; }
#home-hero .hero-copy p, #barracks-hero .hero-copy p { max-width: 250px; }
#home-hero .hero-copy .next-actions, #barracks-hero .hero-copy .next-actions { margin-top: auto; }
#home-hero .bot, #barracks-hero .bot { position: absolute; right: 3%; bottom: -7%; height: 110%; width: 50%; filter: drop-shadow(0 12px 25px #0009); }
.table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.table td, .table th { padding: 12px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.table th { font-size: 10px; letter-spacing: 1px; color: var(--dim); font-weight: 800; }
.table tr.me td { background: #1b383b; }
.table a { color: var(--a); }
.lower { display: grid; grid-template-columns: 1.1fr 1fr 1fr; gap: 16px; margin-top: 16px; }
.lower .panel { min-height: 152px; margin-top: 0; }
.result { font-weight: 800; font-size: 17px; margin: 14px 0 4px; }
.overlay { position: absolute; inset: 0; display: grid; place-items: center; background: #061014b5; text-align: center; z-index: 2; }
.overlay[hidden] { display: none; }
.overlay strong { font-family: var(--display); font-size: 40px; letter-spacing: 1px; display: block; }
.toast { position: fixed; right: 20px; bottom: 20px; background: #d5fff6; color: #102724; padding: 12px 18px; z-index: 30; font-weight: 700; max-width: 90%; border-radius: 2px; }
.toast[hidden] { display: none; }
.modal { position: fixed; inset: 0; background: #050a0dcc; display: grid; place-items: center; padding: 20px; z-index: 20; }
.modal[hidden] { display: none; }
.dialog { width: min(470px, 100%); background: #16242c; border: 1px solid #577574; padding: 25px; border-radius: 3px; }
.dialog h2 { font-family: var(--display); font-size: 34px; letter-spacing: 1px; margin: 8px 0; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.product { background: linear-gradient(140deg, #162b32, #0c1b20); border: 1px solid #2c4952; padding: 22px; text-align: center; border-radius: 3px; }
.product .art { font-size: 42px; color: #d5fff6; }
.product h3 { font-size: 14px; margin: 9px 0 3px; }
.product button { margin-top: 10px; }
.chip-slot { display: inline-flex; align-items: center; gap: 8px; border: 1px dashed var(--line); border-radius: 2px; padding: 10px 14px; font-weight: 800; font-size: 11px; letter-spacing: 0.8px; text-transform: uppercase; color: var(--a); background: transparent; cursor: pointer; font-family: var(--body); }
.chip-slot.filled { border-style: solid; border-color: var(--a); }
.rule { display: flex; justify-content: space-between; align-items: center; gap: 15px; border-bottom: 1px solid var(--line); padding: 9px 0; }
.rule small { display: block; color: var(--dim); font-size: 12px; }
a.link-quiet { color: var(--dim); font-size: 14px; }
/* Arena series HUD: round, local-first score, per-round pips. */
.arena-series { display: flex; gap: 8px; align-items: center; justify-content: center; margin-bottom: 12px; flex-wrap: wrap; }
.arena-series[hidden] { display: none; }
.arena-legend { display: flex; gap: 8px; align-items: center; justify-content: center; margin-bottom: 12px; flex-wrap: wrap; }
.arena-legend[hidden] { display: none; }
.arena-legend .dot { display: inline-block; width: 8px; height: 8px; transform: rotate(45deg); margin: 0 2px 0 6px; }
.arena-legend .dot-g { background: #3dff7a; }
.arena-legend .dot-b { background: #37e0ff; }
.arena-legend .dot-r { background: #ff5d5d; }
.paused-mark { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 44px; font-weight: 800; letter-spacing: 6px; color: #ffffff; background: rgba(5,7,15,0.55); pointer-events: none; }
.paused-mark[hidden] { display: none; }
#series-pips { font-variant-numeric: tabular-nums; letter-spacing: 2px; }
/* MOBA viewer: gold, read-only builds, kill feed. */
.moba-hud { display: grid; grid-template-columns: 1fr 1.2fr 1fr; gap: 12px; align-items: start; margin-bottom: 12px; }
.moba-hud[hidden] { display: none; }
.moba-side { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.moba-side.right { justify-content: end; text-align: right; }
.builds { display: flex; gap: 4px; flex-wrap: wrap; }
.builds img { width: 30px; height: 30px; object-fit: contain; border: 1px solid var(--line); border-radius: 2px; background: var(--panel-low); }
.builds .slot-empty { width: 30px; height: 30px; border: 1px dashed var(--line); border-radius: 2px; }
.moba-kills { min-width: 0; }
#moba-feed { margin: 0; padding-left: 20px; max-height: 96px; overflow: auto; color: var(--dim); font-size: 13px; font-variant-numeric: tabular-nums; }
#moba-feed li.kill { color: var(--ink); font-weight: 700; }
#moba-feed li.nexus { color: var(--gold); font-weight: 800; }
#moba-feed li.econ { color: var(--gold); }
#end-builds { display: flex; gap: 24px; flex-wrap: wrap; justify-content: center; margin: 4px 0 8px; }
#end-builds[hidden] { display: none; }
.recap-side { min-width: 220px; max-width: 320px; }
.recap-head { margin: 0 0 6px; color: var(--dim); font-variant-numeric: tabular-nums; }
.recap-icons { justify-content: center; }
.recap-icons img { width: 34px; height: 34px; }
.recap-none { color: var(--dim); font-size: 13px; }
@media (max-width: 700px) { .moba-hud { grid-template-columns: 1fr; } }
@media (max-width: 700px) {
  .command-grid { grid-template-columns: 1fr; }
  .lower { grid-template-columns: 1fr; }
  .grid3 { grid-template-columns: 1fr; }
  .steps { grid-template-columns: 1fr; }
  .forge { grid-template-columns: 1fr; }
  .forge-stats { grid-template-columns: 1fr; }
  .forge-name { font-size: 34px; }
  .forge-cta { flex-direction: column; }
  .mode-grid { grid-template-columns: 1fr; }
  .score { grid-template-columns: 1fr; text-align: left; }
}
