/* ============================================================
   SMASH FORT 3D — interface
   Mobile-first, safe-area aware, one accent system throughout.
============================================================ */

:root {
  --ink: #0b1428;
  --ink-2: #142240;
  --glass: rgba(13, 26, 52, .62);
  --glass-brd: rgba(255, 255, 255, .16);
  --accent: #ff6a3d;
  --accent-2: #ffb52e;
  --gold: #ffd45e;
  --green: #3ddc84;
  --green-dk: #14a05a;
  --core: #7cf6c8;
  --purple: #8b5cf6;
  --purple-dk: #5b21b6;
  --txt: #eaf2ff;
  --txt-dim: #9fb4d6;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);

  --pad: 12px;
  --r-lg: 20px;
  --r-md: 14px;
  --r-sm: 10px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0d1730;
  overscroll-behavior: none;
}

body {
  font-family: 'Rubik', system-ui, -apple-system, sans-serif;
  color: var(--txt);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#game {
  position: fixed;
  inset: 0;
  display: block;
  cursor: none;
}

.display {
  font-family: 'Luckiest Guy', 'Rubik', system-ui, sans-serif;
  letter-spacing: .035em;
  font-weight: 400;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  color: inherit;
}

/* ============================================================
   OVERLAY LAYERS
============================================================ */
#vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  background: radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(6, 12, 32, .5));
}

#flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 14;
  background: #fff;
  opacity: 0;
  transition: opacity .08s linear;
}

#popLayer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 26;
  overflow: hidden;
}

/* ---------- crosshair ---------- */
#crosshair {
  position: fixed;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  pointer-events: none;
  z-index: 30;
  opacity: 0;
  transition: opacity .18s;
}

#crosshair.on {
  opacity: 1;
}

.ch-ring,
.ch-dot {
  position: absolute;
  border-radius: 50%;
  inset: 0;
}

.ch-ring {
  border: 2.5px solid rgba(255, 255, 255, .9);
  box-shadow: 0 0 10px rgba(0, 0, 0, .45), inset 0 0 8px rgba(0, 0, 0, .3);
  transition: transform .12s, border-color .12s;
}

.ch-dot {
  inset: 16px;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(255, 106, 61, .9);
}

#crosshair.charging .ch-ring {
  animation: chPulse .5s infinite alternate;
  border-color: var(--accent-2);
}

@keyframes chPulse {
  from {
    transform: scale(1);
  }

  to {
    transform: scale(1.4);
  }
}

/* ---------- floating score pops ---------- */
.pop {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: 'Luckiest Guy', sans-serif;
  font-size: clamp(18px, 3.4vw, 26px);
  color: #fff;
  -webkit-text-stroke: 1.4px #17253f;
  text-shadow: 0 3px 0 rgba(0, 0, 0, .35);
  animation: popUp .95s cubic-bezier(.16, .9, .3, 1) forwards;
  white-space: nowrap;
}

.pop.gold {
  color: var(--gold);
  -webkit-text-stroke: 1.4px #7a5200;
  font-size: clamp(22px, 4.2vw, 32px);
}

.pop.core {
  color: var(--core);
  -webkit-text-stroke: 1.4px #0a5c45;
  font-size: clamp(24px, 4.6vw, 36px);
}

.pop.boom {
  color: #ff7a45;
  -webkit-text-stroke: 1.4px #6b2000;
}

@keyframes popUp {
  0% {
    transform: translate(-50%, -50%) scale(.4);
    opacity: 0;
  }

  18% {
    transform: translate(-50%, -75%) scale(1.15);
    opacity: 1;
  }

  100% {
    transform: translate(-50%, -190%) scale(.95);
    opacity: 0;
  }
}

/* ============================================================
   LOADING
============================================================ */
#loading {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  background: linear-gradient(170deg, #16224a, #0a1226 60%, #2a1836);
  transition: opacity .5s, visibility .5s;
}

#loading.done {
  opacity: 0;
  visibility: hidden;
}

.load-inner {
  text-align: center;
  padding: 0 24px;
}

.load-logo {
  font-size: clamp(44px, 11vw, 88px);
  line-height: .95;
  background: linear-gradient(180deg, #fff 10%, var(--gold) 42%, #ff9d2e 68%, #ff4d6d);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 5px 0 rgba(90, 20, 40, .5));
  margin-bottom: 28px;
}

.load-barWrap {
  width: min(320px, 70vw);
  height: 12px;
  border-radius: 99px;
  background: rgba(255, 255, 255, .1);
  overflow: hidden;
  margin: 0 auto;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, .5);
}

