:root {
  --bg: #d8c9b0;
  --bg-2: #cbb999;
  --bg-line: rgba(255, 255, 255, .22);
  --panel: #fde6bd;
  --panel-2: #f7d79f;
  --panel-edge: #a8775a;
  --stitch: #b07d5c;
  --inset: #8c6052;
  --ink: #5a3628;
  --ink-soft: #7a5546;
  --cell: #3a2f2a;
  --cell-2: #463a33;
  --wood-1: #b98455;
  --wood-2: #9a6a42;
  --wood-3: #7a4f2f;
  --channel: #352b27;
  --green-1: #9be33a;
  --green-2: #4fae17;
  --green-edge: #3a8a0e;
  --blue-1: #55d0ff;
  --blue-2: #1b8de6;
  --blue-edge: #1567b3;
  --red-1: #ff7a72;
  --red-2: #e2373a;
  --gold-1: #ffd75a;
  --gold-2: #f2a516;
  --white: #fffaf0;
  --bg-light: rgba(255,236,214,.42);
  --bg-1: #9a8a79;
  --bg-2: #7d6f61;
  --bg-3: #5f544a;
  --page-1: #cbbba5;
  --page-2: #b6a38b;
  --page-glow: rgba(255,248,235,.5);
  --round-hi: #fff3d6;
  --round-edge: #b48663;
  --round-ring: #fff2d2;
  --stone-1: #d9cbbd;
  --stone-2: #c3b3a4;
  --stone-3: #a99788;
  --stone-hi: rgba(255,255,255,.55);
  --frame-base: #5d524b;
  --frame-drop: #4a403a;
  --floor: #2c2421;
  --wall-1: #bdb3ab;
  --wall-2: #978b82;
  --overlay: rgba(30,22,18,.6);
  --logo-stroke: #6b3d26;
  --switch-off: #8d7b70;
  --coin-pill: #4a2c22;
  --font: 'Vazirmatn', Tahoma, sans-serif;
  --title: 'Lalezar', 'Vazirmatn', Tahoma, sans-serif;
  --C: 48px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    var(--clouds, none) 0 0 / 520px 520px,
    radial-gradient(ellipse 90% 70% at 8% 22%, var(--bg-light), transparent 70%),
    linear-gradient(160deg, var(--bg-1), var(--bg-2) 55%, var(--bg-3));
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
button { font-family: inherit; cursor: pointer; border: 0; background: none; padding: 0; color: inherit; }
.hidden { display: none !important; }

#app { position: relative; width: 100%; height: 100%; overflow: hidden; }
.screen { position: absolute; top: 0; bottom: 0; left: 0; right: 0; max-width: 520px; margin: 0 auto; display: flex; flex-direction: column; }

/* ---------- shared pieces ---------- */
.round-btn {
  width: 64px; height: 64px; border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, var(--round-hi), var(--panel-2));
  box-shadow: 0 4px 0 var(--round-edge), 0 6px 10px rgba(0,0,0,.25), inset 0 0 0 3px var(--round-ring);
  display: grid; place-items: center; position: relative;
  transition: transform .08s;
}
.round-btn::after { content: ''; position: absolute; inset: 6px; border-radius: 50%; border: 2px dashed var(--stitch); opacity: .7; }
.round-btn:active { transform: translateY(3px); }
.round-btn svg { width: 40px; height: 40px; position: relative; z-index: 1; }

