:root { color-scheme: dark; background: #050817; }
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: grid; place-items: center; color: #e4f5ef; background: radial-gradient(circle at 50% 0%, #18244d 0%, #080b1d 43%, #03040b 100%); font-family: ui-monospace, monospace; }
.shell { position: relative; width: min(1120px, 100vw); padding: 22px; }
header, footer { display: flex; justify-content: space-between; align-items: center; gap: 18px; color: #9cb6c2; font-size: 10px; letter-spacing: .08em; }
header { margin: 0 4px 12px; }
.brand { color: #d6ff9d; font-family: ui-monospace, monospace; font-weight: 900; letter-spacing: .12em; font-size: 22px; text-shadow: 2px 2px #36564b, 0 0 14px #93d56d; }
.dot { display: inline-block; width: 9px; height: 9px; margin-right: 11px; background: #6ff4dc; box-shadow: 0 0 12px #6ff4dc; }
.screen-wrap { position: relative; overflow: hidden; border: 3px solid #45527a; box-shadow: 0 0 0 3px #0b1023, 0 0 0 6px #354467, 0 22px 70px #000b; background:#0c1330; }
canvas { display: block; width: 100%; height: auto; image-rendering: pixelated; image-rendering: crisp-edges; outline: none; }
canvas { touch-action: none; }
.sub { flex: 1; text-align: right; }
button, select { font: inherit; }
button { cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:focus-visible, select:focus-visible { outline: 3px solid #8bf5df; outline-offset: 4px; }
.menu { position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; padding: 16px; }
.menu[hidden], [hidden] { display: none !important; }
.menu-card { width: min(480px, 90%); text-align: center; }
.eyebrow { color: #83d8c7; font-size: 10px; letter-spacing: .22em; margin: 0 0 12px; }
h1 { margin: 0 0 14px; font-size: clamp(21px, 4.5vw, 46px); letter-spacing: .07em; color: #dcffa5; text-shadow: 3px 3px #305c51; }
#menu-info { color: #c6d7dc; font-size: clamp(10px, 1.25vw, 13px); line-height: 1.7; margin: 0 auto 20px; max-width: 420px; }
.level-results { max-width: 420px; margin: -5px auto 18px; padding: 12px 14px; border: 1px solid #52766d; background: rgba(7, 24, 34, .84); color: #dff7c7; font-size: 11px; line-height: 1.65; letter-spacing: .03em; white-space: pre-line; text-align: left; box-shadow: inset 0 0 0 2px rgba(92, 151, 119, .13); }
#level-options label { display: block; color: #91aaa9; font-size: 9px; letter-spacing: .14em; text-align: left; margin-bottom: 7px; }
#level-select { width: 100%; padding: 10px; margin-bottom: 13px; background: #122736; color: #ddecde; border: 1px solid #486864; font-size: 12px; }
#level-select option:disabled { color: #8d98a5; }
#level-progress { margin: -4px 0 11px; color: #d6ff9d; font-size: 11px; letter-spacing: .06em; }
#menu-action { width: 100%; padding: 14px 10px; background: #c8ef9a; border: 0; box-shadow: 0 4px #68805b; color: #102831; font-weight: 900; font-size: 13px; letter-spacing: .08em; }
#menu-action:hover { background: #e3ffc1; }
.menu-back { width: 100%; padding: 10px; margin-top: 15px; background: transparent; border: 1px solid #719091; color: #c5dcda; font-weight: 800; font-size: 11px; letter-spacing: .08em; }
.menu-back:hover { background: #17313c; }
.menu-hint { color: #94afba; font-size: 10px; line-height: 1.7; margin-top: 17px; }
.touch-controls { display: none; justify-content: space-between; margin-top: 14px; gap: 12px; }
.touch-controls, .touch-controls *, #game {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  -webkit-tap-highlight-color: transparent;
}
.touch-controls, .touch-controls * { touch-action: none; }
.touch-controls div { display: flex; gap: 8px; }
.touch-controls button { width: 50px; height: 46px; border: 1px solid #426264; border-bottom: 3px solid #426264; background: #142b39; color: #cbf1df; font-size: 22px; touch-action: none; }
.touch-controls button:active { background: #396263; }
.touch-controls .fire { background: #abc981; color: #122b32; }
.touch-controls button span { display: none; }
.touch-controls #music-toggle-label { display: inline; margin-left: 5px; font-size: 9px; letter-spacing: .06em; }
.touch-controls .music-toggle.is-muted { background: #171d2d; color: #82909d; box-shadow: inset 0 1px #343e52; }
.mobile-tip { display: none; }
.mobile-hud { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@media (pointer: coarse) { .touch-controls { display: flex; } }
@media (max-width: 700px) {
  .menu { padding: 8px; } .menu-card { width: min(480px, 92%); }
  .eyebrow { display: none; } h1 { margin-bottom: 7px; }
  #menu-info { margin-bottom: 8px; line-height: 1.35; }
  #level-select { padding: 6px; margin-bottom: 8px; font-size: 10px; }
  #menu-action { padding: 9px; font-size: 11px; } .menu-hint { display: none; }
}
.scanlines { pointer-events: none; position: absolute; inset: 0; opacity: .14; background: repeating-linear-gradient(to bottom, transparent 0 3px, #000 3px 4px); mix-blend-mode: multiply; }
footer { margin: 13px 4px 0; flex-wrap: wrap; font-size: 10px; }
footer b { color: #d6ff9d; font-weight: 700; }
@media (max-width: 620px) { .shell { padding: 8px; } .brand { font-size: 13px; } header { margin-top: 5px; } .sub { display:none; } footer { font-size: 8px; gap: 8px; } }
@media (pointer: coarse) {
  body { min-height: 100dvh; overscroll-behavior: none; }
  /* Blend modes force Safari to composite the entire animated canvas again. */
  .scanlines { display: none; }
  .shell { width: 100%; padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
  .touch-controls { position: relative; z-index: 4; margin: 9px auto 0; width: min(100%, 760px); }
  .touch-controls div { gap: 10px; }
  .touch-controls button { width: clamp(54px, 13vw, 72px); height: clamp(52px, 12vh, 68px); border-radius: 10px; border-bottom-width: 4px; font-size: 27px; }
  .touch-controls .fire { width: clamp(62px, 15vw, 84px); font-weight: 900; }
}
@media (pointer: coarse) and (orientation: landscape) {
  .shell { display: grid; justify-items: center; min-height: 100dvh; padding-top: 5px; }
  header { width: min(100%, 920px); margin: 0 0 4px; }
  .brand { font-size: 14px; } .dot { width: 6px; height: 6px; margin-right: 6px; }
  .screen-wrap { width: min(100%, 120dvh); }
  footer { display: none; }
  .touch-controls { margin-top: 5px; }
  .gamepad-dpad .dpad-up, .gamepad-dpad .dpad-down { display: none; }
  .gamepad-dpad { align-items: center; }
  .gamepad-actions { align-items: center; }
  .touch-controls button { width: clamp(48px, 10vw, 62px); height: clamp(42px, 10vh, 56px); font-size: 23px; }
  .touch-controls .fire { width: clamp(56px, 12vw, 72px); }
}
@media (pointer: coarse) and (orientation: portrait) {
  body { display: block; background: #040712; }
  .shell { display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; align-content: start; min-height: 100dvh; padding-top: max(7px, env(safe-area-inset-top)); padding-bottom: max(9px, env(safe-area-inset-bottom)); background: radial-gradient(circle at 50% 100%, #32215d 0%, #121735 45%, #040712 100%); }
  .mobile-tip { display: none; }
  header { min-height: 36px; margin: 0 2px 6px; gap: 8px; }
  .brand { font-size: 16px; }
  .dot { width: 7px; height: 7px; margin-right: 7px; }
  .mobile-hud { display: grid; gap: 8px; margin: 0 0 10px; padding: 10px 12px; border: 3px solid #63798c; border-radius: 8px 8px 3px 3px; background: linear-gradient(135deg, #101c30, #18213d); box-shadow: inset 0 0 0 2px #07101e, 0 4px 16px #0008; letter-spacing: .045em; }
  .mobile-hud-top, .mobile-hud-health, .mobile-hud-stats { display: flex; justify-content: space-between; align-items: center; }
  .mobile-hud-top { color: #d9ffae; font-size: 16px; }
  .mobile-hud-top span { color: #8bfff0; font-size: 14px; }
  .mobile-hud-health { color: #a9c1c9; font-size: 13px; }
  .mobile-hud-health strong { color: #d5f8a0; font-size: 23px; line-height: 1; letter-spacing: .08em; text-shadow: 1px 1px #4a705f; }
  .mobile-hud-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 14px; color: #b7cbd3; font-size: 12px; }
  .mobile-hud-stats span { display: flex; justify-content: space-between; min-width: 0; gap: 7px; padding-top: 6px; border-top: 1px solid #294352; }
  .mobile-hud-stats strong { color: #f3f8da; font-size: 14px; white-space: nowrap; }
  .mobile-boss { margin: 0; padding-top: 7px; border-top: 1px solid #5c3548; color: #ffd2a7; font-size: 13px; line-height: 1.35; }
  .screen-wrap { width: 100%; aspect-ratio: 16 / 9; height: auto; min-height: 0; border: 5px solid #111827; border-radius: 10px 10px 4px 4px; box-shadow: 0 0 0 2px #788393, inset 0 0 0 2px #0a0d17, 0 9px 22px #000b; background: #0c1330; }
  /* Show the complete arena, including the right-hand exit and boss cues. */
  canvas { position: absolute; top: 0; left: 0; width: 100%; max-width: none; height: auto; transform: none; }
  .scanlines { z-index: 1; }
  footer { display: none; }
  .touch-controls { display: grid; grid-template-columns: 1fr 1fr; grid-template-areas: "dpad action" "system system"; align-items: center; width: 100%; margin: 15px 0 0; padding: 15px 13px 10px; border-radius: 3px 3px 16px 16px; background: linear-gradient(145deg, #4d287f, #1d2351 62%, #121a3c); box-shadow: inset 0 2px 0 #8455bb, 0 10px 24px #0009; }
  .touch-controls .gamepad-dpad { grid-area: dpad; position: relative; display: grid; grid-template-columns: repeat(3, 54px); grid-template-rows: repeat(3, 54px); gap: 0; justify-content: start; }
  .touch-controls .gamepad-dpad button { width: 54px; height: 54px; padding: 0; border: 1px solid #060812; border-bottom-width: 5px; border-radius: 0; background: linear-gradient(145deg, #384257, #101522); color: #b9c3ca; font-size: 17px; box-shadow: inset 1px 1px #566479, 2px 4px 5px #05050aaa; }
  .touch-controls .gamepad-dpad .dpad-up { grid-column: 2; grid-row: 1; border-radius: 9px 9px 0 0; }
  .touch-controls .gamepad-dpad .dpad-left { grid-column: 1; grid-row: 2; border-radius: 9px 0 0 9px; }
  .touch-controls .gamepad-dpad .dpad-center { grid-column: 2; grid-row: 2; border-radius: 50%; font-size: 18px; color: #8b98a2; }
  .touch-controls .gamepad-dpad .dpad-right { grid-column: 3; grid-row: 2; border-radius: 0 9px 9px 0; }
  .touch-controls .gamepad-dpad .dpad-down { grid-column: 2; grid-row: 3; border-radius: 0 0 9px 9px; }
  .touch-controls .gamepad-actions { grid-area: action; display: flex; justify-content: flex-end; align-items: center; gap: 13px; padding-right: 5px; transform: rotate(-11deg); }
  .touch-controls .gamepad-actions .action-button { display: grid; place-items: center; width: 68px; height: 68px; padding: 0; border: 2px solid #0a0b13; border-bottom-width: 6px; border-radius: 50%; background: linear-gradient(145deg, #bce782, #688a55); color: #102222; font-size: 25px; font-weight: 900; box-shadow: inset 2px 2px #e3ffc0, 3px 5px 5px #060713aa; }
  .touch-controls .gamepad-actions .fire { background: linear-gradient(145deg, #78e7de, #397f8c); }
  .touch-controls .gamepad-actions .action-button span { display: block; font-size: 8px; letter-spacing: .04em; margin-top: -6px; }
  .touch-controls .gamepad-system { grid-area: system; display: flex; justify-content: center; margin-top: 8px; }
  .touch-controls .gamepad-system button { width: auto; height: 27px; min-width: 100px; padding: 0 14px; border-radius: 15px; border-color: #101527; border-bottom-width: 3px; background: #26314b; color: #cad6dc; font-size: 15px; }
  .touch-controls .gamepad-system button span { display: inline; margin-left: 7px; font-size: 9px; letter-spacing: .08em; }
  .touch-controls button:active { transform: translateY(3px); filter: brightness(.84); }
  .touch-controls .gamepad-actions .action-button:active { transform: translateY(3px); }
}
