/* Tap Lock v3 — candy sticker style.
   Bright world skies, chunky ink outlines, 3D pressable buttons.
   Fonts: Fredoka (display) + Nunito (UI), bundled in assets/fonts (SIL OFL). */

@font-face { font-family: "Fredoka"; font-weight: 500; font-display: swap; src: url(../assets/fonts/fredoka-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Fredoka"; font-weight: 600; font-display: swap; src: url(../assets/fonts/fredoka-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Fredoka"; font-weight: 700; font-display: swap; src: url(../assets/fonts/fredoka-latin-700-normal.woff2) format("woff2"); }
@font-face { font-family: "Nunito"; font-weight: 700; font-display: swap; src: url(../assets/fonts/nunito-latin-700-normal.woff2) format("woff2"); }
@font-face { font-family: "Nunito"; font-weight: 800; font-display: swap; src: url(../assets/fonts/nunito-latin-800-normal.woff2) format("woff2"); }
@font-face { font-family: "Nunito"; font-weight: 900; font-display: swap; src: url(../assets/fonts/nunito-latin-900-normal.woff2) format("woff2"); }

:root {
  --bg1: #ffbe0b;
  --bg2: #fb5607;
  --ink: #2b2350;
  --face1: #fffaf0;
  --face2: #ffe3a8;
  --zone: #ff006e;
  --glow: #fff3b0;
  --brass: #ffd60a;
  --brass2: #f77f00;
  --hi: #ffffff;
  --yellow: #ffd60a;
  --pink: #ff3d7f;
  --blue: #3a86ff;
  --green: #06d6a0;
  --paper: #fffdf7;
  --display: "Fredoka", "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif;
  --ui: "Nunito", "Arial Rounded MT Bold", "Segoe UI", system-ui, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --edge: 4px solid var(--ink);
  --shadow: 0 7px 0 var(--ink);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--ink);
  color: var(--ink);
  font-family: var(--ui);
  font-weight: 800;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; }
button:disabled { cursor: default; }
img { display: block; }

.app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: linear-gradient(170deg, var(--bg1), var(--bg2));
  transition: background 0.6s ease;
}

/* ---------- screens ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.screen.active { display: flex; animation: screenIn .45s cubic-bezier(.2,.8,.2,1) both; }
@keyframes screenIn {
  from { opacity: 0; transform: scale(.97) translateY(12px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- scenes (SVG art fills the screen) ---------- */
.scene { position: absolute; inset: 0; pointer-events: none; }
.scene svg { width: 100%; height: 100%; }

/* ---------- floating bubbles (decor) ---------- */
.bubbles { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.bubbles i {
  position: absolute;
  bottom: -120px;
  width: var(--s, 60px);
  height: var(--s, 60px);
  left: var(--x, 50%);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.9), rgba(255,255,255,.25) 60%, rgba(255,255,255,.1));
  border: 3px solid rgba(255,255,255,.7);
  animation: rise var(--t, 9s) linear infinite;
  animation-delay: var(--d, 0s);
  opacity: .8;
}
.bubbles i:nth-child(1) { --s: 70px; --x: 8%;  --t: 11s; --d: 0s; }
.bubbles i:nth-child(2) { --s: 34px; --x: 26%; --t: 8s;  --d: -3s; }
.bubbles i:nth-child(3) { --s: 92px; --x: 58%; --t: 13s; --d: -6s; }
.bubbles i:nth-child(4) { --s: 46px; --x: 80%; --t: 9s;  --d: -2s; }
.bubbles i:nth-child(5) { --s: 22px; --x: 40%; --t: 7s;  --d: -5s; }
.bubbles i:nth-child(6) { --s: 58px; --x: 92%; --t: 12s; --d: -8s; }
@keyframes rise {
  from { transform: translateY(0) scale(1); }
  to   { transform: translateY(-120vh) scale(1.08); }
}

