:root {
  --bg: #050816;
  --panel: rgba(12, 16, 40, .92);
  --line: #26306a;
  --text: #eef3ff;
  --muted: #9aa6d0;
  --accent: #22e6ff;
  --accent2: #ff3ea5;
  --good: #9dff3a;
  --warn: #ffc81f;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden; overscroll-behavior: none; touch-action: none;
  -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none;
}
[hidden] { display: none !important; }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

/* Buttons */
.btn {
  appearance: none; border: 1px solid var(--line); background: #0c1236; color: var(--text);
  font: inherit; font-weight: 800; padding: 14px 20px; border-radius: 14px; cursor: pointer; min-height: 50px;
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none; width: 100%;
}
.btn:active { transform: translateY(1px); }
.btn.primary {
  border: 0; color: #050816; font-size: 19px; letter-spacing: .04em;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  box-shadow: 0 0 26px color-mix(in srgb, var(--accent) 55%, transparent);
}
.btn + .btn { margin-top: 8px; }
.icon-btn {
  appearance: none; border: 1px solid var(--line); background: rgba(10, 14, 36, .7); color: var(--text);
  width: 40px; height: 40px; border-radius: 12px; font: inherit; font-size: 16px; font-weight: 800; cursor: pointer;
  display: grid; place-items: center; pointer-events: auto;
}
#sound::before { content: "🔊"; }
#sound[aria-pressed="false"]::before { content: "🔇"; }