.btn {
  font-family: var(--title); font-size: 28px; color: #fff; letter-spacing: .5px;
  min-width: 150px; height: 58px; padding: 0 28px; border-radius: 30px;
  text-shadow: 0 2px 0 rgba(0,0,0,.25);
  position: relative; transition: transform .08s, box-shadow .08s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; line-height: 1;
}
.btn > * { position: relative; }
.btn > span:not(.ico) { padding-top: 5px; }   /* Lalezar sits high; centre it against the icon */
.btn .ico { width: 34px; height: 34px; display: inline-flex; flex: none; }
.btn .ico svg { width: 100%; height: 100%; }
.btn-green {
  background: linear-gradient(#a8ec48, #6cc823 55%, #4fae17);
  box-shadow: 0 5px 0 var(--green-edge), 0 8px 14px rgba(0,0,0,.25),
    inset 0 4px 3px rgba(255,255,255,.5), inset 0 -5px 4px rgba(30,90,0,.35), inset 0 0 0 2px rgba(255,255,255,.18);
}
.btn-blue {
  background: linear-gradient(#66d6ff, #2aa2f0 55%, #1b8de6);
  box-shadow: 0 5px 0 var(--blue-edge), 0 8px 14px rgba(0,0,0,.25),
    inset 0 4px 3px rgba(255,255,255,.5), inset 0 -5px 4px rgba(10,50,120,.35), inset 0 0 0 2px rgba(255,255,255,.18);
}
.btn:active { transform: translateY(4px); }
.btn-green:active { box-shadow: 0 1px 0 var(--green-edge), 0 3px 6px rgba(0,0,0,.2), inset 0 3px 6px rgba(30,90,0,.35); }
.btn-blue:active { box-shadow: 0 1px 0 var(--blue-edge), 0 3px 6px rgba(0,0,0,.2), inset 0 3px 6px rgba(10,50,120,.35); }
.btn-wide { min-width: 0; width: 100%; font-size: 24px; }
.btn[disabled] { filter: grayscale(.8); opacity: .7; pointer-events: none; }

.panel {
  background: var(--panel); border-radius: 22px; position: relative;
  box-shadow: 0 6px 0 var(--panel-edge), 0 14px 30px rgba(0,0,0,.35);
}
.panel::before { content: ''; position: absolute; inset: 9px; border: 3px dashed var(--stitch); border-radius: 16px; pointer-events: none; }

/* ---------- home ---------- */
#home { align-items: center; justify-content: center; gap: 26px; padding: 24px 16px; }
.home-top { position: absolute; top: 16px; left: 16px; right: 16px; display: flex; justify-content: space-between; align-items: center; }
/* coin counter: the coin stack sits in a round stitched disc (same as the gear button), the number in a dark pill */
.coin-pill { display: flex; align-items: center; direction: ltr; }
.coin-disc {
  position: relative; z-index: 1; flex: none; width: 50px; height: 50px; border-radius: 50%;
  display: grid; place-items: center;
  background: radial-gradient(circle at 50% 35%, var(--round-hi), var(--panel-2));
  box-shadow: 0 4px 0 var(--round-edge), 0 6px 10px rgba(0,0,0,.25), inset 0 0 0 3px var(--round-ring);
}
.coin-disc::after { content: ''; position: absolute; inset: 5px; border-radius: 50%; border: 2px dashed var(--stitch); opacity: .7; }
.coin-disc svg { width: 30px; height: 30px; position: relative; z-index: 1; filter: drop-shadow(0 2px 1px rgba(0,0,0,.25)); }
.coin-num {
  height: 34px; min-width: 64px; margin-left: -18px; padding: 4px 14px 0 26px;
  display: flex; align-items: center; justify-content: center; border-radius: 0 18px 18px 0;
  background: var(--coin-pill); color: #ffdf8a; font-family: var(--title); font-size: 21px; line-height: 1;
  text-shadow: 0 2px 0 rgba(0,0,0,.35);
  box-shadow: inset 0 3px 4px rgba(0,0,0,.35), 0 2px 0 rgba(255,255,255,.12);
}
.logo { text-align: center; }
.logo h1 {
  margin: 0; font-family: var(--title); font-weight: 400; font-size: 76px; line-height: 1.1;
  color: #fff; -webkit-text-stroke: 3px var(--logo-stroke); paint-order: stroke fill;
  text-shadow: 0 6px 0 var(--logo-stroke), 0 12px 18px rgba(0,0,0,.25);
}
.logo .tiles { display: flex; gap: 6px; justify-content: center; margin-bottom: 10px; }
.logo .tiles i { width: 30px; height: 30px; border-radius: 7px; display: block; box-shadow: inset 0 -4px 0 rgba(0,0,0,.25), inset 0 3px 0 rgba(255,255,255,.35); }
.logo p { margin: 6px 0 0; font-size: 17px; color: var(--ink-soft); font-weight: 700; }
.home-card { padding: 30px 28px 32px; width: min(340px, 100%); display: flex; flex-direction: column; align-items: center; gap: 18px; }
.home-card .lv { font-family: var(--title); font-size: 26px; }
.home-card .btn { width: 100%; height: 66px; font-size: 34px; }
.home-card .progress { width: 100%; height: 14px; border-radius: 8px; background: var(--inset); overflow: hidden; box-shadow: inset 0 2px 0 rgba(0,0,0,.25); }
.home-card .progress i { display: block; height: 100%; background: linear-gradient(var(--green-1), var(--green-2)); border-radius: 8px; }
.home-card small { color: var(--ink-soft); font-weight: 700; }

/* ---------- game ---------- */
.hud { position: relative; z-index: 10; direction: ltr; display: flex; align-items: flex-start; justify-content: space-between; padding: 12px 16px 0; gap: 10px; flex: none; }
.level-pill { padding: 8px 22px 12px; min-width: 190px; text-align: center; border-radius: 18px; }
.level-pill::before { inset: 6px; border-radius: 13px; border-width: 2px; }
.level-pill .lv-title { font-family: var(--title); font-size: 22px; line-height: 1.3; position: relative; }
.level-pill .lv-score {
  position: relative; margin-top: 2px; height: 34px; border-radius: 17px; background: var(--inset); color: #fff;
  font-family: var(--title); font-size: 24px; line-height: 36px; box-shadow: inset 0 3px 0 rgba(0,0,0,.2);
}
.level-pill .lv-score.bump { animation: bump .35s; }
@keyframes bump { 40% { transform: scale(1.12); } }

#stage { flex: 1; position: relative; display: grid; place-items: center; min-height: 0; }
#board-wrap { position: relative; direction: ltr; }

.boosters { position: relative; z-index: 10; direction: ltr; flex: none; display: flex; justify-content: center; gap: 22px; padding: 6px 16px 18px; }
.booster {
  width: 82px; height: 82px; border-radius: 18px; position: relative;
  background: var(--panel); box-shadow: 0 5px 0 var(--panel-edge), 0 8px 14px rgba(0,0,0,.25);
  display: grid; place-items: center; transition: transform .1s;
}
.booster::before { content: ''; position: absolute; inset: 6px; border: 2px dashed var(--stitch); border-radius: 13px; }
.booster svg { width: 54px; height: 54px; position: relative; }
.booster .badge {
  position: absolute; top: -12px; left: -12px; width: 36px; height: 36px; border-radius: 50%; z-index: 2;
  display: grid; place-items: center;
  background: radial-gradient(circle at 38% 30%, #ffe9a6 0 12%, #ffc23a 32%, #ff9a12 62%, #e86f00 100%);
  border: 3px solid #ffd257;
  box-shadow: 0 0 0 2px #b85a00, 0 3px 0 2px #8f4500, inset 0 -3px 0 rgba(150,60,0,.35), inset 0 3px 2px rgba(255,255,255,.55);
  font-family: var(--title); font-size: 21px; line-height: 1; color: #fff;
  -webkit-text-stroke: 1.5px #a24c00; paint-order: stroke fill; text-shadow: 0 2px 0 #a24c00;
}
.booster .badge.plus { font-size: 30px; padding-bottom: 3px; }
.booster.locked svg { width: 34px; height: 34px; margin-top: -14px; }
.booster.locked .lock-lv { position: absolute; bottom: 9px; font-family: var(--title); font-size: 16px; color: var(--ink); }
.booster.active { transform: translateY(-6px) scale(1.06); box-shadow: 0 5px 0 var(--panel-edge), 0 0 0 4px var(--gold-1), 0 10px 18px rgba(0,0,0,.3); }
.booster:active { transform: translateY(3px); }

/* frame + cells */
.frame-base {
  position: absolute; border-radius: calc(var(--C) * .3); background: var(--frame-base);
  box-shadow: 0 6px 0 var(--frame-drop), 0 14px 24px rgba(40,25,15,.35);
}
.seg, .rail {
  position: absolute; z-index: 2; border-radius: 4px;
  background: linear-gradient(180deg, var(--stone-1) 0%, var(--stone-2) 45%, var(--stone-3) 100%);
  box-shadow: inset 0 2px 0 var(--stone-hi), inset 0 -3px 0 rgba(70,55,45,.35), inset 2px 0 0 rgba(255,255,255,.2), inset -2px 0 0 rgba(70,55,45,.18);
}
.seg.corner.tl { border-top-left-radius: calc(var(--C) * .28); }
.seg.corner.tr { border-top-right-radius: calc(var(--C) * .28); }
.seg.corner.bl { border-bottom-left-radius: calc(var(--C) * .28); }
.seg.corner.br { border-bottom-right-radius: calc(var(--C) * .28); }
.rail { border-radius: 3px; box-shadow: inset 0 2px 0 rgba(255,255,255,.5), inset 0 -2px 0 rgba(70,55,45,.35), 0 2px 3px rgba(40,25,15,.3); }
.rail.cap-l { border-radius: 8px 3px 3px 8px; } .rail.cap-r { border-radius: 3px 8px 8px 3px; }
.rail.cap-t { border-radius: 8px 8px 3px 3px; } .rail.cap-b { border-radius: 3px 3px 8px 8px; }

/* dark dotted floor shared by cells and gate docks */
.grid, .dock {
  background-color: var(--floor);
  background-image:
    radial-gradient(circle, rgba(255,235,215,.07) 1px, transparent 1.4px),
    radial-gradient(circle, rgba(255,235,215,.05) 1px, transparent 1.4px);
  background-size: 6px 6px, 6px 6px;
  background-position: 0 0, 3px 3px;
}
.grid { position: absolute; border-radius: 3px; box-shadow: inset 0 3px 8px rgba(0,0,0,.6); }
.cell { position: absolute; width: var(--C); height: var(--C); box-shadow: inset 0 0 0 1px rgba(0,0,0,.45), inset 1px 1px 0 rgba(255,235,215,.05); }
.dock { position: absolute; z-index: 1; box-shadow: inset 0 3px 6px rgba(0,0,0,.55); }
.dock.closed { filter: brightness(.75); }

.chips { position: absolute; z-index: 3; display: flex; align-items: center; gap: calc(var(--C) * .05); padding: calc(var(--C) * .06); }
.chip { display: flex; flex-direction: column; align-items: center; gap: 2px; color: #fff; font-family: var(--title); font-size: calc(var(--C) * .26); line-height: 1; text-shadow: 0 1px 0 rgba(0,0,0,.5); }
.chip i {
  width: calc(var(--C) * .38); height: calc(var(--C) * .38); border-radius: 24%; display: block; position: relative;
  background: linear-gradient(145deg, var(--l) 0%, var(--m) 45%, var(--d) 100%);
  box-shadow: inset 2px 2px 1px rgba(255,255,255,.55), inset -2px -2px 1px rgba(0,0,0,.32), 0 2px 2px rgba(0,0,0,.55);
}
.chip i::after { /* the raised top face of the cube */
  content: ''; position: absolute; inset: 22%; border-radius: 22%;
  background: linear-gradient(145deg, rgba(255,255,255,.45), rgba(255,255,255,.08));
}
.chip.front i { width: calc(var(--C) * .44); height: calc(var(--C) * .44); }
.chip.more span { font-size: calc(var(--C) * .19); opacity: .85; }
.chips:not(.v) { padding-left: 2px; padding-right: 2px; }
.chips.v .chip { flex-direction: row-reverse; gap: 3px; }
.chev-wrap { display: inline-flex; flex: none; }
.chevron { width: calc(var(--C) * .2); height: calc(var(--C) * .32); flex: none; }
.chevron.pulse { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { transform: translateX(3px); } }

/* blocks */
.block { position: absolute; left: 0; top: 0; z-index: 5; transition: transform 70ms linear; cursor: grab; touch-action: none; }
.block.dragging { z-index: 8; transition: transform 45ms linear; filter: drop-shadow(0 8px 6px rgba(0,0,0,.45)) brightness(1.06); }
.block.leaving { transition: transform .32s cubic-bezier(.5,0,.9,.4), opacity .32s; opacity: 0; }
.block.pick { animation: wobble .5s infinite; cursor: pointer; }
@keyframes wobble { 25% { rotate: 2deg; } 75% { rotate: -2deg; } }
.tile { position: absolute; background: var(--m); }   /* flat face: the 3D comes from the per-side bevel, so multi-cell blocks show no seams */
.block { filter: drop-shadow(0 2px 0 rgba(0,0,0,.35)) drop-shadow(0 4px 4px rgba(0,0,0,.25)); }
.stud { position: absolute; width: 38%; height: 38%; border-radius: 24%;
  background: linear-gradient(145deg, color-mix(in srgb, var(--d) 85%, #000), var(--m));
  box-shadow: inset 2px 2px 2px rgba(0,0,0,.4), inset -1px -1px 0 rgba(255,255,255,.3), 0 1px 0 rgba(255,255,255,.25); }
.block .arrow { position: absolute; pointer-events: none; filter: drop-shadow(0 2px 2px rgba(0,0,0,.4)); }

.wall { position: absolute; z-index: 4; border-radius: 4px;
  background:
    linear-gradient(rgba(0,0,0,.15) 1px, transparent 1px) 0 0 / 100% 33.4%,
    linear-gradient(90deg, rgba(0,0,0,.15) 1px, transparent 1px) 0 0 / 50% 33.4%,
    linear-gradient(var(--wall-1), var(--wall-2));
  box-shadow: inset 0 3px 0 rgba(255,255,255,.4), inset 0 -4px 0 rgba(0,0,0,.25);
}
/* wooden board = wooden cover in the shape of the block underneath */
.board { position: absolute; z-index: 7; perspective: 400px; }
.wood {
  position: absolute;
  background:
    repeating-linear-gradient(90deg, transparent 0 calc(var(--C) * .25 - 2px), rgba(110,55,15,.5) calc(var(--C) * .25 - 2px) calc(var(--C) * .25)),
    linear-gradient(#f2a85a, #dc8636 60%, #c8722a);
  box-shadow: inset 0 0 0 2px #b0621f, inset 0 3px 0 rgba(255,235,200,.45), inset 0 -3px 0 rgba(90,40,10,.35), 0 2px 0 #8a4a14;
}
.board-num {
  position: absolute; display: grid; place-items: center; z-index: 1;
  font-family: var(--title); font-size: calc(var(--C) * .58); line-height: 1; color: #fff3c4;
  -webkit-text-stroke: 2px #7a3e0c; paint-order: stroke fill; text-shadow: 0 2px 0 rgba(90,40,10,.45);
}
.board.tick .board-num { animation: bump .35s; }
.board.reveal { animation: woodflip .5s ease-in forwards; transform-origin: 50% 50%; }
@keyframes woodflip { 0% { transform: rotateY(0) scale(1); } 45% { transform: rotateY(70deg) scale(1.06); opacity: 1; } 100% { transform: rotateY(90deg) scale(1.1); opacity: 0; } }
.block.revealed { animation: blockreveal .6s ease-out; }
@keyframes blockreveal { 0% { filter: brightness(2) saturate(.4); scale: .85; } 60% { filter: brightness(1.25); scale: 1.04; } 100% { filter: none; scale: 1; } }

.spark { position: absolute; z-index: 9; width: 10px; height: 10px; border-radius: 50%; pointer-events: none; animation: spark .6s ease-out forwards; }
@keyframes spark { to { transform: translate(var(--dx), var(--dy)) scale(.2); opacity: 0; } }
.pick-hint { position: absolute; left: 50%; bottom: 112px; transform: translateX(-50%); z-index: 20; background: var(--inset); color: #fff; padding: 8px 16px; border-radius: 16px; font-weight: 700; font-size: 15px; white-space: nowrap; box-shadow: 0 4px 10px rgba(0,0,0,.3); }

/* ---------- modal ---------- */
#modal-root { position: absolute; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: var(--overlay); animation: fade .2s; }
#modal-root:empty { display: none; }
@keyframes fade { from { opacity: 0; } }
.modal { width: min(370px, calc(100% - 20px)); padding: 30px 26px 34px; text-align: center; animation: pop .28s cubic-bezier(.3,1.6,.5,1); }
@keyframes pop { from { transform: scale(.7); opacity: 0; } }
.modal h2 { margin: 0 0 14px; font-family: var(--title); font-weight: 400; font-size: 40px; color: var(--ink); position: relative; }
.modal .art { height: 120px; display: grid; place-items: center; position: relative; }
.modal .art svg { height: 110px; width: auto; max-width: 160px; }
.modal .msg { position: relative; margin: 14px 0 22px; background: var(--inset); color: #fff; border-radius: 18px; padding: 18px 16px; font-size: 19px; font-weight: 800; line-height: 1.7; }
.modal .row { display: flex; justify-content: center; align-items: center; gap: 14px; position: relative; }
.modal .note { position: relative; margin: -8px 0 18px; font-weight: 800; font-size: 16px; color: var(--ink); }
.close-x {
  position: absolute; top: -18px; right: -10px; width: 50px; height: 50px; border-radius: 50%; z-index: 2;
  background: radial-gradient(circle at 50% 28%, #ff9a90 0 10%, #ff5a4e 38%, #e2252a 75%, #b8141c 100%);
  box-shadow: 0 0 0 4px #fff, 0 0 0 6px rgba(150,40,30,.35), 0 5px 8px rgba(0,0,0,.35), inset 0 -4px 0 rgba(120,0,10,.35), inset 0 3px 3px rgba(255,255,255,.45);
  display: grid; place-items: center;
}
.close-x svg { width: 22px; height: 22px; filter: drop-shadow(0 2px 0 rgba(120,0,10,.55)); }
.close-x:active { transform: scale(.94); }

/* coin balance shown above the popups */
.coin-top {
  position: absolute; top: 18px; left: 0; right: 0; margin: 0 auto; width: max-content; z-index: 3;
  display: flex; align-items: center; height: 44px; padding: 0 22px 0 58px; border-radius: 24px;
  background: linear-gradient(#b79cff, #7b52e6); border: 3px solid #e6dcff;
  box-shadow: 0 4px 0 #4d2a9e, 0 8px 14px rgba(0,0,0,.35), inset 0 -3px 0 rgba(60,20,140,.35);
  font-family: var(--title); font-size: 26px; line-height: 1; color: #fff; text-shadow: 0 2px 0 rgba(60,20,140,.6);
  animation: pop .3s cubic-bezier(.3,1.6,.5,1);
}
.coin-top svg { position: absolute; left: -14px; top: 50%; transform: translateY(-55%); width: 66px; height: 66px; filter: drop-shadow(0 3px 2px rgba(0,0,0,.35)); }
.nav-arrow { width: 52px; height: 52px; border-radius: 50%; background: radial-gradient(circle at 50% 35%, var(--gold-1), var(--gold-2)); box-shadow: 0 3px 0 #b06c00, 0 0 0 3px #fff3d0; display: grid; place-items: center; }
.nav-arrow svg { width: 26px; height: 26px; }
.nav-arrow[disabled] { opacity: .35; pointer-events: none; }
.dots { display: flex; gap: 6px; justify-content: center; margin-top: 14px; position: relative; }
.dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--stitch); opacity: .4; }
.dots i.on { opacity: 1; }

.toggles { position: relative; background: var(--inset); border-radius: 18px; padding: 14px 24px; margin-bottom: 22px; }
.toggle-row { display: flex; justify-content: space-between; align-items: center; color: #fff; font-family: var(--title); font-size: 28px; padding: 4px 0; }
.switch { width: 78px; height: 38px; border-radius: 20px; background: linear-gradient(#ffcd4a, #f09a16); padding: 4px; box-shadow: 0 0 0 2px #b0670c; position: relative; }
.switch i { position: absolute; inset: 6px 30px 6px 6px; border-radius: 14px; background: linear-gradient(#9be33a, #4fae17); transition: .2s; }
.switch b { position: absolute; top: 3px; left: 42px; width: 32px; height: 32px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #ffe68a, #f0a316); box-shadow: 0 2px 3px rgba(0,0,0,.35); transition: .2s; }
.switch.off i { background: var(--switch-off); inset: 6px 6px 6px 30px; }
.switch.off b { left: 4px; }

/* win */
.win { width: min(380px, 100%); text-align: center; animation: pop .35s cubic-bezier(.3,1.6,.5,1); }
.win-hero { position: relative; width: 220px; height: 180px; margin: 0 auto; display: grid; place-items: center; }
.win-hero .crown { position: relative; width: 190px; height: auto; animation: crownin .6s cubic-bezier(.3,1.6,.5,1) both, crownbob 2.4s ease-in-out .6s infinite; }
.win-hero .rays {
  position: absolute; inset: -60px; border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, rgba(255,214,90,.35) 0 9deg, transparent 9deg 24deg);
  -webkit-mask: radial-gradient(circle, #000 18%, transparent 68%); mask: radial-gradient(circle, #000 18%, transparent 68%);
  animation: spin 14s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes crownin { from { transform: scale(.3) rotate(-12deg); opacity: 0; } }
@keyframes crownbob { 50% { transform: translateY(-6px); } }
.win-title {
  margin: -6px 0 0; position: relative; font-family: var(--title); font-weight: 400; font-size: 56px; line-height: 1.2; color: #fff;
  -webkit-text-stroke: 3px #6b3d26; paint-order: stroke fill; text-shadow: 0 5px 0 #6b3d26, 0 10px 18px rgba(0,0,0,.35);
}
.win .stat { margin: 18px auto 0; width: 240px; padding: 12px 10px; font-family: var(--title); font-size: 30px; color: #fff; -webkit-text-stroke: 2px #6b3d26; paint-order: stroke fill; display: flex; justify-content: center; align-items: center; gap: 8px; }
.win .stat::before { inset: 6px; border-width: 2px; }
.win .stat span, .win .stat svg { position: relative; }
.win .stat svg { width: 40px; height: 40px; }
.win .btns { display: flex; flex-direction: column; align-items: center; gap: 18px; margin-top: 34px; }
.win .btns .btn { min-width: 230px; height: 62px; font-size: 32px; }
.coin-fly { position: absolute; width: 30px; height: 30px; z-index: 60; pointer-events: none; animation: coinfly .9s ease-in forwards; }
@keyframes coinfly { to { transform: translate(var(--dx), var(--dy)) scale(.6); opacity: .2; } }

#toast { position: absolute; top: 96px; left: 50%; transform: translateX(-50%); z-index: 70; background: var(--inset); color: #fff; padding: 8px 18px; border-radius: 16px; font-weight: 800; opacity: 0; transition: opacity .25s; pointer-events: none; white-space: nowrap; }
#toast.show { opacity: 1; }

@media (max-height: 700px) {
  .round-btn { width: 54px; height: 54px; }
  .round-btn svg { width: 32px; height: 32px; }
  .booster { width: 70px; height: 70px; }
  .booster svg { width: 44px; height: 44px; }
}

/* gate → block cube filling */
.stud.filled {
  background: linear-gradient(145deg, var(--l) 0%, var(--m) 45%, var(--d) 100%);
  box-shadow: inset 2px 2px 1px rgba(255,255,255,.55), inset -2px -2px 1px rgba(0,0,0,.32), 0 2px 2px rgba(0,0,0,.4);
}

.fly-stud {
  position: absolute; z-index: 9; pointer-events: none; border-radius: 22%; will-change: transform;   /* moves on the GPU: the textured board under it is not repainted every frame */
  background: linear-gradient(145deg, var(--l) 0%, var(--m) 45%, var(--d) 100%);
  box-shadow: inset 2px 2px 1px rgba(255,255,255,.55), inset -2px -2px 1px rgba(0,0,0,.32), 0 3px 4px rgba(0,0,0,.45);
}

/* ---------- dark theme (data-theme is set from the system setting or the settings switch) ---------- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg-light: rgba(255,226,196,.16);
  --bg-1: #4a4038;
  --bg-2: #352e28;
  --bg-3: #221d19;
  --page-1: #241b17;
  --page-2: #140f0c;
  --page-glow: rgba(255,180,110,.09);
  --panel: #3d2e26;
  --panel-2: #4a382e;
  --panel-edge: #1a120e;
  --stitch: #8f6c55;
  --inset: #251b16;
  --ink: #f6e6cf;
  --ink-soft: #cdb194;
  --round-hi: #5c473a;
  --round-edge: #1a120e;
  --round-ring: rgba(255,220,180,.12);
  --stone-1: #8b7f75;
  --stone-2: #71665d;
  --stone-3: #5a5049;
  --stone-hi: rgba(255,240,225,.28);
  --frame-base: #2a231f;
  --frame-drop: #15100d;
  --floor: #1b1513;
  --wall-1: #8d837b;
  --wall-2: #665d56;
  --overlay: rgba(6,4,3,.72);
  --logo-stroke: #3b2114;
  --switch-off: #5e5049;
  --coin-pill: #140e0b;
}
:root[data-theme="dark"] .panel,
:root[data-theme="dark"] .booster { box-shadow: 0 6px 0 var(--panel-edge), 0 14px 30px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,225,190,.08); }
:root[data-theme="dark"] .modal .msg { box-shadow: inset 0 2px 6px rgba(0,0,0,.45); }
:root[data-theme="dark"] .wood { filter: brightness(.92) saturate(.95); }
:root[data-theme="dark"] .round-btn svg { filter: drop-shadow(0 2px 2px rgba(0,0,0,.4)); }
:root[data-theme="dark"] .win .stat { -webkit-text-stroke-color: #2a170e; }

/* ---------- 3D cards: lighter top → warmer bottom face, inner top light + bottom shade,
   thin outline and a thick darker base underneath (popups, slots, pills, round buttons) ---------- */
:root {
  --card-hi: #fff4dc;
  --card-lo: #f5d7a2;
  --card-rim: #c99466;
  --card-base: #a0704f;
  --card-base-2: #7d5238;
  --card-light: rgba(255,255,255,.75);
  --card-shade: rgba(160,100,55,.28);
}
:root[data-theme="dark"] {
  --card-hi: #4d3a2f;
  --card-lo: #35281f;
  --card-rim: #1d1410;
  --card-base: #1a120e;
  --card-base-2: #0d0806;
  --card-light: rgba(255,225,190,.16);
  --card-shade: rgba(0,0,0,.35);
}
.panel, .booster {
  background: linear-gradient(180deg, var(--card-hi) 0%, var(--panel) 38%, var(--card-lo) 100%);
}
.panel, .booster, :root[data-theme="dark"] .panel, :root[data-theme="dark"] .booster {
  box-shadow:
    inset 0 3px 0 var(--card-light),
    inset 0 -5px 0 var(--card-shade),
    0 0 0 2px var(--card-rim),
    0 6px 0 1px var(--card-base),
    0 8px 0 1px var(--card-base-2),
    0 14px 20px rgba(0,0,0,.3);
}
.booster.active {
  box-shadow:
    inset 0 3px 0 var(--card-light), inset 0 -5px 0 var(--card-shade),
    0 0 0 2px var(--card-rim), 0 0 0 5px var(--gold-1), 0 9px 0 4px var(--card-base), 0 16px 22px rgba(0,0,0,.35);
}
.round-btn, .coin-disc {
  background: radial-gradient(circle at 50% 30%, var(--card-hi) 0%, var(--panel) 55%, var(--card-lo) 100%);
  box-shadow:
    inset 0 3px 0 var(--card-light),
    inset 0 -4px 0 var(--card-shade),
    0 0 0 2px var(--card-rim),
    0 5px 0 1px var(--card-base),
    0 7px 0 1px var(--card-base-2),
    0 11px 16px rgba(0,0,0,.3);
}
.round-btn:active { transform: translateY(4px); box-shadow: inset 0 3px 0 var(--card-light), inset 0 -3px 0 var(--card-shade), 0 0 0 2px var(--card-rim), 0 2px 0 1px var(--card-base), 0 4px 8px rgba(0,0,0,.25); }
.booster:active { transform: translateY(4px); }

/* timer tab under the level pill */
.level-pill { position: relative; }
.timer {
  position: absolute; left: 50%; bottom: -24px; transform: translateX(-50%); z-index: 2;
  display: flex; align-items: center; gap: 6px; height: 32px; padding: 3px 14px 0 8px; direction: ltr;
  border-radius: 16px; background: var(--coin-pill); color: #ffe7b0;
  font-family: var(--title); font-size: 20px; line-height: 1; white-space: nowrap;
  box-shadow: 0 0 0 2px var(--card-rim), 0 3px 0 1px var(--card-base), inset 0 3px 4px rgba(0,0,0,.35);
}
.timer-ico { display: inline-flex; width: 24px; height: 24px; margin-top: -3px; }
.timer-ico svg { width: 100%; height: 100%; }
.timer.low { background: linear-gradient(#ff5a4e, #c41d24); color: #fff; animation: timerpulse .5s ease-in-out infinite alternate; }
@keyframes timerpulse { to { transform: translateX(-50%) scale(1.1); } }
.hud { padding-bottom: 22px; }
.modal .art .clock { height: 110px; }
.btn .price { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px 0; border-radius: 14px; background: rgba(0,0,0,.18); }
.btn .price .ico { width: 26px; height: 26px; }
.btn-half { flex: 1; min-width: 0; }

.round-btn, .coin-disc { width: 50px; height: 50px; }
.round-btn svg { width: 32px; height: 32px; }
.home-card .chapter-name { margin-bottom: -10px; font-family: var(--title); font-size: 18px; color: var(--ink-soft); }

/* background picker in settings */
.scene-pick { position: relative; margin: -8px 0 20px; }
.scene-title { font-family: var(--title); font-size: 24px; color: var(--ink); margin-bottom: 8px; text-align: right; }
.scene-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-height: 300px; overflow-y: auto; padding: 6px 4px; }
.scene .pic.auto { background: conic-gradient(#7fb069, #e0b06a, #6fb7d6, #dde7ef, #e6a05a, #3d6b45, #8fa3b8, #7fb069); }
.scene { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.scene .pic {
  width: 100%; aspect-ratio: 1; border-radius: 12px; background: center / cover no-repeat;
  box-shadow: 0 0 0 2px var(--card-rim), 0 3px 0 1px var(--card-base);
}
.scene .pic.classic { background: radial-gradient(ellipse at 20% 25%, var(--bg-light), transparent 70%), linear-gradient(160deg, var(--bg-1), var(--bg-3)); }
.scene .nm { font-weight: 800; font-size: 13px; color: var(--ink-soft); }
.scene.on .pic { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--gold-2), 0 4px 0 5px var(--card-base); }
.scene.on .nm { color: var(--ink); }

/* art levels: scene + drawn board picture behind the real (transparent) board */
#art-layer { position: absolute; z-index: 0; max-width: none; pointer-events: none; user-select: none; }
#art-layer[hidden] { display: none; }
#app > .screen { z-index: 1; }
#board-wrap.art { z-index: 2; }
#board-wrap.art .grid { background: transparent; box-shadow: none; border-radius: 0; }
#board-wrap.art .cell { box-shadow: none; }

.home-actions { display: flex; gap: 12px; }
.scene-pick { margin-top: 0; }
.scene-pick .scene-list { max-height: none; overflow: visible; }

.level-pill .lv-score { margin-top: 0; }
.level-pill { padding: 10px 22px 12px; }

.level-pill .lv-score { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 2px; min-width: 150px; }
.level-pill .lv-score .ico { display: inline-flex; width: 26px; height: 26px; margin-top: -4px; }
.level-pill .lv-score .ico svg { width: 100%; height: 100%; }
.level-pill .lv-score.bump { animation: bump .25s; }
.level-pill { padding: 6px 22px 12px; }

/* any board outline: the floor is drawn per cell, the grid itself is transparent */
.grid { background: none !important; box-shadow: none; }
.cell {
  background-color: var(--floor);
  background-image: radial-gradient(circle, rgba(255,235,215,.07) 1px, transparent 1.4px), radial-gradient(circle, rgba(255,235,215,.05) 1px, transparent 1.4px);
  background-size: 6px 6px, 6px 6px; background-position: 0 0, 3px 3px;
}
.frame-base.cellbase { border-radius: 0; box-shadow: 0 6px 0 var(--frame-drop); }

/* rounded inside corners of blocks */
.tile-fillet { position: absolute; pointer-events: none; }
.wood-fillet { display: none; }
/* board frame: no sharp stone corners */
.seg, .rail { border-radius: 7px; }
.seg.corner { border-radius: 50%; }
.seg.corner.tl { border-radius: calc(var(--C) * .28) 50% 50% 50%; }
.seg.corner.tr { border-radius: 50% calc(var(--C) * .28) 50% 50%; }
.seg.corner.bl { border-radius: 50% 50% 50% calc(var(--C) * .28); }
.seg.corner.br { border-radius: 50% 50% calc(var(--C) * .28) 50%; }
.frame-base.cellbase { border-radius: 6px; }

/* ===== rocky slate board (texture only: blue-grey stone tiles with cracks, rounded frame stones, moss) ===== */
:root {
  --slate: #262e39; --slate-lo: #1c222b; --slate-hi: #323c4a; --slate-gap: #12161c;
  --rock-1: #8f9bab; --rock-2: #6f7c8d; --rock-3: #556172;
  --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .10 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --mottle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='m'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.045' numOctaves='3' seed='7' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -.6 .3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23m)'/%3E%3C/svg%3E");
  --crack-a: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' preserveAspectRatio='none'%3E%3Cpath d='M8 30 L30 38 L42 33 L58 46 L72 44' fill='none' stroke='%231c232c' stroke-width='1.6' stroke-linecap='round' opacity='.7'/%3E%3Cpath d='M9 31 L30 39.5 L42 34.5 L58 47.5' fill='none' stroke='%23fff' stroke-width='.8' opacity='.12'/%3E%3C/svg%3E");
  --crack-b: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' preserveAspectRatio='none'%3E%3Cpath d='M62 92 L55 70 L64 58 L57 40 M64 58 L80 52' fill='none' stroke='%231c232c' stroke-width='1.6' stroke-linecap='round' opacity='.65'/%3E%3C/svg%3E");
  --crack-c: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' preserveAspectRatio='none'%3E%3Cpath d='M20 12 L34 26 L30 40 M34 26 L50 22' fill='none' stroke='%231c232c' stroke-width='1.4' stroke-linecap='round' opacity='.55'/%3E%3C/svg%3E");
}
/* floor: every cell is its own chiselled slate tile */
.cell {
  background-color: var(--slate);
  background-image: var(--noise), var(--mottle), linear-gradient(160deg, var(--slate-hi) 0%, var(--slate) 45%, var(--slate-lo) 100%);
  background-size: 140px 140px, 220px 220px, 100% 100%;
  box-shadow: inset 0 0 0 1px var(--slate-gap), inset 2px 2px 0 rgba(255,255,255,.07), inset -2px -3px 0 rgba(0,0,0,.4);
  border-radius: 3px;
}
.cell:nth-child(3n+1) { background-color: #232a34; background-position: 40px 60px, 90px 20px, 0 0; }
.cell:nth-child(5n+2) { background-color: #29323e; background-position: 10px 100px, 30px 140px, 0 0; }
.cell:nth-child(7n+3) { background-image: var(--crack-a), var(--noise), var(--mottle), linear-gradient(160deg, var(--slate-hi) 0%, var(--slate) 45%, var(--slate-lo) 100%); background-size: 100% 100%, 140px 140px, 220px 220px, 100% 100%; }
.cell:nth-child(11n+6) { background-image: var(--crack-b), var(--noise), var(--mottle), linear-gradient(160deg, var(--slate-hi) 0%, var(--slate) 45%, var(--slate-lo) 100%); background-size: 100% 100%, 140px 140px, 220px 220px, 100% 100%; }
.cell:nth-child(13n+9) { background-image: var(--crack-c), var(--noise), var(--mottle), linear-gradient(160deg, var(--slate-hi) 0%, var(--slate) 45%, var(--slate-lo) 100%); background-size: 100% 100%, 140px 140px, 220px 220px, 100% 100%; }
/* gate channels: the same slate, a little darker */
.dock {
  background-color: #1f2630;
  background-image: var(--noise), var(--mottle), linear-gradient(180deg, #2a323e, #1b212a);
  background-size: 140px 140px, 220px 220px, 100% 100%;
  box-shadow: inset 0 4px 8px rgba(0,0,0,.7), inset 0 0 0 1px #12161c;
}
/* frame: rounded blue-grey stones with a rough surface */
.frame-base, .frame-base.cellbase { background: #2c3440; box-shadow: 0 6px 0 #1d232c, 0 14px 24px rgba(10,20,15,.35); }
.seg, .rail {
  background-color: var(--rock-2);
  background-image: var(--noise), var(--mottle), linear-gradient(180deg, var(--rock-1) 0%, var(--rock-2) 50%, var(--rock-3) 100%);
  background-size: 140px 140px, 220px 220px, 100% 100%;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.35), inset 0 -3px 0 rgba(15,22,32,.45), inset 2px 0 0 rgba(255,255,255,.12), inset -2px 0 0 rgba(15,22,32,.25), 0 2px 2px rgba(0,0,0,.25);
}


/* walls: rough grey-blue boulders that match the slate */
.wall {
  background-color: #7d8a9c !important;
  background-image: var(--noise), var(--mottle), linear-gradient(160deg, #a3afbf 0%, #7d8a9c 50%, #5d6a7c 100%) !important;
  background-size: 140px 140px, 220px 220px, 100% 100% !important;
  box-shadow: inset 0 3px 0 rgba(255,255,255,.3), inset 0 -4px 0 rgba(15,22,32,.45), 0 3px 3px rgba(0,0,0,.35) !important;
  border-radius: 8px !important;
}
.wall::before, .wall::after { display: none !important; }
/* no dark slab behind the frame stones */
.frame-base, .frame-base.cellbase { background: none !important; box-shadow: none !important; }

/* ===== painted UI (assets/ui): blue stone buttons, grey stone / wood boosters, wooden HUD bar, cards and popups ===== */
img.pic { display: block; object-fit: contain; pointer-events: none; -webkit-user-drag: none; position: relative; z-index: 1; filter: drop-shadow(0 2px 2px rgba(0,0,0,.35)); }
.round-btn, .coin-disc, :root[data-theme="dark"] .round-btn {
  background: url(../assets/ui/stone-blue.webp) center / 100% 100% no-repeat; border-radius: 0; box-shadow: none;
}
.round-btn::after, .coin-disc::after { display: none; }
.round-btn:active { box-shadow: none; transform: translateY(3px); }
.round-btn, .coin-disc { width: 54px; height: 54px; }
.round-btn img.pic { width: 32px; height: 32px; margin-top: -3px; }
.coin-disc img.pic { width: 34px; height: 34px; margin-top: -3px; }
.coin-num { background: #1d1612; height: 36px; margin-left: -12px; }

/* level panel: the wooden bar; its carved slot holds the coins */
.level-pill, :root[data-theme="dark"] .level-pill {
  background: url(../assets/ui/wood-bar.webp) center / 100% 100% no-repeat; box-shadow: none; border-radius: 0;
  width: 250px; height: 81px; min-width: 0; padding: 0;
}
.level-pill::before { display: none; }
.level-pill .lv-title { position: absolute; top: 3px; left: 0; right: 0; font-size: 19px; line-height: 1.2; color: #f6e6cf; text-shadow: 0 2px 0 rgba(0,0,0,.5); }
.level-pill .lv-score {
  position: absolute; left: 13%; right: 13%; top: 42%; height: 36%; min-width: 0; margin: 0;
  background: none; box-shadow: none; font-size: 21px; line-height: 1; color: #ffe39a; padding-top: 3px;
}
.level-pill .lv-score .ico { width: 24px; height: 24px; margin-top: -3px; }
.level-pill .lv-score .ico img.pic { width: 100%; height: 100%; }
.timer { bottom: -14px; }

/* boosters: grey stone when ready, wood while locked */
.booster, :root[data-theme="dark"] .booster {
  background: url(../assets/ui/stone-grey.webp) center / 100% 100% no-repeat; box-shadow: none; border-radius: 16px;
}
.booster.locked, :root[data-theme="dark"] .booster.locked { background-image: url(../assets/ui/wood-tile.webp); }
.booster::before { display: none; }
.booster img.pic { width: 54px; height: 54px; margin-top: -4px; }
.booster.locked img.pic { width: 30px; height: 30px; margin-top: -16px; }
.booster.locked .lock-lv { color: #f6e6cf; text-shadow: 0 2px 0 rgba(0,0,0,.5); bottom: 12px; }
.booster.active, :root[data-theme="dark"] .booster.active { box-shadow: none; filter: drop-shadow(0 0 0 #ffd75a) drop-shadow(0 0 6px #ffd75a) drop-shadow(0 0 2px #ffd75a); }

/* popups: the tall wooden board */
.modal.panel, :root[data-theme="dark"] .modal.panel {
  background: none; box-shadow: none; border-radius: 0;
  border: 0 solid transparent; border-image: url(../assets/ui/modal.webp) 150 fill / 64px stretch;
  padding: 34px 28px 38px; filter: drop-shadow(0 12px 18px rgba(0,0,0,.45));
}
.modal.panel::before { display: none; }
.modal .art img.pic { height: 104px; width: auto; max-width: 150px; }
.modal .msg, .toggles { background: rgba(14,9,6,.55); box-shadow: inset 0 3px 6px rgba(0,0,0,.5), 0 1px 0 rgba(255,235,210,.08); }

/* other brown cards (win results, prizes, …): wooden plank card */
.panel:not(.modal):not(.level-pill), :root[data-theme="dark"] .panel:not(.modal):not(.level-pill) {
  background: none; box-shadow: none; border-radius: 0;
  border: 0 solid transparent; border-image: url(../assets/ui/wood-card.webp) 110 fill / 34px stretch;
  filter: drop-shadow(0 8px 10px rgba(0,0,0,.4));
}
.panel:not(.modal):not(.level-pill)::before { display: none; }
.win .stat img.pic { width: 42px; height: 42px; }
.prize .pic img.pic, .btn .ico img.pic { width: 100%; height: 100%; }
.coin-top img.pic { position: absolute; left: 8px; top: 50%; transform: translateY(-52%); width: 40px; height: 40px; }

/* ===== home: level track ===== */
#home { justify-content: flex-start; padding: 0; gap: 0; }
.home-top { z-index: 5; }
.route { position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; touch-action: pan-y; padding: 86px 0 130px; scrollbar-width: none; }
.route::-webkit-scrollbar { display: none; }
.route .logo { margin-bottom: 10px; }
.route .logo h1 { font-size: 64px; }
.path { position: relative; width: 100%; }
.path .trail { position: absolute; left: 50%; top: 0; transform: translateX(-50%); overflow: visible; pointer-events: none; }
.trail path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.trail .t-all { stroke: rgba(0,0,0,.35); stroke-width: 10; stroke-dasharray: 2 18; }
.trail .t-done { stroke: #ffd75a; stroke-width: 9; stroke-dasharray: 2 18; filter: drop-shadow(0 0 4px rgba(255,200,70,.7)); }
.route-sign {
  position: absolute; left: 50%; transform: translateX(-50%); width: 230px; height: 64px; z-index: 2;
  background: url(../assets/ui/wood-plank.webp) center / 100% 100% no-repeat; filter: drop-shadow(0 6px 8px rgba(0,0,0,.45));
  display: grid; place-items: center; font-family: var(--title); font-size: 22px; color: #f6e6cf; text-shadow: 0 2px 0 rgba(0,0,0,.55);
}
.route-sign span { padding-top: 4px; }
.node {
  --s: 76px; position: absolute; left: calc(50% + var(--x) - var(--s) / 2); width: var(--s); height: var(--s); z-index: 3;
  background: url(../assets/ui/stone-blue.webp) center / 100% 100% no-repeat;
  display: grid; place-items: center; filter: drop-shadow(0 6px 6px rgba(0,0,0,.45)); transition: transform .1s;
}
.node:active { transform: translateY(4px); }
.node .num { font-family: var(--title); font-size: 32px; line-height: 1; padding-top: 6px; color: #fff; -webkit-text-stroke: 2px #1b2638; paint-order: stroke fill; text-shadow: 0 3px 0 #1b2638; }
.node .tick {
  position: absolute; right: -6px; bottom: -4px; width: 28px; height: 28px; border-radius: 50%; font-style: normal;
  display: grid; place-items: center; font-size: 16px; font-weight: 800; color: #fff;
  background: radial-gradient(circle at 40% 30%, #b6f06a, #4fae17 70%); box-shadow: 0 0 0 3px #1d2a12, 0 2px 0 3px #1d2a12;
}
.node.locked { background-image: url(../assets/ui/wood-tile.webp); }
.node.locked .num { font-size: 24px; color: #cdb194; -webkit-text-stroke-color: #2a1a10; text-shadow: 0 2px 0 #2a1a10; margin-top: 16px; }
.node.locked .lk { position: absolute; top: 8px; width: 26px; height: 26px; }
.node.locked .lk img.pic { width: 100%; height: 100%; }
.node.nope { animation: nope .35s; }
@keyframes nope { 20%, 60% { translate: -6px 0; } 40%, 80% { translate: 6px 0; } }
.node.current { --s: 96px; z-index: 4; animation: nodebob 1.6s ease-in-out infinite; will-change: transform; }
.node.current::after { content: ''; position: absolute; inset: -14px; z-index: -1; border-radius: 30px; pointer-events: none;
  background: radial-gradient(closest-side, rgba(255,215,90,.75), rgba(255,215,90,.25) 70%, transparent); }
.node.current .num { font-size: 42px; }
.node.current::before { content: ''; position: absolute; inset: -10px; border-radius: 26px; border: 4px solid rgba(255,215,90,.85); animation: ring 1.6s ease-out infinite; will-change: transform, opacity; }
@keyframes nodebob { 50% { translate: 0 -5px; } }
@keyframes ring { from { transform: scale(.9); opacity: 1; } to { transform: scale(1.18); opacity: 0; } }
.node .bubble {
  position: absolute; bottom: calc(100% + 14px); left: 50%; transform: translateX(-50%); white-space: nowrap;
  padding: 7px 16px 3px; border-radius: 14px; background: #fff3d6; color: #3d2416;
  font-family: var(--title); font-size: 20px; box-shadow: 0 4px 0 #b48663, 0 8px 12px rgba(0,0,0,.35);
}
.node .bubble::after { content: ''; position: absolute; top: 100%; left: 50%; margin-left: -9px; border: 9px solid transparent; border-top-color: #fff3d6; border-bottom: 0; }
.play-float { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 6; min-width: 240px; height: 62px; font-size: 28px; }
.play-float:active { transform: translateX(-50%) translateY(4px); }
/* the top bar stays readable over the scrolling track */
#home::before { content: ''; position: absolute; left: -100vw; right: -100vw; top: 0; height: 96px; z-index: 4; pointer-events: none;
  background: linear-gradient(rgba(16,12,10,.85), rgba(16,12,10,.55) 60%, transparent); }
#home::after { content: ''; position: absolute; left: -100vw; right: -100vw; bottom: 0; height: 120px; z-index: 4; pointer-events: none;
  background: linear-gradient(transparent, rgba(16,12,10,.7)); }

/* smooth dragging: the block tracks the finger directly, then glides onto its cell when let go */
.block { transition: transform .18s cubic-bezier(.2,.9,.3,1); }
/* only the held block gets its own GPU layer; a light two-step glow instead of a five-filter outline */
.block.dragging { transition: none; z-index: 8; will-change: transform; filter: none; }
/* the block shadow is drawn by the halo shapes under the tiles, not a drop-shadow filter: a filter has to be
   recomputed for the whole block every time a cube lands in it, which made filling stutter on phones */
.block { filter: none; }
.halo { position: absolute; display: block; background: transparent; pointer-events: none; box-shadow: 0 2px 0 rgba(0,0,0,.35), 0 4px 4px rgba(0,0,0,.25); }
.block.dragging .halo { display: block; background: #ffe27a; box-shadow: 0 0 0 2.5px #ffe27a, 0 0 6px 3px rgba(255,226,122,.55), 0 9px 8px 1px rgba(0,0,0,.4); }
