:root {
  --bg: #14061f;
  --pink: #ff3d8f;
  --gold: #ffe66d;
  --paper: #fff7ee;
  --muted: #f3d6ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--paper);
  font-family: Nunito, system-ui, sans-serif;
  overflow: hidden;
  touch-action: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hud {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
  pointer-events: none;
}

.hud-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.hud-stats {
  font-weight: 800;
  text-shadow: 0 2px 8px #000a;
}

.pause-btn,
.boost-btn {
  pointer-events: auto;
  background: #ff3d8f;
  color: #fff;
  border: 0;
  padding: 8px 14px;
  min-height: 44px;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  border-radius: 999px;
}

.hud-boost {
  pointer-events: none;
}

.panel {
  pointer-events: auto;
  touch-action: pan-y;
  position: absolute;
  inset: 0;
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.screen-dim {
  align-items: center;
  background: rgba(12, 4, 24, 0.62);
}

.screen-art,
.screen-map {
  flex-direction: column;
  background: #14061f;
}

.screen-map {
  overflow: hidden;
}

.art-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center 30%;
  transform: scale(1.04);
}

.map-bg {
  background-position: center;
  filter: saturate(1.15);
}

.art-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(20, 6, 31, 0.15) 20%, rgba(20, 6, 31, 0.55) 55%, rgba(12, 3, 22, 0.94) 100%);
}

.title-ui,
.story-ui {
  position: relative;
  z-index: 1;
  margin-top: auto;
  width: min(560px, calc(100% - 28px));
  padding: 0 0 28px;
  align-self: center;
}

.title-ui h1,
.story-ui h2 {
  font-family: Fredoka, Nunito, sans-serif;
  font-size: clamp(42px, 8vw, 64px);
  line-height: 0.95;
  margin: 0 0 10px;
  color: var(--gold);
  text-shadow: 0 4px 0 #c43b00, 0 10px 24px #0008;
}

.story-ui h2 {
  font-size: clamp(28px, 6vw, 40px);
}

.tagline,
.story-ui p {
  margin: 0 0 18px;
  font-size: 16px;
  line-height: 1.45;
  color: var(--paper);
  text-shadow: 0 2px 10px #000a;
}

.story-kicker {
  margin: 0 0 6px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 800;
  color: #ffb4de;
}

.juice-chip {
  display: inline-block;
  margin: 0 0 12px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 230, 109, 0.18);
  color: var(--gold);
  font-weight: 800;
}

.candy-btn {
  display: block;
  width: 100%;
  min-height: 54px;
  margin: 0 0 10px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-family: Fredoka, Nunito, sans-serif;
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
}

