:root {
  --ink: #fff7ea;
  --ink-dim: #d8c8b0;
  --panel: rgba(22, 16, 12, 0.86);
  --panel-edge: rgba(255, 210, 150, 0.18);
  --blue: #3d8bff;
  --red: #ff4a4a;
  --gold: #ffc94a;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #1a1410;
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

[hidden] { display: none !important; }

/* ── HUD ─────────────────────────────────────────────────────────────── */
#hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  padding: max(10px, env(safe-area-inset-top)) 12px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
  z-index: 5;
}
.hud-left, .hud-right { display: flex; gap: 8px; align-items: center; }
/* If space runs out, the badges on the left shrink (with "…") so the
   buttons on the right are never pushed off screen. */
.hud-left { min-width: 0; flex: 0 1 auto; }
.hud-left .pill { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
#hudLevel { display: block; }  /* block so the "…" can show */
.hud-right { pointer-events: auto; flex: 0 0 auto; }

.pill {
  font-family: 'Russo One', sans-serif;
  font-size: 14px;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.15);
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.coin {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff2b0, var(--gold) 55%, #b07a10);
  box-shadow: 0 0 6px rgba(255, 201, 74, 0.6);
  display: inline-block;
}

/* Level progress runs full width along the bottom of the screen, which
   leaves the top row room for the pills and buttons on narrow phones. */
.progress {
  position: fixed;
  left: max(16px, env(safe-area-inset-left));
  right: max(22px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  height: 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.15);
}
#progressFill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #6fd36f, #ffd04a);
}
.skull {
  position: absolute;
  right: -6px; top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  filter: drop-shadow(0 1px 2px #000);
}

.icon-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.45);
  color: var(--ink);
  font-size: 15px;
  cursor: pointer;
}
.icon-btn:active { transform: scale(0.94); }
.icon-btn.off { opacity: 0.45; }

/* Phones (up to Pro Max width): keep the top HUD row a notch tighter
   so the pills and 4 icon buttons fit comfortably. */
@media (max-width: 460px) {
  #hud { padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); gap: 6px; }
  .hud-left, .hud-right { gap: 5px; }
  .pill { padding: 6px 9px; font-size: 12px; gap: 4px; }
  .icon-btn { width: 32px; height: 32px; font-size: 13px; }
}

/* Squad count bubble that floats above the squad */
#badge {
  position: fixed;
  left: 0; top: 0;
  transform: translate(-50%, -100%);
  font-family: 'Russo One', sans-serif;
  font-size: 22px;
  padding: 4px 14px;
  border-radius: 10px;
  background: var(--blue);
  border: 2px solid #b9dbff;
  box-shadow: 0 4px 14px rgba(0, 40, 120, 0.5);
  pointer-events: none;
  z-index: 4;
  will-change: transform, left, top;
}
#badge::after {
  content: "";
  position: absolute;
  left: 50%; bottom: -8px;
  transform: translateX(-50%);
  border: 7px solid transparent;
  border-top-color: #b9dbff;
  border-bottom: 0;
}
#badge.bump { animation: bump 0.25s ease; }
@keyframes bump { 50% { transform: translate(-50%, -100%) scale(1.25); } }

/* Boss HP */
#bossbar {
  position: fixed;
  top: calc(max(10px, env(safe-area-inset-top)) + 50px);
  left: 50%;
  transform: translateX(-50%);
  width: min(420px, calc(100% - 32px));
  z-index: 5;
  pointer-events: none;
  text-align: center;
}
.bossname {
  font-family: 'Russo One', sans-serif;
  font-size: 13px;
  letter-spacing: 0.18em;
  color: #ffb3a8;
  text-shadow: 0 1px 3px #000;
  margin-bottom: 4px;
}
.track {
  height: 14px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 120, 100, 0.5);
  overflow: hidden;
}
#bossFill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ff3b3b, #ff8a3b);
  transition: width 0.1s linear;
}