.load-bar {
  height: 100%;
  width: 4%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--gold), var(--accent));
  transition: width .3s ease;
  box-shadow: 0 0 12px rgba(255, 160, 60, .7);
}

.load-tip {
  margin-top: 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--txt-dim);
  letter-spacing: .05em;
}

/* ============================================================
   HUD
============================================================ */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  opacity: 0;
  transition: opacity .3s;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: calc(var(--safe-t) + var(--pad)) calc(var(--safe-r) + var(--pad)) calc(var(--safe-b) + var(--pad)) calc(var(--safe-l) + var(--pad));
}

#hud.show {
  opacity: 1;
}

.hud-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.hud-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.hud-card {
  background: var(--glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--glass-brd);
  border-radius: var(--r-md);
  box-shadow: 0 6px 20px rgba(4, 10, 28, .35);
  padding: 7px 13px;
}

.hud-lbl {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .18em;
  color: var(--txt-dim);
}

#scoreCard {
  min-width: 96px;
}

#score {
  font-size: clamp(24px, 5vw, 34px);
  line-height: 1.05;
  color: var(--gold);
  text-shadow: 0 2px 0 rgba(0, 0, 0, .3);
  transition: transform .09s ease-out;
}

#score.bump {
  transform: scale(1.22);
}

#scoreBest {
  font-size: 10px;
  font-weight: 700;
  color: var(--txt-dim);
}

#levelCard {
  text-align: center;
  flex: 0 1 auto;
  min-width: 0;
}

#levelName {
  font-size: clamp(11px, 2.4vw, 14px);
  font-weight: 800;
  letter-spacing: .08em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 42vw;
}

.core-row {
  display: flex;
  gap: 5px;
  justify-content: center;
  margin: 5px 0 3px;
  flex-wrap: wrap;
  max-width: 42vw;
}

.core-pip {
  width: 13px;
  height: 13px;
  border-radius: 4px;
  background: linear-gradient(160deg, #9dffdd, #14b98a);
  box-shadow: 0 0 9px rgba(60, 240, 190, .8), inset 0 1px 2px rgba(255, 255, 255, .6);
  transition: all .3s cubic-bezier(.2, 1.8, .4, 1);
}

.core-pip.done {
  background: rgba(255, 255, 255, .13);
  box-shadow: none;
  transform: scale(.62) rotate(45deg);
  opacity: .5;
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

.coin-card {
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 800;
  font-size: 14px;
  color: var(--gold);
  padding: 9px 13px;
}

.coin-ico {
  font-size: 15px;
}

.iconBtn {
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  border: 1px solid var(--glass-brd);
  background: var(--glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  display: grid;
  place-items: center;
  transition: transform .12s, background .15s;
  pointer-events: auto;
}

.iconBtn:hover {
  background: rgba(255, 255, 255, .2);
  transform: scale(1.06);
}

.iconBtn:active {
  transform: scale(.93);
}

/* ---------- ammo rail ---------- */
#ammoRail {
  display: flex;
  gap: 8px;
  pointer-events: auto;
  flex-wrap: wrap;
  justify-content: flex-start;
  max-width: 92vw;
  margin-top: 14px;
  /* Pushed to the left so it never sits on top of the cannon, which
     lives centre-bottom of the frame. */
  align-self: flex-start;
  /* Room for the .next arrow that hangs below each tile */
  padding-bottom: 10px;
}

.ammo {
  width: 46px;
  height: 46px;
  border-radius: var(--r-md);
  background: var(--glass);
  border: 2px solid var(--glass-brd);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: grid;
  place-items: center;
  font-size: 20px;
  position: relative;
  transition: transform .16s cubic-bezier(.2, 1.6, .4, 1), border-color .16s, opacity .25s;
  box-shadow: 0 5px 14px rgba(4, 10, 28, .4);
}

.ammo:hover:not(.spent) {
  transform: translateY(-4px) scale(1.06);
}

.ammo.next {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(255, 212, 94, .22), 0 6px 18px rgba(4, 10, 28, .45);
  transform: translateY(-5px) scale(1.1);
}

.ammo.next::after {
  content: '';
  position: absolute;
  bottom: -9px;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-bottom-color: var(--gold);
}

.ammo.spent {
  opacity: .22;
  transform: scale(.82);
  filter: grayscale(1);
  pointer-events: none;
}

.ammo-name {
  position: absolute;
  top: -15px;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .06em;
  color: var(--txt-dim);
  white-space: nowrap;
  opacity: 0;
  transition: opacity .2s;
}

.ammo.next .ammo-name {
  opacity: 1;
  color: var(--gold);
}

/* ---------- power bar ---------- */
#powerWrap {
  position: relative;
  width: min(340px, 62vw);
  height: 16px;
  border-radius: 99px;
  background: rgba(8, 16, 36, .68);
  border: 1px solid var(--glass-brd);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, .55);
  overflow: hidden;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .16s, transform .16s;
}

