/* Balloon Siege.
   The world is landscape (1280x720). Two layouts share one markup:
   - wide viewports (body.wide): board left, control dock as a right sidebar.
     The board keeps almost the full height, which is the point of the whole
     landscape rewrite — on a desktop window a portrait board was a thin strip.
   - narrow viewports: board on top at its natural aspect, dock fills the rest.
     main.js sets the board height there, so the dock never has to fight the
     canvas for space.

   The look: a bright cartoon board framed by a deep indigo "toy box" UI, with
   chunky pressable buttons and a rounded display face for every number. */

:root {
  --bs-display: "Lilita One", "Arial Rounded MT Bold", system-ui, sans-serif;
  --bs-ink: #1a1238;
  --bs-panel: #251a4d;
  --bs-panel-2: #31246a;
  --bs-line: rgba(255, 255, 255, 0.12);
  --bs-gold: #ffd166;
  --bs-go: #3ddc84;
  --bs-go-dark: #1e9a55;
}

body.game-page {
  background: radial-gradient(120% 90% at 30% 20%, #2d2166 0%, #150f30 70%);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.stage {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

body.wide .stage { flex-direction: row; }

/* Narrow layouts: main.js sets an explicit board height, so the board must not
   grow past it or the map floats in a band of dead black. Wide layouts let it
   take every pixel the sidebar leaves. */
.board {
  position: relative;
  flex: 0 0 auto;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 30%, rgba(94, 230, 200, 0.08), transparent 45%),
    radial-gradient(circle at 80% 80%, rgba(255, 93, 143, 0.08), transparent 45%),
    #120c2a;
}

body.wide .board { flex: 1 1 auto; height: auto; }

#map-layer {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.55), 0 0 0 3px rgba(255, 255, 255, 0.08);
}

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

/* ---- Top bar ---- */
.topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  pointer-events: none;
  z-index: 5;
}

.topbar > * { pointer-events: auto; }

.hud-back {
  white-space: nowrap;
  background: rgba(26, 18, 56, 0.85);
  border: 2px solid var(--bs-line);
  border-radius: 999px;
  color: #d8d0ff;
  font-weight: 800;
}

.stats {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  justify-content: flex-end;
  min-width: 0;
}

.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(180deg, #3a2c7a, #241a52);
  border: 2px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  padding: 4px 13px 4px 9px;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.stat-chip .k {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #b9b0e8;
  font-weight: 800;
}

.stat-chip .v {
  font-family: var(--bs-display);
  font-size: 18px;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}

.stat-chip--lives .k,
.stat-chip--cash .k { font-size: 15px; }
.stat-chip--lives .v { color: #ff9dbb; }
.stat-chip--cash .v { color: var(--bs-gold); }
.stat-chip--hero { border-color: rgba(255, 209, 102, 0.55); }
.stat-chip--hero .k { font-size: 16px; }
.stat-chip--hero .v { color: var(--bs-gold); }
.stat-chip--hero[hidden] { display: none; }

.stat-chip--hero .xp {
  width: 42px;
  height: 6px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.stat-chip--hero .xp i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #ffb020, var(--bs-gold));
}

.stat-chip--lives.low { animation: pulse-warn 0.8s ease infinite; }

@keyframes pulse-warn {
  50% { border-color: #ff5d8f; background: linear-gradient(180deg, #8a1f45, #4a0f28); }
}

/* ---- Dock ---- */
.dock {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 120px),
    var(--bs-ink);
  border-top: 3px solid #3b2d7c;
  padding: var(--space-2) var(--space-2) var(--space-3);
  overflow-y: auto;
  overscroll-behavior: contain;
}

body.wide .dock {
  flex: 0 0 auto;
  width: 224px;
  border-top: none;
  border-left: 3px solid #3b2d7c;
  padding-top: var(--space-3);
}

/* ---- Activated abilities ---- */
.abilities {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  justify-content: center;
}

.abilities:empty { display: none; }

.ability {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.2);
  background: radial-gradient(circle at 35% 30%, #5a46b0, #2a1d5e);
  color: var(--fg-0);
  font-family: var(--font-family);
  font-size: 23px;
  line-height: 1;
  cursor: pointer;
  overflow: hidden;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.4);
}

/* Cooldown shade drains from the bottom as --cd goes 1 -> 0. */
.ability::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--cd, 0) * 100%);
  background: rgba(10, 6, 24, 0.78);
  pointer-events: none;
}

