:root {
  color-scheme: dark;
  --bg: #151215;
  --panel: #1d181c;
  --line: #362a2e;
  --paper: #f8ebde;
  --muted: #ada0a1;
  --red: #ff5b49;
  --mono: "Cascadia Mono", "Lucida Console", Consolas, monospace;
  --body: system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  color: var(--paper);
  font: 14px var(--mono);
  background: radial-gradient(ellipse at 62% 4%, #26191b 0%, var(--bg) 60%);
  min-width: 280px;
  min-height: 100vh;
}
button, kbd { font: inherit; }
button { cursor: pointer; color: inherit; }
button:focus-visible { outline: 2px solid #ffbb83; outline-offset: 4px; }
canvas { image-rendering: pixelated; }
.shell { max-width: 1540px; margin: auto; padding: clamp(20px, 3.3vw, 46px) clamp(14px, 5vw, 74px) 24px; }
.masthead { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.brand { display: flex; align-items: center; gap: 12px; font-size: clamp(13px, 1.5vw, 19px); font-weight: 900; letter-spacing: .075em; white-space: nowrap; }
.brand strong { color: var(--red); }
.brand-mark {
  display: grid; place-items: center; width: 39px; height: 39px;
  background: #382124; color: var(--red); border: 1px solid #693332;
  box-shadow: inset 0 -3px #2b191c;
}
.brand-mark canvas { width: 24px; height: 24px; }
.toolbar, .hud-actions { display: flex; gap: 8px; }
.tool {
  display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 38px; height: 36px;
  padding: 0 12px; background: #231c20; border: 1px solid #413238;
  color: #d8c7c2; font-size: 11px; text-transform: uppercase; letter-spacing: .055em;
}
.tool:hover { background: #3a2729; border-color: #95524b; color: var(--paper); }
.tool canvas, .record canvas, .kills canvas { width: 16px; height: 16px; }
.stage {
  position: relative; isolation: isolate; overflow: hidden; width: 100%;
  height: clamp(490px, calc(100svh - 168px), 770px);
  background: #251719; border: 1px solid #533632;
  box-shadow: 0 16px 50px #0907087d;
}
.stage::after {
  content: ""; position: absolute; z-index: 2; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 55px #140a0b94;
  background: repeating-linear-gradient(transparent 0 3px, #170c0d22 3px 4px);
}
.shell:fullscreen { display: flex; flex-direction: column; max-width: none; padding: 12px 16px; background: var(--bg); }
.shell:fullscreen .masthead { margin-bottom: 12px; }
.shell:fullscreen .stage { flex: 1; min-height: 0; height: auto; }
#world, .veil { position: absolute; inset: 0; width: 100%; height: 100%; }
#world { display: block; touch-action: none; }
.veil {
  z-index: 1;
  background: linear-gradient(90deg, #1a1015 1%, #1c1014f3 20%, #1b1114ca 33%, #21111340 55%, transparent 78%);
}
.stage:not([data-mode="menu"]) .veil, .stage:not([data-mode="menu"]) .scene-caption { display: none; }
.scene-caption {
  position: absolute; z-index: 3; color: #dfc2aa; font-size: 10px;
  letter-spacing: .17em; text-transform: uppercase;
}
.scene-caption { top: 22px; left: 25px; display: flex; align-items: center; gap: 9px; }
.scene-caption span { width: 6px; height: 6px; background: var(--red); box-shadow: 0 0 12px #ff5438; }
.menu {
  position: absolute; z-index: 4; left: clamp(28px, 6vw, 90px); top: 50%;
  transform: translateY(-50%); width: min(47%, 470px);
}
.eyebrow { display: flex; align-items: center; gap: 11px; margin: 0 0 19px; color: #ff9074; font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .18em; }
.eyebrow::before { content: ""; width: 23px; height: 2px; background: var(--red); }
h1 { margin: 0; }
h1 canvas { display: block; width: min(100%, clamp(270px, 29.7vw, 420px)); height: auto; }
.intro { margin: 21px 0 25px; color: #e1c9c0; font: 500 clamp(13px, 1.35vw, 17px)/1.55 var(--body); }
.action {
  display: inline-flex; align-items: center; justify-content: center; gap: 11px;
  min-height: 54px; padding: 0 15px 3px 17px;
  background: #ff624c; border: 1px solid #ff886b; box-shadow: inset 0 -4px #a4312c, 4px 4px #10090b;
  color: #210e10; text-transform: uppercase; font-size: 13px; font-weight: 900; letter-spacing: .045em;
}
.action:hover { background: #ff8667; }
.action:active { transform: translateY(2px); box-shadow: inset 0 -2px #a4312c, 2px 2px #10090b; }
.action kbd { margin-left: 11px; background: #b4362d29; border: 1px solid #8e302c63; color: #371317; padding: 4px 6px; font-size: 9px; }
.play-mark { width: 12px; height: 14px; background: #321418; clip-path: polygon(0 0, 30% 0, 30% 14%, 60% 14%, 60% 29%, 85% 29%, 85% 43%, 100% 43%, 100% 57%, 85% 57%, 85% 71%, 60% 71%, 60% 86%, 30% 86%, 30% 100%, 0 100%); }
.deck { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 13px 20px; min-height: 61px; padding: 13px 18px; border: 1px solid var(--line); border-top: 0; background: #20191e; }
.controls, .controls > div, .record { display: flex; align-items: center; }
.controls { gap: clamp(12px, 2.1vw, 35px); flex-wrap: wrap; }
.controls > div { gap: 8px; color: #c7b8b5; font-size: 11px; white-space: nowrap; }
.controls kbd { padding: 4px 6px; color: var(--paper); background: #2c2328; border: 1px solid #524049; box-shadow: 0 2px #160f13; font-size: 10px; font-weight: 700; }
.controls i { width: 7px; height: 7px; background: #ff7454; transform: rotate(45deg); }
.record { gap: 8px; color: #b6a5a6; font-size: 10px; letter-spacing: .08em; }
.record strong { color: #ffbe8c; font-size: 13px; }

.hud { position: absolute; z-index: 4; inset: 0; pointer-events: none; }
.vitals, .run-data, .hud-actions, .progress, .loadout { position: absolute; }
.vitals, .run-data, .kills, .progress { background: #1d1418e8; border: 1px solid #5b3e42; }
.vitals { top: 17px; left: 18px; width: clamp(100px, 21vw, 225px); padding: 9px; }
.hud-label { display: flex; justify-content: space-between; gap: 4px; margin-bottom: 6px; font-size: 10px; }
.health-track, .xp-track { background: #422831; border: 1px solid #72505a; height: 9px; overflow: hidden; }
.health-track > div, .xp-track > div { height: 100%; transition: width .14s; }
.health-track > div { background: #ff5b49; box-shadow: inset 0 2px #ff9d75; }
.dash-label { margin-top: 6px; font-size: 9px; color: #f9bb82; letter-spacing: .06em; }
.region-label { margin-top: 5px; font-size: 10px; font-weight: 700; }
.radar { position: absolute; right: 18px; bottom: 52px; width: 78px; height: 78px; border: 1px solid #a27a69; background: #21191b; }
.run-data { top: 15px; left: 50%; transform: translateX(-50%); min-width: 98px; text-align: center; padding: 8px 12px 7px; }
.run-data strong { display: block; color: #fff1df; font-size: clamp(19px, 2.2vw, 31px); line-height: 1.05; }
.run-data span { color: #f9a384; font-size: 9px; letter-spacing: .13em; }
.combo { position: absolute; top: calc(100% + 7px); left: 50%; transform: translateX(-50%); white-space: nowrap; color: #ffe0a1; background: #251c2aea; border: 1px solid #a4767a; padding: 4px 6px; font-size: 10px; font-weight: 800; }
.combo:empty { display: none; }
.hud-actions { top: 17px; right: 18px; }
.kills { display: flex; align-items: center; gap: 6px; min-width: 50px; padding: 0 8px; color: #ffaf91; }
.pause-button { pointer-events: auto; padding: 0; font-size: 17px; }
.progress { bottom: 15px; left: 18px; right: 18px; display: flex; align-items: center; gap: 9px; padding: 8px 10px; color: #ffe1a1; font-size: 10px; }
.xp-track { flex: 1; height: 7px; }
.xp-track > div { background: #ffb758; box-shadow: inset 0 2px #ffe59c; }
.loadout { display: flex; flex-wrap: wrap; gap: 5px; left: 18px; right: 108px; bottom: 51px; }
.loadout span { padding: 4px 7px; color: #f8d0a7; background: #1d1418df; border: 1px solid #5b3e42; font-size: 9px; }
.announcement {
  position: absolute; z-index: 5; top: 20%; left: 50%; transform: translateX(-50%);
  color: #ffca93; text-shadow: 2px 2px #3b1619, 0 0 12px #160c10;
  font-size: clamp(14px, 2vw, 24px); font-weight: 900; letter-spacing: .14em;
  text-align: center; pointer-events: none; white-space: nowrap;
}
.modal { position: absolute; z-index: 7; inset: 0; display: grid; place-items: center; background: #140d11b8; padding: 14px; overflow: auto; }
.dialog { width: min(100%, 740px); margin: auto; padding: clamp(18px, 4vw, 36px); background: #23191df5; border: 1px solid #764943; box-shadow: 5px 5px #0e080b; }
.dialog.compact { max-width: 415px; }
.dialog h2 { margin: 0 0 8px; color: #ffe4cb; font-size: clamp(23px, 4vw, 42px); font-weight: 900; line-height: 1.05; text-transform: uppercase; }
.dialog p { margin: 0 0 19px; color: #d4b9b0; font: 14px/1.4 var(--body); }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 9px; }
.choice { min-height: 137px; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px; text-align: left; background: #322227; border: 1px solid #61434a; }
.choice:hover, .choice:focus-visible { background: #492c31; border-color: var(--accent); }
.choice em { color: var(--accent); font-style: normal; font-size: 12px; font-weight: 800; }
.choice strong { font-size: 13px; }
.choice small { color: #e4c8bf; font: 12px/1.35 var(--body); }
.choice canvas { display: inline-block; width: 17px; height: 17px; vertical-align: middle; margin-right: 5px; }
.dialog-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.secondary { min-height: 42px; padding: 0 13px; background: #36262c; border: 1px solid #6d4b50; font-size: 11px; text-transform: uppercase; }
.secondary:hover { background: #56343a; }
.touch-controls { position: absolute; z-index: 6; left: 16px; right: 16px; bottom: 58px; display: flex; justify-content: space-between; align-items: end; pointer-events: none; }
.stick, .touch-dash { pointer-events: auto; touch-action: none; user-select: none; background: #22161eb0; border: 1px solid #af796c; border-radius: 50%; }
.stick { width: 88px; height: 88px; display: grid; place-items: center; }
.stick div { width: 33px; height: 33px; border-radius: 50%; background: #dc826b9e; border: 1px solid #ffc3a4; pointer-events: none; }
.touch-dash { width: 56px; height: 56px; color: #ffd4b4; font: 700 11px var(--mono); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

@media (max-width: 650px) {
  .masthead { margin-bottom: 12px; }
  .toolbar .tool { padding: 0 8px; }
  .toolbar .tool span { display: none; }
  .stage { height: clamp(430px, calc(100svh - 137px), 620px); }
  .scene-caption { left: 15px; top: 16px; }
  .menu { left: 22px; width: calc(100% - 44px); }
  .veil { background: linear-gradient(90deg, #170e14ed, #1b1016bb 53%, #1a0e1355); }
  .deck { padding: 11px 9px; }
  .controls { gap: 10px; }
  .controls > div { gap: 5px; font-size: 10px; }
  .vitals, .loadout { left: 7px; }
  .vitals, .hud-actions { top: 8px; }
  .vitals { width: clamp(82px, 28vw, 125px); padding: 7px; }
  .radar { right: 7px; width: 58px; height: 58px; }
  .loadout { right: 71px; }
  .hud-actions { right: 7px; gap: 4px; }
  .kills { min-width: 39px; padding: 0 5px; }
  .run-data { top: 8px; min-width: 0; padding: 6px; }
  .progress { bottom: 7px; left: 7px; right: 7px; }
  .choices { grid-template-columns: 1fr; gap: 6px; }
  .choice { display: grid; min-height: 0; grid-template-columns: 45px 1fr; gap: 3px; padding: 7px; }
  .choice small { grid-column: 2; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .shell:fullscreen h1 canvas { width: min(100%, 47svh); }
  .shell:fullscreen .intro { margin: 9px 0 13px; }
  .shell:fullscreen .eyebrow { margin-bottom: 9px; }
}
@media (pointer: coarse) {
  .controls > div:not(.auto), .action kbd { display: none; }
  .loadout { bottom: 155px; }
  .radar { bottom: 135px; }
}
@media (prefers-reduced-motion: reduce) {
  .health-track > div, .xp-track > div { transition: none; }
}
.boss-hud { position: absolute; top: 81px; left: 50%; transform: translateX(-50%); width: min(320px, 62%); padding: 5px 9px; text-align: center; background: #20151dec; border: 1px solid #8b586c; color: #ffe2c3; font-size: 10px; }
.boss-hud > div { margin-top: 4px; height: 5px; background: #442537; }
.boss-hud i { display: block; height: 100%; }
.stage:has(.boss-hud:not([hidden])) .combo { top: 100px; }
.recipes { margin-top: 14px; color: #d7bdc6; font-size: 11px; line-height: 1.55; }
.recipes summary { cursor: pointer; font-weight: 700; color: #ffe3b8; }