#powerWrap.show {
  opacity: 1;
  transform: translateY(0);
}

#powerBar {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, #ffe27a, var(--accent-2), var(--accent), #ff2e6d);
  box-shadow: 0 0 14px rgba(255, 130, 50, .85);
  transition: width .04s linear;
}

#powerTicks {
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(90deg, transparent 0 24%, rgba(255, 255, 255, .22) 24% 25%);
  pointer-events: none;
}

#hint {
  font-size: clamp(11px, 2.4vw, 14px);
  font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, .75);
  background: rgba(8, 16, 36, .5);
  padding: 7px 16px;
  border-radius: 99px;
  border: 1px solid var(--glass-brd);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  text-align: center;
  max-width: 88vw;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .35s, transform .35s;
}

#hint.show {
  opacity: 1;
  transform: translateY(0);
}

/* ---------- rewarded button ---------- */
.rewardBtn {
  position: absolute;
  right: calc(var(--safe-r) + var(--pad));
  top: calc(var(--safe-t) + 78px);
  display: none;
  align-items: center;
  gap: 8px;
  padding: 9px 14px 9px 11px;
  border-radius: var(--r-md);
  background: linear-gradient(180deg, #ff5f52, #b3160c);
  border: 2px solid rgba(255, 140, 120, .8);
  box-shadow: 0 5px 0 #7d0d06, 0 10px 22px rgba(190, 30, 20, .45);
  color: #fff;
  pointer-events: auto;
  transition: transform .12s, box-shadow .12s;
  animation: rwPulse 2.2s infinite;
}

.rewardBtn.show {
  display: flex;
}

.rewardBtn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #7d0d06;
}

.rw-ico {
  font-size: 22px;
}

.rw-txt {
  font-size: 9px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: .1em;
  text-align: left;
}

.rw-txt b {
  font-size: 13px;
  letter-spacing: .05em;
}

.rw-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: var(--accent-2);
  color: #4a2c00;
  font-size: 8px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 99px;
  border: 2px solid #fff;
  letter-spacing: .08em;
}

@keyframes rwPulse {

  0%,
  100% {
    box-shadow: 0 5px 0 #7d0d06, 0 10px 22px rgba(190, 30, 20, .45), 0 0 0 0 rgba(255, 70, 50, .55);
  }

  60% {
    box-shadow: 0 5px 0 #7d0d06, 0 10px 22px rgba(190, 30, 20, .45), 0 0 0 16px rgba(255, 70, 50, 0);
  }
}

/* ---------- combo & banner ---------- */
#combo {
  position: absolute;
  left: 50%;
  top: 24%;
  transform: translateX(-50%) scale(0);
  font-size: clamp(34px, 8vw, 62px);
  color: var(--gold);
  -webkit-text-stroke: 2.5px #a8340f;
  text-shadow: 0 5px 0 rgba(120, 30, 10, .5), 0 0 34px rgba(255, 180, 40, .75);
  pointer-events: none;
  white-space: nowrap;
}

#combo.show {
  animation: comboPop .85s cubic-bezier(.2, 2.2, .4, 1) forwards;
}

@keyframes comboPop {
  0% {
    transform: translateX(-50%) scale(0) rotate(-10deg);
    opacity: 0;
  }

  40% {
    transform: translateX(-50%) scale(1.2) rotate(4deg);
    opacity: 1;
  }

  70% {
    transform: translateX(-50%) scale(1) rotate(0);
  }

  100% {
    transform: translateX(-50%) scale(1.02);
    opacity: 0;
  }
}

