:root {
  --bg-deep: #0a0b1e;
  --bg-mid: #1a1040;
  --purple: #8a3ffc;
  --purple-bright: #b96bff;
  --gold: #ffd23d;
  --danger: #ff2e63;
  --text: #f2ecff;
  --panel-border: rgba(185, 107, 255, 0.45);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at 50% 20%, var(--bg-mid), var(--bg-deep) 70%);
  color: var(--text);
  font-family: 'Orbitron', 'Segoe UI', system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Neon-city backdrop regenerated by FLUX.2-klein from the gameplay card
   (all items/UI prompted out — the card's own pixels are too occluded to
   extract). Blurred/dimmed into ambience behind every screen. */
#concept-backdrop {
  position: absolute;
  inset: -24px;
  background-image: url('../assets/gen/city-gen.png');
  background-size: cover;
  background-position: center;
  filter: blur(3.5px) brightness(0.66) saturate(1.25);
  transform: scale(1.06);
  z-index: 0;
}

#game-canvas,
.screen {
  z-index: 1;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.screen.active {
  display: flex;
}

#menu-screen.active,
#gameover-screen.active,
#howto-screen.active,
#leaderboard-screen.active {
  pointer-events: auto;
}

/* Menu screen — replicates the top-left concept-art card layout:
   left column = mascot + title + buttons; right column = stats + mode/buy
   side panels. Bottom footer strip lives outside the card.
   No containing box — full-bleed scene; the screen IS the layout. */
#menu-screen.active {
  display: block;
  padding: 3vh 2vw 6vh 0;
}

.menu-left {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
  padding-right: 2rem;
  text-align: left;
}

.panel-stats {
  position: absolute;
  top: 3vh;
  right: 2vw;
  width: min(26vw, 340px);
}

.panel-modes {
  position: absolute;
  top: calc(3vh + 9rem);
  right: 2vw;
  width: min(26vw, 340px);
}

.panel-tokens {
  position: absolute;
  top: calc(3vh + 15.5rem);
  right: 2vw;
  width: min(26vw, 340px);
}

.mode-active {
  border-color: var(--gold);
  background: rgba(255, 210, 61, 0.12);
  box-shadow: 0 0 14px rgba(255, 210, 61, 0.25);
}

.token-icon {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

/* In-game Snippy: card shows him anchored bottom-left mid-slash. Same
   generated sprite, smaller, bleeding off the corner; pointer-transparent. */
.mascot.mascot-game {
  position: absolute;
  left: -1vw;
  bottom: -2vh;
  height: 44vh;
  width: auto;
  z-index: 0;
  pointer-events: none;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.55));
}

.mascot.mascot-menu {
  position: absolute;
  left: 0;
  bottom: -3vh;
  height: 76vh;
  width: auto;
  max-width: none;
  margin: 0;
  z-index: 0;
  pointer-events: none;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.55));
}

.menu-title-block {
  position: relative;
  z-index: 1;
  margin-left: 27vw;
  margin-top: 0.3rem;
}

.menu-desc {
  margin: 0.4rem 0 0;
  margin-left: 12vw;
  font-size: 0.78rem;
  color: rgba(242, 236, 255, 0.65);
  max-width: 320px;
}

.menu-buttons {
  position: relative;
  z-index: 1;
  margin-left: 39vw;
  margin-bottom: 1.6rem;
  width: min(320px, 100%);
}

.menu-powered {
  position: relative;
  z-index: 1;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  color: rgba(242, 236, 255, 0.55);
}

.xpr-mark {
  color: var(--purple-bright);
  font-weight: 700;
}

.side-panel {
  background: rgba(10, 11, 30, 0.5);
  border: 1px solid rgba(185, 107, 255, 0.3);
  border-radius: 14px;
  padding: 0.8rem 1rem;
}

.side-heading {
  margin: 0 0 0.55rem;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  color: rgba(242, 236, 255, 0.7);
  font-weight: 700;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 0.8rem;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.stat-item span {
  font-size: 0.62rem;
  color: rgba(242, 236, 255, 0.55);
}

.stat-item strong {
  font-size: 0.95rem;
  color: var(--gold);
}

.mode-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.55rem 0.7rem;
  margin: 0.25rem 0;
  border: 1px solid rgba(185, 107, 255, 0.35);
  border-radius: 10px;
  background: rgba(138, 63, 252, 0.12);
  color: var(--text);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  text-align: left;
}

