:root {
  color-scheme: dark;
  --night: #081310;
  --panel: #12221d;
  --panel-2: #182d26;
  --line: #315046;
  --ink: #f5f5e8;
  --muted: #aebeb7;
  --acid: #d8f75f;
  --cyan: #65dfd0;
  --orange: #ffab55;
  --danger: #ff726c;
  --display: "Arial Black", "Helvetica Neue", Arial, sans-serif;
  --body: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--night); }
body { min-width: 280px; margin: 0; color: var(--ink); background: radial-gradient(circle at 78% 5%, rgba(101, 223, 208, .1), transparent 29rem), var(--night); font-family: var(--body); line-height: 1.5; }
button, canvas { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
a { color: inherit; }
.site-header, main, footer { width: min(1120px, calc(100% - 36px)); margin-inline: auto; }
.site-header { display: flex; min-height: 76px; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; gap: 10px; align-items: center; font-weight: 850; text-decoration: none; }
.brand-mark { display: grid; width: 34px; height: 34px; place-items: center; color: var(--night); background: var(--acid); border-radius: 9px; font-family: var(--display); }
.all-games { color: var(--muted); font-size: .82rem; font-weight: 850; letter-spacing: .08em; text-decoration: none; text-transform: uppercase; }
.all-games:hover, .all-games:focus-visible { color: var(--acid); }
.eyebrow { margin: 0 0 8px; color: var(--acid); font-size: .7rem; font-weight: 900; letter-spacing: .17em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
.game-heading { display: grid; grid-template-columns: 1fr minmax(280px, 440px); gap: 36px; align-items: end; padding: 44px 0 28px; }
h1 { margin: 0; font-family: var(--display); font-size: clamp(2.8rem, 6vw, 5.2rem); line-height: .94; letter-spacing: -.06em; }
.game-heading > p { margin: 0 0 4px; color: var(--muted); }

.game-shell { padding: 14px; background: rgba(18, 34, 29, .96); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 28px 80px rgba(0,0,0,.28); }
.level-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-bottom: 9px; }
.level-picker button { display: grid; grid-template-columns: auto 1fr auto; gap: 9px; align-items: center; min-height: 52px; padding: 8px 12px; color: var(--ink); background: #0c1915; border: 1px solid #29463c; border-radius: 11px; cursor: pointer; text-align: left; }
.level-picker button:hover:not(:disabled), .level-picker button:focus-visible, .level-picker button.is-selected { border-color: var(--acid); outline: none; }
.level-picker button.is-selected { background: #1c3429; box-shadow: inset 3px 0 var(--acid); }
.level-picker button:disabled { cursor: not-allowed; opacity: .46; }
.level-picker span { color: var(--acid); font: 900 .75rem/1 var(--display); }
.level-picker strong, .level-picker small { display: block; }
.level-picker strong { overflow: hidden; font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }
.level-picker small { color: var(--muted); font-size: .64rem; }

.hud { display: grid; grid-template-columns: 1.3fr repeat(3, 1fr); gap: 7px; margin-bottom: 9px; }
.hud > div { min-width: 0; padding: 8px 11px; background: #0b1813; border: 1px solid #29463c; border-radius: 10px; }
.hud span { display: block; color: var(--muted); font-size: .6rem; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; }
.hud strong { display: block; overflow: hidden; font-size: .84rem; text-overflow: ellipsis; white-space: nowrap; }
.hud i { display: block; overflow: hidden; height: 3px; margin-top: 5px; background: #294039; border-radius: 3px; }
.hud b { display: block; width: 0; height: 100%; background: var(--acid); transition: width .2s linear; }

.play-layout { display: grid; grid-template-columns: minmax(320px, 440px) minmax(280px, 1fr); gap: 14px; justify-content: center; align-items: start; }
.canvas-frame { position: relative; width: min(100%, 440px); margin-inline: auto; overflow: hidden; background: #182523; border: 1px solid #47645b; border-radius: 17px; box-shadow: 0 16px 30px rgba(0,0,0,.25); }
#game-canvas { display: block; width: 100%; height: auto; aspect-ratio: 7 / 12; outline: none; touch-action: none; user-select: none; }
#game-canvas:focus-visible { box-shadow: inset 0 0 0 3px var(--acid); }
.screen-card { position: absolute; inset: 0; z-index: 4; display: grid; place-content: center; justify-items: center; padding: 34px; text-align: center; background: linear-gradient(rgba(6,16,13,.82), rgba(6,16,13,.94)); backdrop-filter: blur(3px); }
.screen-card[hidden] { display: none; }
.screen-kicker { margin-bottom: 7px; color: var(--acid); font-size: .7rem; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }
.screen-card h2 { margin-bottom: 12px; font-family: var(--display); font-size: clamp(2rem, 5vw, 3.6rem); line-height: .98; letter-spacing: -.05em; }
.screen-card > p:not(.screen-kicker) { max-width: 330px; margin-bottom: 20px; color: var(--muted); font-size: .9rem; }
.control-demo { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.control-demo span { display: grid; width: 36px; height: 36px; place-items: center; color: var(--night); background: var(--cyan); border-radius: 50%; font-weight: 900; }
.control-demo b { font-size: .78rem; }
.screen-card button, .run-controls button { min-height: 44px; padding: 8px 16px; color: var(--ink); background: #213a31; border: 1px solid #4b6a5e; border-radius: 9px; cursor: pointer; font-weight: 850; }
.screen-card > button, .result-actions button:first-child { color: #14200f; background: var(--acid); border-color: var(--acid); }
.result-actions { display: flex; gap: 8px; }

.run-panel { display: grid; gap: 11px; }
.run-controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.run-controls button:hover:not(:disabled), .run-controls button:focus-visible { border-color: var(--acid); outline: none; }
.run-controls button:disabled { cursor: not-allowed; opacity: .45; }
.message { min-height: 38px; margin: 0; padding: 9px 11px; color: var(--muted); background: #0b1813; border: 1px solid #29463c; border-radius: 9px; font-size: .75rem; text-align: center; }
.message.is-alert { color: #ffaaa2; border-color: #754944; }
.panel-heading h2 { margin-bottom: 9px; font-size: 1rem; }
.weapon-guide { padding: 13px; background: #0b1813; border: 1px solid #29463c; border-radius: 13px; }
.weapon-guide article { display: flex; gap: 10px; align-items: center; min-height: 59px; padding: 7px; border-top: 1px solid #243c33; }
.weapon-guide article.is-active { margin-inline: -5px; padding-inline: 12px; background: #1d382d; border: 1px solid var(--acid); border-radius: 10px; }
.weapon-guide strong, .weapon-guide small { display: block; }
.weapon-guide strong { font-size: .8rem; }
.weapon-guide small { color: var(--muted); font-size: .67rem; }
.weapon-mark { position: relative; display: block; flex: 0 0 42px; height: 32px; color: var(--cyan); }
.weapon-mark--pistol::before { position: absolute; top: 8px; left: 6px; width: 27px; height: 8px; content: ""; background: currentColor; border-radius: 5px 2px 2px 5px; box-shadow: 12px 8px 0 -3px currentColor; }
.weapon-mark--blade::before { position: absolute; top: 1px; left: 17px; width: 7px; height: 28px; content: ""; background: var(--acid); border-radius: 100% 0; transform: rotate(38deg); }
.weapon-mark--machine::before { position: absolute; top: 8px; left: 4px; width: 33px; height: 8px; content: ""; background: repeating-linear-gradient(90deg, var(--cyan) 0 5px, transparent 5px 7px); border: 2px solid var(--cyan); }
.weapon-mark--cannon::before { position: absolute; top: 5px; left: 5px; width: 25px; height: 18px; content: ""; background: var(--orange); border-radius: 50%; box-shadow: 17px 5px 0 -5px var(--orange); }
.gate-note { padding: 13px; background: #183127; border: 1px solid #385d4e; border-radius: 12px; }
.gate-note strong { font-size: .8rem; }
.gate-note p { margin: 4px 0 0; color: var(--muted); font-size: .7rem; }
.gate-note b { color: var(--acid); }

.instructions { display: grid; grid-template-columns: minmax(260px,.75fr) minmax(500px,1.25fr); gap: clamp(35px,7vw,90px); padding: 70px 0; }
.instructions h2 { margin-bottom: 14px; font-family: var(--display); font-size: clamp(2rem,4vw,3.5rem); line-height: 1; letter-spacing: -.05em; }
.instructions > div > p:last-child, .tips p { color: var(--muted); }
.tips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.tips article { padding: 15px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.tips span { color: var(--acid); font: 900 .7rem/1 var(--display); }
.tips h3 { margin: 9px 0 5px; font-size: .82rem; }
.tips p { margin: 0; font-size: .7rem; }
footer { display: flex; justify-content: space-between; padding: 26px 0 42px; color: var(--muted); border-top: 1px solid var(--line); font-size: .78rem; }
footer a { color: var(--ink); font-weight: 850; text-decoration: none; }

@media (max-width: 820px) {
  .game-heading { grid-template-columns: 1fr; gap: 12px; }
  .play-layout { grid-template-columns: minmax(280px, 440px); }
  .run-panel { grid-row: 2; }
  .weapon-guide { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; }
  .weapon-guide .panel-heading { grid-column: 1 / -1; }
  .weapon-guide article { border: 1px solid #243c33; border-radius: 9px; }
  .instructions { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .site-header, main, footer { width: min(100% - 20px, 1120px); }
  .site-header { min-height: 62px; }
  .game-heading { padding: 28px 2px 19px; }
  h1 { font-size: 2.75rem; }
  .game-heading > p { font-size: .88rem; }
  .game-shell { padding: 7px; border-radius: 15px; }
  .level-picker { gap: 4px; }
  .level-picker button { display: block; min-width: 0; min-height: 48px; padding: 6px; text-align: center; }
  .level-picker span, .level-picker strong, .level-picker small { display: block; }
  .level-picker strong { font-size: .63rem; }
  .level-picker small { font-size: .55rem; }
  .hud { grid-template-columns: 1.25fr 1fr; gap: 4px; }
  .hud > div { padding: 5px 8px; }
  .hud span { font-size: .53rem; }
  .hud strong { font-size: .72rem; }
  .canvas-frame { width: auto; height: min(62svh, 560px); aspect-ratio: 7 / 12; }
  #game-canvas { width: 100%; height: 100%; }
  .screen-card { padding: 22px; }
  .screen-card h2 { font-size: 2rem; }
  .screen-card > p:not(.screen-kicker) { font-size: .76rem; }
  .run-controls button { min-height: 42px; padding: 6px; font-size: .72rem; }
  .message { min-height: 34px; padding: 7px; font-size: .68rem; }
  .weapon-guide { padding: 8px; }
  .weapon-guide article { min-height: 49px; padding: 5px; }
  .weapon-guide strong { font-size: .67rem; }
  .weapon-guide small { font-size: .57rem; }
  .weapon-mark { flex-basis: 34px; transform: scale(.82); }
  .gate-note { padding: 9px; }
  .instructions { gap: 24px; padding: 52px 2px; }
  .tips { grid-template-columns: 1fr; }
  footer { gap: 20px; }
}

@media (max-width: 340px) {
  .weapon-guide small { display: none; }
  .screen-card { padding: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