/* Combo milestone slam — sized to survive video compression */
#milestone {
  position: absolute;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%) scale(0);
  font-size: clamp(42px, 11vw, 104px);
  color: #fff;
  -webkit-text-stroke: 3px #b3350d;
  text-shadow: 0 6px 0 rgba(140, 40, 10, .55), 0 0 46px rgba(255, 170, 60, .9);
  pointer-events: none;
  white-space: nowrap;
  opacity: 0;
  z-index: 24;
}

#milestone.show {
  animation: milestoneSlam 1.15s cubic-bezier(.2, 1.8, .35, 1) forwards;
}

@keyframes milestoneSlam {
  0% {
    transform: translate(-50%, -50%) scale(2.6) rotate(-7deg);
    opacity: 0;
  }

  16% {
    transform: translate(-50%, -50%) scale(1) rotate(2deg);
    opacity: 1;
  }

  30% {
    transform: translate(-50%, -50%) scale(1.12) rotate(-1deg);
  }

  72% {
    transform: translate(-50%, -50%) scale(1) rotate(0);
    opacity: 1;
  }

  100% {
    transform: translate(-50%, -58%) scale(1.05);
    opacity: 0;
  }
}

#banner {
  position: absolute;
  left: 50%;
  top: 36%;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
  opacity: 0;
  width: 90vw;
}

#banner .b1 {
  font-size: clamp(13px, 2.6vw, 18px);
  font-weight: 800;
  letter-spacing: .3em;
  color: var(--gold);
  text-shadow: 0 3px 0 rgba(0, 0, 0, .4);
}

#banner .b2 {
  font-size: clamp(30px, 7vw, 58px);
  color: #fff;
  -webkit-text-stroke: 2px #1c3566;
  text-shadow: 0 6px 0 rgba(16, 38, 78, .55);
}

#banner.show {
  animation: bannerIn 2.4s ease forwards;
}

@keyframes bannerIn {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(26px) scale(.85);
  }

  14% {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }

  78% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
  }
}

/* ============================================================
   OVERLAYS / PANELS
============================================================ */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--safe-t) + 10px) calc(var(--safe-r) + 10px) calc(var(--safe-b) + 10px) calc(var(--safe-l) + 10px);
  background: radial-gradient(ellipse at 50% 30%, rgba(38, 62, 128, .55), rgba(5, 11, 30, .88));
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s;
}

.overlay.show {
  opacity: 1;
  pointer-events: auto;
}

/* The title screen sits over a live, slowly orbiting fort, so it stays
   mostly clear. Every other screen is UI-dense and keeps the heavy blur
   so text and cards have contrast to sit on. */
#menu {
  background: linear-gradient(180deg, rgba(8, 16, 40, .70) 0%, rgba(8, 16, 40, .40) 45%, rgba(8, 16, 40, .80) 100%);
  backdrop-filter: blur(2.5px);
  -webkit-backdrop-filter: blur(2.5px);
}

.panel {
  text-align: center;
  padding: 22px 26px;
  max-height: 100%;
  overflow-y: auto;
  animation: panelIn .45s cubic-bezier(.2, 1.5, .4, 1);
  -webkit-overflow-scrolling: touch;
}