.mode-btn:disabled {
  cursor: default;
  opacity: 0.85;
}

.mode-icon {
  font-size: 1rem;
  width: 1.3rem;
  text-align: center;
}

.mode-icon.ksto {
  color: var(--gold);
  font-weight: 900;
}

/* Power-ups strip — bottom-center of the menu, per the sheet's POWER
   UPS shop card. Buttons stay disabled until wallet/burn wiring. */
.powerups-panel {
  position: absolute;
  left: 31vw;
  right: 29.5vw;
  bottom: 4.5vh;
}

.powerups-sub {
  font-weight: 400;
  letter-spacing: 0.04em;
  color: rgba(242, 236, 255, 0.45);
  font-size: 0.55rem;
}

.powerups-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
}

.powerup {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 2px;
  min-width: 0;
}

.powerup img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.5));
}

.powerup b {
  font-size: 0.5rem;
  letter-spacing: 0.04em;
  color: rgba(242, 236, 255, 0.9);
  white-space: nowrap;
}

.powerup > span {
  font-size: 0.44rem;
  color: rgba(242, 236, 255, 0.55);
  line-height: 1.2;
  min-height: 1.9em;
}

.powerup-buy {
  margin-top: 3px;
  padding: 0.28rem 0.4rem;
  width: 100%;
  border: none;
  border-radius: 7px;
  background: linear-gradient(180deg, #3ddc84, #1d9e56);
  color: #052b14;
  font-family: inherit;
  font-size: 0.55rem;
  font-weight: 900;
  letter-spacing: 0.03em;
}

.powerup-buy:disabled {
  cursor: default;
}

.powerups-note {
  margin-top: 0.45rem;
  font-size: 0.52rem;
  letter-spacing: 0.04em;
  color: rgba(255, 158, 100, 0.9);
}

/* Bottom purple strip, matching the concept sheet's footer band. Only
   visible on the menu screen. */
.app-footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 1.5rem;
  background: linear-gradient(90deg, #3b1470, #5c22b8 50%, #3b1470);
  border-top: 1px solid rgba(185, 107, 255, 0.5);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  pointer-events: none;
}

.app-footer.visible {
  display: flex;
}

.footer-mini {
  color: var(--gold);
  font-weight: 900;
  margin-right: 0.4rem;
}

.footer-left {
  color: rgba(242, 236, 255, 0.75);
}

.footer-logo {
  font-size: 1.1rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  background: linear-gradient(180deg, #fff, var(--purple-bright));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.footer-right {
  color: rgba(242, 236, 255, 0.75);
}

.panel {
  background: linear-gradient(180deg, rgba(26, 16, 64, 0.92), rgba(10, 11, 30, 0.96));
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 2.5rem 3rem;
  text-align: center;
  box-shadow: 0 0 60px rgba(138, 63, 252, 0.35);
  max-width: 90vw;
}

.title {
  font-size: clamp(2.5rem, 8vw, 4rem);
  font-weight: 900;
  margin: 0;
  letter-spacing: 0.08em;
  background: linear-gradient(180deg, #ffffff, var(--purple-bright));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 30px rgba(185, 107, 255, 0.6);
}

.title.small {
  font-size: clamp(1.8rem, 6vw, 2.6rem);
}

/* Native SVG recreation of the Snippy mascot (assets/snippy.svg). */
.mascot {
  display: block;
  margin: 0 auto 0.5rem;
  max-width: 220px;
  width: 60%;
  height: auto;
}

.mascot-gameover {
  max-width: 170px;
}

.scissor {
  display: inline-block;
  color: var(--gold);
  -webkit-text-fill-color: var(--gold);
  transform: rotate(15deg);
}

.tagline {
  margin: 0.3rem 0 0;
  color: var(--gold);
  font-weight: 700;
  letter-spacing: 0.12em;
  font-size: clamp(1rem, 3vw, 1.4rem);
}

.subtitle {
  margin: 0.4rem 0 1.8rem;
  font-size: 0.85rem;
  color: rgba(242, 236, 255, 0.7);
  letter-spacing: 0.04em;
}

.btn {
  display: block;
  width: 100%;
  min-width: 220px;
  padding: 0.9rem 1.5rem;
  margin: 0.5rem 0;
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(180deg, var(--gold), #e0a800);
  color: #241300;
  box-shadow: 0 0 24px rgba(255, 210, 61, 0.5);
}

.btn-secondary {
  background: rgba(138, 63, 252, 0.18);
  border: 1px solid var(--panel-border);
  color: var(--text);
}

.hud-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 1rem 1.5rem;
  pointer-events: none;
}

.hud-block {
  background: rgba(10, 11, 30, 0.55);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 0.5rem 1rem;
  text-align: center;
  min-width: 90px;
}

.hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}

.hud-label {
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  color: rgba(242, 236, 255, 0.6);
}

.hud-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--gold);
}

