:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0b0d14;
  color: #f4f2eb;
  --ink: #f4f2eb;
  --muted: #9ba3b7;
  --panel: rgba(26, 30, 44, 0.86);
  --line: rgba(255, 255, 255, 0.09);
  --gold: #f4c65d;
  --mint: #65e5bc;
  --red: #ff6b6b;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 20% 0%, #252c43 0, transparent 34rem), radial-gradient(circle at 85% 18%, #292041 0, transparent 30rem), #0b0d14; }
button, textarea { font: inherit; }
button { color: inherit; cursor: pointer; }
.shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 36px 0 28px; }
.hero { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.eyebrow { margin: 0 0 7px; color: var(--mint); text-transform: uppercase; letter-spacing: .16em; font-size: 12px; font-weight: 800; }
h1 { margin: 0; font-family: Georgia, serif; font-size: clamp(44px, 8vw, 82px); line-height: .9; letter-spacing: -.05em; }
.lede { color: var(--muted); max-width: 640px; margin: 14px 0 0; font-size: 17px; }
.level-picker { display: flex; gap: 8px; }
.level, .speed button { border: 1px solid var(--line); background: #151925; border-radius: 10px; min-width: 42px; height: 42px; font-weight: 800; }
.level.active { background: var(--gold); color: #16120a; border-color: var(--gold); }
.dashboard { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); border: 1px solid var(--line); background: rgba(16,19,30,.78); border-radius: 18px; overflow: hidden; margin-bottom: 16px; }
.dashboard div { padding: 14px 18px; border-right: 1px solid var(--line); }
.dashboard div:last-child { border-right: 0; }
.dashboard span { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .12em; margin-bottom: 5px; }
.dashboard strong { font-size: 18px; }
.tower-card, .editor-card, .log-card { border: 1px solid var(--line); background: var(--panel); box-shadow: 0 24px 80px rgba(0,0,0,.25); border-radius: 18px; }
.tower-card { padding: 20px; }
.tower-head { display: flex; justify-content: space-between; gap: 16px; align-items: start; }
.tower-head p { margin: 0 0 5px; }
.legend { color: var(--muted); font-size: 12px; }
.speed { display: flex; align-items: center; gap: 8px; }
.speed button { min-width: 32px; width: 32px; height: 32px; }
.speed span { min-width: 30px; text-align: center; color: var(--muted); font-size: 13px; }
.corridor { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(64px, 1fr); gap: 9px; margin: 24px 0 16px; overflow-x: auto; padding: 4px 2px 12px; }
.tile { min-width: 64px; aspect-ratio: 1; border-radius: 16px; border: 1px solid #333b53; background: linear-gradient(145deg, #252b3c, #171b29); display: grid; place-items: center; position: relative; box-shadow: inset 0 -7px 14px rgba(0,0,0,.22); }
.tile::after { content: attr(data-index); position: absolute; right: 7px; bottom: 5px; color: #65708b; font-size: 10px; }
.unit { font-size: 28px; filter: drop-shadow(0 4px 7px rgba(0,0,0,.45)); transition: transform .18s ease; }
.warrior { color: var(--gold); }
.enemy { color: var(--red); }
.captive { color: #8cc8ff; }
.stairs { color: var(--mint); }
.health-track { height: 5px; border-radius: 99px; background: #242838; overflow: hidden; }
.health-track i { display: block; width: 100%; height: 100%; background: linear-gradient(90deg, var(--red), var(--gold), var(--mint)); transition: width .25s ease; }
.status { min-height: 24px; margin: 13px 0 0; color: #d9dce6; }
.workspace { display: grid; grid-template-columns: 1.18fr .82fr; gap: 16px; margin-top: 16px; }
.editor-card, .log-card { min-width: 0; overflow: hidden; }
.panel-title { min-height: 52px; padding: 0 16px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; border-bottom: 1px solid var(--line); color: #d9dce6; font-size: 13px; }
.panel-title > :last-child { justify-self: end; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.red { background: #ff6b6b; }.amber { background: #f4c65d; }.green { background: #65e5bc; }
.text-button { border: 0; background: transparent; color: var(--mint); font-size: 12px; }
textarea { width: 100%; min-height: 250px; resize: vertical; border: 0; outline: none; padding: 20px; color: #edf2ff; background: #10131e; font-family: "SFMono-Regular", Consolas, monospace; font-size: 14px; line-height: 1.8; tab-size: 2; }
.syntax { margin: 0; padding: 13px 18px; color: var(--muted); font-size: 11px; line-height: 1.55; border-top: 1px solid var(--line); }
code { color: #b8a7ff; }
.controls { display: flex; gap: 9px; flex-wrap: wrap; padding: 14px 16px 17px; }
.controls button { border: 1px solid #394158; background: #202638; border-radius: 10px; padding: 10px 16px; font-weight: 750; }
.controls .primary { background: var(--mint); color: #07120f; border-color: var(--mint); }
.log { height: 345px; overflow: auto; margin: 0; padding: 17px 20px 17px 48px; color: #bbc2d2; font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; line-height: 1.65; }
.log li { padding: 3px 0 5px 5px; border-bottom: 1px dashed rgba(255,255,255,.05); }
.log li:last-child { color: var(--ink); }
.badge { border: 1px solid #46506a; border-radius: 99px; padding: 4px 8px; font-size: 10px; letter-spacing: .1em; }
.badge.win { color: var(--mint); border-color: rgba(101,229,188,.45); }
.badge.fail { color: var(--red); border-color: rgba(255,107,107,.45); }
footer { text-align: center; color: #788197; font-size: 12px; margin-top: 22px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@media (max-width: 780px) {
  .hero { align-items: start; flex-direction: column; }
  .dashboard { grid-template-columns: 1fr 1fr; }
  .dashboard div:nth-child(2) { border-right: 0; }
  .dashboard div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .workspace { grid-template-columns: 1fr; }
  .log { height: 250px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; } }