.wide-panel {
  width: 100%;
  max-width: 760px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.menu-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

@keyframes panelIn {
  from {
    transform: scale(.82) translateY(22px);
    opacity: 0;
  }

  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

#title {
  font-size: clamp(46px, 10vw, 96px);
  line-height: .95;
  background: linear-gradient(180deg, #fff 10%, var(--gold) 38%, #ff9d2e 62%, #ff4d6d);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 6px 0 rgba(90, 20, 40, .5)) drop-shadow(0 14px 22px rgba(0, 0, 0, .35));
  animation: titleBob 2.8s ease-in-out infinite alternate;
}

@keyframes titleBob {
  from {
    transform: rotate(-1.4deg) scale(1);
  }

  to {
    transform: rotate(1.4deg) scale(1.035);
  }
}

.subtitle {
  color: #cfe0ff;
  font-weight: 600;
  font-size: clamp(12px, 2.2vw, 16px);
  margin: 10px 0 22px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, .55);
  max-width: 460px;
}

.subtitle b {
  color: var(--gold);
}

.menu-stats {
  display: flex;
  gap: 16px;
  margin-top: 22px;
  font-size: 12px;
  font-weight: 700;
  color: var(--txt-dim);
  flex-wrap: wrap;
  justify-content: center;
}

/* ---------- buttons ---------- */
.bigBtn {
  font-family: 'Luckiest Guy', 'Rubik', sans-serif;
  font-size: clamp(19px, 3.2vw, 28px);
  letter-spacing: .05em;
  color: #fff;
  background: linear-gradient(180deg, #ff8a4d, #f0442c);
  border-radius: 18px;
  padding: 14px 34px 11px;
  box-shadow: 0 6px 0 #a82a17, 0 12px 26px rgba(180, 45, 20, .42), inset 0 2px 2px rgba(255, 255, 255, .4);
  text-shadow: 0 2px 0 rgba(130, 30, 10, .55);
  transition: transform .11s, box-shadow .11s;
  min-height: 52px;
}

.bigBtn:hover {
  transform: translateY(-3px);
  box-shadow: 0 9px 0 #a82a17, 0 18px 32px rgba(180, 45, 20, .5), inset 0 2px 2px rgba(255, 255, 255, .4);
}

.bigBtn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #a82a17, 0 5px 12px rgba(180, 45, 20, .4);
}

.bigBtn.green {
  background: linear-gradient(180deg, #5fe08d, #16a85c);
  box-shadow: 0 6px 0 #0d7340, 0 12px 26px rgba(20, 140, 70, .42), inset 0 2px 2px rgba(255, 255, 255, .4);
}

.bigBtn.green:hover {
  box-shadow: 0 9px 0 #0d7340, 0 18px 32px rgba(20, 140, 70, .5), inset 0 2px 2px rgba(255, 255, 255, .4);
}

.bigBtn.green:active {
  box-shadow: 0 2px 0 #0d7340, 0 5px 12px rgba(20, 140, 70, .4);
}

.midBtn {
  font-weight: 800;
  font-size: clamp(12px, 2.2vw, 15px);
  letter-spacing: .06em;
  color: #fff;
  background: rgba(255, 255, 255, .11);
  border: 2px solid rgba(255, 255, 255, .18);
  border-radius: var(--r-md);
  padding: 12px 20px;
  transition: transform .12s, background .15s, border-color .15s;
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  justify-content: center;
}

.midBtn:hover {
  background: rgba(255, 255, 255, .2);
  border-color: rgba(255, 255, 255, .38);
  transform: translateY(-2px);
}

.midBtn:active {
  transform: translateY(2px);
}

.midBtn.danger {
  border-color: rgba(255, 90, 90, .4);
  color: #ff9c9c;
}

.midBtn.danger:hover {
  background: rgba(255, 60, 60, .18);
}

.adBtn {
  background: linear-gradient(180deg, #a78bfa, #6d28d9);
  border-color: rgba(196, 181, 253, .7);
  box-shadow: 0 5px 0 #4c1d95, 0 10px 22px rgba(109, 40, 217, .4);
  color: #fff;
}

.adBtn:hover {
  background: linear-gradient(180deg, #b9a1ff, #7c3aed);
  box-shadow: 0 8px 0 #4c1d95, 0 14px 28px rgba(109, 40, 217, .5);
}

.adBtn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #4c1d95;
}

.backBtn {
  font-weight: 700;
  font-size: 13px;
  color: var(--txt-dim);
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: var(--r-sm);
  padding: 10px 16px;
  transition: background .15s, color .15s;
  min-height: 40px;
}

.backBtn:hover {
  background: rgba(255, 255, 255, .18);
  color: #fff;
}

.btn-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 8px;
}

.btn-row.col {
  flex-direction: column;
}

.btn-row.col>* {
  width: min(300px, 78vw);
}

.small-row {
  margin-top: 12px;
}

/* ---------- results ---------- */
.resultTitle {
  font-size: clamp(28px, 6vw, 58px);
  color: #fff;
  -webkit-text-stroke: 2px #1c3566;
  text-shadow: 0 5px 0 rgba(16, 38, 78, .5);
  line-height: 1.05;
}

.resultTitle.sm {
  font-size: clamp(20px, 4vw, 32px);
  -webkit-text-stroke: 1.4px #1c3566;
}

.stars {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 12px 0 6px;
  font-size: clamp(38px, 8vw, 62px);
}

.stars span {
  color: #2b3d63;
  text-shadow: 0 3px 0 rgba(0, 0, 0, .3);
  transform: scale(.72);
  transition: none;
}

.stars span.lit {
  color: var(--gold);
  text-shadow: 0 3px 0 #8a5a00, 0 0 26px rgba(255, 200, 60, .8);
  animation: starPop .55s cubic-bezier(.2, 2.4, .4, 1) forwards;
}

@keyframes starPop {
  0% {
    transform: scale(.2) rotate(-40deg);
  }

  60% {
    transform: scale(1.4) rotate(10deg);
  }

  100% {
    transform: scale(1) rotate(0);
  }
}

.result-rows {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 12px auto 6px;
  width: min(330px, 84vw);
}

.result-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 700;
  color: var(--txt-dim);
  padding: 5px 12px;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, .05);
}

