/* =========================================================
   Super Paid ($SAID) — side-scrolling meme adventure
   ========================================================= */

:root {
  --navy: #0b2a8a;
  --navy-deep: #040e34;
  --ink: #1b1b2f;
  --gold: #ffcc33;
  --gold-light: #fff1a8;
  --gold-dark: #c98a0b;
  --red: #e3171b;
  --red-dark: #9e0b0e;
  --cream: #fffaf0;

  /* Set by game.js on load / resize */
  --vh: 100vh;
  --hud: 64px;
  --base: 120px;
  --avail: 500px;
  --heroH: 130px;
  --heroW: 107px;
  --frameH: 240px;
  --fly: -1200px;

  --pixel: "Press Start 2P", monospace;
  --display: "Russo One", "Inter", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html { scrollbar-width: none; }
html::-webkit-scrollbar { display: none; }

body {
  font-family: "Inter", system-ui, sans-serif;
  color: #fff;
  background: var(--navy-deep);
  overscroll-behavior: none;
}

button { font: inherit; color: inherit; cursor: pointer; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: 3px solid #1b1200;
  border-radius: 12px;
  font-family: var(--display);
  font-size: 15px;
  letter-spacing: .5px;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 4px 0 #1b1200;
  transition: transform .1s ease, box-shadow .1s ease, filter .15s ease;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #1b1200; }
.btn svg { width: 18px; height: 18px; }
.btn-buy {
  color: #2a1600;
  background: linear-gradient(180deg, var(--gold-light) 0%, var(--gold) 45%, var(--gold-dark) 100%);
}
.btn-x { color: #fff; background: #000; }
.btn-ghost { color: var(--ink); background: #fff; }
.btn-icon { padding: 10px; }
.btn-sm { padding: 8px 14px; font-size: 13px; }

:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

/* ---------- HUD ---------- */
.hud {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--hud);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  background: linear-gradient(180deg, rgba(4, 14, 52, .92), rgba(4, 14, 52, .7));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 3px solid rgba(255, 204, 51, .55);
}
.hud-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}
.hud-brand img {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 2px solid var(--gold);
}
.hud-name {
  font-family: var(--display);
  font-size: 20px;
  background: linear-gradient(180deg, var(--gold-light), var(--gold) 50%, var(--gold-dark));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hud-coins {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  font-family: var(--pixel);
  font-size: 12px;
  color: var(--gold);
  background: rgba(0, 0, 0, .35);
  border-radius: 999px;
}
.hud-coins-total { color: rgba(255, 255, 255, .5); }
.coin-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--gold-light), var(--gold) 50%, var(--gold-dark));
  border: 2px solid #8a5a00;
}
.hud-coins.bump { animation: bump .3s ease; }

.hud-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.ca-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px 4px 4px 12px;
  background: rgba(0, 0, 0, .45);
  border: 2px solid var(--gold);
  border-radius: 999px;
  min-width: 0;
}
.ca-tag { font-family: var(--pixel); font-size: 9px; color: var(--gold); }
.ca-pill code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ca-copy {
  padding: 7px 10px;
  font-family: var(--pixel);
  font-size: 9px;
  color: #2a1600;
  background: var(--gold);
  border-radius: 999px;
  transition: background .2s;
}
.ca-pill.copied .ca-copy { background: #3ddc84; color: #002b12; }

/* ---------- Stage & layers ---------- */
.stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #2f7cf6;
}