.hud-lives {
  font-size: 1.2rem;
}

.hud-timer {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--gold);
}

.hud-combo-wrap {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}

.hud-combo {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--purple-bright);
}

.hud-combo-label {
  font-size: 0.8rem;
  color: var(--gold);
  text-transform: uppercase;
  min-height: 1em;
}

.mission-bar {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  width: min(90vw, 480px);
  background: rgba(10, 11, 30, 0.6);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 0.75rem 1rem;
  pointer-events: none;
}

.mission-label {
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  margin-bottom: 0.4rem;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.bonus-perfect {
  color: #3ddc84;
  font-weight: 700;
}

.mission-track {
  height: 10px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  overflow: hidden;
}

.mission-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--purple), var(--purple-bright));
  transition: width 0.15s ease;
}

.mission-progress {
  margin-top: 0.3rem;
  text-align: right;
  font-size: 0.75rem;
  color: rgba(242, 236, 255, 0.7);
}

/* Power-up dock — vertical strip on the left edge of gameplay; tap to
   activate mid-run, badge shows how many are left in stock. */
.power-dock {
  position: absolute;
  left: 0.7rem;
  top: 42%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  pointer-events: auto;
  z-index: 2;
}

.dock-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.dock-name {
  font-size: 0.4rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: rgba(242, 236, 255, 0.75);
  white-space: nowrap;
  pointer-events: none;
}

.dock-item {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 12px;
  border: 1px solid rgba(185, 107, 255, 0.4);
  background: rgba(10, 11, 30, 0.65);
  padding: 5px;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.dock-item:hover:not(:disabled) {
  transform: scale(1.06);
  border-color: var(--purple-bright);
}

.dock-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  display: block;
}

.dock-count {
  position: absolute;
  top: -7px;
  right: -7px;
  min-width: 18px;
  padding: 1px 4px;
  border-radius: 9px;
  background: var(--gold);
  color: #241300;
  font-size: 0.58rem;
  font-weight: 900;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

.dock-item.active {
  border-color: var(--gold);
  box-shadow: 0 0 16px rgba(255, 210, 61, 0.6);
}

.dock-item:disabled {
  opacity: 0.35;
  cursor: default;
}

/* Combo meter card — bottom-right of gameplay, per the sheet's COMBO
   METER card: semicircular gauge + milestone track 5→50. */
.combo-meter-card {
  position: absolute;
  right: 1.2rem;
  bottom: 1.4rem;
  width: 272px;
  background: rgba(10, 11, 30, 0.6);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 0.55rem 0.8rem 0.5rem;
  pointer-events: none;
}

.cm-heading {
  margin: 0 0 0.15rem;
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-align: center;
  color: rgba(242, 236, 255, 0.7);
  font-weight: 700;
}

.cm-gauge-wrap {
  position: relative;
}

.cm-gauge {
  display: block;
  width: 100%;
  height: auto;
}

.cm-track,
.cm-fill {
  fill: none;
  stroke-width: 10;
  stroke-linecap: round;
}

.cm-track {
  stroke: rgba(255, 255, 255, 0.12);
}

.cm-fill {
  stroke: url(#cmGrad);
  stroke-dasharray: 251.4;
  stroke-dashoffset: 251.4;
  filter: drop-shadow(0 0 6px rgba(185, 107, 255, 0.75));
  transition: stroke-dashoffset 0.18s ease;
}

.cm-center {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.cm-num {
  font-size: 1.55rem;
  font-weight: 900;
  color: var(--gold);
  line-height: 1;
}

.cm-tier {
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--purple-bright);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  min-height: 1em;
}

.cm-ticks {
  display: flex;
  justify-content: space-between;
  margin-top: 0.2rem;
  padding-top: 16px;
  position: relative;
}

.cm-ticks::before {
  content: '';
  position: absolute;
  top: 14px;
  left: 7%;
  right: 7%;
  height: 2px;
  background: rgba(185, 107, 255, 0.35);
}

.cm-tick {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  position: relative;
  flex: 1;
}

.cm-tick i {
  position: absolute;
  top: -9px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #33235f;
  border: 2px solid rgba(185, 107, 255, 0.45);
}

.cm-tick b {
  font-size: 0.58rem;
  color: rgba(242, 236, 255, 0.85);
}

.cm-tick span {
  font-size: 0.33rem;
  color: rgba(242, 236, 255, 0.5);
  letter-spacing: 0;
  white-space: nowrap;
}

.cm-tick.active i {
  background: var(--purple-bright);
  border-color: #fff;
  box-shadow: 0 0 8px var(--purple-bright);
}

.cm-tick.active b,
.cm-tick.active span {
  color: var(--gold);
}

/* Game-over card — wide 3-column layout per the concept: stats left,
   mascot center, rewards + actions right, tagline footer. */
.gameover-panel {
  width: min(96vw, 880px);
  padding: 1.5rem 2.2rem 1.2rem;
}

.go-title {
  margin: 0 0 1rem;
  font-size: clamp(2rem, 6vw, 2.7rem);
  font-weight: 900;
  letter-spacing: 0.12em;
  background: linear-gradient(180deg, #ff9ec6, var(--danger));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 30px rgba(255, 46, 99, 0.4);
}

.go-grid {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) auto minmax(200px, 1fr);
  gap: 1.5rem;
  align-items: center;
  text-align: left;
}

.mascot.mascot-gameover {
  max-width: 215px;
  width: 18vw;
  margin: 0;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.55));
}

