:root {
  --t: 132px;          /* target tile size */
  --cw: 140px;         /* center card width */
  --ch: 188px;         /* center card height */
  --gap: 18px;
  --glass: rgba(255, 255, 255, .08);
  --good: #4ade80;
  --bad: #fb7185;
  --gold: #fde047;
  --ink: #1e1033;
  --plum: #3b0764;
  --muted: #c4b5fd;
  --font: "Fredoka", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: #fff;
  background: #09041a;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; }

.app { min-height: 100dvh; display: flex; flex-direction: column; position: relative; }

/* ---------- World: gradient sky, drifting bokeh, floating sweets ---------- */
.app::before {
  content: ""; position: fixed; inset: 0; z-index: -3;
  background:
    radial-gradient(ellipse at 50% 55%, transparent 50%, rgba(0,0,0,.5) 100%),
    radial-gradient(1200px 700px at 50% -10%, #7c3aed 0%, #4c1d95 30%, #1e0b3d 65%, #09041a 100%);
}
.app::after {
  content: ""; position: fixed; inset: -10%; z-index: -2; pointer-events: none;
  background:
    radial-gradient(circle at 15% 30%, rgba(244,114,182,.35) 0 60px, transparent 61px),
    radial-gradient(circle at 80% 20%, rgba(251,191,36,.28) 0 40px, transparent 41px),
    radial-gradient(circle at 70% 75%, rgba(96,165,250,.3) 0 70px, transparent 71px),
    radial-gradient(circle at 25% 80%, rgba(74,222,128,.25) 0 50px, transparent 51px),
    radial-gradient(circle at 50% 50%, rgba(255,255,255,.08) 0 90px, transparent 91px);
  filter: blur(30px);
  animation: drift 24s ease-in-out infinite alternate;
}
.bg-candy {
  position: fixed; z-index: -1; pointer-events: none;
  filter: blur(1.2px) saturate(.9);
  animation: bg-float var(--d) ease-in-out var(--delay) infinite alternate;
}
.bg-candy svg { display: block; width: 100%; height: auto; overflow: visible; }

/* ---------- HUD ---------- */
.hud {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px 12px;
  background: rgba(10, 4, 26, .78);
  border-bottom: 1px solid rgba(255,255,255,.1);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; font-size: 1.15rem; white-space: nowrap; letter-spacing: .01em; display: flex; align-items: center; gap: 8px; }
.brand__home { background: none; border: 0; padding: 0; color: inherit; font: inherit; font-weight: 700; cursor: pointer; border-radius: 8px; transition: transform .12s; }
.brand__home:hover { transform: scale(1.04); }
.brand__home:active { transform: scale(.97); }
.brand__home:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.level-chip { font-size: .72rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: rgba(255,255,255,.12); color: var(--muted); letter-spacing: .04em; }
.level-chip:empty { display: none; }
.rule-chip { display: none; font-size: .72rem; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: linear-gradient(90deg, #fde047, #f59e0b); color: #78350f; letter-spacing: .06em; }
.rule-chip.on { display: inline-block; animation: pop .4s cubic-bezier(.2, 1.6, .4, 1); }
.streak-num { display: none; }
.hud.no-pips .pips { display: none; }
.hud.no-pips .streak-num { display: block; }
.stats { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
.stat {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 64px; padding: 4px 10px;
  background: var(--glass); border: 1px solid rgba(255,255,255,.14); border-radius: 14px;
}
.stat__label { font-size: .62rem; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); font-weight: 600; }
.stat__row { display: flex; align-items: center; gap: 6px; }
.stat__value { font-size: 1.2rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat__value.bump { animation: bump .4s cubic-bezier(.2, 1.4, .4, 1); }
.stat--score .stat__value { color: var(--gold); text-shadow: 0 0 12px rgba(253,224,71,.5); }
.multi {
  display: none; padding: 1px 7px; border-radius: 999px;
  background: linear-gradient(135deg, #f472b6, #a855f7); color: #fff;
  font-size: .78rem; font-weight: 700; line-height: 1.3;
  box-shadow: 0 2px 8px rgba(168,85,247,.5);
}
.multi.on { display: inline-block; animation: pop .4s cubic-bezier(.2, 1.6, .4, 1); }

.pips { display: flex; gap: 5px; height: 1.2rem; align-items: center; }
.pip-dot { width: 10px; height: 10px; border-radius: 50%; background: rgba(255,255,255,.18); transition: background .2s, box-shadow .2s; }
.pip-dot.lit { background: var(--gold); box-shadow: 0 0 10px var(--gold); animation: pop .35s cubic-bezier(.2, 1.6, .4, 1); }
.pip-dot.burst { animation: pip-burst .6s ease-out; }

.stars { display: flex; gap: 2px; height: 1.2rem; align-items: center; }
.star { width: 16px; height: 16px; display: block; }
.star path { fill: rgba(255,255,255,.16); stroke: rgba(255,255,255,.25); stroke-width: 1; transition: fill .2s; }
.star.lit path { fill: var(--gold); stroke: #b45309; filter: drop-shadow(0 0 5px rgba(253,224,71,.8)); }
.star.pop { animation: star-pop .7s cubic-bezier(.2, 1.6, .4, 1); }

.icon-btn { background: var(--glass); border: 1px solid rgba(255,255,255,.14); color: #fff; width: 40px; height: 40px; border-radius: 12px; cursor: pointer; font-size: 1.1rem; transition: transform .1s; }
.icon-btn:hover { background: rgba(255,255,255,.16); }
.icon-btn:active { transform: scale(.92); }

.progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 4px; background: rgba(255,255,255,.08); }
.progress__fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, #f472b6, #fde047, #4ade80);
  box-shadow: 0 0 10px rgba(253,224,71,.6);
  transition: width .5s cubic-bezier(.2, .8, .2, 1);
}

/* ---------- Coach (tutorial) ---------- */
.coach {
  display: flex; gap: 10px; align-items: center;
  max-width: 460px; padding: 10px 14px; border-radius: 16px;
  background: #fff; color: var(--ink); font-weight: 600; line-height: 1.35;
  box-shadow: 0 12px 30px rgba(0,0,0,.35);
}
.coach.hidden { display: none; }
.coach.pop { animation: panel-in .35s cubic-bezier(.2, 1.3, .4, 1); }
.coach__icon { font-size: 1.4rem; }
.target.hint { border-color: var(--gold); animation: hint-pulse 1.2s ease-in-out infinite; }
.center .cue.on { display: block !important; opacity: 1; border-color: var(--gold); animation: cue-strong .9s ease-in-out infinite; }

/* ---------- Board ---------- */
/* The board centers itself with auto margins rather than justify-content, so when the screen is
   too short it overflows downward (scrollable) instead of sliding up under the sticky header. */
.table { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 18px; padding: 18px 16px 28px; }
.play { display: flex; flex-direction: column; align-items: center; gap: 18px; margin: auto 0; }
.coach { margin-top: auto; }
.table.shake { animation: shake-screen .4s ease-in-out; }
.table.shake-big { animation: shake-screen-big .55s ease-in-out; }
.board {
  display: grid;
  grid-template-columns: var(--t) var(--cw) var(--t);
  grid-template-rows: var(--t) var(--ch) var(--t);
  gap: var(--gap);
  place-items: center;
}
.center { grid-area: 2 / 2; }
.board.in .target { animation: tile-in .65s cubic-bezier(.2, 1.5, .4, 1) both; animation-delay: calc(var(--i) * 70ms); }
.board.in .center { animation: tile-in .65s cubic-bezier(.2, 1.5, .4, 1) 280ms both; }

/* Target tiles: glass, lit by --hot (0..1) as the card approaches */
.target {
  --hot: 0;
  position: relative;
  width: var(--t); height: var(--t);
  border-radius: 26px;
  background: rgba(255,255,255, calc(.11 + .14 * var(--hot)));
  border: 1.5px solid rgba(255,255,255, calc(.18 + .7 * var(--hot)));
  transform: scale(calc(1 + .12 * var(--hot)));
  box-shadow:
    0 12px 30px rgba(0,0,0,.35),
    0 0 calc(40px * var(--hot)) rgba(255,255,255, calc(.5 * var(--hot))),
    inset 0 1px 0 rgba(255,255,255,.25);
  transition: transform .12s ease-out, box-shadow .12s, background .12s, border-color .12s;
}
.target .pips-area {
  position: absolute; inset: 16px; transform-origin: 50% 70%;
  transform: translate(calc(var(--lx) * var(--hot) * 7px), calc(var(--ly) * var(--hot) * 7px)) scale(calc(1 + .1 * var(--hot)));
  transition: transform .12s ease-out;
}
.target.ready { animation: ready-wiggle .5s ease-in-out infinite; border-color: var(--gold); box-shadow: 0 12px 30px rgba(0,0,0,.35), 0 0 44px rgba(253,224,71,.55), inset 0 1px 0 rgba(255,255,255,.25); }
.target.ready .chev { border-color: var(--gold); }
.target .ring { position: absolute; inset: -2px; border-radius: inherit; border: 3px solid var(--good); opacity: 0; pointer-events: none; }
.target .chev {
  position: absolute; width: 12px; height: 12px;
  border-right: 2.5px solid rgba(255,255,255,.55); border-bottom: 2.5px solid rgba(255,255,255,.55);
  opacity: calc(.5 + .5 * var(--hot));
}

.target.hit-good { animation: target-good .7s cubic-bezier(.2, 1.4, .4, 1); }
.target.hit-good .ring { animation: ring .7s ease-out; }
.target.hit-good .pips-area { animation: sweets-bounce .7s cubic-bezier(.2, 1.6, .4, 1); }
.target.hit-bad { animation: target-bad .5s ease-in-out; }
.target.hit-bad .ring { border-color: var(--bad); animation: ring .55s ease-out; }
.target.hit-bad .pips-area { animation: sweets-shiver .5s ease-in-out; }
.target.wave { animation: wave .6s cubic-bezier(.2, 1.4, .4, 1); }
.target.wave .pips-area { animation: sweets-bounce .6s cubic-bezier(.2, 1.6, .4, 1); }

/* WebKit renders filtered children of a backdrop-filtered element at low resolution
   (and sometimes not at all), so the tiles lose the frosted glass and SVG shadows there. */

/* ---------- Sweets ---------- */
.pip { position: absolute; transform: translate(-50%, -50%); }
/* Sweets stay pure vectors: no CSS or SVG filters, so nothing is rasterized and they are crisp at any pixel density. */
.pip__svg { display: block; width: 100%; height: auto; overflow: visible; }
.card .pip__svg { animation: jiggle 2.8s ease-in-out infinite; animation-delay: calc(var(--i) * -.7s); }

/* ---------- Turn timer ring (timed levels) ---------- */
.timer { position: absolute; inset: -9px; width: calc(100% + 18px); height: calc(100% + 18px); pointer-events: none; overflow: visible; }
.timer.hidden { display: none; }
.timer rect { fill: none; stroke-width: 5; stroke-linecap: round; }
.timer__track { stroke: rgba(255,255,255,.14); }
.timer__fill { stroke: var(--good); stroke-dasharray: 100; stroke-dashoffset: 0; transition: stroke .3s; }
.timer.warn .timer__fill { stroke: var(--gold); }
.timer.urgent .timer__fill { stroke: var(--bad); animation: urgent-pulse .45s ease-in-out infinite; }
.stat--time.hidden { display: none; }
.stat--time { min-width: 0; padding: 4px 8px; }
.stat--time .stat__value { min-width: 2.2em; font-size: 1.3rem; }
.stat--time .stat__value.low { color: var(--bad); animation: urgent-pulse .45s ease-in-out infinite; }

/* ---------- Center stack + card ---------- */
.center { position: relative; width: var(--cw); height: var(--ch); }
.card-wrap { position: absolute; inset: 0; animation: float 3.4s ease-in-out infinite; }
.stack-card {
  position: absolute; inset: 0; border-radius: 18px;
  background: linear-gradient(160deg, #fdf2f8, #e9d5ff);
  box-shadow: 0 10px 24px rgba(0,0,0,.3);
  transition: transform .35s cubic-bezier(.2, 1.3, .4, 1);
}
.stack-card:nth-child(1) { transform: translateY(14px) scale(.9); opacity: .55; }
.stack-card:nth-child(2) { transform: translateY(7px) scale(.95); opacity: .8; }
.card-wrap.empty .stack-card:nth-child(1) { transform: translateY(7px) scale(.95); }
.card-wrap.empty .stack-card:nth-child(2) { transform: translateY(0) scale(1); }

.card {
  position: absolute; inset: 0; border-radius: 18px;
  background: linear-gradient(165deg, #ffffff 0%, #fdf4ff 55%, #f3e8ff 100%);
  box-shadow: 0 18px 40px rgba(0,0,0,.45), inset 0 0 0 3px #fff, inset 0 -8px 16px rgba(168,85,247,.14);
  cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
  overflow: hidden; will-change: transform;
  transition: box-shadow .15s;
}
.card.dragging { cursor: grabbing; box-shadow: 0 34px 70px rgba(0,0,0,.6), inset 0 0 0 3px #fff; }
.card.enter { animation: card-enter .6s cubic-bezier(.2, 1.4, .4, 1); }
.card.nudge { animation: nudge 1.1s cubic-bezier(.3, 1.4, .4, 1); }
.card::after {
  content: ""; position: absolute; inset: -40%; pointer-events: none;
  background: linear-gradient(115deg, transparent 46%, rgba(255,255,255,.4) 50%, transparent 54%);
  transform: translateX(-90%);
  animation: shimmer 4.2s ease-in-out infinite;
}
.sparkle {
  position: absolute; width: 14px; height: 14px; pointer-events: none;
  color: #fff; font-size: 14px; line-height: 1; text-shadow: 0 0 8px #fff, 0 0 2px #fff;
  opacity: 0; animation: twinkle 2.4s ease-in-out infinite;
}
.sparkle::before { content: "✦"; }

/* Gesture cues until the first slide */
.cue {
  position: absolute; width: 14px; height: 14px; pointer-events: none;
  border-right: 3px solid rgba(255,255,255,.7); border-bottom: 3px solid rgba(255,255,255,.7);
  opacity: 0; animation: cue 1.6s ease-in-out infinite;
}
.center.touched .cue { display: none; }

/* ---------- Chunky outlined display text (toast + titles) ---------- */
.toast {
  --size: 1.7rem;
  position: absolute; left: 50%; top: 50%; z-index: 6;
  transform: translate(-50%, -50%) scale(0); opacity: 0;
  font-size: var(--size); font-weight: 700; line-height: 1; white-space: nowrap;
  pointer-events: none;
  filter: drop-shadow(0 6px 0 rgba(0,0,0,.28)) drop-shadow(0 0 18px rgba(255,255,255,.25));
}
.toast.show { animation: toast-in 1.05s cubic-bezier(.2, 1.4, .4, 1) forwards; }
.toast__txt, .title-txt {
  position: relative; display: inline-block;
  color: var(--plum);
  -webkit-text-stroke: .3em var(--plum);
  paint-order: stroke fill;
}
/* The gradient fill is a copy of the text layered above the stroked base. */
.toast__txt::after, .title-txt::after {
  content: attr(data-text); position: absolute; left: 0; top: 0;
  -webkit-text-stroke: 0;
  background: linear-gradient(180deg, #fff 0%, #ffe9f5 45%, #ffb6e1 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.toast.t1 { --size: 1.7rem; }
.toast.t2 { --size: 2rem; }
.toast.t2 .toast__txt::after { background-image: linear-gradient(180deg, #fff 0%, #fff3b0 45%, #fbbf24 100%); }
.toast.t3 { --size: 2.3rem; }
.toast.t3 .toast__txt::after { background-image: linear-gradient(180deg, #fff 0%, #bbf7d0 45%, #22d3ee 100%); }
.toast.t4 { --size: 2.7rem; }
.toast.t4 .toast__txt::after { background-image: linear-gradient(90deg, #f472b6, #fde047, #4ade80, #60a5fa, #f472b6); background-size: 300% 100%; animation: rainbow 1.2s linear infinite; }
.toast.bad { --size: 1.6rem; }
.toast.bad .toast__txt::after { background-image: linear-gradient(180deg, #fff 0%, #fecdd3 55%, #fb7185 100%); }
.toast.big { --size: 2.5rem; }
.toast.big .toast__txt::after { background-image: linear-gradient(180deg, #fff 0%, #fde68a 45%, #f59e0b 100%); }

.float.neg { color: #fecdd3; }
.float {
  position: fixed; z-index: 60; pointer-events: none;
  font-weight: 700; font-size: 1.35rem; color: var(--gold);
  text-shadow: 0 2px 0 var(--plum), 0 -1px 0 var(--plum), 1px 0 0 var(--plum), -1px 0 0 var(--plum), 0 4px 10px rgba(0,0,0,.5);
  animation: float-up 1s ease-out forwards;
}

.hint-text { color: rgba(255,255,255,.65); font-size: .9rem; margin: 0; text-align: center; }
.hint-text__sep { margin: 0 6px; opacity: .5; }

/* ---------- Overlays ---------- */
.overlay { position: fixed; inset: 0; z-index: 40; background: rgba(9, 4, 26, .72); backdrop-filter: blur(8px); display: grid; place-items: center; padding: 16px; animation: fade-in .3s ease-out; overflow-y: auto; }
.overlay .panel { margin: auto; }
.levels { display: grid; gap: 8px; margin: 0 0 16px; text-align: left; }
.level {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 9px 12px; border-radius: 16px; border: 2px solid #ede9fe; background: #faf5ff;
  color: var(--ink); cursor: pointer; text-align: left; transition: transform .12s ease, border-color .12s, box-shadow .12s;
}
.level:hover:not(:disabled), .level:focus-visible { transform: translateY(-2px); border-color: #c4b5fd; box-shadow: 0 8px 20px rgba(124,58,237,.18); outline: none; }
.level:active:not(:disabled) { transform: translateY(0) scale(.99); }
.level:disabled { opacity: .5; cursor: not-allowed; }
.level__num { flex: none; width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; font-weight: 700; font-size: 1.1rem; color: #fff; background: linear-gradient(135deg, #f472b6, #7c3aed); box-shadow: 0 4px 10px rgba(124,58,237,.35); }
.level__body { flex: 1; display: flex; flex-direction: column; line-height: 1.25; }
.level__name { font-weight: 700; }
.level__tag { font-size: .85rem; color: #5b4a7a; }
.level__meta { font-weight: 700; color: #7c3aed; font-size: .9rem; white-space: nowrap; }
.levels { margin-bottom: 18px; }
.about-link { margin: 14px 0 0; font-size: .85rem; color: #7c6a9c; }
.about-link a { color: #7c3aed; font-weight: 600; text-decoration: none; border-bottom: 2px solid #ddd6fe; }
.about-link a:hover { border-color: #7c3aed; }
.btn-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.btn--ghost { background: #f5f3ff; color: #4c1d95; box-shadow: 0 4px 0 #ddd6fe; }
.btn--ghost:hover { transform: translateY(-2px); }
.btn--ghost:active { transform: translateY(2px); box-shadow: 0 2px 0 #ddd6fe; }
.btn.hidden { display: none; }
.unlock { margin: -6px 0 14px; font-weight: 700; color: #be185d; animation: pop .5s cubic-bezier(.2, 1.6, .4, 1); }
.unlock.hidden { display: none; }
.overlay.hidden { display: none; }
.panel {
  width: min(520px, 100%);
  background: linear-gradient(170deg, #ffffff, #fdf4ff);
  color: var(--ink);
  border-radius: 28px; padding: 28px 28px 24px;
  box-shadow: 0 30px 80px rgba(0,0,0,.55), inset 0 0 0 2px rgba(255,255,255,.8);
  text-align: center;
  animation: panel-in .5s cubic-bezier(.2, 1.3, .4, 1);
}
.panel__eyebrow { text-transform: uppercase; letter-spacing: .18em; font-size: .72rem; color: #7c3aed; font-weight: 700; }
.panel__title { margin: 4px 0 10px; font-size: 2.6rem; font-weight: 700; line-height: 1.1; filter: drop-shadow(0 4px 0 rgba(59,7,100,.25)); }
.panel__lead { color: #5b4a7a; margin: 0 0 18px; line-height: 1.5; font-size: 1.05rem; }
.howto { list-style: none; padding: 0; margin: 0 0 18px; text-align: left; display: grid; gap: 10px; }
.howto li { display: flex; gap: 12px; align-items: flex-start; background: #f5f3ff; padding: 10px 12px; border-radius: 14px; line-height: 1.4; }
.howto__icon { font-size: 1.3rem; line-height: 1.2; }
.toggle { display: flex; gap: 10px; align-items: center; justify-content: center; font-size: .92rem; color: #5b4a7a; margin-bottom: 18px; cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: #7c3aed; }
.toggle + .toggle { margin-top: -8px; }
.btn { border: 0; border-radius: 18px; padding: 14px 32px; font-weight: 700; font-size: 1.15rem; cursor: pointer; transition: transform .12s ease, box-shadow .12s ease; letter-spacing: .01em; }
.btn--primary { background: linear-gradient(135deg, #f472b6, #7c3aed); color: #fff; box-shadow: 0 6px 0 #4c1d95, 0 14px 24px rgba(124,58,237,.45); animation: btn-pulse 2.2s ease-in-out infinite; }
.btn--primary:hover { transform: translateY(-2px); box-shadow: 0 8px 0 #4c1d95, 0 18px 30px rgba(124,58,237,.55); }
.btn--primary:active { transform: translateY(4px); box-shadow: 0 2px 0 #4c1d95, 0 8px 16px rgba(124,58,237,.45); }
.rank { display: inline-block; margin: 2px 0 16px; padding: 6px 16px; border-radius: 999px; background: linear-gradient(90deg, #fde047, #f59e0b); color: #78350f; font-weight: 700; letter-spacing: .02em; }
.results { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 22px; }
.result { background: #f5f3ff; border-radius: 14px; padding: 10px 8px; animation: tile-in .55s cubic-bezier(.2, 1.4, .4, 1) both; animation-delay: calc(var(--i) * 70ms + 150ms); }
.result__value { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.result__label { font-size: .68rem; text-transform: uppercase; letter-spacing: .12em; color: #7c6a9c; font-weight: 600; }
.end-stars { display: flex; justify-content: center; gap: 4px; margin: 2px 0 10px; }
.end-stars .star { width: 34px; height: 34px; transform: scale(.6); opacity: .5; transition: none; }
.end-stars .star.lit { transform: scale(1); opacity: 1; animation: star-pop .7s cubic-bezier(.2, 1.6, .4, 1); }
.end-stars .star path { fill: #e9e3f5; stroke: #cbbfe3; }
.end-stars .star.lit path { fill: var(--gold); stroke: #b45309; filter: drop-shadow(0 0 6px rgba(253,224,71,.8)); }

/* While a menu is up the board stays out of the way. */
body.menu .table, body.menu .stats, body.menu .progress { display: none; }

/* ---------- Splash ---------- */
.overlay.splash { background: rgba(9, 4, 26, .28); backdrop-filter: none; display: grid; place-items: center; overflow: hidden; }
.overlay.splash.hidden { display: none; }
.splash__hero { position: absolute; inset: 0; pointer-events: none; }
.hero-sweet { position: absolute; transform: translate(-50%, -50%) rotate(var(--r)); animation: hero-bob var(--d) ease-in-out var(--delay) infinite alternate; }
.hero-sweet svg { display: block; width: 100%; height: auto; overflow: visible; }
.hero-spark { position: absolute; color: #fff; font-size: 18px; line-height: 1; text-shadow: 0 0 10px #fff; opacity: 0; animation: twinkle 2.6s ease-in-out var(--delay) infinite; }
.hero-spark::before { content: "✦"; }
.splash__content { position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 12px 16px; animation: panel-in .6s cubic-bezier(.2, 1.3, .4, 1); }
.splash__title { margin: 0; display: flex; flex-direction: column; align-items: center; line-height: .92; font-size: clamp(4rem, 16vw, 7rem); font-weight: 700; filter: drop-shadow(0 10px 0 rgba(59,7,100,.35)) drop-shadow(0 24px 40px rgba(0,0,0,.5)); animation: title-bob 3.6s ease-in-out infinite; }
.splash__title .title-txt { -webkit-text-stroke: .22em var(--plum); }
.splash__title .title-txt:nth-child(2)::after { background-image: linear-gradient(180deg, #fff 0%, #fff3b0 40%, #fbbf24 100%); }
.splash__tag { margin: 8px 0 18px; font-size: 1.15rem; font-weight: 600; color: #f5d0fe; text-shadow: 0 2px 10px rgba(0,0,0,.5); }
.btn--play {
  min-width: 220px; padding: 18px 48px; font-size: 1.7rem; letter-spacing: .04em; border-radius: 999px; color: #fff;
  background: linear-gradient(180deg, #4ade80, #16a34a); box-shadow: 0 8px 0 #166534, 0 20px 40px rgba(22,163,74,.5), inset 0 2px 0 rgba(255,255,255,.45);
  animation: play-pulse 1.8s ease-in-out infinite;
}
.btn--play:hover { transform: translateY(-3px); box-shadow: 0 11px 0 #166534, 0 26px 46px rgba(22,163,74,.6), inset 0 2px 0 rgba(255,255,255,.45); }
.btn--play:active { transform: translateY(5px); box-shadow: 0 3px 0 #166534, 0 10px 20px rgba(22,163,74,.5), inset 0 2px 0 rgba(255,255,255,.45); animation: none; }
.splash__next { font-size: .85rem; font-weight: 600; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.splash__row { display: flex; gap: 10px; margin-top: 14px; }
.btn--glass { background: rgba(255,255,255,.14); color: #fff; box-shadow: 0 4px 0 rgba(0,0,0,.25); border: 1px solid rgba(255,255,255,.22); text-decoration: none; backdrop-filter: blur(8px); }
.btn--glass:hover { background: rgba(255,255,255,.22); }
.btn--toggle { margin-top: 10px; padding: 10px 20px; font-size: .95rem; }
.btn--toggle[aria-pressed="true"] { background: linear-gradient(135deg, #f472b6, #a855f7); border-color: transparent; box-shadow: 0 4px 0 #6d28d9, 0 10px 24px rgba(168,85,247,.45); }
.target.reshuffle { animation: tile-shuffle .36s ease-in-out; }
.splash__foot { margin: 22px 0 0; font-size: .78rem; color: rgba(255,255,255,.55); }
@keyframes tile-shuffle { 0% { transform: scale(1); } 45% { transform: scale(.7) rotate(-8deg); opacity: .35; } 100% { transform: scale(1); opacity: 1; } }
@keyframes hero-bob { from { transform: translate(-50%, -50%) rotate(var(--r)) translateY(0); } to { transform: translate(-50%, -50%) rotate(calc(var(--r) + 8deg)) translateY(-18px); } }
@keyframes title-bob { 0%, 100% { transform: rotate(-2deg) translateY(0); } 50% { transform: rotate(2deg) translateY(-6px); } }
@keyframes play-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@media (max-width: 480px) {
  .splash__title { font-size: clamp(3.4rem, 22vw, 5rem); }
  .btn--play { font-size: 1.45rem; padding: 16px 40px; }
}

#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 45; }

/* ---------- Keyframes ---------- */
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes jiggle { 0%, 100% { transform: rotate(-4deg) translateY(0); } 50% { transform: rotate(4deg) translateY(-2px); } }
@keyframes shimmer { 0%, 62% { transform: translateX(-90%); } 80%, 100% { transform: translateX(90%); } }
@keyframes twinkle { 0%, 100% { opacity: 0; transform: scale(.4) rotate(0); } 50% { opacity: 1; transform: scale(1) rotate(45deg); } }
@keyframes cue { 0%, 100% { opacity: 0; } 50% { opacity: .9; } }
@keyframes card-enter {
  0% { transform: perspective(700px) rotateY(-80deg) translateX(-14px) scale(.85); opacity: 0; }
  55% { opacity: 1; }
  100% { transform: perspective(700px) rotateY(0) translateX(0) scale(1); opacity: 1; }
}
@keyframes hint-pulse { 0%, 100% { transform: scale(1); box-shadow: 0 12px 30px rgba(0,0,0,.35), 0 0 0 rgba(253,224,71,0); } 50% { transform: scale(1.06); box-shadow: 0 12px 30px rgba(0,0,0,.35), 0 0 34px rgba(253,224,71,.6); } }
@keyframes cue-strong { 0%, 100% { opacity: .5; } 50% { opacity: 1; } }
@keyframes urgent-pulse { 50% { opacity: .45; } }
@keyframes ready-wiggle { 0%, 100% { transform: scale(1.12) rotate(-1.5deg); } 50% { transform: scale(1.16) rotate(1.5deg); } }
@keyframes nudge {
  0%, 100% { transform: translate(0, 0) rotate(0); }
  35% { transform: translate(calc(var(--nx) * 18px), calc(var(--ny) * 18px)) rotate(calc(var(--nx) * 5deg)) scale(1.03); }
  65% { transform: translate(calc(var(--nx) * -3px), calc(var(--ny) * -3px)); }
}
@keyframes tile-in { 0% { transform: scale(0) rotate(-10deg); opacity: 0; } 100% { transform: scale(1) rotate(0); opacity: 1; } }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.35); } 100% { transform: scale(1); } }
@keyframes pop { 0% { transform: scale(.4); } 60% { transform: scale(1.4); } 100% { transform: scale(1); } }
@keyframes star-pop { 0% { transform: scale(.4) rotate(-30deg); } 55% { transform: scale(1.6) rotate(10deg); } 100% { transform: scale(1) rotate(0); } }
@keyframes pip-burst { 0% { transform: scale(1); } 40% { transform: scale(1.8); box-shadow: 0 0 20px #fff; } 100% { transform: scale(0); opacity: 0; } }
@keyframes ring { 0% { transform: scale(1); opacity: .95; } 100% { transform: scale(1.55); opacity: 0; } }
@keyframes target-good {
  0% { transform: scale(1); }
  30% { transform: scale(.92, .88); }
  60% { transform: scale(1.1, 1.14); background: rgba(74,222,128,.35); border-color: var(--good); }
  100% { transform: scale(1); }
}
@keyframes target-bad {
  0%, 100% { transform: translateX(0); }
  15%, 55% { background: rgba(251,113,133,.35); border-color: var(--bad); }
  20% { transform: translateX(-9px) rotate(-2deg); }
  40% { transform: translateX(9px) rotate(2deg); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}
@keyframes sweets-bounce { 0% { transform: scale(1); } 30% { transform: scale(1.25, .8); } 55% { transform: scale(.9, 1.2) translateY(-6px); } 100% { transform: scale(1); } }
@keyframes sweets-shiver { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } 75% { transform: rotate(-5deg); } }
@keyframes wave { 0% { transform: scale(1); } 40% { transform: scale(1.14); background: rgba(253,224,71,.35); border-color: var(--gold); } 100% { transform: scale(1); } }
@keyframes toast-in {
  0% { transform: translate(-50%, -50%) scale(0) rotate(-14deg); opacity: 0; }
  30% { transform: translate(-50%, -50%) scale(1.18) rotate(4deg); opacity: 1; }
  48% { transform: translate(-50%, -50%) scale(.96) rotate(-1deg); }
  62% { transform: translate(-50%, -50%) scale(1) rotate(0); opacity: 1; }
  100% { transform: translate(-50%, calc(-50% - 34px)) scale(.9); opacity: 0; }
}
@keyframes rainbow { from { background-position: 0 0; } to { background-position: 300% 0; } }
@keyframes float-up {
  0% { transform: translate(-50%, 0) scale(.8); opacity: 0; }
  20% { opacity: 1; transform: translate(-50%, -10px) scale(1.2); }
  100% { transform: translate(-50%, -76px) scale(1); opacity: 0; }
}
@keyframes shake-screen { 0%, 100% { transform: translate(0); } 25% { transform: translate(-5px, 2px); } 50% { transform: translate(5px, -2px); } 75% { transform: translate(-3px, 1px); } }
@keyframes shake-screen-big { 0%, 100% { transform: translate(0); } 15% { transform: translate(-9px, 4px) rotate(-.6deg); } 35% { transform: translate(8px, -5px) rotate(.6deg); } 55% { transform: translate(-6px, 3px); } 75% { transform: translate(4px, -2px); } }
@keyframes btn-pulse { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.12); } }
@keyframes bg-float { from { transform: translateY(0) rotate(var(--r)); } to { transform: translateY(-46px) rotate(calc(var(--r) + 28deg)); } }
@keyframes drift { from { transform: translate(-2%, -1%) rotate(0); } to { transform: translate(2%, 2%) rotate(3deg); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes panel-in { from { transform: translateY(30px) scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
  :root { --t: 100px; --cw: 114px; --ch: 154px; --gap: 10px; }
  .hud { padding: 8px 12px 10px; gap: 6px; }
  .brand { font-size: 1rem; }
  .stats { gap: 5px; }
  .stat { min-width: 44px; padding: 3px 6px; border-radius: 11px; }
  .stat__label { font-size: .55rem; letter-spacing: .08em; }
  .stat__value { font-size: 1.05rem; }
  .stat--time .stat__value { font-size: 1.1rem; }
  .pips { gap: 4px; } .pip-dot { width: 8px; height: 8px; }
  .star { width: 14px; height: 14px; }
  .icon-btn { width: 34px; height: 34px; font-size: 1rem; border-radius: 10px; }
  .target { border-radius: 22px; }
  .target .pips-area { inset: 11px; }
  .toast.t1 { --size: 1.4rem; } .toast.t2 { --size: 1.6rem; } .toast.t3 { --size: 1.85rem; } .toast.t4 { --size: 2.1rem; } .toast.big { --size: 2rem; }
  .hint-text { display: none; }
  .results { grid-template-columns: repeat(2, 1fr); }
  .panel { padding: 22px 18px 18px; }
  .panel__title { font-size: 2.1rem; }
}

/* ---------- Landscape phones (e.g. 640x360): everything shrinks to fit the height ---------- */
@media (max-height: 430px) and (orientation: landscape) {
  :root { --t: 70px; --cw: 84px; --ch: 112px; --gap: 8px; }
  .hud { padding: 4px 10px 5px; gap: 6px; flex-wrap: nowrap; }
  .brand { font-size: .9rem; gap: 6px; }
  .level-chip, .rule-chip { font-size: .62rem; padding: 1px 7px; }
  .stats { gap: 5px; flex-wrap: nowrap; }
  .stat { min-width: 40px; padding: 2px 6px; border-radius: 9px; }
  .stat__label { font-size: .5rem; letter-spacing: .06em; }
  .stat__value { font-size: .95rem; line-height: 1.1; }
  .stat--time .stat__value { font-size: 1rem; }
  .pips { gap: 3px; height: 1rem; } .pip-dot { width: 7px; height: 7px; }
  .stars { height: 1rem; } .star { width: 12px; height: 12px; }
  .icon-btn { width: 30px; height: 30px; font-size: .9rem; border-radius: 8px; }
  .progress { height: 3px; }
  .table { padding: 6px 12px 8px; gap: 8px; }
  .play { gap: 8px; }
  .hint-text { display: none; }
  .coach { max-width: 520px; padding: 6px 12px; font-size: .9rem; border-radius: 12px; }
  .coach__icon { font-size: 1.1rem; }
  .target { border-radius: 18px; }
  .target .pips-area { inset: 8px; }
  .card { border-radius: 12px; }
  .cue { width: 10px; height: 10px; }
  .toast.t1 { --size: 1.2rem; } .toast.t2 { --size: 1.35rem; } .toast.t3 { --size: 1.5rem; } .toast.t4 { --size: 1.7rem; } .toast.big { --size: 1.6rem; } .toast.bad { --size: 1.2rem; }
  .timer { inset: -7px; width: calc(100% + 14px); height: calc(100% + 14px); }
  .timer rect { stroke-width: 4; }
  /* splash */
  .splash__content { gap: 4px; padding: 6px 12px; }
  .splash__title { font-size: 2.6rem; flex-direction: row; gap: .3em; filter: drop-shadow(0 5px 0 rgba(59,7,100,.35)) drop-shadow(0 12px 24px rgba(0,0,0,.5)); }
  .splash__tag { margin: 2px 0 8px; font-size: .95rem; }
  .btn--play { min-width: 160px; padding: 10px 34px; font-size: 1.25rem; }
  .splash__next { font-size: .72rem; }
  .splash__row { margin-top: 6px; }
  .splash__row .btn, .btn--toggle { padding: 8px 18px; font-size: .9rem; }
  .btn--toggle { margin-top: 6px; }
  .splash__foot { display: none; }
  .hero-sweet { opacity: .7; }
  /* panels */
  .panel { padding: 16px 18px 14px; border-radius: 20px; }
  .panel__title { font-size: 1.5rem; margin: 2px 0 6px; }
  .results { gap: 6px; margin-bottom: 12px; }
  .result { padding: 6px 6px; }
  .result__value { font-size: 1.15rem; }
  .end-stars { margin: 0 0 6px; } .end-stars .star { width: 26px; height: 26px; }
  .rank { margin: 0 0 8px; padding: 4px 12px; }
  .btn { padding: 10px 20px; font-size: .95rem; }
  .levels { gap: 5px; margin-bottom: 10px; }
  .level { padding: 5px 10px; }
  .level__num { width: 30px; height: 30px; font-size: .9rem; }
  .level__tag { display: none; }
}

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