/* Portrait-only candy game. Everything drawn with CSS/SVG. */
:root {
  --pink: #ff5fa2;
  --pink-dark: #d63d80;
  --purple: #2b0d3a;
  --purple-2: #451459;
  --gold: #ffd166;
  --tile: rgba(255, 255, 255, 0.07);
  --tile-alt: rgba(255, 255, 255, 0.12);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', system-ui, -apple-system, sans-serif;
  color: #fff;
  background: #1b0726;
  user-select: none;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 560px;
  margin: 0 auto;
  overflow: hidden;
  background: radial-gradient(120% 80% at 50% 0%, #5b1d6e 0%, #2b0d3a 55%, #190622 100%);
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}
.screen.active {
  display: flex;
}

/* ------------------------------------------------------------------ home */
.home-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 15% 18%, rgba(255, 95, 162, 0.45), transparent 40%),
    radial-gradient(circle at 85% 25%, rgba(122, 200, 255, 0.35), transparent 42%),
    radial-gradient(circle at 50% 90%, rgba(255, 209, 102, 0.3), transparent 45%);
  animation: floaty 12s ease-in-out infinite alternate;
}
@keyframes floaty {
  to {
    transform: scale(1.12) translateY(-12px);
  }
}
.home-content {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
}
.logo {
  margin: 0;
  font-size: clamp(44px, 15vw, 76px);
  line-height: 0.95;
  text-align: center;
  font-weight: 900;
  letter-spacing: 2px;
  display: flex;
  flex-direction: column;
  color: #fff;
  text-shadow:
    0 4px 0 var(--pink-dark),
    0 10px 22px rgba(0, 0, 0, 0.55);
}
.logo span:last-child {
  color: var(--gold);
  text-shadow:
    0 4px 0 #b5762a,
    0 10px 22px rgba(0, 0, 0, 0.55);
}
.tagline {
  margin: 0;
  opacity: 0.85;
  font-size: 14px;
}
.home-stats {
  font-size: 13px;
  opacity: 0.8;
  text-align: center;
  line-height: 1.7;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 14px 34px;
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(180deg, #ff8ac0, var(--pink) 45%, var(--pink-dark));
  box-shadow:
    0 6px 0 #a72a62,
    0 12px 22px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  transition: transform 0.08s;
}
.btn:active {
  transform: translateY(4px);
  box-shadow:
    0 2px 0 #a72a62,
    0 6px 12px rgba(0, 0, 0, 0.4);
}
.btn.big {
  padding: 16px 46px;
  font-size: 20px;
}
.link-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.75);
  font-size: 15px;
  text-decoration: underline;
  cursor: pointer;
  padding: 6px;
}
.toggles {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.toggles.vertical {
  flex-direction: column;
  align-items: stretch;
  width: 100%;
}
.toggle {
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
}
.toggle.off {
  opacity: 0.4;
  text-decoration: line-through;
}

/* ------------------------------------------------------------------- map */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.35);
}
.topbar-title {
  flex: 1;
  font-weight: 800;
  font-size: 18px;
}
.star-count {
  color: var(--gold);
  font-weight: 800;
}
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 20px;
  font-weight: 800;
  cursor: pointer;
}
.map-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px 60px;
  -webkit-overflow-scrolling: touch;
}
.episode {
  margin-bottom: 22px;
}
.episode-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 16px;
  margin-bottom: 10px;
  padding: 8px 12px;
  border-radius: 14px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.02));
}
.episode-head .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}
.level-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}
.level-node {
  position: relative;
  aspect-ratio: 1;
  border-radius: 18px;
  border: none;
  background: linear-gradient(180deg, #ffd88a, #f0a63c);
  color: #5a2a00;
  font-weight: 900;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 0 #b5762a;
  cursor: pointer;
}
.level-node.locked {
  background: linear-gradient(180deg, #6c5f78, #4b3f56);
  color: rgba(255, 255, 255, 0.5);
  box-shadow: 0 4px 0 #33293c;
}
.level-node.current {
  background: linear-gradient(180deg, #ff9ec9, var(--pink));
  color: #fff;
  box-shadow: 0 4px 0 var(--pink-dark);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  50% {
    transform: scale(1.07);
  }
}
.level-node .node-stars {
  position: absolute;
  bottom: -5px;
  display: flex;
  gap: 1px;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.55));
}
.node-stars .star.off {
  fill: rgba(0, 0, 0, 0.3);
}
.node-stars .star {
  width: 13px;
  height: 13px;
}
.star {
  width: 22px;
  height: 22px;
}
.star.on {
  fill: var(--gold);
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.5));
}
.star.off {
  fill: rgba(255, 255, 255, 0.25);
}
.node-type {
  position: absolute;
  top: 3px;
  right: 5px;
  font-size: 11px;
}