.go-stats {
  display: flex;
  flex-direction: column;
}

.go-final {
  margin-bottom: 0.55rem;
}

.go-final-label {
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  color: rgba(242, 236, 255, 0.6);
}

.go-final-value {
  display: block;
  font-size: 2rem;
  font-weight: 900;
  color: var(--gold);
  line-height: 1.05;
}

.go-right {
  display: flex;
  flex-direction: column;
}

.go-rewards {
  background: rgba(138, 63, 252, 0.1);
  border: 1px solid rgba(185, 107, 255, 0.3);
  border-radius: 12px;
  padding: 0.65rem 0.9rem;
  margin-bottom: 0.7rem;
}

.go-rewards-heading {
  margin: 0 0 0.35rem;
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  color: rgba(242, 236, 255, 0.7);
}

.go-reward {
  font-size: 0.78rem;
  padding: 0.14rem 0;
  color: var(--purple-bright);
  font-weight: 700;
  letter-spacing: 0.03em;
}

.btn-purple {
  background: linear-gradient(180deg, var(--purple-bright), var(--purple));
  color: #fff;
  box-shadow: 0 0 24px rgba(138, 63, 252, 0.55);
}

.btn-gold {
  background: linear-gradient(180deg, var(--gold), #e0a800);
  color: #241300;
  box-shadow: 0 0 24px rgba(255, 210, 61, 0.4);
}

.go-tagline {
  margin-top: 1.1rem;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  color: rgba(242, 236, 255, 0.6);
}

.gameover-panel .stat-row {
  display: flex;
  justify-content: space-between;
  gap: 1.2rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid rgba(185, 107, 255, 0.15);
  font-size: 0.82rem;
}

.gameover-panel .stat-row strong {
  color: var(--gold);
}

.mute-btn {
  border: 1px solid rgba(185, 107, 255, 0.4);
  background: rgba(10, 11, 30, 0.5);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.8rem;
  padding: 0.1rem 0.4rem;
  margin-right: 0.5rem;
  cursor: pointer;
  pointer-events: auto;
}

/* Back button — top-right of gameplay, clears the lives HUD block. */
.back-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 3;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  border: 1px solid var(--panel-border);
  background: rgba(10, 11, 30, 0.6);
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  pointer-events: auto;
}

.hud-top {
  padding-right: 4.6rem;
}

/* --- HOW TO PLAY + LEADERBOARD panels --- */
.howto-panel,
.leaderboard-panel {
  width: min(94vw, 640px);
  padding: 1.6rem 2rem 1.4rem;
}