/* Floating "+12" style popups */
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 6; overflow: hidden; }
.float {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: 'Russo One', sans-serif;
  font-size: 30px;
  color: #fff;
  -webkit-text-stroke: 1.5px rgba(0, 0, 0, 0.6);
  text-shadow: 0 3px 8px rgba(0, 0, 0, 0.5);
  animation: floatUp 1s ease-out forwards;
  white-space: nowrap;
}
.float.good { color: #8fd0ff; }
.float.bad { color: #ff8f8f; }
.float.gold { color: var(--gold); font-size: 22px; }
.float.big { font-size: 46px; }
@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.6); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -160%) scale(1); }
}

/* ── Overlay panels ──────────────────────────────────────────────────── */
#overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.25), rgba(0, 0, 0, 0.6));
  z-index: 10;
}
.panel {
  width: min(420px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 26px 22px 20px;
  border-radius: 20px;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5);
  text-align: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.panel h1 {
  font-family: 'Russo One', sans-serif;
  font-weight: 400;
  font-size: clamp(30px, 9vw, 44px);
  margin: 0 0 6px;
  letter-spacing: 0.03em;
  background: linear-gradient(180deg, #fff, #ffcf7a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
#pSub { margin: 0 0 14px; color: var(--ink-dim); font-size: 15px; line-height: 1.45; }
#pStats {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
#pStats:empty { display: none; }
.stat {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 8px 12px;
  min-width: 84px;
}
.stat b { display: block; font-family: 'Russo One', sans-serif; font-size: 20px; font-weight: 400; }
.stat span { font-size: 11px; color: var(--ink-dim); text-transform: uppercase; letter-spacing: 0.08em; }

#shop { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
#shop:empty { display: none; }
.shop-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-dim);
}
.shop-head .pill { font-size: 13px; padding: 5px 10px; }
.shop-row {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.07);
}
.shop-row .ico { font-size: 22px; width: 28px; text-align: center; }
.shop-row .txt { flex: 1; min-width: 0; }
.shop-row .txt b { display: block; font-size: 14px; }
.shop-row .txt span { font-size: 12px; color: var(--ink-dim); }
.buy {
  font-family: 'Russo One', sans-serif;
  font-size: 14px;
  border: 0;
  border-radius: 10px;
  padding: 8px 12px;
  background: var(--gold);
  color: #2a1a00;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.buy:disabled { background: #4a4036; color: #8a7d6c; cursor: default; }
.buy:not(:disabled):active { transform: scale(0.95); }

button.primary {
  font-family: 'Russo One', sans-serif;
  font-size: 22px;
  letter-spacing: 0.06em;
  width: 100%;
  padding: 14px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(180deg, #4f9bff, #2a64d8);
  color: #fff;
  box-shadow: 0 6px 0 #1b3f8a, 0 10px 24px rgba(40, 100, 220, 0.4);
  cursor: pointer;
}
button.primary:active { transform: translateY(3px); box-shadow: 0 3px 0 #1b3f8a; }
button.primary:disabled { opacity: 0.5; cursor: default; }
.hint { margin: 14px 0 0; font-size: 12px; color: var(--ink-dim); line-height: 1.5; }
.back-link {
  display: inline-block;
  margin-top: 10px;
  font-size: 12px;
  color: var(--ink-dim);
  background: none;
  border: 0;
  font-family: inherit;
  cursor: pointer;
  text-decoration: underline;
}
.back-link:hover { color: var(--ink); }

/* Buy Me a Coffee link on the overlay panels */
.support {
  display: inline-block;
  margin-top: 10px;
  font-size: 12px;
  color: var(--ink-dim);
  opacity: 0.75;
  text-decoration: none;
}
.support:hover { opacity: 1; color: var(--gold); }

/* YouTube link sits first and a touch louder than the coffee link */
.links { display: flex; justify-content: center; gap: 16px; flex-wrap: wrap; margin-top: 10px; }
.links .support { margin-top: 0; }
.yt { font-size: 13px; font-weight: 700; color: #ff6b6b; text-decoration: none; }
.yt:hover { color: #ff9a9a; text-decoration: underline; }

/* Difficulty picker */
#modes { margin-bottom: 14px; }
#modes:empty { display: none; }
#modes .shop-head { margin-bottom: 6px; }
.mode-skulls { font-size: 12px; letter-spacing: -1px; }
.modepick {
  display: flex;
  align-items: stretch;
  gap: 6px;
  border-radius: 12px;
  background: rgba(255, 201, 74, 0.1);
  border: 1px solid rgba(255, 201, 74, 0.45);
  padding: 4px;
}
.mode-step {
  flex: 0 0 40px;
  border: 0;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--gold);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}
.mode-step:disabled { opacity: 0.25; cursor: default; }
.mode-step:not(:disabled):active { transform: scale(0.94); }
.mode-cur { flex: 1; min-width: 0; text-align: center; padding: 6px 2px; }
.mode-cur b { display: block; font-family: 'Russo One', sans-serif; font-weight: 400; font-size: 15px; letter-spacing: 0.02em; color: var(--ink); }
.mode-cur span { font-size: 12px; color: var(--ink-dim); }

/* Back to the landing page + version label */
.panel { position: relative; }
.home-x {
  position: absolute;
  top: 12px; left: 12px;
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  color: var(--ink-dim);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  text-decoration: none;
}
.home-x:hover { color: var(--ink); background: rgba(255, 255, 255, 0.12); }
.ver { margin: 8px 0 0; font-size: 10px; color: var(--ink-dim); opacity: 0.5; letter-spacing: 0.04em; }
.ver:empty { display: none; }

/* Level / boss intro banner */
#banner {
  position: fixed;
  left: 50%; top: 26%;
  transform: translate(-50%, -50%);
  z-index: 7;
  pointer-events: none;
  text-align: center;
  width: min(92vw, 560px);
  animation: bannerIn 2.6s ease forwards;
}
#banner b {
  display: block;
  font-family: 'Russo One', sans-serif;
  font-weight: 400;
  font-size: clamp(30px, 8vw, 48px);
  letter-spacing: 0.04em;
  color: #fff;
  -webkit-text-stroke: 1.5px rgba(0, 0, 0, 0.55);
  text-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
}
#banner span {
  display: inline-block;
  margin-top: 6px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.5);
  padding: 5px 12px;
  border-radius: 999px;
}
#banner.boss b { color: #ff8f7a; }
#banner.tip b { color: #ffd36a; font-size: clamp(24px, 6vw, 34px); }
#banner.tip span { border-radius: 14px; max-width: 440px; line-height: 1.4; }
@keyframes bannerIn {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.7); }
  12% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
  20% { transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -60%); }
}