.ability.ready {
  border-color: var(--bs-gold);
  background: radial-gradient(circle at 35% 30%, #ffe08a, #ff9f1c);
  box-shadow: 0 4px 0 #a35a00, 0 0 0 0 rgba(255, 209, 102, 0.7);
  animation: ability-pulse 1.4s ease-out infinite;
}

@keyframes ability-pulse {
  70% { box-shadow: 0 4px 0 #a35a00, 0 0 0 10px rgba(255, 209, 102, 0); }
  100% { box-shadow: 0 4px 0 #a35a00, 0 0 0 0 rgba(255, 209, 102, 0); }
}

.ability .ab-secs {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--bs-display);
  font-size: 17px;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.6);
  z-index: 2;
}

.ability.ready .ab-secs { display: none; }

/* ---- Round controls ---- */
.round-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.preview {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 100%;
}

.pv {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 800;
  text-transform: capitalize;
  padding: 3px 8px 3px 4px;
  border-radius: 999px;
  background: var(--bs-panel);
  border: 1px solid var(--bs-line);
}

.pv i {
  width: 11px;
  height: 13px;
  border-radius: 50% 50% 45% 45%;
  display: inline-block;
  box-shadow: inset -2px -2px 0 rgba(0, 0, 0, 0.25), inset 2px 2px 0 rgba(255, 255, 255, 0.35);
}

.pv.camo { border-color: #7dff9e; color: #7dff9e; }

.wave-bar {
  width: 100%;
  height: 7px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.wave-bar[hidden] { display: none; }

.wave-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #ff5d8f, var(--bs-gold));
  transition: width 0.15s linear;
}

/* Start on its own full-width row, the three toggles below it: squeezing all
   four into one row clipped the button label at every dock width. */
.round-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  align-items: center;
  width: 100%;
}

.round-buttons .btn--go { grid-column: 1 / -1; }

/* Chunky "toy" buttons: a solid bottom edge that squashes when pressed. */
.btn--go,
.btn--primary {
  font-family: var(--bs-display);
  font-weight: 400;
  letter-spacing: 0.03em;
  background: linear-gradient(180deg, #5cf09c, var(--bs-go));
  color: #0b3a20;
  border-radius: 14px;
  box-shadow: 0 5px 0 var(--bs-go-dark), 0 8px 18px rgba(0, 0, 0, 0.35);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
  transition: transform 0.06s ease, box-shadow 0.06s ease;
}

.btn--go:active,
.btn--primary:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--bs-go-dark), 0 3px 8px rgba(0, 0, 0, 0.3);
}

.btn--go {
  min-height: 48px;
  padding: var(--space-2) var(--space-2);
  font-size: 20px;
  white-space: nowrap;
}

.btn--go.running {
  background: var(--bs-panel);
  color: #9c93c8;
  box-shadow: 0 5px 0 #150e30;
  text-shadow: none;
}

/* Sending the next wave while the current one is still walking is the main
   aggressive play, so the button advertises it instead of greying out. */