/* ---------- loader ---------- */
#loader {
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: linear-gradient(170deg, #ffbe0b, #fb5607 55%, #ff006e);
}
.loader-logo {
  width: min(170px, 42vw);
  height: auto;
  position: relative;
  z-index: 1;
  animation: bob 1.6s ease-in-out infinite;
  filter: drop-shadow(0 8px 0 var(--ink));
}
@keyframes bob { 50% { transform: translateY(-12px) rotate(-4deg); } }
.loader-word {
  position: relative;
  z-index: 1;
  display: flex;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(34px, 9vmin, 52px);
  color: #fff;
  -webkit-text-stroke: 2px var(--ink);
  text-shadow: 0 5px 0 var(--ink);
  letter-spacing: .04em;
}
.loader-word span { display: inline-block; animation: hop 1.2s ease-in-out infinite; }
.loader-word span:nth-child(2) { animation-delay: .08s; }
.loader-word span:nth-child(3) { animation-delay: .16s; }
.loader-word span:nth-child(4) { animation-delay: .24s; }
.loader-word span:nth-child(5) { animation-delay: .32s; }
.loader-word span:nth-child(6) { animation-delay: .4s; }
.loader-word span:nth-child(7) { animation-delay: .48s; }
.loader-word span:nth-child(8) { animation-delay: .56s; }
@keyframes hop { 0%,100% { transform: translateY(0); } 40% { transform: translateY(-14px); } }
.load-dots { position: relative; z-index: 1; display: flex; gap: 10px; }
.load-dots i {
  width: 14px; height: 14px; border-radius: 50%;
  background: #fff; border: 3px solid var(--ink);
  animation: dot 1s ease-in-out infinite;
}
.load-dots i:nth-child(2) { animation-delay: .15s; }
.load-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 50% { transform: scale(1.5); background: var(--yellow); } }