.candy-btn.primary {
  background: linear-gradient(#ffe66d, #ff9f1c);
  color: #5a2208;
}

.candy-btn.ghost {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border: 2px solid rgba(255, 182, 217, 0.7);
}

.candy-btn.danger {
  background: rgba(255, 61, 143, 0.16);
  color: #ffd0ea;
  border: 2px solid #ff3d8f;
}

.candy-btn.mini {
  width: auto;
  min-height: 44px;
  padding: 0 16px;
  font-size: 16px;
  margin: 0;
}

.title-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.text-btn {
  display: block;
  width: 100%;
  background: none;
  border: 0;
  color: #ffd0ea;
  font: inherit;
  font-weight: 800;
  min-height: 44px;
  cursor: pointer;
}

.map-hud {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: linear-gradient(180deg, rgba(20, 6, 31, 0.92), rgba(20, 6, 31, 0.55) 70%, transparent);
}

.map-banner {
  justify-self: center;
  padding: 8px 16px;
  border-radius: 14px 14px 18px 18px;
  background: linear-gradient(#ffe66d, #ff9f1c);
  color: #5a2208;
  font-family: Fredoka, Nunito, sans-serif;
  font-weight: 700;
  font-size: 15px;
  text-align: center;
  box-shadow: 0 4px 0 #c43b00, 0 8px 16px #0006;
  white-space: nowrap;
}

.map-juice {
  margin: 0;
}

.map-scroll {
  position: relative;
  z-index: 1;
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

.trail-world {
  position: relative;
  width: min(420px, 100%);
  margin: 0 auto;
  background:
    linear-gradient(180deg, rgba(42, 16, 80, 0.22), rgba(20, 6, 31, 0.12) 28%, rgba(10, 4, 24, 0.42)),
    url("assets/map.jpg") top center / 100% auto repeat-y;
}

.trail-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.trail-glow {
  fill: none;
  stroke: #ff3d8f;
  stroke-width: 30;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.38;
}

.trail-road {
  fill: none;
  stroke: url(#juice-vein);
  stroke-width: 16;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.trail-shine {
  fill: none;
  stroke: #fff6c8;
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.55;
}

.trail-dot {
  fill: #fff7ee;
  stroke: #ff3d8f;
  stroke-width: 2;
}

.map-deco {
  position: absolute;
  pointer-events: none;
  z-index: 0;
}

.map-deco.lolly {
  width: 14px;
  height: 64px;
  background: linear-gradient(180deg, transparent 22px, #d4a574 22px, #b07a3a);
  border-radius: 4px;
}

.map-deco.lolly::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 50%;
  width: 34px;
  height: 34px;
  margin-left: -17px;
  border-radius: 50%;
  background: conic-gradient(#ff3d8f, #ffe66d, #3d9fff, #ff3d8f);
  box-shadow: 0 4px 10px #0006;
}

.map-deco.crystal {
  width: 22px;
  height: 36px;
  background: linear-gradient(180deg, #ffd08a, #ff7a18);
  clip-path: polygon(50% 0, 100% 38%, 72% 100%, 28% 100%, 0 38%);
  opacity: 0.85;
  filter: drop-shadow(0 0 8px #ff9f1c88);
}

.map-deco.gum {
  width: 28px;
  height: 24px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #c8ffd8, #2f9e62);
  box-shadow: 0 4px 0 #1d6b42;
}

.trail-node {
  position: absolute;
  z-index: 2;
  width: 72px;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  transform: translate(-50%, -50%);
  cursor: pointer;
  color: var(--paper);
  font: inherit;
}

.trail-node .orb {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: 0 auto;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, var(--orb-a, #fff6c8), var(--orb-b, #ff3d8f) 62%);
  box-shadow: 0 0 0 4px #fff6c866, 0 8px 16px #0008;
}

.orb-num {
  font-family: Fredoka, Nunito, sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: #4a1808;
  text-shadow: 0 1px 0 #fff8;
}

.trail-flag {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: max-content;
  max-width: 124px;
  text-align: left;
}

.trail-node.right .trail-flag {
  left: 76px;
}

.trail-node.left .trail-flag {
  right: 76px;
  text-align: right;
}

.trail-flag b {
  display: block;
  font-size: 14px;
  line-height: 1.15;
  text-shadow: 0 2px 8px #000c;
}

.trail-now {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--gold);
}

.trail-now {
  letter-spacing: 0.08em;
  color: #7bed9f;
}

.trail-node.current .orb {
  width: 74px;
  height: 74px;
  box-shadow: 0 0 0 5px #fff, 0 0 26px #7bed9f, 0 8px 18px #0008;
  animation: orb-pulse 1.6s ease-in-out infinite;
}

.trail-node.boss .orb {
  box-shadow: 0 0 0 4px #ffe66d, 0 0 18px #ff9f1c, 0 8px 16px #0008;
}

.trail-node.done .orb {
  box-shadow: 0 0 0 4px #7bed9faa, 0 8px 16px #0008;
}

.trail-node.locked {
  cursor: default;
}

.trail-node.locked .orb {
  background: radial-gradient(circle at 32% 28%, #6a547c, #2a1838);
  box-shadow: 0 0 0 3px #4a3560, 0 6px 12px #0008;
}

.trail-node.locked .orb-num {
  color: #cbb8de;
  text-shadow: none;
}

.trail-node.locked .trail-flag {
  opacity: 0.55;
}

@keyframes orb-pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.08);
  }
}

.map-depths {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 28px;
  margin: 0;
  text-align: center;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 800;
  color: #cbb8de;
  text-shadow: 0 2px 8px #000a;
}

.win-plaque {
  position: relative;
  z-index: 2;
  margin: auto;
  width: min(420px, calc(100% - 28px));
  padding: 22px 20px 18px;
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(90, 34, 20, 0.92), rgba(20, 6, 31, 0.94));
  border: 3px solid #ffe66d;
  box-shadow: 0 0 0 6px rgba(255, 157, 28, 0.25), 0 18px 40px #0008;
  text-align: center;
}

.screen-win {
  background: transparent;
  align-items: center;
  justify-content: center;
}

.win-dim {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(20, 6, 31, 0.18), rgba(12, 4, 24, 0.52));
}

.win-sparks {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.win-sparks::before,
.win-sparks::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 38%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ffe66d;
  box-shadow:
    -120px -40px 0 3px #ff3d8f,
    110px -70px 0 2px #7bed9f,
    -40px -110px 0 4px #ff9f1c,
    80px 20px 0 2px #3d9fff,
    -90px 50px 0 3px #c084fc,
    140px 80px 0 2px #ffe66d;
  animation: spark-fly 1.1s ease-out infinite;
}

.win-sparks::after {
  animation-delay: 0.45s;
  top: 52%;
  box-shadow:
    90px -30px 0 3px #ff3d8f,
    -100px -80px 0 2px #7bed9f,
    30px -120px 0 3px #ffe66d,
    -130px 10px 0 2px #3d9fff;
}

@keyframes spark-fly {
  0% {
    transform: scale(0.4);
    opacity: 0.9;
  }
  100% {
    transform: scale(1.6);
    opacity: 0;
  }
}

.win-plaque.pop-in {
  animation: plaque-in 0.55s cubic-bezier(0.2, 1.4, 0.3, 1);
}

@keyframes plaque-in {
  0% {
    transform: scale(0.52) translateY(36px);
    opacity: 0;
  }
  72% {
    transform: scale(1.05) translateY(-6px);
    opacity: 1;
  }
  100% {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.lose-plaque {
  border-color: #ff8fc4;
}

.win-burst {
  margin: 0 0 4px;
  color: var(--gold);
  letter-spacing: 0.35em;
  font-size: 18px;
  text-shadow: 0 0 12px #ffe66d;
}

.win-plaque h2 {
  font-family: Fredoka, Nunito, sans-serif;
  font-size: clamp(32px, 7vw, 46px);
  line-height: 0.95;
  margin: 0 0 8px;
  color: var(--gold);
  text-shadow: 0 4px 0 #c43b00, 0 10px 24px #0008;
}

.win-name {
  margin: 0 0 8px;
  font-weight: 800;
  color: #fff4d6;
}

.candy-btn.text-link {
  background: none;
  color: #ffd0ea;
  border: 0;
  min-height: 44px;
  font-size: 16px;
}

.card,
.card.glass {
  width: min(720px, calc(100% - 24px));
  max-height: calc(100% - 24px);
  overflow: auto;
  touch-action: pan-y;
  background: rgba(42, 14, 72, 0.92);
  border: 2px solid #ff8fc4;
  padding: 24px;
  border-radius: 24px;
}

h1,
h2,
h3 {
  font-family: Fredoka, Nunito, sans-serif;
  margin: 0 0 8px;
}

.gold {
  color: var(--gold);
  font-weight: 800;
}

.sub {
  margin: 18px 0 8px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.shop-sheet {
  position: relative;
  z-index: 1;
  width: min(720px, calc(100% - 20px));
  margin: 0 auto;
  padding: 12px 4px 24px;
  overflow: auto;
  max-height: 100%;
}

.shop-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.shop-head h2 {
  margin: 0;
  color: var(--gold);
  text-shadow: 0 3px 0 #c43b00, 0 8px 18px #0008;
}

.tree {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.shop-card {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  background: linear-gradient(#5a2288, #341056);
  color: var(--paper);
  border: 2px solid #ff9ad0;
  padding: 8px;
  border-radius: 20px;
  cursor: pointer;
  font: inherit;
  min-height: 88px;
}

.shop-card.owned {
  border-color: #7bed9f;
}

.shop-ico {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  object-fit: cover;
  flex: 0 0 72px;
  background: #1a0830;
}

.shop-body {
  min-width: 0;
  flex: 1;
}

.shop-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.shop-card h3 {
  margin: 0;
  font-size: 16px;
}

.rank-pill {
  flex: 0 0 auto;
  padding: 2px 8px;
  border-radius: 999px;
  background: #ff3d8f;
  font-size: 12px;
  font-weight: 800;
}

.fill {
  height: 7px;
  margin: 6px 0;
  border-radius: 99px;
  background: #1a0830;
  overflow: hidden;
}

.fill i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #ffe66d, #ff9f1c);
}

.shop-card small {
  display: block;
  opacity: 0.85;
  font-size: 12px;
  line-height: 1.25;
}

.shop-card .price {
  display: block;
  margin-top: 4px;
  color: var(--gold);
  font-weight: 800;
  font-size: 13px;
}

button.choice {
  text-align: left;
  background: #43186e;
  color: var(--paper);
  border: 2px solid #7a3ab0;
  padding: 12px;
  border-radius: 14px;
  cursor: pointer;
  font: inherit;
  min-height: 44px;
}

button.owned {
  border-color: #7bed9f;
}

.hidden {
  display: none !important;
}

.audio-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 16px 0;
}

.cloud-box {
  margin: 8px 0 16px;
}

.cloud-label,
.cloud-hint {
  font-size: 13px;
  color: var(--muted);
}

.cloud-label b {
  color: var(--gold);
  letter-spacing: 0.12em;
}

.cloud-row {
  display: flex;
  gap: 8px;
}

.cloud-input {
  flex: 1;
  min-height: 44px;
  background: #43186e;
  color: var(--paper);
  border: 2px solid #7a3ab0;
  padding: 8px 12px;
  font: inherit;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border-radius: 12px;
  touch-action: manipulation;
}

.result-actions .candy-btn {
  margin-bottom: 8px;
}

.toast {
  position: absolute;
  top: 74px;
  left: 50%;
  transform: translate(-50%, -12px);
  padding: 10px 18px;
  border-radius: 999px;
  background: linear-gradient(#ffe66d, #ff9f1c);
  color: #5a2208;
  font-weight: 800;
  box-shadow: 0 6px 18px #000a;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.trail-stars {
  display: block;
  margin-top: 3px;
  font-size: 13px;
  letter-spacing: 0.1em;
  color: var(--gold);
  text-shadow: 0 2px 8px #000c;
}

.pick-list {
  display: grid;
  gap: 10px;
  margin: 12px 0 16px;
}

.pick-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  background: #43186e;
  color: var(--paper);
  border: 2px solid #7a3ab0;
  padding: 8px;
  border-radius: 18px;
  cursor: pointer;
  font: inherit;
}

.pick-card.picked {
  border-color: #7bed9f;
  background: #35624a;
}

.pick-card img {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  object-fit: cover;
  flex: 0 0 56px;
  background: #1a0830;
}

.pick-card h3 {
  margin: 0;
  font-size: 16px;
}

.pick-card small {
  display: block;
  opacity: 0.85;
  font-size: 12px;
  line-height: 1.25;
}

.pick-have {
  display: block;
  margin-top: 4px;
  color: var(--gold);
  font-weight: 800;
  font-size: 13px;
}

.pick-mark {
  position: absolute;
  right: 10px;
  top: 10px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 2px solid #7a3ab0;
  color: #7bed9f;
  font-weight: 800;
}

.pick-card.picked .pick-mark {
  border-color: #7bed9f;
  background: rgba(123, 237, 159, 0.18);
}

@media (max-width: 600px) {
  .tree,
  .grid {
    grid-template-columns: 1fr;
  }

  .card {
    padding: 16px;
  }

  .title-ui h1 {
    font-size: 40px;
  }

  .map-hud {
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
      "banner banner banner"
      "back juice shop";
  }

  .map-hud [data-act="back"] {
    grid-area: back;
  }

  .map-banner {
    grid-area: banner;
    width: max-content;
    justify-self: center;
  }

  .map-juice {
    grid-area: juice;
    justify-self: center;
  }

  .map-hud [data-act="shop"] {
    grid-area: shop;
  }
}

.ad-btn:disabled {
  opacity: 0.6;
  pointer-events: none;
}

.ad-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  background: var(--gold);
  color: #14061f;
  vertical-align: middle;
}
