@charset "UTF-8";
:root {
  color-scheme: dark;
  --ink: #edf6fa;
  --muted: #a1b4c2;
  --cyan: #70f4ce;
  --gold: #ffd26f;
  --bg: #0b101b;
  --panel: #182433;
  --rim: #526b7a;
  --arcade-font: "Courier New", monospace;
  --game-safe-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
  --game-safe-right: var(--safe-area-inset-right, env(safe-area-inset-right, 0px));
  --game-safe-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
  --game-safe-left: var(--safe-area-inset-left, env(safe-area-inset-left, 0px));
  font-family: "Segoe UI", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { height: 100dvh; background: var(--bg); color: var(--ink); -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:disabled { cursor: default; opacity: .5; }
button:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
[hidden] { display: none !important; }
.svg-library, .visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.pixel-icon { width: 16px; height: 16px; flex: none; fill: currentColor; shape-rendering: crispEdges; }
.game-column, .game-stage { width: 100%; height: 100%; }
.game-stage { position: relative; overflow: hidden; isolation: isolate; background: #272a2f; }
#game-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.stage-vignette { position: absolute; inset: 0; z-index: 1; pointer-events: none; box-shadow: inset 0 0 50px #050911a0; }

.game-toolbar {
  position: absolute; z-index: 5; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  left: max(18px, var(--game-safe-left)); right: max(18px, var(--game-safe-right)); top: max(14px, var(--game-safe-top)); pointer-events: none;
}
.scoreboard { display: flex; gap: 5px; min-width: 0; }
.current-stat, .best-stat {
  position: relative; display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 4px 10px;
  background: #101b29f2; border: 2px solid #3f5265; box-shadow: 0 3px 0 #060910;
}
.current-stat svg { width: 18px; height: 20px; flex: none; }
.best-stat[data-record="softcore"] { color: var(--cyan); }
.best-stat[data-record="hardcore"] { color: #ffc391; }
.best-stat .stat-label { text-transform: uppercase; }
.game-stage:not([data-state="ready"]) .record-mode, [data-state="ready"] .record-run,
.game-stage:not([data-state="ready"])[data-mode="softcore"] [data-record="hardcore"],
.game-stage:not([data-state="ready"])[data-mode="hardcore"] [data-record="softcore"],
.game-stage[data-route="study"] [data-record="hardcore"] { display: none; }
@media (hover: hover) and (pointer: fine) {
  .game-stage:not([data-controls="touch"]) .best-stat { pointer-events: auto; }
  .best-stat:hover::after {
    content: attr(data-tip); position: absolute; top: calc(100% + 6px); left: -2px;
    padding: 6px 8px; border: 1px solid var(--rim); background: #111c2b; color: var(--ink);
    white-space: nowrap; font: 700 12px/1.2 var(--arcade-font); pointer-events: none;
  }
}
.stat-label { display: block; color: var(--muted); font: 700 10px/1.1 var(--arcade-font); letter-spacing: .06em; white-space: nowrap; }
.scoreboard strong { display: block; font: 700 21px/1 var(--arcade-font); }
.game-stage:is([data-state="loading"], [data-state="ready"]) .current-stat,
.game-stage:is([data-state="loading"], [data-state="ready"]) #pause-button { display: none; }
.game-stage[data-state="loading"] { background: var(--bg); }
.game-stage[data-state="loading"] #game-frame { opacity: 0; }
.game-stage[data-state="loading"] :is(.game-toolbar, .menu-actions) { display: none; }
.tools { display: flex; align-items: center; gap: 6px; }
.icon-button, .play-button, .secondary-button, .touch-controls button {
  border: 2px solid var(--rim); background: var(--panel);
  box-shadow: inset 0 2px 0 #ffffff14, 0 3px 0 #070e18;
}
.icon-button, .touch-controls button { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; pointer-events: auto; }
.icon-button:hover:enabled, .secondary-button:hover:enabled { border-color: #86aab5; background: #253b4c; }
.icon-button:active:enabled, .play-button:active:enabled, .secondary-button:active:enabled, .touch-controls button:active {
  transform: translateY(2px); box-shadow: inset 0 2px 0 #0003, 0 1px 0 #070e18;
}
.sound-cross { display: none; }
#sound-button[aria-pressed="false"] .sound-waves { display: none; }
#sound-button[aria-pressed="false"] .sound-cross { display: initial; }

.stage-overlay {
  position: absolute; inset: 0; z-index: 3; overflow: auto; display: flex; align-items: safe center; justify-content: safe center;
  padding: var(--game-safe-top) var(--game-safe-right) var(--game-safe-bottom) var(--game-safe-left);
  background: radial-gradient(ellipse at center, #060e19ba 0%, #060e194a 77%, #060e194f);
}
.game-stage:is([data-state="paused"], [data-state="over"], [data-state="error"]) .stage-overlay { background: #080f1cce; }
.menu-content { width: min(490px, 88%); padding: 60px 0 24px; text-align: center; }
#overlay-title { margin: 0; color: var(--ink); font: 700 clamp(25px, 4vw, 45px)/1.1 var(--arcade-font); text-transform: uppercase; text-shadow: 0 3px 0 #080e17; }
#game-wordmark { display: block; width: min(100%, clamp(252px, 48vw, 504px)); height: auto; margin: 0 auto 24px; filter: drop-shadow(0 5px 0 #0a1421); }
.wordmark-accent { fill: var(--cyan); }
#overlay-description { color: #c2d2de; font-size: 14px; line-height: 1.5; margin: 12px auto; max-width: 36ch; }
.menu-actions { display: flex; flex-direction: column; gap: 10px; width: min(260px, 100%); margin: 16px auto 0; }
.play-button, .secondary-button, .text-button {
  min-height: 42px; padding: 8px 12px; display: flex; align-items: center; justify-content: center; gap: 9px;
  font: 700 14px/1.2 var(--arcade-font); text-transform: uppercase;
}
.play-button { min-height: 48px; border-color: #bcffe7; background: var(--cyan); color: #092f30; box-shadow: inset 0 2px 0 #d9ffef85, 0 4px 0 #236d62; font-size: 16px; }
.play-button:hover:enabled { background: #a0ffe1; }
.play-button:active:enabled { box-shadow: inset 0 2px 0 #0003, 0 2px 0 #236d62; }
.secondary-button { color: #dfecf2; }
#hardcore-button { border-color: #835449; color: #ffc391; }
#hardcore-button .pixel-icon { color: inherit; }
.secondary-button .pixel-icon { color: var(--cyan); }
.text-button { min-height: 32px; color: #b6c9d5; background: transparent; border: 0; }
.text-button:hover:enabled { color: var(--cyan); }
.game-loading {
  width: min(254px, 76%); margin: 24px auto 0; padding: 3px;
  border: 2px solid #4b6272; background: #101c28; box-shadow: 0 3px 0 #070e18;
}
.loading-track { overflow: hidden; height: 18px; background: #263b49; }
.loading-fill {
  display: block; height: 100%; width: var(--loaded, 30%); background: var(--cyan);
  box-shadow: inset 0 2px 0 #bdffe6; transition: width .14s ease-out;
}
.game-loading:not([aria-valuenow]) .loading-fill { animation: loading-scan 1.15s ease-in-out infinite alternate; }
@keyframes loading-scan { to { transform: translateX(230%); } }
.result { margin: 12px auto 0; }
.result > span { display: block; font: 700 11px var(--arcade-font); color: var(--gold); letter-spacing: .1em; }
.result strong { display: block; font: 700 clamp(34px, 5vw, 58px)/1.15 var(--arcade-font); color: var(--ink); }
#result-breakdown {
  display: grid; gap: 2px; width: min(260px, 100%); margin: 8px auto 0;
  font: 700 clamp(15px, 1.8vw, 17px)/1.3 var(--arcade-font); color: #bbceda;
}
#result-breakdown > div { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
#result-breakdown b { color: var(--ink); }

.touch-controls { display: none; position: absolute; z-index: 2; right: max(16px, var(--game-safe-right)); bottom: max(16px, var(--game-safe-bottom)); gap: 6px; }
.touch-controls button { width: 48px; height: 48px; background: #182433ed; color: #b3ffec; touch-action: none; }
.touch-controls button:active { background: #246857; }
[data-direction="37"] .pixel-icon, #tutorial-back .pixel-icon { transform: rotate(180deg); }
[data-direction="38"] .pixel-icon { transform: rotate(-90deg); }
[data-direction="40"] .pixel-icon { transform: rotate(90deg); }

#help-dialog, #credits-dialog {
  width: min(688px, calc(100% - 24px)); padding: 20px 24px; overflow: auto;
  inset: var(--game-safe-top) var(--game-safe-right) var(--game-safe-bottom) var(--game-safe-left);
  max-width: calc(100% - var(--game-safe-left) - var(--game-safe-right) - 20px);
  max-height: calc(100dvh - var(--game-safe-top) - var(--game-safe-bottom) - 20px);
  border: 2px solid var(--rim); color: var(--ink); background: #101b29;
  box-shadow: inset 0 2px 0 #ffffff14, 0 4px 0 #070e18;
}
#help-dialog::backdrop, #credits-dialog::backdrop { background: #060c17cf; }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-header h2 { margin: 0; font: 700 26px/1.1 var(--arcade-font); text-transform: uppercase; }
#credits-dialog { width: min(392px, calc(100% - 24px)); }
.music-credit { margin-top: 14px; padding-top: 17px; border-top: 1px solid #3f5265; user-select: text; }
.music-credit h3 { margin: 0; color: var(--cyan); font: 700 13px/1.3 var(--arcade-font); text-transform: uppercase; }
.music-credit p { margin: 4px 0 0; color: var(--muted); font-size: 15px; line-height: 1.45; }
.music-credit .composer { margin-top: 7px; color: var(--ink); font: 700 22px/1.2 var(--arcade-font); }
.music-credit p:last-child { margin-top: 16px; }
.tutorial-progress { display: flex; margin-top: 8px; border-bottom: 1px solid #3f5265; }
.tutorial-progress button {
  flex: 1; min-height: 42px; padding: 6px; border: 0; border-bottom: 3px solid transparent;
  background: transparent; color: var(--muted); font: 700 13px/1.2 var(--arcade-font); text-transform: uppercase;
}
.tutorial-progress button:hover { color: var(--ink); background: var(--panel); }
.tutorial-progress button[aria-current="step"] { color: var(--cyan); border-bottom-color: currentColor; }
.tutorial-page { display: grid; grid-template-columns: 1fr 1.04fr; gap: 22px; align-items: center; padding-block: 20px; }
.lesson-art {
  width: 100%; aspect-ratio: 40 / 21; outline: 1px solid #526b7a; outline-offset: -1px;
  background-color: var(--panel); background-repeat: no-repeat; background-size: 1000% 100%;
  animation: lesson-frames 1.6s steps(10, jump-none) 2 forwards;
}
.movement-demo { background-image: url("../../assets/tutorial/movement.webp"); background-position-x: 55.5556%; }
.spikes-demo { background-image: url("../../assets/tutorial/spikes.webp"); }
.portal-demo { background-image: url("../../assets/tutorial/portal.webp"); }
@keyframes lesson-frames { from { background-position-x: 0%; } to { background-position-x: 100%; } }
.lesson-copy h3 { margin: 0 0 9px; font: 700 22px/1.1 var(--arcade-font); }
.lesson-copy p { margin: 0; font-size: 15px; line-height: 1.45; }
.lesson-copy p:last-child { margin-top: 10px; color: #b6c9d5; }
.lesson-copy strong { color: var(--gold); }
.lesson-copy kbd {
  display: inline-block; min-width: 1.6em; text-align: center; vertical-align: .06em;
  background: var(--panel); border: 1px solid var(--rim); border-bottom-width: 2px;
  color: var(--ink); font: 700 .87em/1.35 var(--arcade-font);
}
#help-dialog[data-controls="touch"] .keyboard-instruction,
#help-dialog:not([data-controls="touch"]) .touch-instruction { display: none; }
.tutorial-footer {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px;
  padding-top: 12px; border-top: 1px solid #3f5265;
}
#tutorial-back { justify-self: start; padding-inline: 4px 8px; }
#tutorial-count { color: var(--muted); font: 700 12px var(--arcade-font); white-space: nowrap; }
#tutorial-next { min-height: 40px; min-width: 90px; justify-self: end; font-size: 14px; }

@media (max-width: 560px) {
  #help-dialog, #credits-dialog { padding: 14px 16px; }
  .dialog-header h2 { font-size: 22px; }
  .tutorial-progress button { font-size: 12px; }
  .tutorial-page { grid-template-columns: 1fr; gap: 14px; padding-block: 14px; }
  .lesson-art { max-width: 400px; justify-self: center; }
  .lesson-copy { min-height: 152px; }
  .lesson-copy h3 { font-size: 21px; }
}
@media (max-width: 360px) {
  .lesson-copy { min-height: 174px; }
}
@media (min-width: 561px) and (max-height: 550px) {
  #help-dialog { padding: 12px 18px; }
  .dialog-header h2 { font-size: 22px; }
  #help-close { width: 36px; height: 36px; }
  .tutorial-progress { margin-top: 2px; }
  .tutorial-progress button { min-height: 34px; }
  .tutorial-page { padding-block: 12px; gap: 16px; }
  .lesson-copy h3 { margin-bottom: 6px; font-size: 20px; }
  .lesson-copy p { font-size: 14px; line-height: 1.35; }
  .lesson-copy p:last-child { margin-top: 6px; }
  .tutorial-footer { padding-top: 8px; }
}
@media (min-width: 561px) and (max-height: 430px) {
  .tutorial-page { grid-template-columns: minmax(0, .72fr) minmax(0, 1.28fr); }
}

.noscript { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 100; padding: 30px; }
.game-stage[data-state="running"][data-controls="touch"] .touch-controls:not([hidden]) { display: flex; }
@media (max-width: 520px) {
  .game-toolbar { left: max(10px, var(--game-safe-left)); right: max(10px, var(--game-safe-right)); top: max(10px, var(--game-safe-top)); gap: 6px; }
  .tools { gap: 4px; }
  .tools .icon-button { width: 36px; height: 40px; }
  .current-stat, .best-stat { min-height: 36px; padding: 4px 7px; gap: 5px; }
  .scoreboard strong { font-size: 16px; }
  .stat-label { font-size: 9px; }
  .scoreboard svg { width: 14px; height: 14px; }
}
@media (max-width: 380px) {
  .game-toolbar { flex-wrap: wrap; }
  .game-toolbar .tools { margin-inline-start: auto; }
  .scoreboard { min-width: max-content; gap: 3px; }
  .best-stat { padding-inline: 5px; gap: 3px; }
  .stat-label { letter-spacing: 0; }
  .current-stat svg { display: none; }
}
@media (max-height: 400px) {
  .menu-content { padding-top: 43px; padding-bottom: 8px; }
  .menu-actions { gap: 7px; margin-top: 10px; }
  #game-wordmark { width: min(100%, 350px); margin-bottom: 14px; }
  .play-button { min-height: 41px; }
  .secondary-button { min-height: 37px; }
}
@media (min-width: 560px) and (max-height: 450px) {
  .game-stage[data-state="over"] .menu-content { padding-block: 12px 4px; }
  .result { margin: 6px auto; }
  #result-breakdown { display: flex; justify-content: center; width: auto; margin-top: 4px; gap: 20px; }
  #result-breakdown > div { gap: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *:before, *:after { animation: none !important; transition: none !important; }
}