/* Screens */
.overlay {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; overflow-y: auto; z-index: 5;
  background: radial-gradient(70% 50% at 50% 0%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%),
              radial-gradient(60% 45% at 50% 100%, color-mix(in srgb, var(--accent2) 18%, transparent), transparent 70%),
              rgba(3, 5, 14, .72);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
.card {
  width: min(420px, 100%); text-align: center; background: var(--panel); border: 1px solid var(--line);
  border-radius: 22px; padding: 22px 18px; box-shadow: 0 0 44px color-mix(in srgb, var(--accent) 22%, transparent);
}
.brand { letter-spacing: .3em; text-transform: uppercase; font-size: 12px; color: var(--muted); margin: 0 0 6px; }
h1 {
  font-size: clamp(40px, 12vw, 62px); line-height: 1; margin: 0 0 8px; font-weight: 900; letter-spacing: -.02em;
  background: linear-gradient(90deg, var(--accent), #fff 50%, var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 16px color-mix(in srgb, var(--accent) 60%, transparent));
}
h2 { font-size: 30px; margin: 0 0 8px; font-weight: 900; }
.tag { color: var(--muted); margin: 0 0 16px; }
.how { text-align: left; color: var(--muted); font-size: 14px; padding-left: 20px; margin: 0 0 16px; }
.how li { margin: 5px 0; }
.how b { color: var(--text); }
.note { color: var(--muted); font-size: 13px; margin: 12px 0 0; min-height: 1.2em; }
.best { color: var(--warn); font-weight: 800; margin: 0 0 12px; }
.score-big { font-size: 56px; font-weight: 900; margin: 0; color: #fff; text-shadow: 0 0 22px var(--accent); font-variant-numeric: tabular-nums; }
.final-best { color: var(--muted); margin: 0 0 12px; font-weight: 700; }
.final-best.new { color: var(--warn); }
.stats { list-style: none; padding: 0; margin: 0 0 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.stats li { background: #0a0f2e; border: 1px solid var(--line); border-radius: 12px; padding: 8px; font-size: 13px; color: var(--muted); }
.stats b { display: block; color: var(--text); font-size: 18px; }
.more { margin: 14px 0 0; font-size: 13px; color: var(--muted); }
.more a { color: var(--accent); }
.seg { display: flex; gap: 4px; background: #0a0f2e; border: 1px solid var(--line); border-radius: 12px; padding: 3px; margin: 0 0 10px; }
.seg button { flex: 1; appearance: none; border: 0; background: none; color: var(--muted); font: inherit; font-weight: 800; padding: 9px; border-radius: 9px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--line); color: var(--text); box-shadow: inset 0 0 0 1px var(--accent); }

/* In-game */
.hud {
  position: fixed; left: 0; right: 0; top: 0; z-index: 3; pointer-events: none;
  display: flex; align-items: flex-start; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 12px 8px;
  font-weight: 800; text-shadow: 0 0 10px rgba(0, 0, 0, .8);
}
.hud .grow { flex: 1; }
.hud .stat { display: flex; flex-direction: column; line-height: 1.1; }
.hud .stat small { font-size: 10px; letter-spacing: .16em; color: var(--muted); text-transform: uppercase; }
.hud .stat b { font-size: 22px; font-variant-numeric: tabular-nums; }
.hud .btns { display: flex; gap: 6px; }
.banner {
  position: fixed; left: 50%; top: 30%; transform: translate(-50%, -50%); z-index: 4; pointer-events: none;
  font-size: clamp(26px, 8.5vw, 64px); font-weight: 900; text-align: center; white-space: normal; width: max-content; max-width: 92vw; line-height: 1.05;
  color: #fff; text-shadow: 0 0 24px var(--accent), 0 0 4px var(--accent);
}
.banner small { display: block; font-size: 15px; font-weight: 700; color: var(--text); text-shadow: 0 0 8px #000; margin-top: 6px; white-space: normal; }
.banner.pop { animation: pop .45s ease-out; }
@keyframes pop { 0% { transform: translate(-50%, -50%) scale(.5); opacity: 0; } 70% { transform: translate(-50%, -50%) scale(1.08); } 100% { transform: translate(-50%, -50%) scale(1); opacity: 1; } }
.lock-hint {
  position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom)); transform: translateX(-50%); margin: 0; z-index: 4;
  padding: 8px 14px; border-radius: 999px; background: rgba(10, 14, 36, .88); border: 1px solid var(--line);
  font-size: 13px; white-space: nowrap; pointer-events: none;
}

/* Game picker (local preview page) */
body.picker { display: grid; place-items: center; overflow: auto; touch-action: auto; }
.pick { width: min(360px, 92vw); text-align: center; }
.pick .btn { margin-top: 10px; }

/* HUD pieces used by the games */
.hud .center { display: flex; flex-direction: column; align-items: center; gap: 2px; padding-top: 2px; }
.hud .combo { color: var(--warn); font-size: 16px; }
.hud .power { color: var(--accent); font-size: 13px; letter-spacing: .12em; }
.hud .lives b { color: #ff5470; letter-spacing: .05em; }
.hud .bars { display: grid; gap: 5px; align-content: start; padding-top: 3px; max-width: 220px; margin-left: auto; }
.bar { display: flex; align-items: center; gap: 6px; font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.bar span { width: 46px; }
.bar i { flex: 1; height: 8px; border-radius: 99px; background: rgba(255, 255, 255, .1); overflow: hidden; display: block; min-width: 70px; }
.bar u { display: block; height: 100%; width: 100%; border-radius: 99px; background: var(--good); box-shadow: 0 0 10px var(--good); transition: width .15s; }
.bar.heat u { background: var(--warn); box-shadow: 0 0 10px var(--warn); }
.bar.heat.hot u { background: #ff3355; box-shadow: 0 0 12px #ff3355; }
.bar.heat.hot span { color: #ff3355; }

/* Upgrade picker (TurretTower) */
.shop-cards { display: grid; gap: 8px; }
.shop-card {
  appearance: none; text-align: left; font: inherit; color: var(--text); cursor: pointer;
  background: #0a0f2e; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px;
  display: grid; grid-template-columns: 40px 1fr; gap: 2px 12px; align-items: center;
}
.shop-card:hover, .shop-card:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 16px color-mix(in srgb, var(--accent) 45%, transparent); }
.shop-card .ico { grid-row: span 2; font-size: 26px; text-align: center; }
.shop-card b { font-size: 16px; }
.shop-card small { color: var(--muted); font-size: 13px; }

/* Nova button (SpaceHero) */
.nova {
  position: fixed; right: calc(14px + env(safe-area-inset-right)); bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 3;
  width: 78px; height: 78px; border-radius: 50%; border: 2px solid var(--accent2); background: rgba(10, 8, 30, .75);
  color: #fff; font: 900 13px system-ui, sans-serif; letter-spacing: .1em; cursor: pointer; overflow: hidden; padding: 0;
}
.nova i { position: absolute; left: 0; right: 0; bottom: 0; height: 0%; background: color-mix(in srgb, var(--accent2) 55%, transparent); }
.nova span { position: relative; }
.nova.ready { box-shadow: 0 0 24px var(--accent2); animation: throb 1s ease-in-out infinite; }
.nova:disabled { opacity: .55; cursor: default; }
@keyframes throb { 50% { transform: scale(1.06); } }

/* Arcade: one page, three modes, each with its own colors */
body[data-mode="skyrange"] { --accent: #ff9a5c; --accent2: #ff3ea5; }
body[data-mode="turrettower"] { --accent: #ff8a1f; --accent2: #22e6ff; }
body[data-mode="spacehero"] { --accent: #9dff3a; --accent2: #b86bff; }
.mode-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 4px 0 14px; }
.mode-tabs button {
  appearance: none; font: inherit; font-size: 13px; font-weight: 800; color: var(--muted); cursor: pointer;
  background: #0a0f2e; border: 1px solid var(--line); border-radius: 12px; padding: 8px 4px; display: grid; gap: 2px; justify-items: center;
}
.mode-tabs .ico { font-size: 20px; }
.mode-tabs button[aria-pressed="true"] { color: var(--text); border-color: var(--accent); box-shadow: 0 0 14px color-mix(in srgb, var(--accent) 45%, transparent); }
.mode-extra { text-align: left; margin: 0 0 12px; }
.pick-label { margin: 6px 0 6px; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); font-weight: 800; }
.gun-desc { color: var(--muted); font-size: 13px; margin: -4px 0 8px; }
.levels { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; margin-bottom: 8px; }
.level {
  appearance: none; font: inherit; color: var(--text); cursor: pointer; background: #0a0f2e; border: 1px solid var(--line);
  border-radius: 10px; padding: 5px 0 3px; display: grid; justify-items: center; line-height: 1.1;
}
.level b { font-size: 16px; }
.level small { font-size: 9px; color: var(--warn); letter-spacing: -.05em; min-height: 1em; }
.level[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.level:disabled { opacity: .45; cursor: default; }
.hud-mode { display: flex; align-items: flex-start; gap: 10px; flex: 1; min-width: 0; }
.hud .btns { margin-left: auto; }
.gun-bar {
  position: fixed; left: 0; right: 0; bottom: 0; flex: none; align-items: center; justify-content: center; gap: 10px;
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
}
.gun-name { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.ammo { font-size: 15px; letter-spacing: .08em; color: var(--warn); min-width: 4em; }
.act-btn {
  pointer-events: auto; appearance: none; font: inherit; font-weight: 800; color: var(--text); cursor: pointer;
  background: rgba(10, 14, 36, .8); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; min-height: 44px;
}
.act-btn:disabled { opacity: .4; cursor: default; }
.act-btn.fire { position: fixed; right: calc(14px + env(safe-area-inset-right)); bottom: calc(70px + env(safe-area-inset-bottom)); width: 84px; height: 84px; border-radius: 50%; border: 2px solid var(--accent2); font-size: 16px; }
.nova { pointer-events: auto; }