/* ── Cutscenes ───────────────────────────────────────────────────────────
   Short story beats drawn over the game: into the sewers (after level 5),
   the thank-you ending (EXIT) and endless mode (CONTINUE). */
.cutscene {
  position: fixed; inset: 0; z-index: 20; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 26px;
  padding: 24px; text-align: center; color: #fff7ea; cursor: pointer;
  animation: cs-in .4s ease both; transition: opacity .45s ease;
}
.cutscene.out { opacity: 0; }
@keyframes cs-in { from { opacity: 0; } }
.cs-text { position: relative; z-index: 2; }
.cs-text b { display: block; font-family: 'Russo One', sans-serif; font-size: clamp(30px, 8vw, 54px); letter-spacing: .03em; }
.cs-text span { display: block; margin-top: 10px; font-size: clamp(15px, 4vw, 19px); line-height: 1.5; opacity: .9; }
.cs-text em { font-style: normal; font-size: .85em; opacity: .8; }
.cs-skip { position: absolute; bottom: max(16px, env(safe-area-inset-bottom)); font-size: 12px; opacity: .5; animation: cs-in .5s ease 1.2s both; }
.cs-stage { position: relative; width: 320px; height: 170px; }
.cs-trooper { position: absolute; width: 14px; height: 24px; }
.cs-trooper::before { content: ''; position: absolute; left: 3px; top: 0; width: 8px; height: 8px; border-radius: 50%; background: #1d3f7a; }
.cs-trooper::after { content: ''; position: absolute; left: 1px; top: 7px; width: 12px; height: 17px; border-radius: 5px 5px 3px 3px;
  background: #3d8bff; box-shadow: 0 0 8px rgba(61,139,255,.8); }

/* Into the sewers: the manhole opens, the squad drops in one by one, the
   green glow swells and the screen closes in. */
.cut-sewers { background: radial-gradient(circle at 50% 45%, #2a2420 0%, #0c0a08 75%); }
.cut-sewers::after { content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle at 50% 38%, transparent 0%, transparent 18%, #000 60%);
  opacity: 0; animation: cs-close 1.2s ease 2.6s forwards; }
@keyframes cs-close { to { opacity: .92; } }
.cs-street { position: absolute; left: 0; right: 0; bottom: 0; height: 90px; border-radius: 8px;
  background: linear-gradient(#4a4440, #2e2a28); box-shadow: inset 0 2px 0 #6a625a; }
.cs-hole { position: absolute; left: 110px; bottom: 30px; width: 100px; height: 34px; border-radius: 50%;
  background: radial-gradient(ellipse at 50% 40%, #6aff3a 0%, #1f5a10 35%, #050805 70%);
  box-shadow: 0 0 0 4px #1a1816; animation: cs-glow 1.6s ease-in-out .8s infinite alternate; }
@keyframes cs-glow { to { box-shadow: 0 0 0 4px #1a1816, 0 0 40px 10px rgba(106,255,58,.45); } }
.cs-cover { position: absolute; left: 106px; bottom: 32px; width: 108px; height: 34px; border-radius: 50%;
  background: repeating-linear-gradient(90deg, #6a645c 0 9px, #4a4640 9px 12px); box-shadow: 0 3px 0 #2a2622;
  animation: cs-cover .7s cubic-bezier(.5,0,.3,1) .3s both; }
@keyframes cs-cover { to { transform: translate(120px, 6px) rotate(18deg); } }
.cut-sewers .cs-trooper { left: -30px; bottom: 44px; opacity: 0;
  animation: cs-drop 1s ease-in calc(.9s + var(--i) * .2s) both; }
@keyframes cs-drop {
  0% { opacity: 1; transform: translateX(0); }
  65% { opacity: 1; transform: translateX(185px) translateY(0); }
  100% { opacity: 0; transform: translateX(185px) translateY(26px) scale(.3); } }
.cut-sewers .cs-text { opacity: 0; animation: cs-rise 1s ease 3.2s both; }
.cut-sewers .cs-text b { color: #8aff5a; text-shadow: 0 0 22px rgba(106,255,58,.55); }
@keyframes cs-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; } }

/* The ending: confetti, a cheering squad, and a thank-you. */
.cut-thanks { background: radial-gradient(circle at 50% 40%, #3a1410 0%, #120404 75%); color: #3a2400; }
/* Dawn breaks after the story captions. */
.cs-dawn { position: absolute; inset: 0; background: radial-gradient(circle at 50% 40%, #fff6dc 0%, #ffd987 45%, #d98a2a 100%);
  opacity: 0; animation: cs-dawn 1.4s ease 4.6s forwards; }
@keyframes cs-dawn { to { opacity: 1; } }
.cut-thanks .cs-text b { color: #fff; text-shadow: 0 3px 0 #a0601a, 0 0 30px rgba(255,255,255,.8); animation: cs-pop .7s cubic-bezier(.2,1.5,.4,1) 5.3s both; }
.cut-thanks .cs-text span { animation: cs-rise .8s ease 6.1s both; }
.cut-thanks .cs-cheer { animation: cs-rise .6s ease 5.6s both; }
@keyframes cs-pop { from { opacity: 0; transform: scale(.4); } }
.cs-confetti { position: absolute; top: -20px; width: 9px; height: 14px; background: var(--c); transform: rotate(var(--r));
  animation: cs-fall var(--t) linear var(--d) infinite; }
@keyframes cs-fall { to { transform: translateY(110vh) rotate(calc(var(--r) + 540deg)); } }
.cs-cheer { height: 40px; width: 240px; }
.cs-cheer .cs-trooper { bottom: 0; left: calc(var(--i) * 34px + 8px); animation: cs-hop .5s ease-in-out calc(var(--i) * .07s) infinite alternate; }
@keyframes cs-hop { to { transform: translateY(-16px); } }

/* Endless mode: the screen catches fire. */
.cut-continue { background: radial-gradient(circle at 50% 80%, #7a1a08 0%, #2a0604 60%, #0a0202 100%); animation: cs-in .4s ease both, cs-quake .5s linear .2s 2; }
@keyframes cs-quake { 25% { transform: translate(-6px, 3px); } 50% { transform: translate(5px, -4px); } 75% { transform: translate(-3px, -2px); } }
.cs-flame { position: absolute; bottom: -60px; width: 22vw; height: 40vh; margin-left: -11vw; border-radius: 50% 50% 40% 40%;
  background: radial-gradient(ellipse at 50% 80%, rgba(255,210,90,.9), rgba(255,90,20,.6) 40%, transparent 70%);
  transform-origin: 50% 100%; animation: cs-flicker .6s ease-in-out var(--d) infinite alternate; filter: blur(4px); }
@keyframes cs-flicker { from { transform: scaleY(calc(var(--s) * .7)); opacity: .7; } to { transform: scaleY(var(--s)) scaleX(.9); opacity: 1; } }
.cut-continue .cs-text b { color: #ffcf5a; text-shadow: 0 0 24px rgba(255,120,30,.8), 0 4px 0 #6a1404; animation: cs-slam .5s cubic-bezier(.2,1.5,.4,1) 4.9s both; }
.cut-continue .cs-text span { animation: cs-rise .8s ease 5.5s both; }
@keyframes cs-slam { from { opacity: 0; transform: scale(2.2) rotate(-4deg); } }

@media (prefers-reduced-motion: reduce) {
  .cutscene *, .cutscene::after { animation-duration: .01s !important; animation-iteration-count: 1 !important; }
}

/* Intro (before level 1): the horde marches across a city whose lights go
   out, then the squad steps in. */
.cut-intro { background: linear-gradient(#3a0a0a 0%, #6a1a10 45%, #1a0806 100%); justify-content: flex-start; padding-top: 14vh; }
.cs-city { position: absolute; left: 0; right: 0; bottom: 18%; height: 55%; }
.cs-tower { position: absolute; bottom: 0; background: #120606;
  box-shadow: inset 0 0 0 1px #000; }
.cs-tower::after { content: ''; position: absolute; inset: 8% 14% 4%;
  background: repeating-linear-gradient(0deg, transparent 0 7px, rgba(255,190,90,.75) 7px 11px),
              repeating-linear-gradient(90deg, transparent 0 5px, #120606 5px 9px);
  animation: cs-lightsout .5s steps(2) var(--d) forwards; }
@keyframes cs-lightsout { to { opacity: .06; } }
.cs-ground { position: absolute; left: 0; right: 0; bottom: 0; height: 18%; background: linear-gradient(#1a0a08, #0a0404); }
.cs-zombie { position: absolute; left: 0; width: calc(12px * var(--s)); height: calc(22px * var(--s));
  transform: translateX(110vw); animation: cs-march var(--t) linear var(--d) both; }
.cs-zombie::before { content: ''; position: absolute; left: 20%; top: 0; width: 60%; height: 34%; background: #9ec074;
  animation: cs-bob .35s ease-in-out infinite alternate; }
.cs-zombie::after { content: ''; position: absolute; left: 0; top: 30%; width: 100%; height: 70%; border-radius: 3px; background: var(--c);
  box-shadow: calc(-5px * var(--s)) calc(-3px * var(--s)) 0 calc(-2px * var(--s)) #9ec074; /* arms reaching forward */
  animation: cs-bob .35s ease-in-out infinite alternate-reverse; }
@keyframes cs-march { from { transform: translateX(110vw); } to { transform: translateX(-20vw); } }
@keyframes cs-bob { to { transform: translateY(-2px); } }
.cs-caption { position: absolute; z-index: 2; top: 16vh; color: #fff7ea; left: 0; right: 0; font-size: clamp(17px, 4.6vw, 24px); font-weight: 600;
  opacity: 0; text-shadow: 0 2px 8px #000; }
.cs-caption.c1 { animation: cs-caption 2.2s ease .3s both; }
.cs-caption.c2 { animation: cs-caption 2.2s ease 2.6s both; }
@keyframes cs-caption { 0% { opacity: 0; transform: translateY(8px); } 20%, 80% { opacity: 1; transform: none; } 100% { opacity: 0; } }
.cut-intro .cs-text { animation: cs-slam .5s cubic-bezier(.2,1.5,.4,1) 4.9s both; }
.cut-intro .cs-text b { color: #ff5a4a; text-shadow: 0 0 26px rgba(255,60,40,.6), 0 4px 0 #3a0404; line-height: 1.05; }
.cut-intro .cs-text span { animation: cs-rise .8s ease 5.6s both; }
.cs-squad { position: absolute; z-index: 3; bottom: 3%; left: 0; width: 220px; height: 50px; filter: drop-shadow(0 0 8px rgba(61,139,255,.9)); animation: cs-squadin 1s ease-out 5.4s both; }
.cs-squad .cs-trooper { bottom: 0; left: calc(var(--i) * 38px); transform: scale(2.1); transform-origin: bottom left; }
@keyframes cs-squadin { from { transform: translateX(-220px); } to { transform: translateX(8vw); } }

/* ── Music menu + "music by Jeff" credit ─────────────────────────────── */
#musicMenu {
  position: fixed; z-index: 30; width: 250px; padding: 10px;
  background: var(--panel); border: 1px solid var(--panel-edge); border-radius: 16px;
  box-shadow: 0 18px 40px -12px rgba(0,0,0,.7); backdrop-filter: blur(6px);
}
#musicMenu[hidden] { display: none; }
.mm-head { font-family: 'Russo One', sans-serif; font-size: 12px; letter-spacing: .14em; color: var(--ink-dim); margin: 2px 4px 8px; }
.mm-opt {
  display: flex; align-items: center; gap: 10px; width: 100%; margin-bottom: 6px; padding: 8px 10px;
  border-radius: 12px; border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.04);
  color: var(--ink); text-align: left; cursor: pointer; font-family: inherit;
}
.mm-opt.on { border-color: var(--gold); background: rgba(255,201,74,.14); }
.mm-ico { font-size: 20px; width: 26px; text-align: center; }
.mm-txt b { display: block; font-size: 14px; }
.mm-txt small { display: block; font-size: 11.5px; color: var(--ink-dim); }
.mm-yt { display: block; margin: 4px 4px 2px; font-size: 12px; color: #ff6a5a; text-decoration: none; font-weight: 600; line-height: 1.35; }
.mm-yt:hover { text-decoration: underline; }

#nowPlaying {
  position: fixed; z-index: 6; left: max(12px, env(safe-area-inset-left)); bottom: calc(max(14px, env(safe-area-inset-bottom)) + 22px);
  display: flex; align-items: center; gap: 8px; max-width: calc(100vw - 24px);
  padding: 7px 12px; border-radius: 999px; background: rgba(0,0,0,.55); border: 1px solid rgba(255,255,255,.15);
  color: var(--ink); font-size: 12.5px; text-decoration: none; animation: np-in .4s ease both;
}
#nowPlaying[hidden] { display: none; }
#nowPlaying b { color: var(--gold); }
#nowPlaying .np-note { color: var(--gold); font-size: 15px; animation: np-bob .8s ease-in-out infinite alternate; }
#nowPlaying.np-out { opacity: 0; transform: translateY(8px); transition: opacity .45s ease, transform .45s ease; }
@keyframes np-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes np-bob { to { transform: translateY(-3px); } }

/* Music choice on the menu */
.musicpick { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.mp-label { font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-dim); margin-right: 2px; }
.mp-opt { flex: 1; padding: 7px 4px; border-radius: 10px; border: 1px solid rgba(255,255,255,.14); background: rgba(255,255,255,.04);
  color: var(--ink); font: 600 12.5px Inter, sans-serif; cursor: pointer; white-space: nowrap; }
.mp-opt.on { border-color: var(--gold); background: rgba(255,201,74,.16); }
.mp-credit { display: block; margin-top: 6px; font-size: 11.5px; color: #ff6a5a; text-decoration: none; font-weight: 600; }
.mp-credit:hover { text-decoration: underline; }

/* Skill unlock card (after the level 5 boss) */
.cut-skill-squeeze { background: radial-gradient(circle at 50% 40%, #16301a 0%, #07100a 75%); }
.cs-unlock { font: 800 13px/1 Inter, sans-serif; letter-spacing: .3em; text-transform: uppercase; color: #8aff5a;
  animation: cs-rise .6s ease .2s both; }
.cs-sq-demo { display: flex; align-items: center; gap: 22px; height: 170px; animation: cs-rise .6s ease .4s both; }
.cs-sq-squad { position: relative; width: 90px; height: 170px; }
.cs-sq-squad .cs-trooper { left: 38px; top: 73px; animation: cs-squeeze 3.2s ease-in-out .9s infinite; transform: translate(var(--gx), var(--gy)); }
@keyframes cs-squeeze {
  0%, 15% { transform: translate(var(--gx), var(--gy)); }
  45%, 65% { transform: translate(var(--cx), var(--cy)); }
  95%, 100% { transform: translate(var(--gx), var(--gy)); } }
.cs-sq-arrow { font-size: 26px; color: #8aff5a; opacity: .35; }
.cs-sq-arrow.up { animation: cs-arrow 3.2s ease-in-out .9s infinite; }
.cs-sq-arrow.down { animation: cs-arrow 3.2s ease-in-out 2.5s infinite; }
@keyframes cs-arrow { 0%, 10% { opacity: .35; transform: none; } 22% { opacity: 1; transform: scale(1.3); } 40%, 100% { opacity: .35; transform: none; } }
.cut-skill-squeeze .cs-text b { color: #8aff5a; text-shadow: 0 0 22px rgba(106,255,58,.5); animation: cs-slam .5s cubic-bezier(.2,1.5,.4,1) .6s both; }
.cut-skill-squeeze .cs-text span { animation: cs-rise .8s ease 1.1s both; max-width: 520px; margin-left: auto; margin-right: auto; }
.cut-skill-squeeze .cs-text span b.hl { display: inline; font-family: inherit; font-size: inherit; letter-spacing: 0; color: #8aff5a; text-shadow: none; animation: none; }

/* Hidden debug menu (tap the title 5 times on the main menu) */
#debugMenu { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.6); padding: 12px; }
#debugMenu[hidden] { display: none; }
.dbg-card { width: min(520px, 100%); max-height: calc(100dvh - 24px); overflow-y: auto; background: #12161f; color: #e6ebf5;
  border: 1px solid #3a4560; border-radius: 14px; padding: 14px; font: 13px/1.35 Inter, sans-serif; }
.dbg-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.dbg-head b { font-family: 'Russo One', sans-serif; letter-spacing: .2em; color: #7fd4ff; }
.dbg-x { background: none; border: 1px solid #3a4560; color: #e6ebf5; border-radius: 8px; width: 30px; height: 30px; cursor: pointer; }
.dbg-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-bottom: 10px; }
.dbg-lv { background: #1c2333; border: 1px solid #3a4560; color: #e6ebf5; border-radius: 8px; padding: 6px 4px; cursor: pointer; text-align: center; }
.dbg-lv b { display: block; font-size: 16px; color: #ffc94a; }
.dbg-lv span { display: block; font-size: 9.5px; color: #9aa6c0; line-height: 1.25; }
.dbg-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0; }
.dbg-row input[type=number] { width: 72px; background: #0b0e14; color: #fff; border: 1px solid #3a4560; border-radius: 6px; padding: 4px 6px; }
.dbg-go { width: 100%; margin: 8px 0; padding: 10px; border: 0; border-radius: 10px; background: #3d8bff; color: #fff; font: 700 15px Inter, sans-serif; cursor: pointer; }
.dbg-cuts button { background: #1c2333; border: 1px solid #3a4560; color: #c8d0e0; border-radius: 6px; padding: 4px 8px; cursor: pointer; font-size: 12px; }

/* Act titles (ACT I — TO THE STREETS, …) */
.cs-act { position: absolute; z-index: 3; top: 7vh; left: 0; right: 0; font: 800 clamp(12px, 3.4vw, 15px)/1 Inter, sans-serif;
  letter-spacing: .32em; color: #ffc94a; text-shadow: 0 2px 8px #000; animation: cs-rise .8s ease both; }
.cs-act span { opacity: .6; letter-spacing: 0; margin: 0 .3em; }

/* Act III: up out of the sewers toward a rift in the sky */
.cut-sky { background: linear-gradient(#1a0f3a 0%, #3a2a6a 40%, #6a8acc 75%, #2a2a2a 100%); }
.cs-rift { position: absolute; left: 50%; top: 22%; width: 70vw; max-width: 520px; height: 8px; margin-left: min(-35vw, -260px);
  border-radius: 50%; background: #e8d0ff; box-shadow: 0 0 30px 12px #b48aff, 0 0 90px 30px rgba(180,138,255,.5);
  transform: rotate(-8deg) scaleX(.2); animation: cs-rift 2s ease-out .4s forwards; }
@keyframes cs-rift { to { transform: rotate(-8deg) scaleX(1); } }
.cs-skyline { position: absolute; left: 0; right: 0; bottom: 0; height: 14%; background: linear-gradient(#2a2420, #0c0a08); }
.cs-rise { position: absolute; left: 50%; bottom: 10%; width: 260px; height: 40px; margin-left: -130px; z-index: 2;
  animation: cs-ascend 3.6s cubic-bezier(.5,0,.4,1) 2.2s both; }
.cs-rise .cs-trooper { bottom: 0; left: calc(var(--i) * 36px + 10px); transform: scale(1.6); transform-origin: bottom center; }
.cs-rise .cs-trooper:nth-child(odd) { bottom: 14px; }
.cs-rise .cs-trooper::before { box-shadow: 0 30px 0 2px rgba(255,176,58,.0); }
.cs-rise .cs-trooper { filter: drop-shadow(0 10px 6px #ffb03a); }
@keyframes cs-ascend { from { transform: translateY(0); } to { transform: translateY(-46vh); opacity: .9; } }
.cut-sky .cs-text { animation: cs-slam .5s cubic-bezier(.2,1.5,.4,1) 5.1s both; }
.cut-sky .cs-text b { color: #e8d0ff; text-shadow: 0 0 26px rgba(180,138,255,.8), 0 4px 0 #2a1a5a; line-height: 1.05; }
.cut-sky .cs-text span { animation: cs-rise .8s ease 5.8s both; }

/* Flight card (first time through level 10) */
.cut-skill-flight { background: radial-gradient(circle at 50% 40%, #3a5a9a 0%, #101a36 75%); }
.cs-fly-demo { position: relative; width: 180px; height: 150px; animation: cs-rise .6s ease .4s both; }
.cs-fly-squad { position: absolute; left: 50%; top: 50%; animation: cs-fly 4s ease-in-out .9s infinite; }
.cs-fly-squad .cs-trooper { left: calc(var(--gx) - 7px); top: calc(var(--gy) - 12px); filter: drop-shadow(0 6px 4px #ffb03a); }
@keyframes cs-fly { 0%, 100% { transform: translate(0, 0); } 25% { transform: translate(0, -38px); } 50% { transform: translate(44px, 0); } 75% { transform: translate(0, 34px); } }
.cs-fly-a { position: absolute; font-size: 20px; color: #9fd6ff; opacity: .5; }
.cs-fly-a.up { left: 50%; top: -8px; margin-left: -10px; } .cs-fly-a.down { left: 50%; bottom: -8px; margin-left: -10px; }
.cs-fly-a.left { left: -10px; top: 50%; margin-top: -12px; } .cs-fly-a.right { right: -10px; top: 50%; margin-top: -12px; }
.cut-skill-flight .cs-unlock { color: #9fd6ff; }
.cut-skill-flight .cs-text b { color: #9fd6ff; text-shadow: 0 0 22px rgba(120,190,255,.6); animation: cs-slam .5s cubic-bezier(.2,1.5,.4,1) .6s both; }
.cut-skill-flight .cs-text span { animation: cs-rise .8s ease 1.1s both; max-width: 540px; margin-left: auto; margin-right: auto; }
.cut-skill-flight .cs-text span b.hl { display: inline; font-family: inherit; font-size: inherit; letter-spacing: 0; color: #9fd6ff; text-shadow: none; animation: none; }