.sky { position: absolute; inset: 0; background: linear-gradient(180deg, #0b3fbf 0%, #2f7cf6 45%, #a4d0ff 100%); }
.sky-sunset,
.sky-night { position: absolute; inset: 0; opacity: 0; }
.sky-sunset { background: linear-gradient(180deg, #1c2a8c 0%, #8f3f8a 38%, #ff7a3d 70%, #ffd27a 100%); }
.sky-night { background: linear-gradient(180deg, #01030f 0%, #061347 60%, #0d2170 100%); }
.stars {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1.5px 1.5px at 20px 30px, #fff, transparent),
    radial-gradient(1.5px 1.5px at 140px 90px, #fff, transparent),
    radial-gradient(2px 2px at 230px 40px, #fff8c9, transparent),
    radial-gradient(1px 1px at 80px 160px, #fff, transparent),
    radial-gradient(1.5px 1.5px at 270px 200px, #fff, transparent),
    radial-gradient(1px 1px at 180px 250px, #cfe0ff, transparent);
  background-size: 300px 300px;
  animation: twinkle 3s ease-in-out infinite alternate;
}
.sun {
  position: absolute;
  left: 14%;
  top: 0;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: radial-gradient(circle, #fffbe0 0%, #ffe066 50%, #ffc233 68%, rgba(255, 194, 51, 0) 72%);
  box-shadow: 0 0 90px 40px rgba(255, 210, 90, .45);
  will-change: transform, opacity;
}
.moon {
  position: absolute;
  right: 12%;
  top: calc(var(--hud) + 5%);
  width: clamp(80px, 14vh, 150px);
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 60%, rgba(160, 155, 130, .55) 0 10%, transparent 11%),
    radial-gradient(circle at 62% 30%, rgba(160, 155, 130, .5) 0 8%, transparent 9%),
    radial-gradient(circle at 70% 70%, rgba(160, 155, 130, .45) 0 6%, transparent 7%),
    radial-gradient(circle at 35% 35%, #fffef2, #e9e6d2 55%, #c9c4a8 100%);
  box-shadow: 0 0 70px 14px rgba(255, 255, 230, .35);
  opacity: 0;
  will-change: transform, opacity;
}

.layer {
  position: absolute;
  left: 0;
  background-repeat: repeat-x;
  background-size: auto 100%;
  background-position: left bottom;
  will-change: transform;
}
.layer-far { bottom: calc(var(--base) - 10px); height: calc(var(--vh) * .42); }
.layer-city { bottom: calc(var(--base) - 6px); height: calc(var(--vh) * .3); }
.layer-clouds { top: 0; bottom: 0; }

.cloud {
  position: absolute;
  width: 120px;
  height: 38px;
  background: #fff;
  border-radius: 40px;
  opacity: .92;
  box-shadow: inset 0 -8px 0 rgba(160, 190, 240, .45);
}
.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  background: #fff;
  border-radius: 50%;
}
.cloud::before { width: 54px; height: 54px; left: 16px; top: -28px; }
.cloud::after { width: 70px; height: 70px; left: 50px; top: -40px; }

/* ---------- World ---------- */
.world {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  will-change: transform;
}
.world > .terrain { position: absolute; left: 0; bottom: 0; }
.world [data-x],
.world .welcome-sign,
.world .billboard,
.world .launchpad,
.world .rocket { position: absolute; }
.say { display: none; }

/* Signposts */
.signpost,
.gate { display: flex; flex-direction: column; align-items: center; }
.sign-board,
.gate-board {
  padding: 10px 14px;
  font-family: var(--pixel);
  color: #fff3cf;
  text-align: center;
  line-height: 1.6;
  background: linear-gradient(180deg, #c3843f, #8a5327);
  border: 4px solid #3b2210;
  border-radius: 8px;
  text-shadow: 2px 2px 0 #3b2210;
  box-shadow: 0 6px 0 rgba(0, 0, 0, .25);
}
.sign-post { width: 14px; height: 56px; background: linear-gradient(90deg, #6b4020, #8a5327); border: 3px solid #3b2210; border-top: 0; }
.welcome-sign .sign-board { display: flex; flex-direction: column; gap: 6px; padding: 14px 18px; }
.sign-small { font-size: 10px; }
.sign-big { font-size: 26px; color: var(--gold); }
.sign-hint { font-size: 10px; color: #fff; }
.blink { animation: blink 1s steps(2) infinite; }
.gate-board { font-size: 10px; }
.gate-board b { display: block; font-size: 8px; color: var(--gold); font-weight: 400; }

/* Billboard */
.billboard {
  top: calc(var(--hud) + 22px);
  bottom: var(--base);
  width: min(700px, 84vw);
  display: flex;
  flex-direction: column;
}
.billboard-board {
  padding: 10px;
  background: var(--ink);
  border: 4px solid var(--gold);
  border-radius: 14px;
  box-shadow: 0 0 40px rgba(255, 204, 51, .35), 0 12px 0 rgba(0, 0, 0, .25);
}
.billboard-board img { display: block; width: 100%; border-radius: 6px; }
.billboard-legs { flex: 1; display: flex; justify-content: space-around; }
.billboard-legs span { width: 16px; background: linear-gradient(90deg, #4a5068, #7a8099); border: 3px solid #23263a; border-top: 0; }

/* Houses (World 1) */
.house {
  width: var(--w);
  height: min(calc(var(--avail) * var(--h)), calc(var(--h) * 600px));
  background: var(--c);
  border: 4px solid var(--ink);
  border-bottom: 0;
  box-shadow: inset -16px 0 0 rgba(0, 0, 0, .12);
}
.house-roof {
  position: absolute;
  left: -18px;
  right: -18px;
  bottom: 100%;
  height: 62px;
  background: var(--roof);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}
.house-sign {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 8px;
  font-family: var(--pixel);
  font-size: 9px;
  color: var(--gold);
  white-space: nowrap;
  background: var(--ink);
  border-radius: 4px;
}
.house-windows {
  position: absolute;
  inset: 48px 18px 84px 18px;
  background: conic-gradient(from 90deg at 14px 14px, #ffe9a3 90deg, transparent 0) 0 0 / 44px 48px;
}
.house-door {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 42px;
  height: 66px;
  transform: translateX(-50%);
  background: #3a2414;
  border: 3px solid var(--ink);
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
}
.bank .bank-roof {
  position: absolute;
  top: 0;
  left: -10px;
  right: -10px;
  height: 44px;
  display: grid;
  place-items: center;
  font-family: var(--pixel);
  font-size: 12px;
  color: var(--gold);
  background: var(--roof);
  border: 4px solid var(--ink);
}
.bank .bank-roof::before {
  content: "";
  position: absolute;
  left: -4px;
  right: -4px;
  bottom: 100%;
  height: 46px;
  background: var(--roof);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}
.bank-cols {
  position: absolute;
  inset: 52px 22px 0 22px;
  display: flex;
  justify-content: space-between;
}
.bank-cols span { width: 24px; background: linear-gradient(90deg, #cfc6ae, #fff, #bdb293); border: 2px solid #8a8266; }

/* Wallet shop (World 2) */
.shop {
  width: 260px;
  height: clamp(160px, calc(var(--avail) - 250px), 280px);
  display: flex;
  flex-direction: column;
}
.shop-sign {
  padding: 8px;
  font-family: var(--pixel);
  font-size: 12px;
  color: var(--gold);
  text-align: center;
  background: #5b2bd6;
  border: 4px solid var(--ink);
  border-radius: 8px 8px 0 0;
}
.shop-awning {
  height: 30px;
  background: repeating-linear-gradient(90deg, var(--red) 0 26px, #fff 26px 52px);
  border: 4px solid var(--ink);
  border-top: 0;
  border-radius: 0 0 14px 14px;
  margin: 0 -10px;
}
.shop-body {
  position: relative;
  flex: 1;
  background: #f3d9a4;
  border: 4px solid var(--ink);
  border-top: 0;
  border-bottom: 0;
  margin-top: -4px;
}
.shop-window {
  position: absolute;
  left: 16px;
  top: 18px;
  width: 110px;
  bottom: 30px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #bfe3ff, #7cb8f0);
  border: 4px solid var(--ink);
}
.wallet-icon {
  position: relative;
  width: 56px;
  height: 40px;
  background: #7b3fe4;
  border: 3px solid var(--ink);
  border-radius: 8px;
}
.wallet-icon::after {
  content: "";
  position: absolute;
  right: -3px;
  top: 10px;
  width: 20px;
  height: 14px;
  background: var(--gold);
  border: 3px solid var(--ink);
  border-radius: 4px 0 0 4px;
}
.shop .house-door { left: auto; right: 30px; transform: none; }

/* SOL station */
.station {
  width: 300px;
  height: clamp(160px, calc(var(--avail) - 250px), 270px);
  display: flex;
  flex-direction: column;
}
.station-canopy {
  display: grid;
  place-items: center;
  height: 48px;
  font-family: var(--pixel);
  font-size: 12px;
  color: #fff;
  text-shadow: 2px 2px 0 var(--ink);
  background: linear-gradient(90deg, #9945ff, #19c3c3, #14f195);
  border: 4px solid var(--ink);
  border-radius: 8px;
}
.station-pillars { flex: 1; display: flex; justify-content: space-between; padding: 0 22px; }
.station-pillars span { width: 18px; background: linear-gradient(90deg, #aab3cc, #eef1f8, #aab3cc); border: 3px solid var(--ink); border-top: 0; }
.station-pump {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 70px;
  height: min(120px, 55%);
  transform: translateX(-50%);
  background: var(--red);
  border: 4px solid var(--ink);
  border-radius: 10px 10px 0 0;
}
.pump-screen {
  margin: 10px 8px;
  padding: 6px 0;
  font-family: var(--pixel);
  font-size: 10px;
  color: #14f195;
  text-align: center;
  background: #06121e;
  border-radius: 4px;
}
.pump-hose {
  position: absolute;
  right: -26px;
  top: 34px;
  width: 26px;
  height: 50px;
  border: 5px solid var(--ink);
  border-left: 0;
  border-radius: 0 16px 16px 0;
}

/* Swap machine */
.swapper {
  width: 150px;
  height: clamp(170px, calc(var(--avail) - 250px), 260px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 12px 10px 0;
  background: linear-gradient(180deg, #7a2cff, #3b12a6);
  border: 4px solid var(--ink);
  border-bottom: 0;
  border-radius: 22px 22px 6px 6px;
}
.swapper-top { font-family: var(--pixel); font-size: 13px; color: var(--gold); text-shadow: 2px 2px 0 var(--ink); }
.swapper-screen {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 0;
  font-family: var(--pixel);
  font-size: 10px;
  color: #3dffa0;
  background: #041008;
  border: 3px solid var(--ink);
  border-radius: 6px;
}
.swap-arrows { font-size: 16px; color: var(--gold); animation: spin 2s linear infinite; }
.swapper-buttons { display: flex; gap: 8px; }
.swapper-buttons span { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--ink); }
.swapper-buttons span:nth-child(1) { background: var(--red); }
.swapper-buttons span:nth-child(2) { background: var(--gold); }
.swapper-buttons span:nth-child(3) { background: #3ddc84; }
.swapper-slot { width: 44px; height: 10px; background: #000; border-radius: 4px; margin-top: auto; margin-bottom: 18px; }

/* Cards (steps, dex, roadmap) */
.step-card,
.milestone-card {
  color: var(--ink);
  background: var(--cream);
  border: 4px solid var(--ink);
  border-radius: 14px;
  box-shadow: 6px 6px 0 rgba(0, 0, 0, .3);
  transition: opacity .45s ease, transform .45s cubic-bezier(.2, 1.4, .4, 1);
}
.step-card {
  top: calc(var(--hud) + 22px);
  width: min(300px, 78vw);
  padding: 18px 18px 16px;
}
.step-card h3,
.milestone-card h3 { font-family: var(--display); font-weight: 400; color: var(--navy); }
.step-card h3 { font-size: 22px; margin-bottom: 6px; }
.step-card p { font-size: 15px; line-height: 1.5; }
.step-num {
  position: absolute;
  top: -20px;
  left: -16px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  font-family: var(--pixel);
  font-size: 14px;
  color: #2a1600;
  background: radial-gradient(circle at 35% 30%, var(--gold-light), var(--gold) 55%, var(--gold-dark));
  border: 3px solid var(--ink);
  border-radius: 50%;
}
.card-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.pending { opacity: 0; transform: translateY(24px) scale(.94); }

/* Museum (World 3) */
.museum-facade {
  width: 420px;
  height: clamp(220px, calc(var(--avail) - 30px), 440px);
  display: flex;
  flex-direction: column;
}
.museum-pediment { display: flex; flex-direction: column; }
.museum-pediment::before {
  content: "";
  height: 58px;
  margin: 0 -14px;
  background: linear-gradient(180deg, #f4ecd6, #d9cdaa);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}
.museum-pediment span {
  padding: 8px 0;
  margin: 0 -14px;
  font-family: var(--pixel);
  font-size: 14px;
  color: #6d1a1f;
  text-align: center;
  background: #efe6cf;
  border: 4px solid #8a7d5a;
}
.museum-cols { flex: 1; display: flex; justify-content: space-between; padding: 0 16px; }
.museum-cols span { width: 30px; background: linear-gradient(90deg, #cfc6ae, #fffdf5 45%, #bdb293); border-left: 2px solid #8a7d5a; border-right: 2px solid #8a7d5a; }
.museum-steps { height: 26px; margin: 0 -18px; background: repeating-linear-gradient(180deg, #e2d8bd 0 9px, #a79a78 9px 13px); }

.museum-hall {
  height: calc(var(--avail) - 6px);
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, .03) 0 12px, transparent 12px 24px),
    linear-gradient(180deg, #4a0f14, #6d1a1f 70%, #3a0a0e);
  border: 4px solid var(--ink);
  border-bottom: 0;
}
.hall-trim { position: absolute; left: 0; right: 0; top: 0; height: 16px; background: linear-gradient(180deg, var(--gold-light), var(--gold-dark)); border-bottom: 3px solid #5c3a00; }
.hall-floor { position: absolute; left: 0; right: 0; bottom: 0; height: 20px; background: repeating-linear-gradient(90deg, #6b4020 0 60px, #7d4c27 60px 120px); border-top: 3px solid #3b2210; }

.frame {
  top: calc(var(--hud) + 44px);
  width: calc(var(--frameH) * 1.5 + 28px);
  text-align: center;
}
.frame::before {
  content: "";
  position: absolute;
  left: 10%;
  right: 10%;
  top: -40px;
  height: calc(var(--frameH) + 90px);
  background: radial-gradient(ellipse at 50% 0%, rgba(255, 240, 190, .35), transparent 70%);
  pointer-events: none;
}
.frame button {
  position: relative;
  display: block;
  width: 100%;
  padding: 12px;
  border: 0;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--gold-light), var(--gold-dark) 30%, #ffe27a 55%, #8a5a00 80%, var(--gold));
  box-shadow: 0 14px 24px rgba(0, 0, 0, .45);
  transition: transform .2s ease;
}
.frame button:hover { transform: scale(1.03) rotate(-.5deg); }
.frame img {
  display: block;
  width: 100%;
  height: var(--frameH);
  object-fit: cover;
  border: 3px solid #3a2400;
  background: #20060a;
}
.frame figcaption {
  display: inline-block;
  margin-top: 14px;
  padding: 7px 12px;
  font-family: var(--pixel);
  font-size: 9px;
  color: #3a2400;
  background: linear-gradient(180deg, var(--gold-light), var(--gold));
  border: 2px solid #5c3a00;
  border-radius: 4px;
}
.rope {
  height: 50px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='50'%3E%3Cpath d='M8 14 Q150 44 292 14' fill='none' stroke='%23b3131a' stroke-width='7'/%3E%3Crect x='3' y='10' width='10' height='40' fill='%23d9a62a' stroke='%235c3a00' stroke-width='2'/%3E%3Ccircle cx='8' cy='9' r='7' fill='%23ffd966' stroke='%235c3a00' stroke-width='2'/%3E%3C/svg%3E") repeat-x left bottom / 300px 50px;
}

/* Roadmap (World 4) */
.milestone { top: 0; bottom: 0; width: 0; }
.flag { position: absolute; left: 0; width: 80px; height: 110px; }
.flag-pole { position: absolute; left: 0; bottom: 0; width: 7px; height: 100%; background: linear-gradient(90deg, #aab3cc, #fff, #aab3cc); border: 2px solid var(--ink); }
.flag-pole::before { content: ""; position: absolute; top: -10px; left: -5px; width: 13px; height: 13px; border-radius: 50%; background: var(--gold); border: 2px solid var(--ink); }
.flag-cloth {
  position: absolute;
  left: 6px;
  top: calc(100% - 46px);
  width: 64px;
  height: 42px;
  display: grid;
  place-items: center;
  padding-right: 10px;
  font-family: var(--pixel);
  font-size: 13px;
  color: var(--gold);
  background: var(--red);
  border: 3px solid #6b0a0c;
  clip-path: polygon(0 0, 100% 0, 80% 50%, 100% 100%, 0 100%);
  transition: top .8s cubic-bezier(.3, 1.4, .5, 1);
  transform-origin: left center;
}
.milestone.raised .flag-cloth { top: 4px; animation: wave 1.4s ease-in-out infinite; }
.milestone-card {
  position: absolute;
  left: -40px;
  width: min(250px, 72vw);
  padding: 14px 16px;
}
.milestone-card h3 { font-size: 20px; margin: 4px 0 8px; }
.milestone-card ul { list-style: none; font-size: 14px; line-height: 1.6; font-weight: 700; }
.milestone-card li::before { content: "★ "; color: var(--gold-dark); }
.phase { font-family: var(--pixel); font-size: 9px; color: var(--red); }

/* Trading tower (World 5) */
.tower { width: 300px; height: calc(var(--avail) - 56px); }
.tower-antenna {
  position: absolute;
  left: 50%;
  bottom: 100%;
  width: 8px;
  height: 44px;
  transform: translateX(-50%);
  background: #aab3cc;
  border: 2px solid var(--ink);
}
.tower-antenna::before {
  content: "";
  position: absolute;
  top: -12px;
  left: -6px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 16px 4px rgba(255, 40, 40, .8);
  animation: blink 1.2s steps(2) infinite;
}
.tower-body {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: linear-gradient(90deg, #13235e, #2c4fc0 50%, #13235e);
  border: 4px solid #0a1238;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
}
.tower-name { font-family: var(--pixel); font-size: 11px; color: var(--gold); text-align: center; text-shadow: 2px 2px 0 #000; }
.tower-screen { height: clamp(90px, 26%, 170px); padding: 8px; background: #050a1f; border: 4px solid var(--gold); border-radius: 6px; flex-shrink: 0; }
.tower-screen svg { display: block; width: 100%; height: 100%; }
.candles rect { transform-box: fill-box; transform-origin: bottom; transform: scaleY(0); transition: transform .5s ease; }
.candles .up { fill: #22e07a; }
.candles .down { fill: #ff4d4d; }
.tower.active .candles rect { transform: scaleY(1); }
.candles rect:nth-child(2) { transition-delay: .08s; } .candles rect:nth-child(3) { transition-delay: .16s; }
.candles rect:nth-child(4) { transition-delay: .24s; } .candles rect:nth-child(5) { transition-delay: .32s; }
.candles rect:nth-child(6) { transition-delay: .4s; }  .candles rect:nth-child(7) { transition-delay: .48s; }
.candles rect:nth-child(8) { transition-delay: .56s; } .candles rect:nth-child(9) { transition-delay: .64s; }
.trend { fill: none; stroke: var(--gold); stroke-width: 2.5; stroke-dasharray: 300; stroke-dashoffset: 300; transition: stroke-dashoffset 1.4s ease .5s; vector-effect: non-scaling-stroke; }
.tower.active .trend { stroke-dashoffset: 0; }
.tower-ticker { overflow: hidden; padding: 6px 0; background: #000; border: 2px solid #0a1238; flex-shrink: 0; }
.tower-ticker span { display: inline-block; white-space: nowrap; font-family: var(--pixel); font-size: 10px; color: #3dffa0; animation: marquee 10s linear infinite; }
.tower-windows { flex: 1; min-height: 0; background: conic-gradient(from 90deg at 12px 10px, rgba(255, 233, 163, .85) 90deg, transparent 0) 0 0 / 36px 28px; opacity: .8; }
.tower-door { width: 90px; height: 64px; margin: 0 auto -1px; flex-shrink: 0; background: linear-gradient(90deg, #7cb8f0 0 48%, var(--ink) 48% 52%, #7cb8f0 52%); border: 4px solid var(--ink); border-bottom: 0; }

/* Launch pad & rocket */
.launchpad { width: 280px; height: calc(var(--rocketH, 220px) + 70px); }
.pad { position: absolute; left: 0; right: 0; bottom: 0; height: 18px; background: repeating-linear-gradient(45deg, var(--gold) 0 14px, #111 14px 28px); border: 3px solid var(--ink); }
.gantry {
  position: absolute;
  right: 40px;
  bottom: 18px;
  width: 40px;
  top: 0;
  background:
    repeating-linear-gradient(45deg, transparent 0 12px, #c4121a 12px 16px),
    repeating-linear-gradient(-45deg, transparent 0 12px, #c4121a 12px 16px);
  border-left: 5px solid #8a0c10;
  border-right: 5px solid #8a0c10;
}
.rocket { will-change: transform; }
.rocket svg { display: block; width: 100%; height: 100%; overflow: visible; }
.rocket .flame { opacity: 0; transform-origin: 50px 176px; }
.rocket.launched { animation: launch 3s ease-in forwards; }
.rocket.launched .flame { opacity: 1; animation: flicker .12s linear infinite alternate; }

/* Coins */
.coin {
  position: absolute;
  width: 28px;
  height: 28px;
  margin-left: -14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--gold-light), var(--gold) 50%, var(--gold-dark));
  border: 3px solid #8a5a00;
  box-shadow: 0 0 12px rgba(255, 204, 51, .6);
  animation: coinSpin 1.6s ease-in-out infinite;
}
.coin::after { content: "P"; position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--display); font-size: 13px; color: #8a5a00; }
.coin.got { animation: collect .5s ease-out forwards; }

/* ---------- Hero ---------- */
.hero {
  position: absolute;
  left: 0;
  bottom: 0;
  z-index: 20;
  width: var(--heroW);
  height: var(--heroH);
  filter: drop-shadow(0 6px 3px rgba(0, 0, 0, .35));
  transition: opacity .35s ease;
  will-change: transform;
}
.hero.boarded { opacity: 0; }
.hero-svg { display: block; width: 100%; height: 100%; overflow: visible; }
.hero-body { animation: breathe 2.4s ease-in-out infinite; }
.cape { transform-origin: 75px 38px; animation: capeIdle 2.4s ease-in-out infinite; }
.leg-back { transform-origin: 60px 124px; }
.leg-front { transform-origin: 80px 124px; }
.arm-back { transform-origin: 52px 82px; }
.arm-front { transform-origin: 108px 70px; }
.hero.walking .hero-body { animation: bob .22s ease-in-out infinite alternate; }
.hero.walking .cape { animation: capeRun .44s ease-in-out infinite; }
.hero.walking .leg-back,
.hero.walking .arm-front { animation: stepA .44s linear infinite; }
.hero.walking .leg-front,
.hero.walking .arm-back { animation: stepB .44s linear infinite; }
.hero.back .leg,
.hero.back .arm { animation-direction: reverse; }

.bubble {
  position: absolute;
  bottom: calc(100% + 14px);
  left: 6px;
  width: max-content;
  max-width: min(270px, 68vw);
  padding: 10px 13px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
  color: #111;
  background: #fff;
  border: 3px solid #111;
  border-radius: 14px;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, .3);
  transform-origin: 24px 100%;
  opacity: 0;
  transform: scale(.6);
  transition: opacity .2s ease, transform .25s cubic-bezier(.3, 1.6, .5, 1);
  pointer-events: none;
}
.bubble::after {
  content: "";
  position: absolute;
  left: 22px;
  top: 100%;
  border: 10px solid transparent;
  border-top-color: #111;
  border-bottom: 0;
}
.bubble.show { opacity: 1; transform: scale(1); }
.bubble.show.blocked { opacity: 0; transform: scale(.6); }

/* ---------- Level map ---------- */
.level-map {
  --nodeW: 58px;
  position: absolute;
  z-index: 30;
  left: 50%;
  bottom: max(10px, env(safe-area-inset-bottom));
  width: min(640px, calc(100% - 20px));
  padding: 10px 6px 6px;
  transform: translateX(-50%);
  background: rgba(6, 10, 38, .82);
  border: 3px solid var(--gold);
  border-radius: 14px;
  box-shadow: 0 6px 0 rgba(0, 0, 0, .35);
}
.map-track { position: relative; height: 6px; margin: 0 calc(var(--nodeW) / 2); background: rgba(255, 255, 255, .18); border-radius: 3px; }
.map-fill { height: 100%; width: 0; background: var(--gold); border-radius: 3px; }
.map-marker {
  position: absolute;
  top: 50%;
  left: 0;
  width: 16px;
  height: 16px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 35% 30%, var(--gold-light), var(--gold) 55%, var(--gold-dark));
  border: 2px solid var(--ink);
  border-radius: 50%;
  box-shadow: -6px 2px 0 -1px var(--red);
}
.map-nodes { display: flex; justify-content: space-between; list-style: none; margin-top: 6px; }
.map-nodes button {
  width: var(--nodeW);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 2px 0;
  background: none;
  border: 0;
}
.map-nodes .node {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  font-family: var(--pixel);
  font-size: 9px;
  color: var(--gold);
  background: #1b2a6b;
  border: 2px solid var(--gold);
  border-radius: 6px;
  transition: background .2s, color .2s, transform .2s;
}
.map-nodes .label { font-family: var(--pixel); font-size: 7px; color: rgba(255, 255, 255, .75); }
.map-nodes .done .node { background: #6b5a1a; }
.map-nodes .active .node { background: var(--gold); color: var(--ink); transform: scale(1.15); }
.map-nodes .active .label { color: var(--gold); }
.map-nodes button:hover .node { transform: scale(1.15); }

.scroll-hint {
  position: absolute;
  z-index: 30;
  right: 20px;
  bottom: calc(var(--base) + 24px);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-family: var(--pixel);
  font-size: 10px;
  background: rgba(0, 0, 0, .5);
  border-radius: 10px;
  transition: opacity .4s ease;
}
.scroll-hint.hide { opacity: 0; pointer-events: none; }
.mouse { position: relative; width: 16px; height: 24px; border: 2px solid #fff; border-radius: 10px; }
.mouse::after { content: ""; position: absolute; left: 50%; top: 4px; width: 3px; height: 6px; margin-left: -1.5px; background: #fff; border-radius: 2px; animation: wheel 1.2s ease infinite; }

/* ---------- Ending overlay ---------- */
.ending {
  position: fixed;
  inset: var(--hud) 0 0 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 12px 16px 16px;
  background: rgba(2, 8, 30, .55);
  animation: fadeIn .4s ease;
}
.ending-card {
  width: min(440px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 18px;
  text-align: center;
  background: linear-gradient(180deg, #0f2f9a, #061347);
  border: 4px solid var(--gold);
  border-radius: 20px;
  box-shadow: 0 0 60px rgba(255, 204, 51, .35);
  animation: pop .5s cubic-bezier(.3, 1.5, .5, 1);
}
.ending-card img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 12px; border: 3px solid var(--ink); }
.ending-kicker { display: block; margin-top: 14px; font-family: var(--pixel); font-size: 10px; color: #3dffa0; }
.ending-card h2 {
  margin: 8px 0 6px;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(24px, 6vw, 32px);
  background: linear-gradient(180deg, var(--gold-light), var(--gold) 50%, var(--gold-dark));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.ending-card p { color: #c9d3ff; }
.ending-card .card-actions { justify-content: center; }
.ca-wide { margin-top: 14px; max-width: 100%; }
.replay { margin-top: 14px; padding: 8px; font-family: var(--pixel); font-size: 10px; color: var(--gold); background: none; border: 0; }

/* ---------- Lightbox ---------- */
.lightbox {
  margin: auto;
  max-width: min(1000px, 94vw);
  padding: 12px;
  color: var(--ink);
  background: linear-gradient(135deg, var(--gold-light), var(--gold-dark) 30%, #ffe27a 55%, #8a5a00 80%, var(--gold));
  border: 0;
  border-radius: 10px;
}
.lightbox::backdrop { background: rgba(2, 6, 24, .85); }
.lightbox img { display: block; max-width: 100%; max-height: 78vh; border: 3px solid #3a2400; }
.lightbox p { padding-top: 10px; font-family: var(--pixel); font-size: 11px; text-align: center; color: #3a2400; }
.lightbox-close {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 36px;
  height: 36px;
  font-weight: 800;
  color: #fff;
  background: var(--red);
  border: 3px solid var(--ink);
  border-radius: 50%;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  z-index: 70;
  left: 50%;
  top: calc(var(--hud) + 14px);
  padding: 10px 18px;
  font-family: var(--pixel);
  font-size: 10px;
  color: #002b12;
  background: #3ddc84;
  border: 3px solid var(--ink);
  border-radius: 10px;
  transform: translate(-50%, -10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Keyframes ---------- */
@keyframes stepA { 0%, 100% { transform: rotate(26deg); } 50% { transform: rotate(-26deg); } }
@keyframes stepB { 0%, 100% { transform: rotate(-26deg); } 50% { transform: rotate(26deg); } }
@keyframes bob { from { transform: translateY(0); } to { transform: translateY(-5px); } }
@keyframes breathe { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }
@keyframes capeIdle { 0%, 100% { transform: skewY(0) scaleX(1); } 50% { transform: skewY(-4deg) scaleX(.96); } }
@keyframes capeRun { 0%, 100% { transform: skewY(-7deg) scaleX(1.06); } 50% { transform: skewY(4deg) scaleX(.94); } }
@keyframes wave { 0%, 100% { transform: skewY(0); } 50% { transform: skewY(-6deg) scaleX(.95); } }
@keyframes coinSpin { 0%, 100% { transform: scaleX(1) translateY(0); } 50% { transform: scaleX(.35) translateY(-6px); } }
@keyframes collect { to { transform: translateY(-70px) scale(1.4); opacity: 0; } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes twinkle { from { opacity: .6; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes marquee { to { transform: translateX(-50%); } }
@keyframes wheel { 0% { transform: translateY(0); opacity: 1; } 100% { transform: translateY(8px); opacity: 0; } }
@keyframes bump { 50% { transform: scale(1.18); } }
@keyframes flicker { from { transform: scaleY(.85); } to { transform: scaleY(1.15); } }
@keyframes launch {
  0% { transform: translate(0, 0); }
  4%, 12% { transform: translate(-3px, 0); }
  8%, 16% { transform: translate(3px, 0); }
  20% { transform: translate(0, 0); }
  100% { transform: translate(0, var(--fly)); }
}
@keyframes fadeIn { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.7); opacity: 0; } }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .hud { gap: 8px; padding: 0 10px; }
  .hud-name,
  .hud-coins-total,
  .hud .ca-pill code { display: none; }
  .hud-brand img { width: 36px; height: 36px; }
  .hud-actions { gap: 6px; }
  .hud .btn { padding: 8px 12px; font-size: 13px; }
  .hud .btn-icon { padding: 8px; }
  .level-map { --nodeW: 36px; }
  .map-nodes .label { display: none; }
  .scroll-hint { right: 50%; transform: translateX(50%); top: calc(var(--hud) + 14px); bottom: auto; white-space: nowrap; }
  .welcome-sign .sign-board { padding: 10px 12px; gap: 4px; }
  .welcome-sign .sign-big { font-size: 18px; }
  .welcome-sign .sign-post { height: 30px; }
  .step-card h3 { font-size: 19px; }
  .step-card p { font-size: 14px; }
}
@media (max-width: 360px) {
  .hud-coins { padding: 6px 8px; font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .rocket.launched { animation: none; transform: translate(0, var(--fly)); }
}
