@import url("assets/fonts/fonts.css");

:root {
  color-scheme: dark;
  --bg: #0b0c12;
  --panel: #12141e;
  --stroke: #2c3040;
  --muted: #a2abc2;
  --text: #f4f3fa;
  --yellow: #f3e95d;
  --cyan: #67efdc;
  --warn: #ff8d9e;
  --display: "Barlow Condensed", "Arial Narrow", Impact, sans-serif;
  --body: "DM Sans", Arial, sans-serif;
  --mono: Consolas, "Courier New", monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--text); background: var(--bg); font: 14px/1.45 var(--body); }
body::before {
  content: ""; position: fixed; z-index: -1; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 14% -16%, #36325055, transparent 58%),
    radial-gradient(ellipse at 95% 90%, #2a22423d, transparent 58%);
}
button, input { font: inherit; }
button { color: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { opacity: .45; cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible, canvas:focus-visible {
  outline: 2px solid var(--cyan); outline-offset: 3px;
}
a { color: inherit; }
h1, h2, h3, p, dl, dd { margin: 0; }
p { color: var(--muted); }
.sr-only, .skip:not(:focus) {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.skip:focus { position: fixed; top: 8px; left: 8px; z-index: 10; padding: 12px; background: var(--panel); }
.shell { max-width: 1472px; margin: auto; padding: 0 clamp(12px, 3vw, 52px) 24px; }
.topbar { min-height: 78px; display: grid; align-items: center; grid-template-columns: 1fr auto 1fr; gap: 12px; border-bottom: 1px solid var(--stroke); }
.wordmark { justify-self: start; font: italic 800 34px/.9 var(--display); letter-spacing: -.04em; text-decoration: none; white-space: nowrap; }
.wordmark span { color: var(--yellow); }
.wordmark i {
  display: inline-block; width: 19px; height: 15px; margin-right: 5px; background: var(--yellow);
  clip-path: polygon(29% 0, 100% 0, 71% 100%, 0 100%, 25% 20%, 56% 20%, 42% 67%, 55% 67%, 77% 12%, 24% 12%);
}
.topbar nav { display: flex; gap: clamp(2px, 1.4vw, 20px); }
.nav-button { border: 0; background: none; padding: 10px 9px; color: var(--muted); font-weight: 700; }
.nav-button:hover, .nav-button:focus-visible { color: var(--text); }
.audio-toggle, .icon-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 6px 13px; border: 1px solid var(--stroke); background: var(--panel);
}
.audio-toggle { justify-self: end; color: var(--muted); font: 700 11px var(--mono); }
.audio-toggle span { font-size: 20px; }
.audio-toggle[aria-pressed=true] { color: var(--yellow); border-color: #77743b; }
.icon-button { width: 44px; font: 700 23px var(--display); }
.icon-button:hover:enabled { border-color: var(--yellow); }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(239px, 268px); gap: 18px; padding-top: 24px; }
.game-column { min-width: 0; align-self: start; }
.hud, .systems { display: flex; align-items: center; background: var(--panel); border: 1px solid var(--stroke); }
.hud { min-height: 71px; padding: 8px 15px; gap: clamp(12px, 2.7vw, 42px); }
.label { color: var(--muted); font: 700 10px/1.2 var(--mono); text-transform: uppercase; letter-spacing: .075em; }
.hud .label { display: block; }
.timer { min-width: 103px; }
.timer strong, .score strong, .record-score { font: 800 37px/.95 var(--display); font-variant-numeric: tabular-nums; }
.timer strong { color: var(--yellow); }
.timer.low strong { color: var(--warn); }
.timer small { margin-left: 4px; color: var(--muted); }
.stage { flex: 1; max-width: 282px; }
#stage-bars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 7px; }
#stage-bars i { height: 4px; background: #303448; }
#stage-bars i.active { background: var(--stage, var(--yellow)); }
.score { margin-left: auto; text-align: right; }
.score strong { font-size: 30px; }
.hud .icon-button { flex: 0 0 44px; }

.arena {
  position: relative; isolation: isolate; overflow: hidden; background: #10111c;
  width: 100%; border-inline: 1px solid var(--stroke); aspect-ratio: var(--ratio, 960 / 600);
  max-height: min(67svh, 690px); min-height: 330px;
}
canvas { display: block; width: 100%; height: 100%; outline-offset: -5px !important; }
body[data-phase=playing] canvas:focus, body[data-phase=countdown] canvas:focus { outline: none; }
.arena-frame {
  position: absolute; z-index: 1; pointer-events: none; inset: 10px;
  border: 1px solid #8e91b623; clip-path: polygon(0 0, 24% 0, 24% 1px, 76% 1px, 76% 0, 100% 0, 100% 100%, 76% 100%, 76% calc(100% - 1px), 24% calc(100% - 1px), 24% 100%, 0 100%);
}
.launch { position: absolute; z-index: 2; inset: 0; display: grid; align-content: center; gap: 36px; padding: 18px clamp(24px, 5vw, 78px); }
.title-lockup h1 {
  font: italic 800 clamp(80px, 11vw, 170px)/.78 var(--display); letter-spacing: -.058em;
  color: #f7f6ff; text-shadow: 0 9px 35px #080811aa;
}
.title-lockup h1 span { color: var(--yellow); }
.title-lockup p { margin-top: 17px; max-width: 260px; color: #d3d5e6; font-weight: 600; }
.launch-actions { width: min(100%, 386px); }
.mode-select { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin-bottom: 9px; }
.mode-select button {
  min-height: 43px; padding: 5px; font: 700 16px var(--display); text-transform: uppercase;
  color: #bcc4dc; background: #171928ee; border: 1px solid #363b52; letter-spacing: .03em;
  transition: background .15s, color .15s, border-color .15s;
}
.mode-select button:hover { border-color: #9299b0; }
.mode-select button[aria-pressed=true] { color: var(--yellow); border-color: #aca34c; background: #363321; }
.primary, .secondary {
  min-height: 44px; padding: 9px 18px; border: 1px solid transparent; text-transform: uppercase;
  font: 800 18px/1.1 var(--display); letter-spacing: .055em; transition: background .16s, border-color .16s;
}
.primary { background: var(--yellow); color: #11101a; }
.primary:hover { background: #fff794; }
.secondary { background: #222638; color: var(--text); border-color: #424962; }
.secondary:hover { border-color: var(--cyan); }
.launch-button { display: flex; align-items: center; justify-content: space-between; width: 100%; padding-inline: 17px; min-height: 52px; }
.launch-button span { font-size: 24px; line-height: 1; }
.overlay {
  position: absolute; z-index: 4; inset: 0; display: grid; place-items: center; overflow: auto;
  padding: 16px; background: #080a13e8; animation: overlay-in .18s ease-out;
}
@keyframes overlay-in { from { opacity: .35; } to { opacity: 1; } }
.overlay-content, .upgrade-content { width: min(100%, 600px); text-align: center; }
.overlay h2, .panel-header h2 { font: 800 clamp(37px, 5.5vw, 64px)/.92 var(--display); text-transform: uppercase; }
.overlay p { margin: 11px auto 0; max-width: 440px; }
.overlay-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 20px; }
.result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 16px auto 0; max-width: 410px; }
.result-grid div { background: #181a2b; border: 1px solid #373b53; padding: 9px 6px; }
.result-grid strong { display: block; font: 800 27px/.9 var(--display); color: var(--yellow); }
.result-grid span { display: block; margin-top: 6px; }
.countdown, .stage-banner { position: absolute; z-index: 2; pointer-events: none; text-align: center; }
.countdown { display: grid; place-items: center; inset: 0; color: var(--yellow); font: italic 800 clamp(105px, 17vw, 212px)/1 var(--display); background: #0b0d1c86; }
.stage-banner {
  top: 32%; left: 50%; transform: translate(-50%, -50%); width: max-content; max-width: 95%;
  padding: 6px 18px; color: var(--stage, var(--yellow)); background: #101323e8; border: 1px solid currentColor;
  font: 800 clamp(19px, 3.6vw, 37px)/1 var(--display); text-transform: uppercase; letter-spacing: .05em;
}
.boss-status { position: absolute; top: 20px; left: 50%; transform: translateX(-50%); width: min(57%, 340px); z-index: 2; pointer-events: none; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 4px; }
#boss-name { color: var(--stage); font: 800 19px/1 var(--display); letter-spacing: .12em; }
#boss-time { font: 700 12px var(--mono); color: var(--text); }
.boss-status div { flex: 0 0 100%; height: 5px; background: #372a42; }
.boss-status i { height: 100%; display: block; background: var(--stage); transform-origin: left; }
.upgrade-content > .label { color: var(--cyan); }
.upgrade-content > h2 { margin: 4px 0 19px; font-size: clamp(30px, 4.3vw, 52px); }
#upgrade-title:focus { outline: none; }
.upgrade-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.upgrade-card {
  display: flex; flex-direction: column; align-items: flex-start; min-height: 157px; gap: 6px; padding: 13px;
  text-align: left; border: 1px solid #4b536c; background: #1a1e32; transition: border-color .15s, background .15s;
}
.upgrade-card:hover, .upgrade-card:focus-visible { background: #253146; border-color: var(--cyan); }
.upgrade-card .upgrade-icon { color: var(--cyan); font: 700 30px/1 var(--display); }
.upgrade-card strong { font: 800 22px/1 var(--display); text-transform: uppercase; }
.upgrade-card small { color: #c5cbe0; font-size: 12px; }
.upgrade-card kbd { margin-top: auto; }

.systems { align-items: stretch; min-height: 57px; }
.system-item { flex: 1; min-width: 0; padding: 11px 14px; }
.system-item + .system-item { border-left: 1px solid var(--stroke); }
.system-item .label { display: flex; justify-content: space-between; gap: 4px; align-items: center; min-height: 17px; color: #aeb7cd; }
.system-item b { color: var(--text); font-variant-numeric: tabular-nums; }
.track { height: 4px; margin-top: 5px; background: #2e344a; }
.track i { display: block; height: 100%; transform-origin: left; background: var(--yellow); }
.xp-system .track i { background: var(--cyan); }
.shield-system .track i { background: #bf9dff; }
.wave-system .track i { background: #ff93c8; }
kbd { display: inline-block; border: 1px solid #515a73; padding: 1px 4px; color: #c0c8df; font: 700 10px/1.2 var(--mono); }
.touch-controls { display: none; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 13px 0; }
.joystick, .touch-dash, .touch-wave {
  border: 1px solid #5b637e; background: #1a1d2c; border-radius: 50%; touch-action: none; user-select: none;
}
.joystick { position: relative; width: 90px; height: 90px; display: grid; place-items: center; }
.joystick::before { content: ""; position: absolute; inset: 12px; border: 1px solid #454b65; border-radius: 50%; pointer-events: none; }
.joystick i { width: 32px; height: 32px; border: 1px solid var(--cyan); border-radius: 50%; background: #3c6e76; pointer-events: none; }
.touch-actions { display: flex; align-items: center; gap: 12px; }
.touch-dash, .touch-wave { width: 76px; height: 76px; color: var(--yellow); font: 800 32px/.9 var(--display); }
.touch-wave { width: 62px; height: 62px; color: #ff93c8; font-size: 26px; }
.touch-dash small, .touch-wave small { display: block; margin-top: 3px; font: 700 10px var(--body); text-transform: uppercase; }
.touch-dash.cooldown, .touch-wave.cooldown { color: #a4abc4; }
.touch-dash:active, .touch-wave:active { background: #353a53; }

.sidebar { display: grid; gap: 10px; align-content: start; min-width: 0; }
.side-panel { padding: 17px; background: var(--panel); border: 1px solid var(--stroke); }
.side-heading { display: flex; justify-content: space-between; align-items: start; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.side-heading h2 { font: 800 21px/.95 var(--display); text-transform: uppercase; letter-spacing: .035em; }
.credit, .mode-label { color: var(--yellow); font: 700 11px/1.2 var(--mono); }
.pilot-identity { display: flex; align-items: center; gap: 10px; }
.pilot-identity strong { font: 800 29px/1 var(--display); }
.pilot-identity p, .briefing p { font-size: 12px; margin-top: 4px; }
.pilot-mark {
  --pilot: var(--yellow);
  flex: 0 0 44px; height: 44px; border: 1px solid #55536d; background: #242435;
  display: grid; place-items: center;
}
.pilot-mark::before { content: ""; width: 23px; height: 23px; background: var(--pilot); clip-path: polygon(50% 0, 100% 100%, 50% 73%, 0 100%); }
.pilot-mark[data-pilot=drift]::before { clip-path: polygon(50% 0, 98% 44%, 50% 100%, 2% 44%, 50% 55%); }
.pilot-mark[data-pilot=aegis]::before { clip-path: polygon(28% 0, 72% 0, 100% 50%, 72% 100%, 28% 100%, 0 50%); }
.pilot-mark[data-pilot=ion]::before { clip-path: polygon(50% 0, 100% 36%, 82% 100%, 18% 100%, 0 36%); }
.text-button {
  display: flex; justify-content: space-between; width: 100%; gap: 6px; margin-top: 12px; padding: 8px 0 0;
  border: 0; border-top: 1px solid var(--stroke); background: none; text-align: left; color: var(--cyan); font-weight: 700; font-size: 12px;
}
.text-button:hover { color: var(--text); }
.record-score { margin-bottom: 9px; color: var(--yellow); font-size: 52px; letter-spacing: .02em; }
dl > div { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px solid var(--stroke); }
dt { color: var(--muted); }
dd { text-align: right; font: 700 12px/1.5 var(--mono); }
.fine { font-size: 11px; margin-top: 8px; }
.briefing p { white-space: pre-line; }

dialog {
  width: min(690px, calc(100% - 22px)); max-height: min(90svh, 780px); padding: 16px 20px 22px; overflow: auto;
  color: var(--text); background: #151827; border: 1px solid #515775; box-shadow: 0 18px 90px #000a;
}
dialog::backdrop { background: #060711d9; }
dialog[open] { animation: overlay-in .18s ease-out; }
.panel-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.panel-header h2 { font-size: 42px; }
.panel-section + .panel-section { margin-top: 22px; }
.panel-section h3 { font: 800 24px var(--display); text-transform: uppercase; margin-bottom: 7px; }
.catalog-grid, .stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.catalog-card, .stat-card { padding: 10px; background: #1d2134; border: 1px solid #373e58; }
.catalog-card { display: grid; grid-template-columns: 41px 1fr; align-content: start; gap: 8px; }
.catalog-card .pilot-mark { height: 37px; }
.catalog-card .pilot-mark[data-color]::before { clip-path: none; border-radius: 50%; width: 14px; height: 14px; }
.catalog-card strong, .stat-card strong { font: 800 23px/1 var(--display); }
.catalog-card p { margin-top: 3px; font-size: 12px; }
.catalog-card button { grid-column: 1 / -1; font-size: 15px; min-height: 35px; }
.catalog-card.selected { border-color: #8a8247; }
.panel-lede { margin-bottom: 14px; }
.setting-row { display: grid; align-items: center; grid-template-columns: minmax(120px, 1fr) minmax(115px, 1fr) 43px; gap: 9px; min-height: 47px; border-top: 1px solid var(--stroke); }
.setting-row output { font: 700 12px var(--mono); text-align: right; }
.setting-row input { width: 100%; accent-color: var(--yellow); }
.setting-row input[type=checkbox] { width: 20px; height: 20px; justify-self: end; grid-column: 3; }
.stat-card strong { display: block; color: var(--yellow); margin-bottom: 6px; }
.stat-card p { font-size: 12px; }
.achievement-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.achievement-grid li { padding: 9px; border: 1px solid #3a415b; }
.achievement-grid li.earned { border-color: #86824c; background: #373323; }
.achievement-grid p { margin-top: 2px; font-size: 12px; }
.guide-list { margin: 0; padding-left: 22px; }
.guide-list li { padding: 4px 0; color: #d1d6e9; }

@media (pointer: coarse), (max-width: 740px) {
  .touch-controls:not([hidden]) { display: flex; }
  .systems kbd { display: none; }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 12px; padding-top: 12px; }
  .sidebar { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .shell { padding-inline: 8px; padding-bottom: 12px; }
  .topbar { min-height: 53px; gap: 3px; }
  .wordmark { font-size: 25px; }
  .wordmark i { width: 14px; height: 12px; margin-right: 2px; }
  .topbar nav { gap: 0; }
  .nav-button { padding: 9px 6px; font-size: 12px; }
  .audio-toggle { gap: 4px; padding: 2px 6px; min-height: 34px; font-size: 10px; }
  .audio-toggle span { font-size: 17px; }
  .layout { padding-top: 8px; }
  .hud { gap: 9px; min-height: 57px; padding: 6px 7px; }
  .timer { min-width: 68px; }
  .timer strong { font-size: 29px; }
  .score strong { font-size: 24px; }
  .hud .icon-button { flex-basis: 34px; width: 34px; min-height: 36px; }
  .label { font-size: 9px; }
  .arena { min-height: 280px; max-height: 54svh; }
  .launch { align-content: end; gap: 18px; padding: 15px 12px 21px; }
  .title-lockup h1 { font-size: clamp(65px, 18vw, 112px); }
  .title-lockup p { margin-top: 7px; font-size: 12px; }
  .launch-actions { width: 100%; }
  .launch-button { min-height: 43px; }
  .mode-select { margin-bottom: 6px; }
  .mode-select button { min-height: 37px; font-size: 15px; }
  .systems { min-height: 42px; }
  .system-item { padding: 6px 5px; }
  .system-item .label { letter-spacing: 0; }
  .boss-status { top: 13px; }
  .overlay { padding: 8px; }
  .overlay-actions { margin-top: 13px; }
  .upgrade-grid { grid-template-columns: 1fr; gap: 5px; }
  .upgrade-content > h2 { margin: 4px 0 7px; }
  .upgrade-card { display: grid; grid-template-columns: 24px 1fr; min-height: 0; gap: 2px 7px; padding: 6px 8px; }
  .upgrade-card .upgrade-icon { grid-row: span 2; }
  .upgrade-card strong { font-size: 17px; }
  .upgrade-card small { font-size: 11px; }
  .upgrade-card kbd { display: none; }
  .sidebar { grid-template-columns: 1fr 1fr; gap: 6px; }
  .side-panel { padding: 10px; }
  .side-heading { margin-bottom: 7px; }
  .side-heading h2 { font-size: 18px; }
  .record-score { font-size: 36px; }
  .pilot-mark { flex-basis: 32px; height: 32px; }
  .pilot-mark::before { width: 17px; height: 17px; }
  .pilot-identity strong { font-size: 22px; }
  .side-panel dl > div { font-size: 11px; padding: 3px 0; }
  .briefing { grid-column: 1 / -1; }
}
@media (orientation: landscape) and (pointer: coarse) and (max-height: 570px) {
  .topbar { min-height: 43px; }
  body.in-run .topbar, body.in-run .sidebar { display: none; }
  body.in-run .layout { padding-top: 4px; grid-template-columns: minmax(0, 1fr); }
  .arena { min-height: 165px; max-height: 67svh; }
  .hud { min-height: 45px; padding-block: 4px; }
  .systems { min-height: 37px; }
  .system-item { padding-block: 4px; }
  .touch-controls { position: fixed; z-index: 3; inset: 50% 8px auto; transform: translateY(-50%); padding: 0; pointer-events: none; }
  .joystick, .touch-actions { pointer-events: auto; }
  .touch-actions { flex-direction: column-reverse; gap: 6px; }
  .joystick { width: 76px; height: 76px; }
  .touch-dash { width: 63px; height: 63px; }
  .touch-wave { width: 55px; height: 55px; }
}
body.reduced *, body.reduced *::before, body.reduced *::after {
  animation-duration: 0s !important; transition-duration: 0s !important;
}