/* ------------------------------------------------------------------ game */
.hud {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 4px;
}
.hud > div {
  background: rgba(0, 0, 0, 0.28);
  border-radius: 14px;
  padding: 4px 12px;
  text-align: center;
  min-width: 62px;
}
.hud-score {
  flex: 1;
}
.hud-label {
  font-size: 11px;
  opacity: 0.7;
}
.hud-value {
  font-size: 19px;
  font-weight: 900;
  line-height: 1.15;
}
.hud-moves.low .hud-value {
  color: #ff6b6b;
  animation: pulse 0.7s infinite;
}

.progress-wrap {
  position: relative;
  margin: 4px 14px 0;
  height: 16px;
}
.progress-bar {
  position: absolute;
  inset: 3px 0;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #7ef2b0, #ffd166, var(--pink));
  transition: width 0.35s ease;
}
.progress-stars {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.progress-stars .star {
  position: absolute;
  top: -3px;
  transform: translateX(-50%);
  width: 20px;
  height: 20px;
}

.goals {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  padding: 8px 12px 6px;
}
.goal {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  padding: 5px 10px;
  font-size: 14px;
  font-weight: 700;
}
.goal.done {
  background: rgba(60, 190, 120, 0.35);
}
.goal .g-icon {
  font-size: 16px;
}
.goal .g-num {
  font-variant-numeric: tabular-nums;
}

.board {
  position: relative;
  margin: auto 10px; /* centres the board in whatever height is left over */
  width: calc(100% - 20px);
  max-width: min(100%, 78vh);
  align-self: center;
  padding: 8px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.34), rgba(0, 0, 0, 0.18));
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.08);
}
.board-inner {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
}
.layer {
  position: absolute;
  inset: 0;
}
.layer.fx {
  pointer-events: none;
  overflow: hidden;
  border-radius: 12px;
}
/* new candies queue up above row 0 — they must pour in from behind the top
   edge instead of floating over the frame */
.layer.candies {
  overflow: hidden;
  border-radius: 12px;
}

.tile,
.candy,
.fx-el,
.particle,
.float-text {
  position: absolute;
  top: 0;
  left: 0;
  width: calc(100% / var(--cols, 9));
  height: calc(100% / var(--rows, 9));
  transform: translate(calc(var(--c, 0) * 100%), calc(var(--r, 0) * 100%));
}

.tile {
  border-radius: 10%;
  background: var(--tile);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}
.tile.alt {
  background: var(--tile-alt);
}
.tile.jelly1 {
  background: rgba(120, 220, 255, 0.35);
  box-shadow: inset 0 0 0 2px rgba(180, 240, 255, 0.55);
}
.tile.jelly2 {
  background: rgba(120, 180, 255, 0.55);
  box-shadow:
    inset 0 0 0 2px rgba(200, 230, 255, 0.8),
    inset 0 0 12px rgba(255, 255, 255, 0.5);
}
.tile.exit .exit-arrow {
  position: absolute;
  inset: auto 0 -2px 0;
  text-align: center;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.55);
  animation: bob 1.2s infinite;
}
@keyframes bob {
  50% {
    transform: translateY(3px);
  }
}
.tile .icing {
  position: absolute;
  inset: 0;
}
.tile .icing.breaking {
  animation: icebreak 0.26s ease-in forwards;
}
@keyframes icebreak {
  100% {
    transform: scale(1.35);
    opacity: 0;
    filter: brightness(2);
  }
}
.tile.jelly-cleared {
  animation: jellygone 0.35s ease-out;
}
@keyframes jellygone {
  0% {
    box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.9);
    background: rgba(200, 245, 255, 0.6);
  }
}