.btn--go.early {
  background: linear-gradient(180deg, #ffd166, #ffa31a);
  color: #3a2200;
  box-shadow: 0 5px 0 #b86a00, 0 8px 18px rgba(0, 0, 0, 0.35);
}

.btn--ghost {
  font-family: var(--bs-display);
  font-weight: 400;
  letter-spacing: 0.03em;
  border-radius: 14px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  color: #e4defc;
  background: rgba(255, 255, 255, 0.06);
}

.chip-btn {
  appearance: none;
  border: 2px solid var(--bs-line);
  background: linear-gradient(180deg, #3a2c7a, #2a1f5c);
  color: var(--fg-0);
  font-family: var(--bs-display);
  font-size: 15px;
  letter-spacing: 0.03em;
  min-height: 44px;
  min-width: 44px;
  padding: 0 8px;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 4px 0 #150e30;
  transition: transform 0.06s ease, box-shadow 0.06s ease;
}

.chip-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #150e30;
}

.chip-btn[aria-pressed="true"],
.chip-btn.on {
  background: linear-gradient(180deg, #7ff3dc, var(--accent));
  border-color: transparent;
  color: #06231d;
  box-shadow: 0 4px 0 #22957e;
}

.chip-btn--danger {
  background: linear-gradient(180deg, #ff7d9f, #e8456f);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 0 #9e2346;
}

.chip-btn:disabled { opacity: 0.4; }

/* ---- Shop ---- */
/* A wrapping grid in both layouts: a horizontal scroller left most of a
   portrait dock empty and hid half the roster behind a swipe. */
.shop {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  gap: 8px;
  padding: 2px 2px 6px;
  align-content: start;
}

body.wide .shop { grid-template-columns: 1fr 1fr; }

.shop-item {
  --c: #8a93a6;
  position: relative;
  width: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px 7px;
  border-radius: 16px;
  background: linear-gradient(180deg, #33266e, #251b52);
  border: 2px solid rgba(255, 255, 255, 0.1);
  color: var(--fg-0);
  font-family: var(--font-family);
  cursor: pointer;
  box-shadow: 0 4px 0 #120b2a;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.shop-item:active { transform: translateY(3px); box-shadow: 0 1px 0 #120b2a; }

/* The icon sits in a bubble in the tower's own colour — the same colour its
   platform has on the board, so shop and map read as one. */
.shop-item .si-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  font-size: 24px;
  line-height: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--c) 55%, white), var(--c) 60%, color-mix(in srgb, var(--c) 60%, black));
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25), 0 2px 0 rgba(0, 0, 0, 0.35);
}

.shop-item .si-name { font-size: 10px; font-weight: 800; text-align: center; line-height: 1.15; color: #e4defc; }

.shop-item .si-cost {
  font-family: var(--bs-display);
  font-size: 14px;
  color: var(--bs-gold);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}

.shop-item.selected {
  border-color: #ffffff;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 45%, #33266e), #2a1f5c);
  box-shadow: 0 4px 0 #120b2a, 0 0 0 3px color-mix(in srgb, var(--c) 60%, transparent);
}

.shop-item.poor { opacity: 0.5; filter: saturate(0.4); }
.shop-item.poor .si-cost { color: #ff8fa9; }
.shop-item.gone { opacity: 0.3; filter: grayscale(1); }
.shop-item--hero { border-color: rgba(255, 209, 102, 0.55); }

.shop-item--hero::after {
  content: "HERO";
  position: absolute;
  top: -7px;
  right: -4px;
  font-family: var(--bs-display);
  font-size: 10px;
  letter-spacing: 0.06em;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--bs-gold);
  color: #3a2400;
  box-shadow: 0 2px 0 #a35a00;
}

/* ---- Inspector ---- */
.inspector[hidden] { display: none; }

.inspector { --c: #8a93a6; }

.inspector-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-1) var(--space-2);
}

.insp-icon {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  font-size: 26px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--c) 55%, white), var(--c) 60%, color-mix(in srgb, var(--c) 60%, black));
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25), 0 3px 0 rgba(0, 0, 0, 0.35);
}

