/* Glide Maze — one stylesheet.
   Visual concept: three hand-drawn worlds (Ice, Cave, Desert), each by day and by
   night; soft light from the top left, rounded shapes, a fine grain; calm,
   translucent 14 px panels over a slowly living landscape. Motion explains:
   things glide, settle with a small spring, pop, fade — transform and opacity
   only, and plain fades with reduced motion. */

:root {
  color-scheme: light;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --r: 14px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.3, 1.45, .55, 1);
  --t: 250ms;
  --star: #f6b62a;
  --star-edge: #c9840f;
  /* Ice · day */
  --bg: #d6eefb; --sky1: #cfe9fa; --sky2: #f2f9ff;
  --far: #a9cde8; --near: #eaf6ff; --snow: #ffffff; --tree: #4f8f86;
  --text: #0f2d4a; --muted: #3f5f7c; --line: rgba(15, 45, 74, .12);
  --panel: rgba(255, 255, 255, .82); --panel-solid: #f6fbff; --panel-edge: rgba(255, 255, 255, .8);
  --accent: #1f68b0; --accent-ink: #185d9f; --accent-soft: rgba(31, 104, 176, .12);
  --ca-accent: #1f68b0;
  --glow: rgba(255, 196, 102, .85); --focus: #1f68b0; --shadow: 0 18px 40px -22px rgba(20, 60, 110, .55);
  --sun: #fff6cf;
}
:root[data-dark="1"][data-theme="ice"], :root[data-dark="1"]:not([data-theme]) {
  color-scheme: dark;
  --bg: #0d1d3d; --sky1: #071233; --sky2: #173467;
  --far: #1d3864; --near: #12284b; --snow: #c8e2fb; --tree: #0f2d33;
  --text: #e8f3ff; --muted: #a7c0da; --line: rgba(200, 225, 255, .14);
  --panel: rgba(12, 28, 60, .78); --panel-solid: #13284f; --panel-edge: rgba(160, 205, 255, .16);
  --accent: #2a6fc0; --accent-ink: #92c9ff; --accent-soft: rgba(110, 175, 255, .16);
  --ca-accent: #2a6fc0;
  --glow: rgba(255, 210, 120, .9); --focus: #8fd0ff; --shadow: 0 18px 44px -20px rgba(0, 0, 0, .8);
}
:root[data-theme="cave"] {
  --bg: #d6ab82; --sky1: #f0d6b2; --sky2: #d6ab82;
  --far: #8a6246; --near: #6c4b36; --snow: #c49b74; --tree: #5a3e2c;
  --text: #2b1a0f; --muted: #4a3020; --line: rgba(60, 35, 15, .14);
  --panel: rgba(255, 246, 232, .84); --panel-solid: #fbf1e3; --panel-edge: rgba(255, 245, 230, .8);
  --accent: #6e42bf; --accent-ink: #5f36ad; --accent-soft: rgba(110, 66, 191, .12);
  --ca-accent: #6e42bf;
  --glow: rgba(255, 186, 80, .85); --focus: #6e42bf; --shadow: 0 18px 40px -22px rgba(60, 30, 10, .6);
  --sun: #ffd38a;
}
:root[data-theme="cave"][data-dark="1"] {
  color-scheme: dark;
  --bg: #14111c; --sky1: #0c0a12; --sky2: #241b33;
  --far: #1e1829; --near: #17121f; --snow: #3a3050; --tree: #120e19;
  --text: #f1eaff; --muted: #b8aacd; --line: rgba(220, 200, 255, .13);
  --panel: rgba(26, 20, 38, .8); --panel-solid: #201a2d; --panel-edge: rgba(200, 170, 255, .14);
  --accent: #7448cc; --accent-ink: #cdb2ff; --accent-soft: rgba(170, 130, 255, .16);
  --ca-accent: #7448cc;
  --glow: rgba(110, 240, 210, .85); --focus: #b99bff; --shadow: 0 18px 44px -20px rgba(0, 0, 0, .85);
}
:root[data-theme="desert"] {
  --bg: #f7d9a0; --sky1: #ffe7b0; --sky2: #fff6dc;
  --far: #e9a96a; --near: #f3c784; --snow: #ffe3a6; --tree: #5d9a5a;
  --text: #3a2108; --muted: #6e4b24; --line: rgba(90, 50, 10, .14);
  --panel: rgba(255, 249, 236, .84); --panel-solid: #fff8ea; --panel-edge: rgba(255, 250, 235, .85);
  --accent: #ad4c18; --accent-ink: #9c4315; --accent-soft: rgba(173, 76, 24, .12);
  --ca-accent: #ad4c18;
  --glow: rgba(255, 190, 90, .85); --focus: #ad4c18; --shadow: 0 18px 40px -22px rgba(120, 60, 10, .5);
  --sun: #fff1c4;
}
:root[data-theme="desert"][data-dark="1"] {
  color-scheme: dark;
  --bg: #2a1a40; --sky1: #140b26; --sky2: #47295e;
  --far: #3a2350; --near: #2a1a3c; --snow: #5a3d6c; --tree: #1d2f2a;
  --text: #fcf0ff; --muted: #cfb8dc; --line: rgba(255, 220, 250, .13);
  --panel: rgba(34, 20, 52, .78); --panel-solid: #2c1c44; --panel-edge: rgba(255, 200, 240, .14);
  --accent: #ad4c18; --accent-ink: #ffb685; --accent-soft: rgba(255, 160, 100, .14);
  --ca-accent: #ad4c18;
  --glow: rgba(255, 200, 120, .9); --focus: #ffb685; --shadow: 0 18px 44px -20px rgba(0, 0, 0, .8);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; height: 100%; }
body {
  margin: 0; height: 100%; min-height: 100dvh; overflow: hidden;
  background: var(--bg); color: var(--text);
  font: 16px/1.45 var(--font); -webkit-font-smoothing: antialiased;
  overscroll-behavior: none; -webkit-tap-highlight-color: transparent;
}
body.booting .shell, body.booting .landing { opacity: 0; }
button, input, select { font: inherit; color: inherit; }
button { -webkit-user-select: none; user-select: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.defs { position: absolute; width: 0; height: 0; overflow: hidden; }
svg { fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.scene svg, svg.pip { stroke: none; stroke-width: 1; }
svg .fill { fill: currentColor; stroke: none; }
svg .dot { fill: currentColor; }

/* ---- the living landscape ---------------------------------------------------------------- */
.scene { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; --px: 0; --py: 0; }
.scene .world { position: absolute; inset: 0; opacity: 0; transition: opacity .9s var(--ease); }
.scene .world.in { opacity: 1; }
.scene .world.out { opacity: 0; }
.scene .sky { position: absolute; inset: 0; background: linear-gradient(180deg, var(--sky1), var(--sky2) 75%); }
.scene .layer { position: absolute; left: -24px; right: -24px; bottom: 0; width: calc(100% + 48px); height: 46vh; min-height: 220px; transition: transform 1.6s var(--ease); }
.scene .layer.far { transform: translate3d(calc(var(--px) * -8px), calc(var(--py) * -4px), 0); }
.scene .layer.near { height: 34vh; transform: translate3d(calc(var(--px) * -18px), calc(var(--py) * -6px), 0); }
.scene .ceiling { top: 0; bottom: auto; height: 22vh; min-height: 130px; }
:root:not([data-dark="1"]) .scene .ceiling .m-far { opacity: .55; }
.m-far { fill: var(--far); }
.m-near { fill: var(--near); }
.m-snow { fill: var(--snow); opacity: .9; }
.m-tree { fill: var(--tree); }
.m-crystal { fill: #b89cff; opacity: .7; }
:root[data-dark="1"] .m-crystal { fill: #c9a6ff; opacity: .95; filter: drop-shadow(0 0 6px #a57bff); }
.sun, .moon { position: absolute; border-radius: 50%; }
.sun { top: 3%; right: 4%; width: 110px; height: 110px; background: radial-gradient(circle, var(--sun) 0 34%, transparent 70%); }
:root[data-dark="1"] .sun { display: none; }
.moon { display: none; top: 4%; right: 9%; width: 40px; height: 40px; box-shadow: -10px 6px 0 2px #fff4d8; transform: rotate(-20deg); }
:root[data-dark="1"] .moon { display: block; }
.star-dot { position: absolute; left: var(--x); top: var(--y); width: var(--s); height: var(--s); border-radius: 50%; background: #fff; opacity: 0; }
:root[data-dark="1"] .star-dot { opacity: .8; animation: twinkle 4.5s var(--d) ease-in-out infinite; }
.aurora { display: none; position: absolute; left: -20%; width: 140%; height: 22vh; border-radius: 50%; filter: blur(22px); opacity: .5; will-change: transform; }
:root[data-dark="1"] .aurora { display: block; }
.aurora.a1 { top: 6%; background: linear-gradient(90deg, transparent, #3ff0b8 30%, #39c6ff 60%, transparent); animation: aurora 16s ease-in-out infinite alternate; }
.aurora.a2 { top: 16%; background: linear-gradient(90deg, transparent, #7c6bff 35%, #3ff0b8 70%, transparent); opacity: .35; animation: aurora 21s -6s ease-in-out infinite alternate-reverse; }
.aurora.a3 { top: 2%; height: 14vh; background: linear-gradient(90deg, transparent 10%, #5cffd0 50%, transparent 90%); opacity: .3; animation: aurora 13s -3s ease-in-out infinite alternate; }
.cloud { position: absolute; height: 34px; border-radius: 34px; background: rgba(255, 255, 255, .75); will-change: transform; }
.cloud::before, .cloud::after { content: ""; position: absolute; border-radius: 50%; background: inherit; }
.cloud::before { width: 46px; height: 46px; left: 18%; top: -22px; }
.cloud::after { width: 32px; height: 32px; left: 52%; top: -14px; }
.cloud.c1 { top: 12%; width: 130px; animation: drift 70s linear infinite; }
.cloud.c2 { top: 22%; width: 90px; opacity: .7; animation: drift 95s -40s linear infinite; }
.cloud.c3 { top: 6%; width: 70px; opacity: .55; animation: drift 120s -80s linear infinite; }
:root[data-dark="1"] .cloud { display: none; }
.torch { position: absolute; top: 18%; width: 220px; height: 220px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 200, 110, .55), transparent 65%); animation: flicker 2.6s ease-in-out infinite alternate; }
.torch.t1 { left: -60px; }
.torch.t2 { right: -60px; top: 34%; animation-delay: -1.2s; }
:root[data-dark="1"] .torch { display: none; }
.glowcap { display: none; position: absolute; bottom: 10%; width: 18px; height: 12px; border-radius: 50% 50% 30% 30%; background: #6cf3d4; box-shadow: 0 0 18px 6px rgba(80, 240, 205, .55); animation: pulse-glow 3.4s ease-in-out infinite alternate; }
:root[data-dark="1"] .glowcap { display: block; }
.glowcap.g1 { left: 8%; }
.glowcap.g2 { left: 13%; bottom: 8%; transform: scale(.7); animation-delay: -1s; background: #c79bff; box-shadow: 0 0 18px 6px rgba(190, 140, 255, .55); }
.glowcap.g3 { right: 10%; bottom: 12%; animation-delay: -2s; }
.glowcap.g4 { right: 16%; bottom: 9%; transform: scale(.6); animation-delay: -.4s; background: #ffd27a; box-shadow: 0 0 16px 5px rgba(255, 200, 110, .5); }
.drip { position: absolute; top: 7vh; width: 4px; height: 7px; border-radius: 50% 50% 50% 50% / 30% 30% 70% 70%; background: rgba(200, 230, 255, .8); opacity: 0; animation: drip 3.2s ease-in infinite; }
.drip.d1 { left: 12.5%; }
.drip.d2 { left: 51.7%; animation-delay: -1.3s; animation-duration: 4.1s; }
.drip.d3 { left: 92.5%; top: 9vh; animation-delay: -2.4s; }
.sandline { position: absolute; height: 2px; width: 120px; border-radius: 2px; background: linear-gradient(90deg, transparent, rgba(255, 245, 220, .8), transparent); opacity: 0; animation: sand 7s linear infinite; }
:root[data-dark="1"] .sandline { background: linear-gradient(90deg, transparent, rgba(255, 210, 250, .4), transparent); }
.sandline.s1 { bottom: 26%; animation-delay: -1s; }
.sandline.s2 { bottom: 18%; width: 180px; animation-delay: -3.6s; animation-duration: 9s; }
.sandline.s3 { bottom: 31%; width: 80px; animation-delay: -5.5s; }
.flurry { position: absolute; inset: 0; background-image: radial-gradient(1.5px 1.5px at 20% 30%, #fff 50%, transparent 51%), radial-gradient(2px 2px at 70% 20%, #fff 50%, transparent 51%), radial-gradient(1.5px 1.5px at 45% 70%, #fff 50%, transparent 51%), radial-gradient(2px 2px at 85% 60%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 10% 85%, #fff 50%, transparent 51%); background-size: 260px 260px; opacity: .6; animation: snow 24s linear infinite; }
:root:not([data-dark="1"]) .flurry { opacity: .9; filter: drop-shadow(0 0 1px rgba(80, 140, 200, .5)); }

/* ---- the shell --------------------------------------------------------------------------- */
.shell { position: relative; z-index: 1; height: 100dvh; display: flex; flex-direction: column; transition: opacity .3s;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.bar { display: flex; align-items: center; gap: 10px; min-height: 60px; padding: 8px 14px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.brand-icon { width: 34px; height: 34px; border-radius: 10px; box-shadow: 0 6px 14px -8px rgba(0, 0, 0, .5); flex: none; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-title { font-weight: 750; font-size: 18px; letter-spacing: -.01em; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-title { display: none; flex: 1; margin: 0; font-size: 19px; font-weight: 750; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .bar-back { display: none; }
.shell[data-view="levels"] .brand, .shell[data-view="board"] .brand, .shell[data-view="wardrobe"] .brand { display: none; }
.shell[data-view="levels"] .bar-title, .shell[data-view="board"] .bar-title, .shell[data-view="wardrobe"] .bar-title,
.shell[data-view="levels"] .bar-back, .shell[data-view="board"] .bar-back, .shell[data-view="wardrobe"] .bar-back { display: block; }
.shell[data-view="levels"] .bar .bar-back, .shell[data-view="board"] .bar .bar-back, .shell[data-view="wardrobe"] .bar .bar-back { display: grid; }
.shell[data-view="game"] .bar { display: none; }
.bar-tools { display: flex; align-items: center; gap: 6px; flex: none; }
.chip-slot { display: grid; place-items: center; min-width: 44px; min-height: 44px; }
.icon-btn { display: grid; place-items: center; width: 44px; height: 44px; flex: none; padding: 0; border: 1px solid var(--panel-edge); border-radius: 50%;
  background: var(--panel); color: var(--text); cursor: pointer; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: transform 80ms var(--ease), background .2s; }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:hover { background: var(--panel-solid); }
.icon-btn:active, .btn:active, .ctrl:active, .tile-btn:active, .continue:active, .lvl:active, .wr-item:active { transform: scale(.96); }
@media (max-width: 400px) { .brand-sub { display: none; } .brand-icon { display: none; } .brand-title { font-size: 17px; } .bar { gap: 6px; padding: 8px 10px; } .bar-tools { gap: 4px; } }

.views { position: relative; flex: 1; min-height: 0; }
.view { position: absolute; inset: 0; display: flex; flex-direction: column; overflow: hidden; }
.view.enter { animation: view-in var(--t) var(--ease) both; }
.view.leave { animation: view-out var(--t) var(--ease) both; pointer-events: none; }

.panel { background: var(--panel); border: 1px solid var(--panel-edge); border-radius: var(--r); box-shadow: var(--shadow);
  backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px; border: 0; border-radius: 14px;
  font-weight: 700; font-size: 16px; cursor: pointer; text-decoration: none; transition: transform 80ms var(--ease), filter .2s, background .2s; }
.btn.primary { background: var(--accent); color: #fff; box-shadow: 0 10px 22px -12px var(--accent); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.soft { background: var(--accent-soft); color: var(--accent-ink); }
.btn.soft:hover { filter: brightness(1.05); }
.btn.sm { min-height: 44px; padding: 0 16px; font-size: 15px; border-radius: 12px; }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: .5; cursor: default; }

.stars { display: inline-flex; gap: 2px; align-items: center; }
.star { width: 22px; height: 22px; color: var(--star); stroke: var(--star-edge); stroke-width: 1.2; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .18)); transition: opacity .35s var(--ease), transform .35s var(--ease); }
.star use { fill: currentColor; }
.star.off { color: transparent; stroke: var(--muted); opacity: .55; filter: none; }
.stars.sm .star { width: 16px; height: 16px; }
.stars.live .star.lost { opacity: .22; transform: scale(.82); filter: grayscale(1); }

/* ---- landing ------------------------------------------------------------------------------ */
.landing { position: relative; z-index: 1; height: 100dvh; overflow-y: auto; overscroll-behavior: contain; transition: opacity .3s;
  padding: calc(env(safe-area-inset-top) + 18px) calc(env(safe-area-inset-right) + 16px) calc(env(safe-area-inset-bottom) + 24px) calc(env(safe-area-inset-left) + 16px); }
.landing-in { max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.l-head { text-align: center; }
.l-icon { width: 64px; height: 64px; border-radius: 18px; box-shadow: 0 14px 28px -14px rgba(0, 0, 0, .6); animation: pop .6s var(--spring) both; }
.l-title { margin: 10px 0 2px; font-size: clamp(30px, 8vw, 42px); font-weight: 800; letter-spacing: -.02em; line-height: 1.05; }
.l-slogan { margin: 0; color: var(--muted); font-size: 17px; font-weight: 600; }
.l-demo { padding: 12px; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.demo-board { position: relative; width: 100%; height: min(64vw, 300px); display: grid; place-items: center; }
.l-cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.l-cards li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; font-weight: 600; animation: up .5s var(--ease) both; }
.l-cards li:nth-child(2) { animation-delay: .06s; }
.l-cards li:nth-child(3) { animation-delay: .12s; }
.l-cards .ico { width: 30px; height: 30px; flex: none; padding: 5px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-ink); }
.l-info { margin: 0; padding: 12px 16px; border-radius: var(--r); background: var(--panel); border: 1px solid var(--panel-edge); color: var(--muted); font-size: 14.5px; text-align: center; text-wrap: pretty;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.l-actions { position: sticky; bottom: calc(env(safe-area-inset-bottom) + 10px); z-index: 2; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 8px; border-radius: 20px;
  background: var(--panel); border: 1px solid var(--panel-edge); box-shadow: var(--shadow); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
.l-actions .btn { padding: 0 10px; white-space: nowrap; font-size: 15.5px; }
.l-actions .btn.soft { background: var(--panel-solid); box-shadow: inset 0 0 0 1.5px var(--accent-soft); }
.l-foot { margin: 0 auto; padding: 6px 12px; border-radius: 999px; background: var(--panel); color: var(--muted); font-size: 13px; text-align: center; }
@media (min-width: 900px) and (min-height: 640px) {
  .landing-in { max-width: 980px; display: grid; grid-template-columns: 1.1fr 1fr; grid-template-areas: "head head" "demo cards" "demo info" "demo actions" "demo foot"; gap: 14px 28px; align-items: start; }
  .l-head { grid-area: head; } .l-demo { grid-area: demo; } .l-cards { grid-area: cards; } .l-info { grid-area: info; text-align: left; } .l-actions { grid-area: actions; } .l-foot { grid-area: foot; text-align: left; margin: 0; justify-self: start; }
  .demo-board { height: 380px; }
  .l-actions { position: static; padding: 0; background: none; border: 0; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; }
}

/* segmented control */
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 12px; background: var(--accent-soft); }
.seg button { min-height: 40px; min-width: 44px; padding: 0 14px; border: 0; border-radius: 9px; background: transparent; color: var(--accent-ink); font-weight: 650; font-size: 14.5px; cursor: pointer; transition: background .2s, color .2s; white-space: nowrap; }
.seg button[aria-checked="true"], .seg button[aria-selected="true"] { background: var(--accent); color: #fff; box-shadow: 0 4px 10px -6px rgba(0, 0, 0, .5); }

/* ---- home ----------------------------------------------------------------------------------- */
.home { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; padding: 0 16px 16px; gap: 12px; }
.home-hero { position: relative; flex: 1 1 auto; min-height: 150px; display: grid; place-items: center; }
.home-pip { width: min(46vw, 230px); aspect-ratio: 120 / 130; max-height: 30vh; }
.home-pip .pip { filter: drop-shadow(0 12px 18px rgba(0, 0, 0, .18)); }
.home-cards { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 560px; margin: 0 auto; }
.continue { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 76px; padding: 12px 18px 12px 12px; border: 0; border-radius: 20px; cursor: pointer;
  background: var(--accent); color: #fff; text-align: left; box-shadow: 0 16px 30px -16px var(--accent); transition: transform 80ms var(--ease), filter .2s; }
.continue:hover { filter: brightness(1.06); }
.continue-play { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 16px; background: rgba(255, 255, 255, .18); flex: none; }
.continue-play svg { width: 28px; height: 28px; }
.continue-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.continue-label { font-size: 13px; font-weight: 650; opacity: .85; text-transform: uppercase; letter-spacing: .06em; }
.continue-level { font-size: 23px; font-weight: 800; letter-spacing: -.01em; }
.continue .star.off { stroke: rgba(255, 255, 255, .75); }
.daily { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.daily-top { display: flex; align-items: center; gap: 12px; }
.daily-ico { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-ink); flex: none; }
.daily-ico svg { width: 22px; height: 22px; }
.daily-head { flex: 1; min-width: 0; }
.daily-head h2 { margin: 0; font-size: 17px; font-weight: 750; }
.daily-date { margin: 0; color: var(--muted); font-size: 13.5px; }
.streak { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px 4px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); font-weight: 750; font-size: 14px; white-space: nowrap; }
.streak svg { width: 18px; height: 18px; }
.streak.zero { opacity: .6; }
.daily-state { margin: 0; font-weight: 650; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.daily-state.late { color: var(--muted); }
.daily-bottom { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.daily-next { margin: 0; color: var(--muted); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.home-nav { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 76px; padding: 10px 6px; border: 1px solid var(--panel-edge); border-radius: var(--r);
  background: var(--panel); color: var(--text); font-weight: 700; font-size: 14px; cursor: pointer; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow); transition: transform 80ms var(--ease), background .2s; text-align: center; line-height: 1.2; }
.tile-btn svg { width: 26px; height: 26px; color: var(--accent-ink); }
.tile-btn:hover { background: var(--panel-solid); transform: translateY(-2px); }
.gift { position: absolute; left: 50%; bottom: 8%; width: 70px; height: 70px; transform: translateX(-50%); }
.gift-box { position: absolute; inset: 18px 8px 0; border-radius: 8px; background: linear-gradient(135deg, #ff8a8a, #d9364d); box-shadow: 0 10px 18px -10px rgba(0, 0, 0, .5); animation: gift-wiggle .5s ease-in-out 3; }
.gift-box::after { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 10px; margin-left: -5px; background: #ffd166; }
.gift-lid { position: absolute; left: 3px; right: 3px; top: 8px; height: 16px; border-radius: 6px; background: linear-gradient(135deg, #ff9d9d, #e2475d); animation: gift-lid .7s 1.6s var(--ease) both; }
.gift-lid::after { content: ""; position: absolute; left: 50%; top: -10px; width: 20px; height: 14px; margin-left: -10px; border-radius: 50% 50% 0 0; border: 4px solid #ffd166; border-bottom: 0; }
.gift.open .gift-box { animation: gift-out .5s 2.1s var(--ease) both; }
@media (orientation: landscape) and (min-width: 760px) {
  .home { flex-direction: row; align-items: center; justify-content: center; gap: clamp(28px, 5vw, 80px); width: 100%; max-width: 1180px; margin: 0 auto; padding: 8px 28px 28px; }
  .home-hero { flex: 0 1 440px; min-height: 0; align-self: stretch; }
  .home-pip { width: min(30vw, 320px); max-height: 56vh; }
  .home-cards { flex: 0 1 480px; margin: 0; }
}
@media (orientation: landscape) and (max-height: 520px) {
  .home { flex-direction: row; align-items: center; gap: 16px; }
  .home-hero { min-height: 0; flex: 0 0 30%; }
  .home-pip { width: 100%; max-height: 50vh; }
  .continue { min-height: 62px; }
  .tile-btn { min-height: 56px; flex-direction: row; }
}

/* ---- level select ----------------------------------------------------------------------------- */
.levels-head { padding: 0 16px 6px; }
.levels-total { margin: 0; color: var(--muted); font-weight: 650; display: flex; align-items: center; gap: 6px; }
.levels-total .star { width: 18px; height: 18px; }
.levels-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 16px calc(16px + env(safe-area-inset-bottom)); }
.levels { max-width: 920px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.chapter { content-visibility: auto; contain-intrinsic-size: auto 360px; }
.chapter-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 6px 4px 8px; }
.chapter-head h2 { margin: 0; font-size: 17px; font-weight: 800; letter-spacing: -.01em; }
.chapter-head .new { display: inline-block; margin-left: 6px; padding: 2px 8px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; vertical-align: 2px; }
.chapter-stars { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chapter-stars .star { width: 15px; height: 15px; }
.lvl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; }
.lvl { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 84px; padding: 8px 4px; border-radius: var(--r);
  border: 1px solid var(--panel-edge); background: var(--panel); color: var(--text); cursor: pointer; box-shadow: var(--shadow);
  transition: transform .18s var(--ease), background .2s; }
.lvl:hover { transform: translateY(-2px); background: var(--panel-solid); }
.lvl-n { font-size: 21px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.lvl .stars .star { width: 15px; height: 15px; }
.lvl-best { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.lvl.improvable::after { content: ""; position: absolute; top: 7px; right: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent-ink); opacity: .55; }
.lvl.next { border: 2px solid var(--accent); background: var(--accent-soft); animation: next-pulse 1.8s ease-in-out infinite; }
.lvl.next .lvl-best { color: var(--accent-ink); font-weight: 700; }

/* ---- leaderboard ------------------------------------------------------------------------------- */
.lb { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 640px; margin: 0 auto; padding: 0 16px calc(16px + env(safe-area-inset-bottom)); }
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); padding: 3px; gap: 2px; border-radius: 13px; background: var(--accent-soft); }
.tabs button { min-height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--accent-ink); font-weight: 700; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--accent); color: #fff; }
.lb-sub { margin: 0 4px; color: var(--muted); font-weight: 650; font-size: 14.5px; }
.lb-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 6px; }
.lb-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.lb-row { display: grid; grid-template-columns: 34px 38px 1fr auto; align-items: center; gap: 10px; min-height: 56px; padding: 6px 12px 6px 8px; border-radius: 12px; }
.lb-row + .lb-row { border-top: 1px solid var(--line); }
.lb-rank { text-align: center; font-weight: 800; font-size: 17px; font-variant-numeric: tabular-nums; color: var(--muted); }
.lb-row:nth-child(1) .lb-rank { color: var(--star-edge); }
.lb-av { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; color: #fff; font-weight: 750; background: var(--av, #8a8f9b); }
.lb-name { min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-name small { color: var(--muted); font-weight: 600; }
.lb-heart { color: #e5484d; margin-left: 4px; }
.lb-score { display: flex; flex-direction: column; align-items: flex-end; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lb-score .stars .star { width: 13px; height: 13px; }
.lb-row.me { position: sticky; top: 0; bottom: 0; z-index: 1; background: var(--panel-solid); box-shadow: 0 0 0 2px var(--accent) inset, 0 6px 16px -10px rgba(0, 0, 0, .5); }
.lb-row.idle { opacity: .55; }
.lb-row.idle .lb-score { font-weight: 600; font-size: 13px; color: var(--muted); }
.lb-note { margin: 8px 6px; color: var(--muted); font-size: 13.5px; display: flex; gap: 8px; align-items: center; }
.lb-note svg { width: 18px; height: 18px; flex: none; }
.lb-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 18px 12px 22px; text-align: center; }
.lb-empty .scope-pip { width: 130px; aspect-ratio: 120 / 130; position: relative; }
.lb-empty h3 { margin: 0; font-size: 19px; }
.lb-empty p { margin: 0; color: var(--muted); max-width: 36ch; }
.scope { position: absolute; right: -6%; top: 26%; width: 46%; height: 16%; border-radius: 6px; background: linear-gradient(180deg, #7a5a3a, #4b3423); transform: rotate(-18deg); box-shadow: 0 4px 8px -4px rgba(0, 0, 0, .5); }
.scope::before { content: ""; position: absolute; right: -6px; top: -3px; bottom: -3px; width: 12px; border-radius: 4px; background: #c9a24a; }
.skeleton { height: 56px; border-radius: 12px; background: linear-gradient(100deg, transparent 30%, var(--accent-soft) 50%, transparent 70%) 0 0 / 250% 100%, var(--line); animation: shimmer 1.4s linear infinite; margin: 4px 0; opacity: .6; }

/* ---- wardrobe ------------------------------------------------------------------------------------ */
.wardrobe { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 14px; padding: 0 16px calc(18px + env(safe-area-inset-bottom)); }
.wr-stage { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.wr-pip { width: min(48vw, 210px); aspect-ratio: 120 / 130; }
.wr-stars { margin: 0; font-weight: 750; display: inline-flex; gap: 6px; align-items: center; color: var(--muted); }
.wr-stars .star { width: 18px; height: 18px; }
.wr-side { display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 620px; margin: 0 auto; }
.wr-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.wr-item { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; min-height: 150px; padding: 10px 8px 12px; border-radius: var(--r);
  border: 1px solid var(--panel-edge); background: var(--panel); color: var(--text); cursor: pointer; box-shadow: var(--shadow); text-align: center; transition: transform .18s var(--ease), background .2s; }
.wr-item:hover { transform: translateY(-2px); background: var(--panel-solid); }
.wr-item[aria-checked="true"] { border: 2px solid var(--accent); background: var(--accent-soft); }
.wr-item .mini { width: 70px; aspect-ratio: 120 / 130; pointer-events: none; }
.wr-name { font-weight: 750; font-size: 14.5px; line-height: 1.2; }
.wr-tag { font-size: 12.5px; font-weight: 700; color: var(--accent-ink); }
.wr-item.locked { cursor: default; }
.wr-item.locked .mini { opacity: .35; filter: grayscale(.8); }
.wr-item.locked .wr-name { color: var(--muted); }
.wr-lock { display: flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--muted); font-weight: 650; font-variant-numeric: tabular-nums; }
.wr-lock svg { width: 14px; height: 14px; }
.bar-progress { width: 80%; height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; }
.bar-progress i { display: block; height: 100%; width: 100%; border-radius: inherit; background: var(--accent); transform-origin: 0 50%; transform: scaleX(var(--p, 0)); }
.stats { padding: 14px 16px; }
.stats h2 { margin: 0 0 8px; font-size: 17px; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin: 0; }
.stats-grid div { padding: 10px 12px; border-radius: 12px; background: var(--accent-soft); }
.stats-grid dt { font-size: 12.5px; color: var(--muted); font-weight: 650; }
.stats-grid dd { margin: 2px 0 0; font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stats-grid dd small { display: block; font-size: 12px; font-weight: 650; color: var(--accent-ink); }
@media (min-width: 860px) {
  .wardrobe { flex-direction: row; align-items: flex-start; justify-content: center; gap: 28px; padding-top: 10px; }
  .wr-stage { position: sticky; top: 10px; flex: 0 0 300px; }
  .wr-pip { width: 260px; }
}

/* ---- the game ------------------------------------------------------------------------------------- */
.game { display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; grid-template-columns: minmax(0, 1fr); }
.gbar { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 10px; padding: 8px 12px 4px; }
.g-mid { min-width: 0; justify-self: center; max-width: 100%; padding: 4px 14px; border-radius: var(--r); text-align: center; background: var(--panel); border: 1px solid var(--panel-edge);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.g-title { margin: 0; font-size: 18px; font-weight: 800; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-moves { margin: 0; font-size: 14.5px; font-weight: 650; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.roll { display: inline-block; overflow: hidden; vertical-align: bottom; height: 1.45em; }
.roll-in { display: inline-block; color: var(--text); font-weight: 800; }
.roll-in.roll-up { animation: roll-up .26s var(--ease); }
.roll-in.roll-down { animation: roll-down .26s var(--ease); }
.gbar .stars { justify-self: end; min-width: 44px; padding: 6px 8px; border-radius: var(--r); background: var(--panel); border: 1px solid var(--panel-edge); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.gbar .star { width: 24px; height: 24px; }
.play { position: relative; min-height: 0; min-width: 0; overflow: hidden; display: grid; place-items: center; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; overscroll-behavior: none; }
.play.can-click { cursor: pointer; }
.board-wrap { position: relative; width: var(--board-w, 300px); height: var(--board-h, 300px); outline: none; border-radius: 18px; }
.board-wrap:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; }
.board { position: absolute; left: 0; top: 0; transform-origin: 0 0; transform: scale(var(--board-scale, 1)); }
.board.appear { animation: board-in .4s var(--ease) both; }
.board canvas { position: absolute; left: 0; top: 0; }
.board-hint { opacity: 0; transition: opacity .35s var(--ease); pointer-events: none; }
.board-hint.show { opacity: 1; animation: hint-breathe 1.2s ease-in-out infinite alternate; }
.pip-host { position: absolute; left: 0; top: 0; width: calc(var(--cell) * 1.2); height: calc(var(--cell) * 1.3); will-change: transform; pointer-events: none; }
.exit-glow { position: absolute; left: 0; top: 0; width: calc(var(--cell) * 2); height: calc(var(--cell) * 2); border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, var(--glow) 0, transparent 62%); mix-blend-mode: screen; animation: glow 2.6s ease-in-out infinite; }
.board.no-exit .exit-glow { display: none; }
:root:not([data-dark="1"]) .exit-glow { mix-blend-mode: normal; opacity: .55; }
.exit-glow.flare { animation: flare 1.2s var(--ease) both; }
.hover-arrow, .guide-arrow { position: absolute; left: 0; top: 0; width: calc(var(--cell) * .42); height: calc(var(--cell) * .42); margin: calc(var(--cell) * -.21) 0 0 calc(var(--cell) * -.21);
  background: var(--accent-ink); clip-path: polygon(20% 15%, 85% 50%, 20% 85%, 35% 50%); opacity: 0; pointer-events: none; transition: opacity .15s; }
.hover-arrow.show { opacity: .55; }
.guide-arrow { width: calc(var(--cell) * .7); height: calc(var(--cell) * .7); margin: calc(var(--cell) * -.35) 0 0 calc(var(--cell) * -.35); background: var(--accent); }
.guide-arrow.show { opacity: .95; animation: guide 1s ease-in-out infinite; }
.bubble { position: absolute; left: 50%; bottom: calc(100% + 10px); z-index: 3; width: max-content; max-width: min(88vw, 340px); padding: 10px 14px; border-radius: 14px;
  background: var(--panel-solid); color: var(--text); font-weight: 700; font-size: 15px; text-align: center; box-shadow: var(--shadow); border: 1px solid var(--panel-edge);
  transform: translateX(-50%) scale(calc(1 / var(--board-scale, 1))); transform-origin: 50% 100%; animation: bubble-in .45s .35s var(--spring) both; }
.bubble::after { content: ""; position: absolute; left: 50%; top: 100%; margin-left: -8px; border: 8px solid transparent; border-top-color: var(--panel-solid); }
.bubble.out { animation: bubble-out .3s var(--ease) both; }
.dead { margin: 0 auto 2px; padding: 6px 12px; border-radius: 999px; background: var(--panel-solid); color: var(--text); font-size: 13.5px; font-weight: 650; box-shadow: var(--shadow); animation: up .3s var(--ease) both; text-align: center; max-width: calc(100% - 24px); }
.gctrl { display: flex; justify-content: center; gap: 10px; padding: 8px 14px 12px; width: 100%; max-width: 560px; margin: 0 auto; }
.ctrl { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 60px; min-width: 48px; padding: 6px 4px; border: 1px solid var(--panel-edge);
  border-radius: 16px; background: var(--panel); color: var(--text); font-weight: 700; font-size: 13.5px; cursor: pointer; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow); transition: transform 80ms var(--ease), background .2s, opacity .2s; white-space: nowrap; }
.ctrl svg { width: 24px; height: 24px; color: var(--accent-ink); }
.ctrl:hover { background: var(--panel-solid); }
.ctrl[disabled] { opacity: .45; cursor: default; }
.ctrl.pulse { animation: soft-pulse 1.4s ease-in-out infinite; border-color: var(--accent); }
@media (orientation: landscape) and (max-height: 560px) {
  .game { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto minmax(0, 1fr) auto; }
  .gbar { grid-column: 1 / -1; padding-top: 4px; padding-bottom: 0; }
  .play { grid-row: 2 / 4; grid-column: 1; }
  .gctrl { grid-row: 2; grid-column: 2; flex-direction: column; justify-content: center; width: auto; padding: 0 14px 0 0; }
  .ctrl { flex: 0 0 auto; width: 86px; }
  .dead { grid-row: 3; grid-column: 2; margin: 0 8px 8px; border-radius: 12px; font-size: 12.5px; }
  /* the top bar folds into one row */
  .g-mid { display: flex; align-items: baseline; gap: 12px; padding: 3px 14px; }
  .g-title { font-size: 16px; }
  .ctrl { min-height: 54px; }
}
@media (max-width: 359px) { .gbar { gap: 6px; padding: 4px 8px 2px; } .g-title { font-size: 16px; } .g-moves { font-size: 13px; } .gbar .star { width: 19px; height: 19px; } .ctrl { font-size: 12.5px; } }

/* ---- the result ---------------------------------------------------------------------------------- */
.result-wrap { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center;
  background: linear-gradient(180deg, transparent 20%, rgba(0, 0, 0, .28)); animation: fade .3s var(--ease) both; }
.result { width: min(100%, 520px); padding: 10px 20px calc(18px + env(safe-area-inset-bottom)); border-radius: 26px 26px 0 0; background: var(--panel-solid); border: 1px solid var(--panel-edge); border-bottom: 0;
  backdrop-filter: blur(22px) saturate(1.3); -webkit-backdrop-filter: blur(22px) saturate(1.3); box-shadow: 0 -20px 50px -24px rgba(0, 0, 0, .55); text-align: center;
  animation: sheet-up .42s var(--spring) both; outline: none; }
.r-grip { width: 40px; height: 5px; margin: 0 auto 10px; border-radius: 5px; background: var(--line); }
.r-title { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -.01em; }
.r-stars { display: flex; justify-content: center; gap: 10px; margin: 12px 0 6px; min-height: 58px; }
.r-stars .star { width: 54px; height: 54px; transform: scale(0); }
.r-stars .star.pop { animation: star-pop .42s var(--spring) both; }
.r-stars .star.off.pop { animation: star-pop-off .3s var(--ease) both; }
.r-moves { margin: 0; font-size: 17px; font-weight: 700; }
.r-best { display: inline-block; margin: 8px 0 0; padding: 4px 12px; border-radius: 999px; background: var(--star); color: #3a2508; font-weight: 800; font-size: 14px; animation: pop .5s .9s var(--spring) both; }
.r-rank { margin: 8px 0 0; font-weight: 750; color: var(--accent-ink); }
.r-note { margin: 8px auto 0; max-width: 40ch; color: var(--muted); font-size: 14px; }
.r-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.r-actions .btn:first-child { grid-column: 1 / -1; }
@media (orientation: landscape) and (max-height: 520px) { .result { padding-top: 6px; } .r-stars { margin: 6px 0 2px; min-height: 44px; } .r-stars .star { width: 40px; height: 40px; } .r-actions { grid-template-columns: repeat(3, 1fr); margin-top: 10px; } .r-actions .btn:first-child { grid-column: auto; } }

/* ---- sheets ----------------------------------------------------------------------------------------- */
.sheet { width: min(100% - 24px, 520px); max-height: min(88dvh, 820px); padding: 0; border: 1px solid var(--panel-edge); border-radius: 22px; background: var(--panel-solid); color: var(--text);
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .6); overflow: hidden; }
.sheet[open] { display: flex; flex-direction: column; animation: sheet-in .32s var(--spring) both; }
.sheet::backdrop { background: rgba(8, 12, 24, .42); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: fade .25s both; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 14px 8px 20px; }
.sheet-head h2 { margin: 0; font-size: 20px; font-weight: 800; }
.sheet-x { box-shadow: none; }
.sheet-body { overflow-y: auto; overscroll-behavior: contain; padding: 0 20px calc(20px + env(safe-area-inset-bottom)); }
.sheet-body h3 { margin: 18px 0 8px; font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.sheet-body p { margin: 6px 0; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 54px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.row > span:first-child { font-weight: 650; }
.row-note { display: block; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.row select { min-height: 44px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--accent-soft); color: var(--text); font-weight: 650; }
.row.slider { display: grid; grid-template-columns: minmax(90px, 1fr) minmax(110px, 1.6fr) 44px; }
.row output { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 650; font-size: 14px; }
input[type="range"] { width: 100%; min-height: 44px; accent-color: var(--accent); }
.switch { appearance: none; -webkit-appearance: none; position: relative; width: 52px; height: 32px; flex: none; margin: 0; border-radius: 999px; background: var(--line); cursor: pointer; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .35); transition: transform .22s var(--ease); }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(20px); }
.version { margin-top: 14px !important; color: var(--muted); font-size: 13px; text-align: center; }
.theme-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.theme-card { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 6px 6px 8px; border: 2px solid transparent; border-radius: 16px; background: var(--accent-soft); color: var(--text); cursor: pointer; text-align: center; transition: transform .18s var(--ease), border-color .2s; }
.theme-card:hover { transform: translateY(-2px); }
.theme-card[aria-checked="true"] { border-color: var(--accent); }
.theme-card canvas { width: 100%; aspect-ratio: 1; border-radius: 11px; display: block; }
.theme-card b { font-size: 14.5px; }
.theme-card small { display: none; color: var(--muted); font-size: 12.5px; line-height: 1.3; }
.theme-cards.big .theme-card small { display: block; }
.theme-card .tick { position: absolute; top: 10px; right: 10px; width: 26px; height: 26px; padding: 4px; border-radius: 50%; background: var(--accent); color: #fff; opacity: 0; transform: scale(.6); transition: opacity .2s, transform .25s var(--spring); }
.theme-card[aria-checked="true"] .tick { opacity: 1; transform: none; }
.welcome { padding-top: 22px; text-align: center; }
.welcome h2 { margin: 0 0 4px; font-size: 24px; font-weight: 800; }
.welcome > p { color: var(--muted); margin: 0 0 16px; }
.welcome .btn { margin-top: 18px; }
@media (max-width: 420px) { .theme-cards.big { grid-template-columns: 1fr; } .theme-cards.big .theme-card { flex-direction: row; align-items: center; text-align: left; } .theme-cards.big .theme-card canvas { width: 84px; flex: none; } }
@media (max-width: 560px) {
  .sheet { width: 100%; max-width: 100%; max-height: 92dvh; margin: auto 0 0; border-radius: 22px 22px 0 0; border-bottom: 0; }
  .sheet[open] { animation: sheet-up .36s var(--spring) both; }
}
.help .help-demo { display: grid; place-items: center; padding: 6px; border-radius: 16px; background: var(--accent-soft); }
.help .demo-board { height: 210px; }
.help .seg { margin-bottom: 8px; }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.legend li { display: grid; grid-template-columns: 48px 1fr; gap: 12px; align-items: center; min-height: 54px; }
.legend canvas { width: 48px; height: 48px; border-radius: 10px; }
.legend b { display: block; }
.legend span { color: var(--muted); font-size: 14px; }
.help-example { color: var(--muted); font-size: 14px; }
.keys { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.keys th, .keys td { padding: 8px 4px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.keys th { font-weight: 650; color: var(--muted); width: 45%; }
kbd { display: inline-block; min-width: 24px; padding: 1px 6px; margin: 1px; border-radius: 6px; border: 1px solid var(--line); border-bottom-width: 2px; background: var(--accent-soft); font: 600 13px var(--font); text-align: center; }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 30; max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 14px; background: var(--panel-solid); color: var(--text);
  font-weight: 700; box-shadow: var(--shadow); border: 1px solid var(--panel-edge); transform: translateX(-50%); animation: toast-in .35s var(--spring) both; display: flex; gap: 12px; align-items: center; }
.toast .btn { min-height: 40px; }

/* ---- Pip ---------------------------------------------------------------------------------------- */
.pip { display: block; width: 100%; height: 100%; overflow: visible; --lx: 0px; --ly: 0px; --trail: 1; }
.pip .p-fur, .pip .p-ear { fill: url(#gFur); stroke: #c08d5c; stroke-width: 1.5; }
.pip .p-ear-in { fill: #f6aeb4; }
.pip .p-belly { fill: #fff8ee; opacity: .72; }
.pip .p-cheek { fill: #ff8fa0; opacity: .5; }
.pip .p-foot { fill: #ecc79c; stroke: #c08d5c; stroke-width: 1.2; }
.pip .p-white { fill: #fff; stroke: #c08d5c; stroke-width: .8; }
.pip .p-pupil { transform: translate(var(--lx), var(--ly)); transition: transform .16s var(--ease); }
.pip .p-lid { fill: #f3d6b2; stroke: #c08d5c; stroke-width: .8; transform-box: fill-box; transform-origin: 50% 0; transform: scaleY(0); transition: transform .3s var(--ease); }
.pip.blink .p-lid { animation: blink .26s ease-in-out; }
.pip[data-face="sleepy"] .p-lid { transform: scaleY(.62); }
.pip[data-face="yawn"] .p-lid { transform: scaleY(.5); }
.pip[data-face="surprised"] .p-white { transform: scale(1.12); transform-box: fill-box; transform-origin: 50% 50%; }
.pip .p-happyeyes { display: none; stroke: #2b1f3d; stroke-width: 2.6; }
.pip[data-face="happy"] .p-eyes { display: none; }
.pip[data-face="happy"] .p-happyeyes { display: inline; }
.pip .p-brows { display: none; stroke: #8a5a3a; stroke-width: 1.8; }
.pip[data-face="surprised"] .p-brows, .pip[data-face="curious"] .p-brows { display: inline; }
.pip .p-mouth { display: none; stroke: #6b3a2c; stroke-width: 1.9; }
.pip .p-fillmouth { fill: #a2453f; }
.pip[data-face="calm"] .m-calm, .pip[data-face="curious"] .m-curious, .pip[data-face="happy"] .m-happy,
.pip[data-face="surprised"] .m-surprised, .pip[data-face="sleepy"] .m-sleepy, .pip[data-face="yawn"] .m-yawn { display: inline; }
.pip .p-shadow { fill: rgba(10, 20, 40, .2); }
.pip .st, .pip .acc, .pip .p-lampglow { display: none; }
.pip[data-world="ice"] .st-ice, .pip[data-world="cave"] .st-cave, .pip[data-world="desert"] .st-desert { display: inline; }
.pip[data-acc="default"][data-world="ice"] .acc-scarf, .pip[data-acc="default"][data-world="ice"] .acc-pompom,
.pip[data-acc="default"][data-world="cave"] .acc-headlamp, .pip[data-acc="default"][data-world="desert"] .acc-straw,
.pip[data-acc="redhat"] .acc-redhat, .pip[data-acc="sunglasses"] .acc-sunglasses, .pip[data-acc="earmuffs"] .acc-earmuffs,
.pip[data-acc="explorer"] .acc-explorer, .pip[data-acc="crown"] .acc-crown, .pip[data-acc="cape"] .acc-cape { display: inline; }
.pip[data-acc="default"][data-world="cave"][data-dark="1"] .p-lampglow { display: inline; animation: lamp 3s ease-in-out infinite alternate; }
.pip .p-scarftail, .pip .acc-cape { transform-box: fill-box; transform-origin: 0 0; }
.pip.sliding .p-scarftail { animation: flutter .2s ease-in-out infinite alternate; }
.pip.sliding .acc-cape { transform-origin: 50% 0; animation: cape .24s ease-in-out infinite alternate; }
.pip.sliding .acc-pompom circle, .pip.sliding .acc-straw { transform-box: fill-box; transform-origin: 50% 100%; animation: bob .18s ease-in-out infinite alternate; }
.pip .p-eyes, .pip .p-mouth, .pip .acc, .pip .p-cheek { transition: transform .5s var(--ease); }
.pip.sitting .p-eyes, .pip.sitting .p-mouth, .pip.sitting .acc, .pip.sitting .p-cheek, .pip.sitting .p-brows { transform: translateY(5px); }
.pip.sitting .p-fur, .pip.sitting .p-ear, .pip.sitting .p-ear-in, .pip.sitting .p-belly { transform: translateY(5px) scaleY(.93); transform-box: view-box; transform-origin: 0 0; }
.pip.shake .p-body { animation: shake .42s ease-in-out; }
.pip.gone { opacity: 0; transition: opacity .3s; }
.pip-host .pip { filter: drop-shadow(0 calc(var(--cell) * .04) calc(var(--cell) * .05) rgba(0, 0, 0, .12)); }

/* ---- motion --------------------------------------------------------------------------------- */
@keyframes view-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes view-out { to { opacity: 0; transform: translateY(-6px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { opacity: 0; transform: translateY(8px); } }
@keyframes pop { 0% { opacity: 0; transform: scale(.4); } }
@keyframes sheet-in { from { opacity: 0; transform: translateY(16px) scale(.98); } }
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 14px); } }
@keyframes star-pop { 0% { transform: scale(0); } 65% { transform: scale(1.15); } 100% { transform: scale(1); } }
@keyframes star-pop-off { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); } }
@keyframes roll-up { from { transform: translateY(100%); opacity: 0; } }
@keyframes roll-down { from { transform: translateY(-100%); opacity: 0; } }
@keyframes board-in { from { opacity: 0; } }
@keyframes bubble-in { from { opacity: 0; transform: translateX(-50%) translateY(8px) scale(.85); } }
@keyframes bubble-out { to { opacity: 0; transform: translateX(-50%) translateY(-6px) scale(.9); } }
@keyframes guide { 0%, 100% { transform: translate3d(var(--gx), var(--gy), 0) rotate(var(--gr)) translateX(0); } 50% { transform: translate3d(var(--gx), var(--gy), 0) rotate(var(--gr)) translateX(22%); } }
@keyframes glow { 0%, 100% { opacity: .45; transform: scale(.92); } 50% { opacity: .9; transform: scale(1.04); } }
@keyframes flare { 0% { opacity: .6; } 30% { opacity: 1; filter: brightness(1.6); } 100% { opacity: .9; } }
@keyframes hint-breathe { to { opacity: .55; } }
@keyframes soft-pulse { 50% { transform: scale(1.05); box-shadow: 0 0 0 6px var(--accent-soft), var(--shadow); } }
@keyframes next-pulse { 50% { box-shadow: 0 0 0 5px var(--accent-soft), var(--shadow); } }
@keyframes shimmer { to { background-position: -150% 0, 0 0; } }
@keyframes blink { 0%, 100% { transform: scaleY(0); } 45%, 55% { transform: scaleY(1); } }
@keyframes flutter { from { transform: scaleX(var(--trail)) rotate(-6deg); } to { transform: scaleX(var(--trail)) rotate(14deg) skewY(6deg); } }
@keyframes cape { to { transform: skewX(6deg) scaleY(1.04); } }
@keyframes bob { to { transform: translateY(-1.5px); } }
@keyframes shake { 0%, 100% { transform: none; } 20% { transform: rotate(-7deg); } 40% { transform: rotate(6deg); } 60% { transform: rotate(-4deg); } 80% { transform: rotate(2deg); } }
@keyframes lamp { to { opacity: .75; } }
@keyframes twinkle { 50% { opacity: .2; } }
@keyframes aurora { 0% { transform: translateX(-6%) scaleY(.8) skewX(-8deg); } 100% { transform: translateX(6%) scaleY(1.25) skewX(8deg); } }
@keyframes drift { from { transform: translateX(-30vw); } to { transform: translateX(130vw); } }
@keyframes flicker { 0% { opacity: .75; transform: scale(1); } 40% { opacity: 1; } 70% { opacity: .82; transform: scale(1.05); } 100% { opacity: .95; } }
@keyframes pulse-glow { to { opacity: .55; } }
@keyframes drip { 0% { opacity: 0; transform: translateY(0) scaleY(.6); } 12% { opacity: 1; transform: translateY(0); } 60% { opacity: 1; transform: translateY(46vh) scaleY(1.3); } 61%, 100% { opacity: 0; transform: translateY(46vh); } }
@keyframes sand { 0% { opacity: 0; transform: translateX(-20vw); } 20%, 70% { opacity: 1; } 100% { opacity: 0; transform: translateX(110vw); } }
@keyframes snow { to { background-position: 40px 260px, -30px 260px, 20px 260px, -50px 260px, 10px 260px; } }
@keyframes gift-wiggle { 25% { transform: rotate(-6deg); } 75% { transform: rotate(6deg); } }
@keyframes gift-lid { to { transform: translate(18px, -36px) rotate(28deg); opacity: 0; } }
@keyframes gift-out { to { opacity: 0; transform: scale(.6); } }

/* reduced motion: the setting or the system — crossfades instead of travel, no parallax, no shake */
:root[data-motion="reduce"] .scene *, :root[data-motion="reduce"] .scene { animation: none !important; transition: none !important; }
:root[data-motion="reduce"] .scene .layer { transform: none !important; }
:root[data-motion="reduce"] .scene .world { transition: opacity .3s !important; }
:root[data-motion="reduce"] .view.enter { animation: fade .2s both; }
:root[data-motion="reduce"] .view.leave { animation: fade .2s reverse both; }
:root[data-motion="reduce"] .result, :root[data-motion="reduce"] .sheet[open], :root[data-motion="reduce"] .toast { animation: fade .2s both; }
:root[data-motion="reduce"] .pip *, :root[data-motion="reduce"] .lvl.next, :root[data-motion="reduce"] .ctrl.pulse,
:root[data-motion="reduce"] .exit-glow, :root[data-motion="reduce"] .guide-arrow.show, :root[data-motion="reduce"] .board-hint.show,
:root[data-motion="reduce"] .skeleton, :root[data-motion="reduce"] .l-icon, :root[data-motion="reduce"] .l-cards li { animation: none !important; }
:root[data-motion="reduce"] .r-stars .star.pop { animation: fade .2s both; transform: none; }
:root[data-motion="reduce"] .ctrl.pulse { box-shadow: 0 0 0 3px var(--accent); }
:root[data-motion="reduce"] .guide-arrow.show { transform: translate3d(var(--gx), var(--gy), 0) rotate(var(--gr)); }
:root[data-motion="reduce"] .exit-glow { opacity: .8; }