.candy {
  transition: transform 150ms cubic-bezier(0.36, 0.07, 0.28, 1.2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.cand-svg {
  width: 92%;
  height: 92%;
  display: block;
  pointer-events: none;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}
.candy .lock-svg {
  position: absolute;
  inset: 4%;
  width: 92%;
  height: 92%;
}
.candy.selected {
  z-index: 5;
}
.candy.selected .cand-svg {
  animation: bounce 0.45s ease-in-out infinite alternate;
  filter: drop-shadow(0 0 8px #fff);
}
@keyframes bounce {
  to {
    transform: scale(1.14);
  }
}
.candy.hint .cand-svg {
  animation: hint 0.8s ease-in-out infinite;
}
@keyframes hint {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.16) rotate(6deg);
  }
}
.candy.pop {
  animation: pop 0.28s ease-out forwards;
  animation-fill-mode: both; /* hold the pre-pop frame while the sweep arrives */
  z-index: 4;
}

/* winding up before a special-on-special combo lets go */
.candy.charging {
  z-index: 7;
}
.candy.charging .cand-svg {
  animation: charge 0.34s cubic-bezier(0.4, 0, 0.6, 1) forwards;
}
.candy.charging-big .cand-svg {
  animation: chargeBig 0.34s cubic-bezier(0.4, 0, 0.6, 1) forwards;
  filter: drop-shadow(0 0 10px #fff);
}
@keyframes charge {
  0% {
    transform: scale(1);
  }
  55% {
    transform: scale(1.3) rotate(-8deg);
  }
  100% {
    transform: scale(0.86) rotate(4deg);
  }
}
@keyframes chargeBig {
  0% {
    transform: scale(1);
    filter: brightness(1);
  }
  40% {
    transform: scale(1.45) rotate(10deg);
    filter: brightness(2.2);
  }
  70% {
    transform: scale(1.2) rotate(-10deg);
    filter: brightness(1.4);
  }
  100% {
    transform: scale(0.8);
    filter: brightness(3);
  }
}
@keyframes pop {
  40% {
    transform: translate(calc(var(--c) * 100%), calc(var(--r) * 100%)) scale(1.28);
  }
  100% {
    transform: translate(calc(var(--c) * 100%), calc(var(--r) * 100%)) scale(0);
    opacity: 0;
  }
}
@keyframes morph {
  0% {
    transform: scale(0.45) rotate(-25deg);
    filter: brightness(2.6);
  }
  60% {
    transform: scale(1.2) rotate(6deg);
    filter: brightness(1.5);
  }
  100% {
    transform: scale(1);
    filter: brightness(1);
  }
}
@keyframes land {
  0% {
    transform: scaleY(var(--squash, 0.8)) scaleX(calc(2 - var(--squash, 0.8)));
  }
  55% {
    transform: scaleY(1.07) scaleX(0.95);
  }
  100% {
    transform: scale(1);
  }
}
.candy.born .cand-svg {
  animation: born 0.34s cubic-bezier(0.2, 1.6, 0.4, 1);
}
@keyframes born {
  0% {
    transform: scale(0.2) rotate(-40deg);
  }
  100% {
    transform: scale(1) rotate(0);
  }
}
.candy.collected {
  animation: collected 0.4s ease-in forwards;
  z-index: 6;
}
@keyframes collected {
  100% {
    transform: translate(calc(var(--c) * 100%), calc(var(--r) * 100% + 120%)) scale(0.4);
    opacity: 0;
  }
}
.candy.shake .cand-svg {
  animation: shake 0.25s;
}
@keyframes shake {
  25% {
    transform: translateX(-12%) rotate(-8deg);
  }
  75% {
    transform: translateX(12%) rotate(8deg);
  }
}
.candy.ingredient .cand-svg {
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.5));
}