.insp-title { flex: 1; min-width: 0; }
.insp-title h3 { font-family: var(--bs-display); font-weight: 400; font-size: 18px; letter-spacing: 0.02em; }
.insp-title p { font-size: 11px; color: #b9b0e8; }

.upgrades {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}

.upgrades[hidden] { display: none; }

.upgrade {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
  padding: 8px 10px;
  border-radius: 14px;
  background: linear-gradient(180deg, #33266e, #251b52);
  border: 2px solid rgba(255, 255, 255, 0.1);
  color: var(--fg-0);
  font-family: var(--font-family);
  min-height: 82px;
  cursor: pointer;
  box-shadow: 0 4px 0 #120b2a;
  transition: transform 0.06s ease, box-shadow 0.06s ease;
}

.upgrade:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #120b2a; }
.upgrade:disabled { opacity: 0.45; cursor: default; }
.upgrade .up-path { font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; color: #b9b0e8; }
#up-0 .up-path { color: #ffc566; }
#up-1 .up-path { color: #7ff3dc; }
.upgrade .up-name { font-family: var(--bs-display); font-weight: 400; font-size: 15px; letter-spacing: 0.02em; }
.upgrade .up-desc { font-size: 10px; color: #c9c1ee; line-height: 1.25; }
.upgrade .up-cost { font-family: var(--bs-display); font-size: 16px; color: var(--bs-gold); margin-top: auto; }

.upgrade.affordable {
  border-color: rgba(61, 220, 132, 0.8);
  background: linear-gradient(180deg, #2c5a5a, #213a48);
  box-shadow: 0 4px 0 #0e2a26;
}

.upgrade.too-dear .up-cost { color: #ff8fa9; }

/* ---- Hero panel ---- */
.hero-panel[hidden] { display: none; }

.hero-panel {
  background: linear-gradient(180deg, #4a3a18, #2e2410);
  border: 2px solid rgba(255, 209, 102, 0.5);
  border-radius: 14px;
  padding: 8px 10px;
}

.hp-row { display: flex; justify-content: space-between; font-size: 12px; }
.hp-row strong { font-family: var(--bs-display); font-weight: 400; font-size: 16px; color: var(--bs-gold); }
.hp-row span { color: #e8d9a8; }

.hp-bar {
  height: 8px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.4);
  overflow: hidden;
  margin: 6px 0;
}

.hp-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ffb020, var(--bs-gold)); }
.hp-perk { font-size: 10px; color: #e8d9a8; line-height: 1.3; }

.insp-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.insp-actions .chip-btn { flex: 1; }

/* ---- Hint bar & toast ---- */
.hint-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  top: 16%;
  background: rgba(26, 18, 56, 0.92);
  border: 2px solid var(--bs-gold);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 800;
  color: #fff5d6;
  z-index: 12;
  pointer-events: none;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.hint-bar[hidden] { display: none; }

.toast {
  font-family: var(--bs-display);
  font-weight: 400;
  font-size: 28px;
  letter-spacing: 0.03em;
  color: #fff;
  -webkit-text-stroke: 1.5px #1a1238;
  text-shadow: 0 3px 0 #1a1238, 0 6px 18px rgba(0, 0, 0, 0.5);
}

/* ---- Menu ---- */
.overlay--menu {
  justify-content: flex-start;
  overflow-y: auto;
  padding-top: max(var(--space-5), env(safe-area-inset-top));
  background: linear-gradient(180deg, #4fb4ff 0%, #8fd6ff 55%, #c9f0ff 100%);
  color: #1a1238;
}

/* Decorative sky behind the menu: drifting clouds and rising balloons. */
.sky {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.cloud {
  position: absolute;
  width: 180px;
  height: 56px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  animation: drift 60s linear infinite;
}

.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  background: inherit;
  border-radius: 50%;
}

.cloud::before { width: 80px; height: 80px; left: 24px; top: -38px; }
.cloud::after { width: 60px; height: 60px; left: 88px; top: -26px; }
.cloud.c1 { top: 12%; left: -200px; }
.cloud.c2 { top: 44%; left: -200px; animation-duration: 85s; animation-delay: -40s; transform: scale(0.7); }
.cloud.c3 { top: 74%; left: -200px; animation-duration: 70s; animation-delay: -18s; opacity: 0.7; }

@keyframes drift {
  to { translate: calc(100vw + 400px) 0; }
}

.bln {
  --c: #e2444a;
  position: absolute;
  bottom: -120px;
  width: 44px;
  height: 54px;
  border-radius: 50% 50% 48% 48% / 55% 55% 45% 45%;
  background: radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.75) 0 8%, transparent 9%),
    radial-gradient(circle at 40% 35%, color-mix(in srgb, var(--c) 70%, white), var(--c) 55%, color-mix(in srgb, var(--c) 65%, black));
  animation: rise 16s linear infinite;
}

.bln::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  width: 1.5px;
  height: 46px;
  background: rgba(26, 18, 56, 0.35);
}

.bln.b1 { left: 6%; --c: #e2444a; animation-delay: -2s; }
.bln.b2 { left: 18%; --c: #4aa3e8; animation-duration: 19s; animation-delay: -9s; transform: scale(0.8); }
.bln.b3 { left: 84%; --c: #3fc26a; animation-duration: 14s; animation-delay: -5s; }
.bln.b4 { left: 93%; --c: #f2d040; animation-duration: 21s; animation-delay: -13s; transform: scale(0.7); }
.bln.b5 { left: 72%; --c: #ff7fc4; animation-duration: 17s; animation-delay: -1s; transform: scale(0.9); }
.bln.b6 { left: 30%; --c: #b06bff; animation-duration: 23s; animation-delay: -16s; transform: scale(0.6); }
.bln.b7 { left: 55%; --c: #ff9d3d; animation-duration: 20s; animation-delay: -7s; transform: scale(0.75); }

@keyframes rise {
  0% { translate: 0 0; rotate: -4deg; }
  50% { translate: 18px -60vh; rotate: 4deg; }
  100% { translate: -6px calc(-100vh - 200px); rotate: -4deg; }
}

@media (prefers-reduced-motion: reduce) {
  .cloud, .bln { animation: none; }
  .bln { display: none; }
}

.menu-inner {
  position: relative;
  width: 100%;
  max-width: 760px;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  align-items: stretch;
  text-align: center;
}

.logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: var(--bs-display);
  font-weight: 400;
  line-height: 0.92;
  letter-spacing: 0.02em;
  transform: rotate(-3deg);
  margin: 4px 0 2px;
}

.logo span {
  display: block;
  -webkit-text-stroke: 3px #1a1238;
  paint-order: stroke fill;
  text-shadow: 0 6px 0 #1a1238, 0 12px 24px rgba(26, 18, 56, 0.35);
}

.logo .l1 { font-size: clamp(38px, 9vw, 68px); color: #ffd166; }
.logo .l2 { font-size: clamp(44px, 11vw, 84px); color: #ff5d8f; margin-top: -2px; }

.tagline {
  font-size: 14px;
  font-weight: 800;
  color: #1a1238;
  opacity: 0.75;
  margin-top: 6px;
}

.section-label {
  font-family: var(--bs-display);
  font-weight: 400;
  font-size: 16px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #1a1238;
  text-align: left;
  margin-top: var(--space-1);
}

.map-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.map-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: flex-start;
  text-align: left;
  padding: 7px 7px 10px;
  border-radius: 18px;
  background: #ffffff;
  border: 3px solid transparent;
  color: #1a1238;
  font-family: var(--font-family);
  cursor: pointer;
  box-shadow: 0 5px 0 rgba(26, 18, 56, 0.25);
  transition: transform 0.1s ease;
}

.map-card:hover { transform: translateY(-2px); }

.map-card.selected {
  border-color: #ff5d8f;
  box-shadow: 0 5px 0 #b8325c, 0 10px 24px rgba(26, 18, 56, 0.25);
  transform: translateY(-3px);
}

.map-card canvas { width: 100%; height: auto; border-radius: 12px; background: #d8f0d0; margin-bottom: 3px; }
.map-card .mc-name { font-family: var(--bs-display); font-weight: 400; font-size: 17px; padding: 0 3px; }

.map-card .mc-diff {
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #fff;
  background: #3ddc84;
  border-radius: 999px;
  padding: 1px 8px;
  margin-left: 3px;
}

.map-card[data-map="canyon"] .mc-diff { background: #4aa3e8; }
.map-card[data-map="meadow"] .mc-diff { background: #ffa31a; }
.map-card[data-map="shortcut"] .mc-diff { background: #e8456f; }
.map-card .mc-blurb { font-size: 11px; color: #5a5280; line-height: 1.3; padding: 0 3px; }

.diff-row { display: flex; gap: var(--space-2); }

.diff-card {
  flex: 1;
  padding: 10px var(--space-2);
  border-radius: 16px;
  background: #ffffff;
  border: 3px solid transparent;
  color: #1a1238;
  font-family: var(--font-family);
  cursor: pointer;
  box-shadow: 0 5px 0 rgba(26, 18, 56, 0.25);
}

.diff-card.selected { color: #fff; transform: translateY(-2px); }
.diff-card--easy.selected { background: #3ddc84; border-color: #1e9a55; box-shadow: 0 5px 0 #1e9a55; }
.diff-card--normal.selected { background: #4aa3e8; border-color: #2471b0; box-shadow: 0 5px 0 #2471b0; }
.diff-card--hard.selected { background: #e8456f; border-color: #9e2346; box-shadow: 0 5px 0 #9e2346; }
.diff-card .dc-name { display: block; font-family: var(--bs-display); font-weight: 400; font-size: 18px; }
.diff-card .dc-sub { display: block; font-size: 11px; font-weight: 700; opacity: 0.75; margin-top: 2px; }

.btn--wide { width: 100%; margin-top: var(--space-3); font-size: 26px; min-height: 60px; }

.best-line { font-size: 13px; font-weight: 800; color: #1a1238; opacity: 0.7; }
.rotate-note { font-size: 13px; font-weight: 800; color: #b8325c; }
.rotate-note[hidden] { display: none; }

/* ---- Pause / end ---- */
.overlay--card {
  background: radial-gradient(circle at 50% 40%, rgba(49, 36, 106, 0.94), rgba(14, 9, 32, 0.96));
  backdrop-filter: blur(4px);
}

.overlay--card h2 {
  font-family: var(--bs-display);
  font-weight: 400;
  font-size: clamp(40px, 9vw, 64px);
  letter-spacing: 0.02em;
  color: #ffd166;
  -webkit-text-stroke: 2px #1a1238;
  paint-order: stroke fill;
  text-shadow: 0 5px 0 #1a1238;
  transform: rotate(-2deg);
}

.overlay--card .stat {
  min-width: 240px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 8px 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.07);
  color: #c9c1ee;
  font-weight: 700;
}

.overlay--card .stat strong { font-family: var(--bs-display); font-weight: 400; color: #fff; }
.overlay--card #end-best { justify-content: center; color: #ffd166; background: none; }
.overlay--card .actions .btn { min-width: 150px; }

@media (min-width: 1100px) {
  body.wide .dock { width: 268px; }
}

@media (min-width: 760px) {
  .map-grid { grid-template-columns: repeat(4, 1fr); }
}

/* A phone in portrait has no room for a full HUD row, and a wrapped top bar
   eats board height. Everything non-essential shrinks or goes. */
@media (max-width: 480px) {
  .hud-back { font-size: 12px; padding: 6px 10px; }
  .stat-chip { padding: 3px 8px 3px 6px; gap: 3px; }
  .stat-chip .k { font-size: 9px; }
  .stat-chip--lives .k,
  .stat-chip--cash .k { font-size: 12px; }
  .stat-chip .v { font-size: 15px; }
  .stat-chip--hero .xp { display: none; }
}

/* Very short viewports (a phone in landscape) cannot spare a line of chrome. */
@media (max-height: 430px) {
  .stat-chip { padding: 2px 10px 2px 7px; }
  .stat-chip .v { font-size: 15px; }
  .topbar { padding: 6px var(--space-2); }
  .shop-item .si-icon { width: 34px; height: 34px; font-size: 20px; }
  .logo { flex-direction: row; gap: 10px; }
}

/* ---- Pause button, saved game, mode picker ---- */
.hud-left { display: flex; gap: 6px; align-items: center; }

.pause-btn {
  appearance: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 2px solid var(--bs-line);
  background: linear-gradient(180deg, #3a2c7a, #241a52);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
}

.pause-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35); }

.continue-box {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px 10px 10px 16px;
  border-radius: 18px;
  background: #ffffff;
  border: 3px solid #ffd166;
  box-shadow: 0 5px 0 #c9971f;
  text-align: left;
}

.continue-box[hidden] { display: none; }
.continue-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.continue-text strong { font-family: var(--bs-display); font-weight: 400; font-size: 18px; color: #1a1238; }
.continue-text span { font-size: 12px; font-weight: 700; color: #5a5280; }
.continue-box .btn { flex: 0 0 auto; font-size: 20px; min-height: 48px; }

.mode-card--endless.selected { background: #9b6bff; border-color: #6a3fd0; box-shadow: 0 5px 0 #6a3fd0; }
.mode-card:not(.mode-card--endless).selected { background: #ffa31a; border-color: #b86a00; box-shadow: 0 5px 0 #b86a00; }

.actions--stack { flex-direction: column; align-items: stretch; min-width: 240px; }

.btn--save {
  font-family: var(--bs-display);
  font-weight: 400;
  letter-spacing: 0.03em;
  border-radius: 14px;
  background: linear-gradient(180deg, #ffd166, #ffa31a);
  color: #3a2200;
  box-shadow: 0 5px 0 #b86a00;
}

.btn--save:active { transform: translateY(4px); box-shadow: 0 1px 0 #b86a00; }

@media (max-width: 480px) {
  .pause-btn { width: 36px; height: 36px; font-size: 13px; }
  .continue-box { flex-direction: column; align-items: stretch; }
}
