:root {
  --ink: #e9fff1;
  --muted: #8eb5a8;
  --night: #06151c;
  --panel: rgba(5, 22, 26, 0.86);
  --line: rgba(178, 255, 204, 0.16);
  --gold: #ffd35a;
  --green: #70ed95;
  --pixel: ui-monospace, 'SFMono-Regular', 'Cascadia Mono', monospace;
  --body: ui-rounded, 'Arial Rounded MT Bold', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--night); }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--body);
  background:
    radial-gradient(circle at 50% 15%, rgba(44, 113, 87, 0.23), transparent 42rem),
    linear-gradient(#06151c, #030b10 80%);
  overflow-x: hidden;
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .2;
  background-image: linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 4px 4px;
}
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }

.file-notice {
  position: sticky;
  top: 0;
  z-index: 20;
  width: 100%;
  padding: 12px 18px;
  border-bottom: 2px solid #ffd35a;
  color: #20311f;
  background: #fff0a0;
  text-align: center;
  box-shadow: 0 7px 24px rgba(0,0,0,.35);
}
.file-notice[hidden] { display: none; }
.file-notice strong { margin-right: 10px; font: 9px var(--pixel); text-transform: uppercase; }
.file-notice span { font-size: 13px; font-weight: 800; }

.game-shell { width: min(1180px, 100%); margin: 0 auto; padding: 18px 28px 24px; }
.topbar, .footer-note { display: flex; align-items: center; justify-content: space-between; }
.topbar { height: 64px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; text-transform: uppercase; }
.brand-gem {
  width: 24px; height: 32px; display: block;
  background: linear-gradient(135deg, #fff5a6 0 22%, #ffd24f 23% 48%, #ed8d2f 49% 72%, #a9462a 73%);
  clip-path: polygon(50% 0, 100% 28%, 83% 80%, 50% 100%, 17% 80%, 0 28%);
  filter: drop-shadow(0 0 8px rgba(255, 207, 72, .5));
}
.brand b { display: block; font: 9px/1.5 var(--pixel); letter-spacing: .04em; }
.brand small { display: block; color: var(--green); font: 8px/1.4 var(--pixel); letter-spacing: .25em; }
.top-actions { display: flex; gap: 8px; }
.icon-button, .text-button { border: 1px solid var(--line); color: var(--ink); background: rgba(255,255,255,.035); cursor: pointer; }
.icon-button { width: 38px; height: 38px; border-radius: 3px; font: 16px var(--pixel); }
.audio-button { width: 46px; line-height: 1; }
.audio-button span { display: block; font-size: 13px; }
.audio-button small { display: block; margin-top: 3px; color: var(--muted); font: 5px var(--pixel); text-transform: uppercase; }
.text-button { padding: 0 16px; border-radius: 3px; font-size: 13px; font-weight: 800; }
.icon-button:hover, .text-button:hover { background: rgba(112,237,149,.1); border-color: rgba(112,237,149,.4); }
.icon-button.active { color: #142c20; border-color: #fff09a; background: var(--gold); box-shadow: 0 0 14px rgba(255,211,90,.35); }
.icon-button.active small { color: #314b2e; }

.game-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 2px solid rgba(183, 255, 197, .2);
  border-radius: 5px;
  background: #122b35;
  box-shadow: 0 30px 70px rgba(0,0,0,.5), 0 0 0 6px rgba(0,0,0,.17), inset 0 0 0 1px rgba(255,255,255,.06);
}
.game-frame::after {
  content: '';
  position: absolute; inset: 0; pointer-events: none; z-index: 8;
  background: repeating-linear-gradient(0deg, rgba(1,13,14,.09) 0, rgba(1,13,14,.09) 1px, transparent 1px, transparent 3px);
  mix-blend-mode: multiply;
}
canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
html.game-fullscreen,
html.game-fullscreen body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}
.game-shell:fullscreen,
.game-shell:-webkit-full-screen,
.game-shell.theater-mode {
  width: var(--game-viewport-width, 100vw);
  max-width: none;
  height: var(--game-viewport-height, 100dvh);
  min-height: 0;
  margin: 0;
  padding:
    env(safe-area-inset-top, 0)
    env(safe-area-inset-right, 0)
    env(safe-area-inset-bottom, 0)
    env(safe-area-inset-left, 0);
  background: #07151b;
  display: grid;
  place-items: center;
  overflow: hidden;
  overscroll-behavior: none;
}
.game-shell:fullscreen .game-frame,
.game-shell:-webkit-full-screen .game-frame,
.game-shell.theater-mode .game-frame {
  width: var(--fullscreen-frame-width, 100%);
  height: var(--fullscreen-frame-height, auto);
  max-width: 100%;
  max-height: 100%;
  margin: 0;
  place-self: center;
}
.game-shell:fullscreen .topbar,
.game-shell:-webkit-full-screen .topbar,
.game-shell.theater-mode .topbar {
  position: absolute;
  z-index: 12;
  top: max(6px, env(safe-area-inset-top));
  right: max(6px, env(safe-area-inset-right));
  left: auto;
  height: auto;
  pointer-events: none;
}
.game-shell:fullscreen .brand,
.game-shell:-webkit-full-screen .brand,
.game-shell.theater-mode .brand,
.game-shell:fullscreen #helpButton,
.game-shell:-webkit-full-screen #helpButton,
.game-shell.theater-mode #helpButton,
.game-shell:fullscreen .footer-note,
.game-shell:-webkit-full-screen .footer-note,
.game-shell.theater-mode .footer-note {
  display: none;
}
.game-shell:fullscreen .top-actions,
.game-shell:-webkit-full-screen .top-actions,
.game-shell.theater-mode .top-actions {
  padding: 4px;
  border: 1px solid rgba(183, 255, 197, .16);
  border-radius: 4px;
  background: rgba(3, 18, 23, .72);
  backdrop-filter: blur(7px);
  pointer-events: auto;
}
.game-shell:fullscreen .hud,
.game-shell:-webkit-full-screen .hud,
.game-shell.theater-mode .hud {
  right: 168px;
}
.game-shell.theater-mode {
  position: fixed;
  inset: 0;
  z-index: 100;
}
.vignette { position: absolute; inset: 0; z-index: 4; pointer-events: none; box-shadow: inset 0 0 110px 20px rgba(1, 9, 13, .6); }

.hud { position: absolute; top: 20px; left: 22px; right: 22px; z-index: 6; display: flex; justify-content: space-between; pointer-events: none; text-shadow: 2px 2px #15302b; }
.hud-item { min-width: 110px; }
.hud-item strong { display: flex; align-items: center; gap: 8px; font: 13px var(--pixel); }
.hud-item em { color: rgba(255,255,255,.45); font-style: normal; font-size: 8px; }
.hud-label { display: block; margin-bottom: 6px; color: #b8dbcb; font: 7px var(--pixel); text-transform: uppercase; letter-spacing: .14em; }
.hud-center { text-align: center; }
.hud-center strong { justify-content: center; }
.hud-power { text-align: center; }
.hud-power strong { justify-content: center; color: #f4d7ff; font-size: 9px; }
.hud-lives { text-align: right; }
.hud-lives strong { justify-content: flex-end; color: #ff7567; letter-spacing: 3px; }
.mini-shard { width: 10px; height: 15px; background: var(--gold); clip-path: polygon(50% 0,100% 28%,80% 78%,50% 100%,20% 78%,0 28%); box-shadow: 0 0 8px var(--gold); }

.start-card, .result-card { position: absolute; z-index: 7; text-align: center; }
.start-card { left: 50%; top: 47%; width: min(610px, 86%); transform: translate(-50%, -50%); }
.eyebrow { margin: 0 0 13px; color: var(--gold); font: 8px var(--pixel); letter-spacing: .23em; text-transform: uppercase; text-shadow: 2px 2px #72501d; }
.logo-title {
  margin: 0 0 32px;
  color: #fff5a0;
  font: clamp(40px, 7vw, 72px)/1.15 var(--pixel);
  letter-spacing: -.09em;
  text-transform: none;
  text-shadow:
    4px 0 #e77b3c,
    -4px 0 #6bd790,
    0 5px #24564b,
    7px 9px rgba(2, 16, 18, .72),
    0 0 32px rgba(255, 222, 92, .28);
}
.start-button {
  display: inline-flex; align-items: center; gap: 18px; padding: 15px 19px 15px 24px;
  border: 2px solid #fff39a; border-radius: 2px; color: #283415;
  background: linear-gradient(#ffe77a 0 48%, #f7b943 49% 100%);
  box-shadow: 0 5px 0 #9e5b2c, 0 9px 24px rgba(7,15,11,.4), inset 0 1px rgba(255,255,255,.8);
  font: 9px var(--pixel); text-transform: uppercase; cursor: pointer;
}
.start-button i { font-style: normal; font-size: 15px; }
.start-button:hover { transform: translateY(-2px); box-shadow: 0 7px 0 #9e5b2c, 0 11px 28px rgba(7,15,11,.48); }
.start-button:active { transform: translateY(3px); box-shadow: 0 2px 0 #9e5b2c; }
kbd { display: inline-grid; min-width: 25px; height: 24px; place-items: center; padding: 0 5px; border: 1px solid rgba(255,255,255,.35); border-radius: 3px; background: rgba(5,23,23,.72); box-shadow: inset 0 -2px rgba(0,0,0,.35); color: #fff; font: 8px var(--pixel); }

.result-card { left: 50%; top: 50%; width: min(400px, 82%); transform: translate(-50%, -50%); padding: 28px 32px; border: 1px solid rgba(255,231,122,.35); background: rgba(3,20,22,.9); box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.result-card[hidden] { display: none; }
.result-icon { margin-bottom: 12px; color: var(--gold); font-size: 42px; text-shadow: 0 0 25px var(--gold); }
.result-card h2 { margin: 0 0 12px; color: #fff4a0; font: 18px/1.45 var(--pixel); text-transform: uppercase; }
.result-card p:not(.eyebrow) { color: #c4dfd1; font-size: 14px; }
.final-score { display: block; margin: 19px 0; color: var(--muted); font: 8px var(--pixel); text-transform: uppercase; }
.final-score span { margin-left: 8px; color: #fff; }

.mobile-controls,
.mobile-controls * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}
.mobile-controls {
  display: none;
  position: absolute;
  z-index: 9;
  left: 18px;
  right: 18px;
  bottom: 16px;
  justify-content: space-between;
  pointer-events: none;
  overscroll-behavior: contain;
}
.mobile-controls button { pointer-events: auto; border: 1px solid rgba(255,255,255,.25); color: white; background: rgba(3,24,28,.64); backdrop-filter: blur(4px); touch-action: none; }
.dpad { display: flex; gap: 8px; }
.dpad button { width: 54px; height: 54px; font: 18px var(--pixel); }
.action-pad { display: flex; align-items: flex-end; gap: 8px; }
.jump-button { width: 68px; height: 68px; border-radius: 50%; font: 17px var(--pixel); }
.shoot-button { width: 54px; height: 54px; border-radius: 50%; font: 14px var(--pixel); border-color: rgba(255,126,190,.55) !important; }
.shoot-button.armed { color: #321529; background: #ff8fc4; box-shadow: 0 0 14px rgba(255,108,180,.55); }
.jump-button small, .shoot-button small { display: block; margin-top: 4px; font: 6px var(--pixel); }
.footer-note { padding-top: 14px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .03em; }
.status-dot { display: inline-block; width: 6px; height: 6px; margin-right: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 7px var(--green); }

dialog { max-width: 470px; width: calc(100% - 32px); padding: 30px; border: 1px solid rgba(112,237,149,.28); border-radius: 4px; color: var(--ink); background: #071d21; box-shadow: 0 25px 80px #000; }
dialog::backdrop { background: rgba(1,8,11,.78); backdrop-filter: blur(5px); }
dialog h2 { margin: 0 0 20px; font: 16px/1.5 var(--pixel); color: #fff2a0; }
dialog ul { padding-left: 20px; color: #c5ded1; line-height: 2; font-size: 14px; }
.dialog-close { position: absolute; top: 9px; right: 11px; border: 0; color: white; background: transparent; font-size: 25px; cursor: pointer; }

button:focus-visible, a:focus-visible { outline: 3px solid #fff09a; outline-offset: 3px; }
.playing .start-card { opacity: 0; visibility: hidden; transform: translate(-50%, -46%); transition: opacity .35s, transform .35s, visibility .35s; }

@media (max-width: 720px), (pointer: coarse) {
  .game-shell { padding: 8px 8px 14px; }
  .topbar { height: 54px; }
  .text-button { display: none; }
  .game-frame { aspect-ratio: 16 / 9; }
  .mobile-controls { display: flex; }
  .hud { top: 12px; left: 12px; right: 12px; }
  .hud-item { min-width: 68px; }
  .hud-item strong { font-size: 9px; }
  .hud-label { font-size: 5px; }
  .hud-power strong { font-size: 6px; }
  .logo-title { margin-bottom: 20px; font-size: clamp(26px, 7vw, 46px); }
  .start-card { top: 43%; }
  .footer-note span:last-child { display: none; }
  .game-shell:fullscreen .audio-button,
  .game-shell:-webkit-full-screen .audio-button,
  .game-shell.theater-mode .audio-button {
    display: none;
  }
  .game-shell:fullscreen .top-actions,
  .game-shell:-webkit-full-screen .top-actions,
  .game-shell.theater-mode .top-actions {
    gap: 0;
  }
  .game-shell:fullscreen .hud,
  .game-shell:-webkit-full-screen .hud,
  .game-shell.theater-mode .hud {
    right: 58px;
  }
  .game-shell:fullscreen .mobile-controls,
  .game-shell:-webkit-full-screen .mobile-controls,
  .game-shell.theater-mode .mobile-controls {
    right: max(12px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
    left: max(12px, env(safe-area-inset-left));
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