.result-row b {
  color: #fff;
}

.resultScore {
  color: var(--gold);
  font-family: 'Luckiest Guy', sans-serif;
  font-size: clamp(28px, 6vw, 46px);
  margin: 8px 0 2px;
  text-shadow: 0 3px 0 rgba(0, 0, 0, .35);
}

.coin-earn {
  font-weight: 800;
  color: var(--gold);
  font-size: 15px;
  margin-bottom: 16px;
}

.fail-sub {
  color: #ffb3b3;
  font-weight: 700;
  font-size: clamp(13px, 2.4vw, 16px);
  margin: 10px 0 0;
}

/* ---------- panel head ---------- */
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.star-total {
  font-weight: 800;
  font-size: 14px;
  color: var(--gold);
  background: rgba(255, 255, 255, .08);
  border-radius: 99px;
  padding: 8px 14px;
  white-space: nowrap;
}

/* ---------- world tabs ---------- */
.world-tabs {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.world-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 15px;
  border-radius: 99px;
  background: rgba(255, 255, 255, .07);
  border: 2px solid transparent;
  font-weight: 800;
  font-size: 12px;
  color: var(--txt-dim);
  transition: all .18s;
  min-height: 40px;
}

.world-tab:hover {
  background: rgba(255, 255, 255, .14);
}

.world-tab.active {
  background: rgba(255, 255, 255, .16);
  border-color: var(--gold);
  color: #fff;
}

.world-tab.locked {
  opacity: .45;
  cursor: not-allowed;
}

.world-tab .wt-req {
  font-size: 10px;
  color: var(--gold);
}

/* ---------- level grid ---------- */
.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 10px;
  max-height: 52vh;
  overflow-y: auto;
  padding: 4px;
}

.level-grid::-webkit-scrollbar {
  width: 8px;
}

.level-grid::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .25);
  border-radius: 4px;
}

.level-card {
  background: rgba(18, 32, 62, .66);
  border: 2px solid rgba(255, 255, 255, .14);
  border-radius: var(--r-md);
  padding: 12px 8px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  position: relative;
  transition: transform .15s, background .15s, border-color .15s;
  min-height: 96px;
  justify-content: center;
}

.level-card:hover:not(.locked) {
  transform: translateY(-4px);
  background: rgba(255, 255, 255, .15);
  border-color: rgba(255, 255, 255, .35);
}

.level-card.locked {
  opacity: .45;
  cursor: not-allowed;
  filter: grayscale(.8);
}

.level-card.cleared {
  border-color: rgba(61, 220, 132, .4);
}

.lc-num {
  font-family: 'Luckiest Guy', sans-serif;
  font-size: 26px;
  color: var(--gold);
  -webkit-text-stroke: 1.2px #6b4a00;
  line-height: 1;
}

.lc-name {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--txt-dim);
  text-align: center;
  line-height: 1.25;
  min-height: 22px;
  display: flex;
  align-items: center;
}

.lc-stars {
  display: flex;
  gap: 2px;
  font-size: 14px;
}

.lc-stars span {
  color: #2b3d63;
}

.lc-stars span.lit {
  color: var(--gold);
  text-shadow: 0 0 8px rgba(255, 200, 60, .6);
}

.level-card.locked::after {
  content: '🔒';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 26px;
  background: rgba(8, 14, 32, .45);
  border-radius: inherit;
}

/* ---------- shop ---------- */
.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 12px;
  max-height: 52vh;
  overflow-y: auto;
  padding: 4px;
}

.shop-item {
  background: rgba(18, 32, 62, .66);
  border: 2px solid rgba(255, 255, 255, .14);
  border-radius: var(--r-md);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  transition: transform .15s, border-color .15s;
}