/* --------------------------------------------------------------- effects */
.fx-el.beam-h {
  width: 100%;
  height: calc(100% / var(--rows, 9));
  background: linear-gradient(90deg, transparent, var(--col, #fff), transparent);
  filter: blur(1px);
  animation: beam 0.45s ease-out forwards;
  border-radius: 50%;
}
.fx-el.beam-v {
  height: 100%;
  width: calc(100% / var(--cols, 9));
  background: linear-gradient(180deg, transparent, var(--col, #fff), transparent);
  filter: blur(1px);
  animation: beam 0.45s ease-out forwards;
  border-radius: 50%;
}
@keyframes beam {
  0% {
    opacity: 0;
    filter: brightness(2.4);
  }
  25% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}
.fx-el.boom {
  background: radial-gradient(circle, #fff 0%, #ffd166 35%, rgba(255, 100, 60, 0.6) 60%, transparent 72%);
  animation: boom 0.5s ease-out forwards;
  border-radius: 50%;
}
.fx-el.boom.big {
  animation: boombig 0.6s ease-out forwards;
}
@keyframes boom {
  0% {
    transform: translate(calc(var(--c) * 100%), calc(var(--r) * 100%)) scale(0.3);
    opacity: 1;
  }
  100% {
    transform: translate(calc(var(--c) * 100%), calc(var(--r) * 100%)) scale(3.4);
    opacity: 0;
  }
}
@keyframes boombig {
  0% {
    transform: translate(calc(var(--c) * 100%), calc(var(--r) * 100%)) scale(0.3);
    opacity: 1;
  }
  100% {
    transform: translate(calc(var(--c) * 100%), calc(var(--r) * 100%)) scale(6);
    opacity: 0;
  }
}
/* colour bomb lightning */
.fx-bolt {
  position: absolute;
  height: 5px;
  margin-top: -2.5px;
  transform-origin: 0 50%;
  border-radius: 3px;
  background: linear-gradient(90deg, #fff 0%, var(--col, #fff) 45%, rgba(255, 255, 255, 0.9) 100%);
  box-shadow: 0 0 10px var(--col, #fff);
  animation: bolt 0.42s cubic-bezier(0.1, 0.9, 0.3, 1) both;
  pointer-events: none;
}
@keyframes bolt {
  0% {
    clip-path: inset(0 100% 0 0);
    opacity: 0;
    filter: brightness(2.4);
  }
  22% {
    clip-path: inset(0 0 0 0);
    opacity: 1;
  }
  55% {
    opacity: 0.9;
    height: 5px;
  }
  100% {
    clip-path: inset(0 0 0 0);
    opacity: 0;
    height: 1px;
  }
}
.fx-bolt-core {
  position: absolute;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, var(--col, #fff) 55%, transparent 72%);
  box-shadow: 0 0 26px var(--col, #fff);
  animation: boltcore 0.6s ease-out forwards;
  pointer-events: none;
}
@keyframes boltcore {
  0% {
    transform: scale(0.3);
    opacity: 1;
  }
  35% {
    transform: scale(1.8);
    opacity: 1;
  }
  100% {
    transform: scale(1.1);
    opacity: 0;
  }
}

.fx-flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0) 70%);
  animation: flash 0.45s ease-out forwards;
}
@keyframes flash {
  0% {
    opacity: 0.95;
  }
  100% {
    opacity: 0;
  }
}
.particle {
  width: var(--size, 8px);
  height: var(--size, 8px);
  border-radius: 50%;
  margin: calc(100% / var(--cols, 9) / 2) 0 0 calc(100% / var(--cols, 9) / 2);
  animation: particle 0.6s cubic-bezier(0.2, 0.7, 0.4, 1) forwards;
}
.particle.shard {
  border-radius: 2px;
}
@keyframes particle {
  0% {
    transform: translate(calc(var(--c) * 100%), calc(var(--r) * 100%)) scale(0.6) rotate(0deg);
    opacity: 1;
  }
  30% {
    transform: translate(calc(var(--c) * 100% + var(--dx) * 34px), calc(var(--r) * 100% + var(--dy) * 34px)) scale(1.15)
      rotate(calc(var(--spin, 0deg) * 0.4));
    opacity: 1;
  }
  100% {
    transform: translate(calc(var(--c) * 100% + var(--dx) * 78px), calc(var(--r) * 100% + var(--dy) * 78px + 34px)) scale(0.15)
      rotate(var(--spin, 0deg));
    opacity: 0;
  }
}

/* expanding ring left behind by a big clear */
.fx-el.shockwave {
  border-radius: 50%;
  border: 3px solid var(--col, #fff);
  box-shadow:
    0 0 18px var(--col, #fff),
    inset 0 0 18px var(--col, #fff);
  animation: shockwave 0.55s cubic-bezier(0.15, 0.7, 0.3, 1) forwards;
}
@keyframes shockwave {
  0% {
    transform: translate(calc(var(--c) * 100%), calc(var(--r) * 100%)) scale(0.2);
    opacity: 0.95;
    border-width: 6px;
  }
  100% {
    transform: translate(calc(var(--c) * 100%), calc(var(--r) * 100%)) scale(calc(3.4 * var(--scale, 1)));
    opacity: 0;
    border-width: 1px;
  }
}

/* rays thrown out when a special candy is born */
.fx-el.spark {
  border-radius: 50%;
  background: var(--col, #fff);
  box-shadow: 0 0 10px var(--col, #fff);
  width: 10px;
  height: 10px;
  margin: calc(100% / var(--cols, 9) / 2 - 5px) 0 0 calc(100% / var(--cols, 9) / 2 - 5px);
  animation: spark 0.6s cubic-bezier(0.1, 0.8, 0.3, 1) forwards;
}
@keyframes spark {
  0% {
    transform: translate(calc(var(--c) * 100%), calc(var(--r) * 100%)) scale(0.4);
    opacity: 1;
  }
  100% {
    transform: translate(calc(var(--c) * 100% + var(--dx) * 96px), calc(var(--r) * 100% + var(--dy) * 96px)) scale(0.1);
    opacity: 0;
  }
}

/* the Swedish fish swimming to its prey */
.fx-fish {
  position: absolute;
  top: 0;
  left: 0;
  width: calc(100% / var(--cols, 9));
  height: calc(100% / var(--rows, 9));
  z-index: 9;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.5));
  animation: fishswim 0.36s cubic-bezier(0.45, 0, 0.5, 1) forwards;
}
@keyframes fishswim {
  0% {
    transform: translate(calc(var(--c) * 100%), calc(var(--r) * 100%)) scale(0.5) scaleX(calc(0.5 * var(--flip, 1)));
    opacity: 0;
  }
  20% {
    opacity: 1;
  }
  55% {
    transform: translate(calc((var(--c) + var(--tc)) * 50%), calc((var(--r) + var(--tr)) * 50% + var(--arc, 1) * 55%))
      scale(1.25) scaleX(calc(1.25 * var(--flip, 1)));
    opacity: 1;
  }
  100% {
    transform: translate(calc(var(--tc) * 100%), calc(var(--tr) * 100%)) scale(0.8) scaleX(calc(0.8 * var(--flip, 1)));
    opacity: 0.9;
  }
}

/* board kick on heavy clears */
.board-inner.quake {
  animation: quake 0.4s ease-out;
}
.board-inner.quake.hard {
  animation: quakehard 0.42s ease-out;
}
@keyframes quake {
  20% {
    transform: translate(3px, -3px) rotate(0.35deg);
  }
  45% {
    transform: translate(-3px, 2px) rotate(-0.3deg);
  }
  70% {
    transform: translate(2px, 2px);
  }
  100% {
    transform: none;
  }
}
@keyframes quakehard {
  15% {
    transform: translate(-7px, 5px) rotate(-0.8deg) scale(1.012);
  }
  35% {
    transform: translate(7px, -5px) rotate(0.8deg) scale(1.012);
  }
  55% {
    transform: translate(-5px, -3px) rotate(-0.5deg);
  }
  78% {
    transform: translate(4px, 3px);
  }
  100% {
    transform: none;
  }
}
.float-text {
  width: auto;
  height: auto;
  font-weight: 900;
  font-size: 15px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.7);
  animation: floatUp 0.9s ease-out forwards;
  white-space: nowrap;
}
@keyframes floatUp {
  0% {
    opacity: 0;
    transform: translate(calc(var(--c) * 100%), calc(var(--r) * 100%)) scale(0.6);
  }
  25% {
    opacity: 1;
    transform: translate(calc(var(--c) * 100%), calc(var(--r) * 100% - 20%)) scale(1.1);
  }
  100% {
    opacity: 0;
    transform: translate(calc(var(--c) * 100%), calc(var(--r) * 100% - 90%)) scale(1);
  }
}
.board-banner {
  position: absolute;
  left: 0;
  right: 0;
  top: 42%;
  text-align: center;
  font-size: 22px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 3px 0 var(--pink-dark), 0 8px 18px rgba(0, 0, 0, 0.6);
  animation: banner 1.4s ease-out forwards;
}
.board-banner.big {
  font-size: 34px;
  color: var(--gold);
}
@keyframes banner {
  0% {
    opacity: 0;
    transform: scale(0.5);
  }
  20% {
    opacity: 1;
    transform: scale(1.1);
  }
  70% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(1.2);
  }
}

.playbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 12px;
}
.pill {
  border: none;
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  cursor: pointer;
}
.pill:active {
  background: rgba(255, 255, 255, 0.26);
}
.episode-tag {
  flex: 1;
  text-align: center;
  font-size: 12px;
  opacity: 0.7;
}

/* --------------------------------------------------------------- popups */
.overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(10, 2, 16, 0.86);
  z-index: 20;
  padding: 20px;
}
.overlay.active {
  display: flex;
  animation: fadeIn 0.2s;
}
@keyframes fadeIn {
  from {
    opacity: 0;
  }
}
.popup {
  position: relative;
  width: 100%;
  max-width: 360px;
  max-height: 92%;
  overflow-y: auto;
  background: linear-gradient(180deg, #6a2280, #3c1150);
  border: 3px solid rgba(255, 255, 255, 0.22);
  border-radius: 24px;
  padding: 26px 22px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
  animation: popIn 0.28s cubic-bezier(0.2, 1.5, 0.4, 1);
}
@keyframes popIn {
  from {
    transform: scale(0.7);
    opacity: 0;
  }
}
.popup h2 {
  margin: 0;
  font-size: 26px;
}
.popup-ribbon {
  background: var(--gold);
  color: #5a2a00;
  font-weight: 800;
  font-size: 13px;
  padding: 4px 16px;
  border-radius: 999px;
}
.intro-type {
  font-size: 15px;
  font-weight: 700;
  color: var(--gold);
}
.intro-desc {
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
  opacity: 0.9;
}
.intro-goals {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.result-stars {
  display: flex;
  gap: 6px;
}
.result-stars .star {
  width: 46px;
  height: 46px;
}
.result-stars .star.on {
  animation: starPop 0.4s cubic-bezier(0.2, 1.7, 0.4, 1) backwards;
}
.result-stars .star.on:nth-child(2) {
  animation-delay: 0.18s;
}
.result-stars .star.on:nth-child(3) {
  animation-delay: 0.36s;
}
@keyframes starPop {
  from {
    transform: scale(0) rotate(-90deg);
  }
}
.result-score {
  font-size: 34px;
  font-weight: 900;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.result-note {
  font-size: 14px;
  opacity: 0.85;
}
.howto {
  text-align: left;
}
.howto-list {
  font-size: 13.5px;
  line-height: 1.65;
  max-height: 52vh;
  overflow-y: auto;
}
.howto-list p {
  margin: 0 0 8px;
}
.howto-list b {
  color: var(--gold);
}
.popup.win .burst {
  position: absolute;
  inset: -40%;
  background: conic-gradient(from 0deg, rgba(255, 209, 102, 0.25) 0 8%, transparent 8% 16%);
  animation: spin 9s linear infinite;
  z-index: -1;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------------------------------------------------- portrait-only lock */
.rotate-lock {
  display: none;
}
@media (orientation: landscape) and (max-height: 560px) {
  .rotate-lock {
    position: absolute;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1b0726;
    text-align: center;
  }
  .rotate-inner .phone {
    font-size: 60px;
    animation: rotatehint 1.8s ease-in-out infinite;
  }
  .rotate-inner p {
    font-size: 22px;
    font-weight: 800;
    margin: 12px 0 4px;
  }
  .rotate-inner small {
    opacity: 0.7;
  }
  @keyframes rotatehint {
    0%,
    100% {
      transform: rotate(0);
    }
    50% {
      transform: rotate(-90deg);
    }
  }
}