.panel-title {
  margin: 0 0 0.9rem;
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  font-weight: 900;
  letter-spacing: 0.1em;
  background: linear-gradient(180deg, #fff, var(--purple-bright));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 26px rgba(185, 107, 255, 0.5);
}

.howto-steps {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 1rem;
  text-align: left;
}

.howto-step {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-size: 0.82rem;
}

.howto-step b {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--purple);
  color: #fff;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.howto-step .bad { color: var(--danger); font-style: normal; font-weight: 700; }
.howto-step .good { color: #3ddc84; font-style: normal; font-weight: 700; }

.legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
  margin-bottom: 0.9rem;
}

.legend-heading {
  margin: 0 0 0.45rem;
  font-size: 0.66rem;
  letter-spacing: 0.14em;
}
.legend-heading.bad { color: var(--danger); }
.legend-heading.good { color: #3ddc84; }

.legend-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
}

.legend-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 0.4rem 0.2rem;
  border-radius: 10px;
  background: rgba(138, 63, 252, 0.08);
  border: 1px solid rgba(185, 107, 255, 0.2);
}

.legend-item img {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.legend-item span {
  font-size: 0.48rem;
  letter-spacing: 0.03em;
  color: rgba(242, 236, 255, 0.8);
  text-align: center;
  line-height: 1.25;
}

.howto-tip {
  margin: 0 0 1rem;
  font-size: 0.7rem;
  color: rgba(255, 210, 61, 0.85);
}

.lb-sub {
  margin: -0.4rem 0 0.9rem;
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  color: rgba(242, 236, 255, 0.55);
}

.lb-rows {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.9rem;
}

.lb-row {
  display: grid;
  grid-template-columns: 2.4rem 1fr auto;
  align-items: center;
  gap: 0.7rem;
  padding: 0.45rem 0.8rem;
  border-radius: 10px;
  background: rgba(138, 63, 252, 0.08);
  border: 1px solid rgba(185, 107, 255, 0.2);
  text-align: left;
}

.lb-rank {
  font-weight: 900;
  font-size: 0.95rem;
  color: rgba(242, 236, 255, 0.6);
}
.lb-row:nth-child(1) .lb-rank { color: var(--gold); }
.lb-row:nth-child(2) .lb-rank { color: #d7d7e8; }
.lb-row:nth-child(3) .lb-rank { color: #d08a4e; }

.lb-score {
  font-weight: 900;
  color: var(--gold);
  font-size: 1rem;
}
.lb-row .lb-meta {
  font-size: 0.58rem;
  color: rgba(242, 236, 255, 0.55);
}
.lb-date { font-size: 0.6rem; color: rgba(242, 236, 255, 0.5); }

.lb-empty {
  padding: 1.2rem 0;
  font-size: 0.75rem;
  color: rgba(242, 236, 255, 0.6);
}

.lb-note {
  margin: 0 0 0.9rem;
  font-size: 0.6rem;
  letter-spacing: 0.06em;
  color: rgba(242, 236, 255, 0.5);
}

/* ============ Mobile (<=768px) ============ */
@media (max-width: 768px) {
  #app { height: 100dvh; }

  /* Menu becomes a vertical scroll: title → mascot → buttons → powered,
     then stats / modes / power-ups as full-width cards below. */
  #menu-screen.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    overflow-y: auto;
    padding: 4vh 4vw 5.5rem;
    gap: 0.7rem;
    touch-action: pan-y;
  }

  .menu-left {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: auto;
    padding-right: 0;
    width: 100%;
    text-align: center;
    gap: 0.5rem;
  }

  .menu-title-block { order: 1; margin: 0; }
  .menu-buttons    { order: 3; margin: 0; width: min(340px, 88vw); }
  .menu-powered    { order: 4; margin-top: 0.2rem; }

  .mascot.mascot-menu {
    order: 2;
    position: relative;
    left: auto;
    bottom: auto;
    height: 30vh;
    max-width: 72vw;
  }

  .menu-desc { margin: 0.4rem auto 0; max-width: 300px; }

  .btn { min-width: 0; padding: 0.8rem 1.2rem; font-size: 0.92rem; }

  .panel-stats,
  .panel-modes,
  .panel-tokens,
  .powerups-panel {
    position: static;
    width: min(420px, 100%);
  }

  .panel-modes,
  .panel-tokens {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
  }
  .panel-modes .side-heading,
  .panel-tokens .side-heading { grid-column: 1 / -1; margin-bottom: 0.1rem; }
  .panel-modes .mode-btn,
  .panel-tokens .mode-btn { margin: 0; padding: 0.5rem 0.55rem; font-size: 0.68rem; }
  .panel-modes .mode-icon { width: 1rem; font-size: 0.85rem; }
  .token-icon { width: 1.2rem; height: 1.2rem; }

  .powerups-panel { padding-bottom: 0.5rem; }
  .powerup img { width: 38px; height: 38px; }
  .powerup b { font-size: 0.42rem; }
  .powerup > span { display: none; }
  .powerup-buy { font-size: 0.48rem; padding: 0.24rem 0.2rem; }
  .powerups-note { font-size: 0.48rem; text-align: center; }

  .app-footer { padding: 0.5rem 0.8rem; font-size: 0.58rem; gap: 0.5rem; }
  .app-footer .footer-left { display: none; }
  .app-footer .footer-logo { font-size: 0.9rem; }

  /* Gameplay: compact HUD, smaller dock, combo card above mission bar. */
  .hud-top { padding: 0.5rem 0.6rem; padding-right: 3.4rem; }
  .back-btn { top: 0.55rem; right: 0.55rem; width: 34px; height: 34px; font-size: 0.9rem; }
  .hud-block { padding: 0.35rem 0.6rem; min-width: 64px; }
  .hud-value { font-size: 1.05rem; }
  .hud-timer { font-size: 1.25rem; }
  .hud-lives { font-size: 0.95rem; }
  .hud-combo { font-size: 1.15rem; }
  .hud-combo-label { font-size: 0.62rem; }

  .mascot.mascot-game { height: 13vh; }

  .power-dock { left: 0.4rem; top: 5rem; transform: none; gap: 0.4rem; }
  .dock-slot { width: 66px; }
  .dock-item { width: 46px; height: 46px; border-radius: 10px; }
  .dock-name { font-size: 0.27rem; letter-spacing: 0.02em; }
  .dock-count { font-size: 0.5rem; min-width: 15px; top: -5px; right: -5px; }

  /* Combo meter + mission bar share the bottom row side by side. */
  .combo-meter-card {
    width: 128px;
    right: 0.45rem;
    bottom: 0.55rem;
    padding: 0.3rem 0.45rem 0.3rem;
  }
  .cm-heading { font-size: 0.5rem; }
  .cm-num { font-size: 0.95rem; }
  .cm-tier { font-size: 0.46rem; }
  .cm-tick b { font-size: 0.46rem; }
  .cm-tick span { display: none; }
  .cm-ticks { padding-top: 9px; margin-top: 0.1rem; }
  .cm-ticks::before { top: 7px; }
  .cm-tick i { top: -4px; width: 5px; height: 5px; }

  .mission-bar {
    bottom: 0.55rem;
    left: 86px;
    right: 140px;
    transform: none;
    width: auto;
    padding: 0.45rem 0.6rem;
  }
  .mission-label { font-size: 0.55rem; }
  .mission-progress { font-size: 0.62rem; }

  /* Overlay panels: scrollable, top-anchored so nothing clips. */
  #gameover-screen.active,
  #howto-screen.active,
  #leaderboard-screen.active {
    overflow-y: auto;
    touch-action: pan-y;
    padding: 4vh 3vw;
    justify-content: flex-start;
  }
  .howto-panel,
  .leaderboard-panel {
    padding: 1.1rem 1.1rem 1rem;
    margin: auto;
  }
  .legend { gap: 0.5rem; }
  .legend-grid { grid-template-columns: repeat(2, 1fr); gap: 0.35rem; }
  .legend-item img { width: 34px; height: 34px; }
  .howto-step { font-size: 0.72rem; }
  .howto-tip { font-size: 0.62rem; }
  .panel.gameover-panel {
    width: min(94vw, 420px);
    padding: 1.1rem 1.1rem 1rem;
    margin: auto;
  }
  .go-grid {
    grid-template-columns: 1fr;
    gap: 0.8rem;
    text-align: center;
  }
  .go-stats { text-align: left; }
  .go-final { text-align: center; }
  .mascot.mascot-gameover {
    width: 42vw;
    max-width: 150px;
    margin: 0 auto;
  }
  .go-rewards { margin-bottom: 0.5rem; }
  .go-tagline { margin-top: 0.7rem; font-size: 0.58rem; }
}