.shop-item:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 255, 255, .4);
}

.shop-item.equipped {
  border-color: var(--green);
  background: rgba(61, 220, 132, .14);
  box-shadow: 0 0 18px rgba(61, 220, 132, .3);
}

.shop-item.cant {
  opacity: .6;
}

.si-orb {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  box-shadow: inset -6px -8px 14px rgba(0, 0, 0, .45), inset 4px 5px 10px rgba(255, 255, 255, .35), 0 4px 10px rgba(0, 0, 0, .4);
}

.si-name {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.si-price {
  font-family: 'Luckiest Guy', sans-serif;
  font-size: 15px;
  color: var(--gold);
}

.si-price.owned {
  color: var(--green);
}

.si-price.equipped {
  color: #fff;
}

/* ---------- settings ---------- */
.opt-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 22px auto;
  width: min(360px, 86vw);
}

.opt-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: var(--r-md);
  padding: 12px 16px;
  font-weight: 700;
  font-size: 14px;
}

.toggle {
  width: 52px;
  height: 30px;
  border-radius: 99px;
  background: rgba(255, 255, 255, .16);
  position: relative;
  transition: background .2s;
  flex: none;
}

.toggle i {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  transition: transform .2s cubic-bezier(.3, 1.6, .5, 1);
}

.toggle[data-on="1"] {
  background: var(--green);
}

.toggle[data-on="1"] i {
  transform: translateX(22px);
}

.seg {
  display: flex;
  gap: 3px;
  background: rgba(0, 0, 0, .3);
  border-radius: var(--r-sm);
  padding: 3px;
}

.seg button {
  padding: 7px 12px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 800;
  color: var(--txt-dim);
  background: transparent;
  transition: background .15s, color .15s;
}

.seg button.active {
  background: rgba(255, 255, 255, .22);
  color: #fff;
}

/* ============================================================
   RESPONSIVE
============================================================ */
@media (max-width: 620px) {
  :root {
    --pad: 9px;
  }

  .panel {
    padding: 16px 14px;
  }

  /* Shrink the flanking cards so the level name gets real width
     instead of being cut to "LEVEL 8 · ME…". */
  #scoreCard {
    min-width: 0;
    padding: 6px 10px;
  }

  #scoreBest {
    display: none;
  }

  #score {
    font-size: 22px;
  }

  .coin-card {
    padding: 7px 10px;
    font-size: 12px;
  }

  .iconBtn {
    width: 36px;
    height: 36px;
  }

  #levelCard {
    padding: 6px 10px;
  }

  #levelName {
    max-width: 46vw;
    font-size: 10px;
  }

  .core-row {
    max-width: 46vw;
    gap: 4px;
  }

  .core-pip {
    width: 11px;
    height: 11px;
  }

  .ammo {
    width: 40px;
    height: 40px;
    font-size: 17px;
  }

  .level-grid {
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    gap: 8px;
    max-height: 46vh;
  }

  .lc-num {
    font-size: 21px;
  }

  .lc-name {
    font-size: 8px;
    min-height: 18px;
  }

  .rewardBtn {
    top: auto;
    bottom: calc(var(--safe-b) + 120px);
    padding: 7px 11px;
  }

  .menu-stats {
    gap: 10px;
    font-size: 11px;
  }

  .result-rows {
    width: min(300px, 90vw);
  }
}

/* Landscape phones: the HUD must not eat the play area */
@media (max-height: 460px) and (orientation: landscape) {
  #hud {
    padding: calc(var(--safe-t) + 6px) calc(var(--safe-r) + 8px) calc(var(--safe-b) + 6px) calc(var(--safe-l) + 8px);
  }

  .hud-card {
    padding: 5px 10px;
  }

  #score {
    font-size: 20px;
  }

  .ammo {
    width: 34px;
    height: 34px;
    font-size: 15px;
  }

  .ammo-name {
    display: none;
  }

  #powerWrap {
    height: 12px;
  }

  .stars {
    font-size: 34px;
    margin: 6px 0 2px;
  }

  .resultTitle {
    font-size: clamp(22px, 5vw, 34px);
  }

  .panel {
    padding: 12px 16px;
  }

  .level-grid {
    max-height: 40vh;
  }

  #title {
    font-size: clamp(34px, 7vw, 56px);
  }

  .subtitle {
    margin: 6px 0 12px;
  }
}

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