/* ---------- menu ---------- */
#menu {
  align-items: center;
  justify-content: safe center;
  overflow-y: auto;
  padding: calc(16px + var(--safe-t)) 18px calc(16px + var(--safe-b));
  background: linear-gradient(170deg, #4cc9f0, #7b2ff7 70%, #f72585);
}
#menu .scene { inset: 0; }
.menu-card {
  position: relative;
  z-index: 1;
  width: min(380px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(10px, 2.2vh, 16px);
  padding: clamp(18px, 3.4vh, 28px) 20px clamp(18px, 3.4vh, 24px);
  border-radius: 34px;
  background: var(--paper);
  border: var(--edge);
  box-shadow: 0 12px 0 var(--ink), 0 30px 60px rgba(20,10,50,.35);
  animation: pop .6s cubic-bezier(.2,1.3,.4,1) both;
}
@keyframes pop { from { opacity: 0; transform: scale(.85) translateY(20px); } to { opacity: 1; transform: none; } }
.menu-logo { width: clamp(78px, 15vh, 112px); height: auto; animation: bob 2.4s ease-in-out infinite; }
.logo {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  line-height: .95;
  text-align: center;
  font-size: clamp(42px, 9vh, 58px);
  letter-spacing: .01em;
}
.logo .w1 { color: var(--pink); text-shadow: 0 5px 0 var(--ink); -webkit-text-stroke: 1px var(--ink); }
.logo .w2 { color: var(--blue); text-shadow: 0 5px 0 var(--ink); -webkit-text-stroke: 1px var(--ink); }
.tagline {
  margin: 0;
  text-align: center;
  color: #5a5480;
  font-size: 15px;
  line-height: 1.45;
  max-width: 30ch;
  font-weight: 700;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 18px 7px 12px;
  border-radius: 999px;
  background: var(--yellow);
  border: 3px solid var(--ink);
  box-shadow: 0 4px 0 var(--ink);
  font-family: var(--display);
  font-weight: 600;
  font-size: 18px;
}
.ico-star { width: 26px; height: 26px; }

/* ---------- buttons (chunky, pressable) ---------- */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  padding: 12px 18px;
  border: var(--edge);
  border-radius: 20px;
  cursor: pointer;
  font-family: var(--display);
  font-weight: 600;
  font-size: 18px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 6px 0 var(--ink);
  transition: transform .12s ease, box-shadow .12s ease, filter .15s ease;
}
.btn:hover:not(:disabled) { filter: brightness(1.05); }
.btn:active:not(:disabled) { transform: translateY(5px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { filter: grayscale(.7); opacity: .55; }
.btn .ico { width: 24px; height: 24px; flex: none; }

.btn-play {
  background: var(--yellow);
  font-size: 22px;
  min-height: 60px;
  box-shadow: 0 7px 0 var(--ink);
}
.btn-wide { width: 100%; }
.btn-play .btn-text { display: flex; flex-direction: column; align-items: center; line-height: 1; }
.btn-play .btn-text b { font-weight: 700; font-size: 24px; }
.btn-play .btn-text small { font-family: var(--ui); font-size: 12px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; margin-top: 3px; opacity: .8; }
.btn-play .ico { width: 30px; height: 30px; }

.btn-tile {
  flex-direction: column;
  gap: 6px;
  min-height: 84px;
  padding: 12px 6px;
  font-size: 14px;
  color: #fff;
  -webkit-text-stroke: 0;
  text-shadow: 0 2px 0 rgba(43,35,80,.55);
}
.btn-tile .ico { width: 30px; height: 30px; }
.btn-tile.small { min-height: 50px; flex-direction: row; font-size: 16px; padding: 10px 14px; }
.tile-blue { background: var(--blue); }
.tile-pink { background: var(--pink); }
.tile-green { background: var(--green); color: var(--ink); text-shadow: none; }
.tile-yellow { background: var(--yellow); color: var(--ink); text-shadow: none; }
.menu-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; }

.btn-danger { background: #ff5d5d; color: #fff; text-shadow: 0 2px 0 rgba(43,35,80,.5); min-height: 46px; padding: 10px 16px; }
.btn-toggle { background: var(--green); min-height: 46px; min-width: 96px; padding: 10px 14px; }
.btn-toggle[aria-pressed="false"] { background: #d8d4ea; }

.btn-lock {
  width: min(290px, 80vw);
  min-height: 70px;
  font-family: var(--display);
  font-size: 26px;
  letter-spacing: .08em;
  text-transform: uppercase;
  background: var(--pink);
  color: #fff;
  -webkit-text-stroke: 0;
  text-shadow: 0 3px 0 var(--ink);
  border-radius: 999px;
  box-shadow: 0 8px 0 var(--ink);
}
.btn-lock .ico { width: 28px; height: 28px; }
.btn-lock:active:not(:disabled) { transform: translateY(6px); box-shadow: 0 2px 0 var(--ink); }

.icon-btn {
  width: 50px;
  height: 50px;
  border-radius: 16px;
  border: var(--edge);
  background: var(--pink);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 5px 0 var(--ink);
  flex: none;
  padding: 0;
}
.icon-btn img { width: 24px; height: 24px; }
.icon-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }

/* ---------- top bar (map) ---------- */
.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(12px + var(--safe-t)) 14px 12px;
  background: var(--paper);
  border-bottom: var(--edge);
  box-shadow: 0 5px 0 rgba(43,35,80,.25);
}
.topbar h2 {
  margin: 0;
  flex: 1;
  text-align: center;
  font-family: var(--display);
  font-weight: 700;
  font-size: 26px;
  color: var(--pink);
  text-shadow: 0 3px 0 var(--ink);
}
.topbar .spacer { width: 50px; }

/* ---------- world map ---------- */
#map { background: linear-gradient(180deg, #e9f7ff, #fff5e6); }
.map-list {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 16px calc(40px + var(--safe-b));
  -webkit-overflow-scrolling: touch;
}
.world-block { margin-bottom: 22px; }
.world-head {
  position: relative;
  height: 176px;
  border-radius: 28px;
  overflow: hidden;
  border: var(--edge);
  box-shadow: 0 8px 0 var(--ink);
  margin-bottom: 8px;
  background: linear-gradient(160deg, var(--n1, #ffbe0b), var(--n2, #fb5607));
}
.wh-scene, .wh-shade { position: absolute; inset: 0; }
.wh-scene svg { width: 100%; height: 100%; }
.wh-shade { background: linear-gradient(180deg, transparent 35%, rgba(43,35,80,.75)); }
.wh-text {
  position: absolute;
  left: 18px; right: 18px; bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: #fff;
}
.wh-kicker {
  align-self: flex-start;
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  background: var(--yellow);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 2px 10px;
  margin-bottom: 4px;
}
.wh-text h3 { margin: 0; font-family: var(--display); font-weight: 700; font-size: 30px; line-height: 1.05; text-shadow: 0 3px 0 var(--ink); }
.wh-text p { margin: 0; font-size: 14px; font-weight: 700; opacity: .95; }
.wh-prog {
  margin-top: 8px;
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,.95);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 3px 12px 3px 8px;
  font-size: 13px;
  font-weight: 900;
}
.wh-prog img { width: 16px; height: 16px; }
.wh-prog b { color: var(--pink); }

.world-nodes {
  position: relative;
  width: min(360px, 100%);
  margin: 0 auto;
}
.world-nodes .path {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}
.world-nodes .path path {
  fill: none;
  stroke: #ffffff;
  stroke-width: 9;
  stroke-dasharray: 0 15;
  stroke-linecap: round;
  opacity: .9;
}
.node {
  position: absolute;
  width: 62px;
  height: 62px;
  transform: translate(-50%, 0);
  margin-top: -31px;
  border-radius: 50%;
  border: var(--edge);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  background: linear-gradient(160deg, var(--n1, #ffbe0b), var(--n2, #fb5607));
  box-shadow: 0 6px 0 var(--ink);
  transition: transform .12s ease;
  z-index: 1;
}
.node:active:not(:disabled) { transform: translate(-50%, 4px); box-shadow: 0 2px 0 var(--ink); }
.node .nn {
  font-family: var(--display);
  font-weight: 700;
  font-size: 22px;
  color: #fff;
  -webkit-text-stroke: 0;
  text-shadow: 0 3px 0 var(--ink);
}
.node .ns {
  position: absolute;
  left: 50%;
  bottom: -20px;
  transform: translateX(-50%);
  display: flex;
  gap: 1px;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 1px 5px;
}
.node .ns img { width: 11px; height: 11px; }
.node.done { background: linear-gradient(160deg, #fff2a8, var(--yellow)); }
.node.done .nn { color: var(--ink); text-shadow: 0 2px 0 #fff; }
.node.locked {
  background: #e4e0f2;
  box-shadow: 0 6px 0 #b9b3d6;
  border-color: #b9b3d6;
  cursor: default;
}
.node.locked .lk { width: 24px; height: 24px; }
.node.next::before {
  content: "";
  position: absolute;
  inset: -12px;
  border-radius: 50%;
  border: 4px solid var(--pink);
  animation: pulse 1.6s ease-out infinite;
}
@keyframes pulse {
  0% { transform: scale(.85); opacity: 1; }
  100% { transform: scale(1.4); opacity: 0; }
}
.map-list .world-block:last-child .world-nodes { margin-bottom: 0; }

/* ---------- game HUD ---------- */
#game { align-items: stretch; background: linear-gradient(170deg, var(--bg1), var(--bg2)); }
.hud {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(10px + var(--safe-t)) 14px 6px;
}
.hud-title {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-align: center;
}
.lvl-line {
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 2px 14px;
  font-size: 12px;
  letter-spacing: .12em;
  text-transform: uppercase;
  box-shadow: 0 4px 0 var(--ink);
}
.lvl-line b { font-family: var(--display); font-weight: 700; font-size: 18px; color: var(--pink); letter-spacing: .03em; margin-left: 4px; }
.world-line {
  font-family: var(--display);
  font-weight: 600;
  font-size: 17px;
  color: #fff;
  -webkit-text-stroke: 0;
  text-shadow: 0 2px 0 var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.pill {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--paper);
  border: var(--edge);
  box-shadow: 0 4px 0 var(--ink);
}
.hearts img { width: 26px; height: 26px; }
.hearts img.lost { filter: grayscale(1) opacity(.5); }
.hearts img.pop { animation: heartPop .55s ease both; }
@keyframes heartPop {
  0% { transform: scale(1); }
  35% { transform: scale(1.5) rotate(-8deg); }
  100% { transform: scale(1); }
}

.stage-bar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 18px 8px;
}
.pips { flex: 1; display: flex; gap: 6px; }
.seg {
  flex: 1;
  height: 12px;
  border-radius: 999px;
  background: rgba(255,255,255,.55);
  border: 2px solid var(--ink);
  transition: background .3s ease;
}
.seg.done { background: var(--yellow); }
.seg.now { background: #fff; animation: blink .9s ease-in-out infinite; }
@keyframes blink { 50% { background: var(--pink); } }
.stage-text {
  min-width: 92px;
  text-align: right;
  font-size: 13px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 0 var(--ink);
  white-space: nowrap;
}

.board {
  position: relative;
  flex: 1;
  min-height: 0;
  margin: 0 8px;
}
.board canvas {
  position: absolute;
  inset: 0 0 48px 0;
  width: 100%;
  height: calc(100% - 48px);
  display: block;
}
.coach {
  position: absolute;
  left: 50%;
  bottom: 2px;
  transform: translate(-50%, 8px);
  width: max-content;
  max-width: 90%;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--paper);
  border: var(--edge);
  box-shadow: 0 5px 0 var(--ink);
  font-size: 15px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .35s ease, transform .35s ease;
}
.coach b { color: var(--pink); letter-spacing: .06em; }
.coach.show { opacity: 1; transform: translate(-50%, 0); animation: float 2.4s ease-in-out infinite; }
@keyframes float { 50% { transform: translate(-50%, -5px); } }

.dock {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 16px calc(18px + var(--safe-b));
}
.flash { position: absolute; inset: 0; pointer-events: none; opacity: 0; z-index: 3; }
.flash.on { animation: flashAnim .6s ease-out both; }
.flash.on.miss { background: radial-gradient(70% 60% at 50% 60%, rgba(255,61,127,.55), rgba(255,61,127,0) 70%); }
.flash.on.gold { background: radial-gradient(60% 50% at 50% 55%, rgba(255,214,10,.6), rgba(255,214,10,0) 70%); }
@keyframes flashAnim { 0% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- modals ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(43,35,80,.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal.show { display: flex; animation: fadeIn .25s ease both; }
.modal.show .card { animation: pop .42s cubic-bezier(.2,1.3,.4,1) both; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.card {
  position: relative;
  width: min(340px, 100%);
  max-height: calc(100dvh - 36px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 26px 22px 22px;
  border-radius: 34px;
  text-align: center;
  background: var(--paper);
  border: var(--edge);
  box-shadow: 0 12px 0 var(--ink), 0 30px 60px rgba(20,10,50,.4);
}
.card h3 {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 30px;
  color: var(--ink);
  line-height: 1.05;
}
.card p { margin: 0; color: #5a5480; line-height: 1.45; font-size: 15px; font-weight: 700; }
.badge {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 999px;
  border: 3px solid var(--ink);
  background: var(--yellow);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
  box-shadow: 0 3px 0 var(--ink);
}
.badge-pink { background: var(--pink); color: #fff; }
.badge-blue { background: var(--blue); color: #fff; }
.badge-green { background: var(--green); }
.badge-yellow { background: var(--yellow); }
.col { display: flex; flex-direction: column; gap: 12px; width: 100%; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.rules {
  margin: 0;
  padding: 0;
  list-style: none;
  text-align: left;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: #5a5480;
  font-size: 15px;
  line-height: 1.4;
  font-weight: 700;
  counter-reset: r;
}
.rules li { padding-left: 40px; position: relative; }
.rules li::before {
  content: counter(r);
  counter-increment: r;
  position: absolute;
  left: 0; top: 0;
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--display);
  font-size: 15px; font-weight: 700;
  color: var(--ink);
  background: var(--yellow);
  border: 3px solid var(--ink);
}
.rules li:nth-child(2)::before { background: var(--green); }
.rules li:nth-child(3)::before { background: var(--pink); color: #fff; }
.rules li:nth-child(4)::before { background: var(--blue); color: #fff; }
.rules li b { color: var(--ink); }
.set-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 6px;
  border-bottom: 3px dashed rgba(43,35,80,.18);
  font-size: 17px;
  font-weight: 900;
}
.set-row .btn { min-width: 96px; }

.stars { display: flex; gap: 10px; justify-content: center; min-height: 80px; align-items: center; }
.stars img {
  width: 58px;
  height: 58px;
  transform: scale(.3) rotate(-20deg);
  transition: transform .5s cubic-bezier(.2,1.5,.4,1);
  filter: drop-shadow(0 4px 0 rgba(43,35,80,.25));
}
.stars img:nth-child(2) { width: 72px; height: 72px; }
.stars img.show { transform: scale(1) rotate(0deg); }
.stars img.on.show { filter: drop-shadow(0 0 10px rgba(255,214,10,.8)) drop-shadow(0 4px 0 rgba(43,35,80,.25)); }

.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti i {
  position: absolute;
  top: -14px;
  width: 9px;
  height: 14px;
  border-radius: 3px;
  border: 2px solid var(--ink);
  animation: fall linear both;
}
.confetti i:nth-child(3n) { border-radius: 50%; width: 10px; height: 10px; }
@keyframes fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(540px) rotate(560deg); opacity: 0; }
}

/* ---------- desktop: keep the phone frame centred ---------- */
@media (min-width: 700px) and (min-height: 700px) {
  .screen.active { max-width: 460px; left: 0; right: 0; margin: 0 auto; box-shadow: 0 0 80px rgba(20,10,50,.5); }
}

/* ---------- landscape phones / very short screens ---------- */
@media (max-height: 500px) {
  .menu-logo { display: none; }
  .menu-card { flex-direction: row; flex-wrap: wrap; width: min(660px, 100%); gap: 10px 16px; padding: 14px 18px; }
  .menu-card > * { margin: 0; }
  .logo { flex: 1 1 100%; font-size: 40px; }
  .tagline { flex: 1 1 100%; font-size: 13px; }
  .chip, #playBtn { flex: 1 1 40%; }
  .menu-row { flex: 1 1 100%; }
  .menu-row .btn-tile { min-height: 60px; flex-direction: row; }
}

/* ---------- short phones ---------- */
@media (max-height: 680px) {
  .btn-tile { min-height: 66px; }
  .world-head { height: 150px; }
  .hud { padding-top: 6px; }
  .dock { padding-top: 4px; padding-bottom: 10px; }
  .btn-lock { min-height: 58px; }
  .menu-row .btn-tile { min-height: 66px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- action HUD: score, combo, power-ups, toast ---------- */
.scorebar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 18px 6px;
}
.score-chip, .combo-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 14px;
  border-radius: 999px;
  border: 3px solid var(--ink);
  box-shadow: 0 4px 0 var(--ink);
  font-family: var(--display);
  font-weight: 600;
  font-size: 16px;
  background: var(--paper);
  color: var(--ink);
}
.score-chip small { font-family: var(--ui); font-size: 11px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; color: #5a5480; }
.score-chip b { font-weight: 700; font-size: 20px; color: var(--pink); }
.combo-chip { background: var(--yellow); }
.combo-chip.hot { background: var(--pink); color: #fff; animation: pulse 1s ease-in-out infinite; }
.items { display: flex; gap: 14px; justify-content: center; margin-bottom: 10px; }
.pw {
  position: relative;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: var(--edge);
  background: var(--paper);
  box-shadow: 0 5px 0 var(--ink);
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
}
.pw img { width: 30px; height: 30px; }
.pw em {
  position: absolute;
  top: -6px;
  right: -6px;
  font-style: normal;
  font-size: 12px;
  min-width: 22px;
  height: 22px;
  padding: 0 4px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: var(--pink);
  color: #fff;
  display: grid;
  place-items: center;
}
.pw:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.pw:disabled { opacity: .5; filter: grayscale(.6); }
.pw.active { background: var(--green); animation: pulse 1s ease-in-out infinite; }
.pw-slow { background: #bde0fe; }
.pw-shield { background: #caf0f8; }
.pw-heal { background: #ffe5ec; }
.toast {
  position: absolute;
  top: 34%;
  left: 50%;
  z-index: 4;
  padding: 10px 20px;
  border-radius: 999px;
  border: var(--edge);
  background: var(--paper);
  box-shadow: 0 5px 0 var(--ink);
  font-family: var(--display);
  font-weight: 600;
  font-size: 20px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 0);
}
.toast.show { animation: toastAnim 1.4s ease both; }
@keyframes toastAnim {
  0% { opacity: 0; transform: translate(-50%, 12px) scale(.8); }
  15% { opacity: 1; transform: translate(-50%, 0) scale(1.06); }
  25% { transform: translate(-50%, 0) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -24px); }
}
.score-line { font-size: 16px; color: #5a5480; }
.score-line b { color: var(--pink); font-family: var(--display); font-size: 20px; }
@keyframes pulse { 50% { transform: scale(1.06); } }

/* ---------- v1.1: long world names, desktop backdrop ---------- */
@media (max-width: 420px) { .world-line { font-size: 14px; } }
@media (min-width: 700px) and (min-height: 700px) {
  .app::before {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background:
      radial-gradient(circle at 10% 18%, rgba(255,255,255,.26) 0 8vmin, transparent 8.1vmin),
      radial-gradient(circle at 17% 72%, rgba(255,255,255,.18) 0 12vmin, transparent 12.1vmin),
      radial-gradient(circle at 5% 92%, rgba(255,255,255,.22) 0 4vmin, transparent 4.1vmin),
      radial-gradient(circle at 90% 14%, rgba(255,255,255,.2) 0 11vmin, transparent 11.1vmin),
      radial-gradient(circle at 84% 66%, rgba(255,255,255,.26) 0 6vmin, transparent 6.1vmin),
      radial-gradient(circle at 94% 88%, rgba(255,255,255,.16) 0 9vmin, transparent 9.1vmin);
  }
}
.loader-word span:nth-child(4) { margin-left: .35em; }

/* ---------- v1.2: wide desktop layout, dial on the left and controls on the right ---------- */
@media (min-width: 600px) and (max-height: 559px) {
  #game.screen.active {
    max-width: 1000px; display: grid; column-gap: 20px; padding: 0 20px;
    grid-template-columns: 1fr 320px; grid-template-rows: auto 1fr auto auto auto 1fr;
    grid-template-areas: "hud hud" "board ." "board stage" "board score" "board dock" "board .";
  }
  #game .hud { grid-area: hud; }
  #game .stage-bar { grid-area: stage; flex-direction: column; align-items: stretch; gap: 6px; }
  #game .scorebar { grid-area: score; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 14px 0; }
  #game .board { grid-area: board; margin: 0; }
  #game .dock { grid-area: dock; justify-content: flex-start; gap: 18px; padding: 10px 0 24px; }
  #game .dock .items { justify-content: center; }
  #game .btn-lock { width: 100%; min-height: 84px; }
}

@media (min-width: 600px) and (max-height: 559px) {
  #game.screen.active { max-width: none; grid-template-columns: 1fr 300px; column-gap: 16px; padding: 0 16px; }
  #game .hud { padding-top: 4px; }
  #game .stage-bar { margin: 0; }
  #game .scorebar { margin: 8px 0; }
  #game .dock { gap: 10px; padding-bottom: 10px; }
  #game .btn-lock { min-height: 62px; }
  #game .items { margin-bottom: 0; }
  .board canvas { inset: 0 0 40px 0; height: calc(100% - 40px); }
  .coach { font-size: 13px; padding: 6px 14px; }
}
@media (max-height: 680px) and (max-width: 599px) {
  .board canvas { inset: 0 0 40px 0; height: calc(100% - 40px); }
  .coach { font-size: 13px; padding: 7px 14px; }
}
