/* Hanging Snake — "rubber and ceramic": cream (or night-blue) paper, glazed indigo tiles,
   a mint rubber snake, amber fruit, coral spikes, ice-blue ice. Rounded geometry, soft drop
   shadows with an inner light, springy motion. */

:root {
  color-scheme: light;
  --bg: #f6efe0;
  --bg2: #ede2c8;
  --card: #fffaf0;
  --card2: #f8efdc;
  --text: #23264a;
  --muted: #555878;
  --line: rgba(35, 38, 74, 0.13);
  --indigo: #3d4294;
  --mint: #3fcf98;
  --mint-ink: #0f6b49;
  --amber: #f3a81e;
  --amber-ink: #7a4a00;
  --coral: #e8584e;
  --gold: #e9b10f;
  --accent: #127a57; /* deep mint: white text on it reaches 5.3:1 */
  --accent-hover: #0f6a4b;
  --ca-accent: #127a57; /* the accounts SDK's sheets and chip */
  --focus: #4b3fd0;
  --scrim: rgba(28, 24, 60, 0.38);
  --shadow: 0 14px 34px -14px rgba(40, 34, 90, 0.38), 0 2px 6px -2px rgba(40, 34, 90, 0.12);
  --shadow-s: 0 6px 16px -8px rgba(40, 34, 90, 0.4);
  --radius: 20px;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", "Quicksand", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --out: cubic-bezier(0.2, 0.8, 0.2, 1);
}
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141a35;
  --bg2: #0f1429;
  --card: #1e2549;
  --card2: #262e58;
  --text: #eef0ff;
  --muted: #b1b6de;
  --line: rgba(238, 240, 255, 0.13);
  --indigo: #7a82ec;
  --amber-ink: #ffd27a;
  --focus: #b3a8ff;
  --scrim: rgba(4, 6, 18, 0.55);
  --shadow: 0 16px 38px -14px rgba(0, 0, 0, 0.6), 0 2px 6px -2px rgba(0, 0, 0, 0.3);
  --shadow-s: 0 6px 16px -8px rgba(0, 0, 0, 0.6);
}
/* before the script has run: the system's choice */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #141a35;
    --bg2: #0f1429;
    --card: #1e2549;
    --card2: #262e58;
    --text: #eef0ff;
    --muted: #b1b6de;
    --line: rgba(238, 240, 255, 0.13);
    --indigo: #7a82ec;
    --amber-ink: #ffd27a;
    --focus: #b3a8ff;
    --scrim: rgba(4, 6, 18, 0.55);
    --shadow: 0 16px 38px -14px rgba(0, 0, 0, 0.6), 0 2px 6px -2px rgba(0, 0, 0, 0.3);
    --shadow-s: 0 6px 16px -8px rgba(0, 0, 0, 0.6);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; height: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-user-select: none; user-select: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ico { width: 24px; height: 24px; display: block; flex: none; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

#app { height: 100dvh; }
.screen { position: relative; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }

/* ---- shared controls ---------------------------------------------------------------- */
.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(10px + var(--safe-t)) calc(14px + var(--safe-r)) 10px calc(14px + var(--safe-l));
  position: relative; z-index: 3;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-icon { width: 34px; height: 34px; border-radius: 10px; flex: none; box-shadow: var(--shadow-s); }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.brand-title { font-weight: 800; font-size: 18px; letter-spacing: -0.01em; 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-tools { display: flex; align-items: center; gap: 6px; flex: none; }
.icon-btn {
  position: relative; width: 44px; height: 44px; border-radius: 14px; border: 0;
  display: grid; place-items: center; background: var(--card); color: var(--text);
  box-shadow: var(--shadow-s); transition: transform 0.18s var(--spring), background 0.2s;
}
.icon-btn:hover { background: var(--card2); }
.icon-btn:active { transform: scale(0.92); }
.chip-slot { display: inline-flex; min-width: 36px; }
.chip-host { display: inline-flex; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px; border-radius: 16px; border: 0;
  background: var(--card); color: var(--text); font-weight: 700; font-size: 16px;
  box-shadow: var(--shadow-s); transition: transform 0.18s var(--spring), background 0.2s, box-shadow 0.2s;
  max-width: 100%;
}
.btn:hover { background: var(--card2); }
.btn:active { transform: scale(0.96); }
.btn.primary { background: var(--accent); color: #fff; box-shadow: 0 10px 22px -10px rgba(18, 122, 87, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.25); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.big { min-height: 56px; padding: 0 30px; font-size: 18px; border-radius: 18px; }
.btn.link { background: none; box-shadow: none; color: var(--text); text-decoration: underline; text-underline-offset: 3px; min-height: 44px; font-weight: 600; }
.btn.ghost { background: transparent; box-shadow: inset 0 0 0 2px var(--line); }
.btn.wide { width: 100%; }

.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 14px; background: var(--card2); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.08); }
.seg button { border: 0; background: none; min-height: 40px; min-width: 44px; padding: 0 12px; border-radius: 11px; font-weight: 700; color: var(--muted); transition: background 0.2s, color 0.2s; }
.seg button[aria-checked="true"] { background: var(--card); color: var(--text); box-shadow: var(--shadow-s); }
.seg-small button { min-height: 36px; min-width: 40px; font-size: 13px; }

/* ---- the landing page ------------------------------------------------------------------ */
.landing { background: radial-gradient(120% 90% at 50% 20%, #fff7e6 0%, var(--bg) 55%, var(--bg2) 100%); overflow-y: auto; }
[data-theme="dark"] .landing { background: radial-gradient(120% 90% at 50% 20%, #232b57 0%, var(--bg) 55%, var(--bg2) 100%); }
.land-demo, .land-stills { position: absolute; left: 0; right: 0; top: calc(58px + var(--safe-t)); height: min(46%, 440px); width: 100%; }
.land-stills canvas { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; animation: still-fade 12s infinite; }
.land-stills canvas:nth-child(2) { animation-delay: 4s; }
.land-stills canvas:nth-child(3) { animation-delay: 8s; }
@keyframes still-fade { 0%, 100% { opacity: 0; } 8%, 33% { opacity: 1; } 41% { opacity: 0; } }
.land-veil { display: none; }
.land-bar {
  position: relative; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(12px + var(--safe-t)) calc(16px + var(--safe-r)) 8px calc(16px + var(--safe-l));
}
.land-hero {
  position: relative; z-index: 2; flex: 1 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  text-align: center; gap: 8px; padding: calc(min(46dvh, 440px) - 30px) calc(20px + var(--safe-r)) calc(22px + var(--safe-b)) calc(20px + var(--safe-l));
  max-width: 560px; margin: 0 auto; width: 100%;
}
@media (min-width: 760px) and (min-aspect-ratio: 1/1) {
  .land-demo, .land-stills { top: 0; bottom: 0; height: 100%; width: 56%; right: auto; }
  .land-hero { padding-top: 24px; justify-content: center; margin: 0 3% 0 auto; width: 44%; max-width: 520px; }
}
.land-hero > * { animation: rise 0.7s var(--out) both; }
.land-hero > :nth-child(2) { animation-delay: 0.06s; }
.land-hero > :nth-child(3) { animation-delay: 0.12s; }
.land-hero > :nth-child(4) { animation-delay: 0.16s; }
.land-hero > :nth-child(5) { animation-delay: 0.22s; }
.land-hero > :nth-child(6), .land-hero > :nth-child(7) { animation-delay: 0.28s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
.land-title { margin: 0; font-size: clamp(38px, 11vw, 64px); line-height: 1; font-weight: 900; letter-spacing: -0.03em; color: var(--text); text-shadow: 0 2px 0 var(--card), 0 10px 30px color-mix(in srgb, var(--bg) 70%, transparent); }
.land-lead { margin: 4px 0 10px; font-size: clamp(17px, 4.6vw, 21px); font-weight: 600; max-width: 30ch; }
.land-cards { list-style: none; padding: 0; margin: 14px 0 6px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; width: 100%; }
.land-card {
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 8px; border-radius: 18px;
  background: color-mix(in srgb, var(--card) 88%, transparent); box-shadow: var(--shadow-s); font-size: 14px; font-weight: 700; line-height: 1.25;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.land-card .ico { width: 30px; height: 30px; color: var(--accent); }
[data-theme="dark"] .land-card .ico { color: var(--mint); }
.land-card:nth-child(2) .ico { color: var(--indigo); }
.land-card:nth-child(3) .ico { color: #c4561c; }
[data-theme="dark"] .land-card:nth-child(3) .ico { color: var(--amber); }
.land-note, .land-offline { margin: 6px 0 0; font-size: 14px; color: var(--muted); max-width: 42ch; background: color-mix(in srgb, var(--bg) 70%, transparent); border-radius: 10px; padding: 2px 8px; }
.land-offline { color: var(--text); font-weight: 600; }
@media (max-width: 380px) { .land-cards { grid-template-columns: 1fr; } .land-card { flex-direction: row; justify-content: flex-start; text-align: left; padding: 10px 14px; } }

/* ---- the world map ---------------------------------------------------------------------- */
.map { background: linear-gradient(180deg, #e9eefc 0%, #f4eefc 18%, #e3f4fb 38%, #f8ead2 58%, #e3eaf8 76%, #eef3d6 100%); }
[data-theme="dark"] .map { background: linear-gradient(180deg, #241d40 0%, #1d1c3c 18%, #0f2536 38%, #2a1d17 58%, #111a37 76%, #172a26 100%); }
.map .bar { background: linear-gradient(180deg, color-mix(in srgb, var(--bg) 92%, transparent), color-mix(in srgb, var(--bg) 0%, transparent)); }
.daily-btn .tick { position: absolute; right: -4px; top: -4px; width: 20px; height: 20px; border-radius: 50%; background: #127a57; color: #fff; display: grid; place-items: center; box-shadow: 0 0 0 2px var(--card); }
.daily-btn .tick .ico { width: 14px; height: 14px; }
.star-count { display: inline-flex; align-items: center; gap: 4px; height: 44px; padding: 0 12px 0 10px; border-radius: 14px; background: var(--card); box-shadow: var(--shadow-s); font-weight: 800; }
.star-count .ico { width: 20px; height: 20px; color: var(--gold); }
.star-count .of { color: var(--muted); font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; }
.map-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scroll-behavior: auto; -webkit-overflow-scrolling: touch; }
.map-inner { position: relative; margin: 0 auto; width: 100%; max-width: 520px; padding-bottom: calc(30px + var(--safe-b)); }
.island { position: relative; height: 760px; }
.island-art { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.island-name {
  position: absolute; left: 50%; transform: translateX(-50%); top: 26px; z-index: 2;
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 999px;
  background: color-mix(in srgb, var(--card) 92%, transparent); box-shadow: var(--shadow-s); font-weight: 800; font-size: 17px; white-space: nowrap;
}
.island-name .wstars { display: inline-flex; align-items: center; gap: 2px; color: var(--muted); font-size: 14px; font-weight: 700; }
.island-name .wstars .ico { width: 16px; height: 16px; color: var(--gold); }
.island.locked .island-art { opacity: 0.55; filter: saturate(0.5); }
.island-lock {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 3;
  display: inline-flex; align-items: center; gap: 10px; padding: 12px 18px; border-radius: 18px;
  background: var(--card); box-shadow: var(--shadow); font-weight: 800; font-size: 20px;
}
.island-lock .ico { width: 22px; height: 22px; color: var(--muted); }
.island-lock .bar-mini { width: 70px; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.island-lock .bar-mini i { display: block; height: 100%; width: var(--p, 0%); background: var(--accent); border-radius: 4px; }
.node {
  position: absolute; z-index: 2; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%; border: 0; padding: 0;
  display: grid; place-items: center; background: var(--card); color: var(--text); font-weight: 800; font-size: 15px;
  box-shadow: 0 6px 0 -1px color-mix(in srgb, var(--indigo) 55%, transparent), var(--shadow-s);
  transition: transform 0.2s var(--spring);
}
.node:hover { transform: translateY(-2px) scale(1.04); }
.node:active { transform: scale(0.94); }
.node.locked { background: color-mix(in srgb, var(--card) 55%, transparent); color: var(--muted); box-shadow: none; cursor: default; }
.node.locked .ico { width: 18px; height: 18px; opacity: 0.7; }
.node.open::before {
  content: ""; position: absolute; inset: -7px; border-radius: 50%; border: 3px solid var(--accent);
  animation: ring-pulse 1.6s ease-in-out infinite;
}
[data-theme="dark"] .node.open::before { border-color: var(--mint); }
@keyframes ring-pulse { 0%, 100% { transform: scale(0.92); opacity: 0.9; } 50% { transform: scale(1.08); opacity: 0.35; } }
.node.solved { background: linear-gradient(180deg, var(--card) 0%, var(--card2) 100%); }
.node.parx { box-shadow: 0 0 0 3px var(--gold), 0 6px 0 -1px color-mix(in srgb, var(--gold) 60%, transparent), var(--shadow-s); }
.node .nstars { position: absolute; top: -12px; left: 50%; transform: translateX(-50%); display: flex; gap: 0; }
.node .nstars .ico { width: 15px; height: 15px; color: var(--line); }
.node .nstars .ico.on { color: var(--gold); filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.2)); }
.node { grid-template-rows: auto auto; align-content: center; gap: 0; line-height: 1.05; }
.node .nbest { font-size: 11.5px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.node.current { animation: node-bob 2.4s ease-in-out infinite; }
@keyframes node-bob { 0%, 100% { translate: 0 0; } 50% { translate: 0 -3px; } }
.map.finale .island-art { animation: glow 3s ease-in-out 1; }
@keyframes glow { 0%, 100% { filter: none; } 40% { filter: brightness(1.35) saturate(1.3) drop-shadow(0 0 18px #ffd25a); } }

/* ---- the game screen ---------------------------------------------------------------------- */
.game { --g1: #f6f3cc; --g2: #d9efc2; background: linear-gradient(170deg, var(--g1) 0%, var(--g2) 100%); }
.game[data-world="2"] { --g1: #e3e8f8; --g2: #c7d1ee; }
.game[data-world="3"] { --g1: #faebcf; --g2: #f0d1a2; }
.game[data-world="4"] { --g1: #e6f7fc; --g2: #c6e9f5; }
.game[data-world="5"] { --g1: #f8e8f3; --g2: #dde6fb; }
.game[data-world="0"] { --g1: #eee8f9; --g2: #ddd2f3; }
[data-theme="dark"] .game { --g1: #1d2a31; --g2: #142a22; }
[data-theme="dark"] .game[data-world="2"] { --g1: #151c3c; --g2: #0c1230; }
[data-theme="dark"] .game[data-world="3"] { --g1: #2c1e19; --g2: #321f10; }
[data-theme="dark"] .game[data-world="4"] { --g1: #102536; --g2: #0b2b3c; }
[data-theme="dark"] .game[data-world="5"] { --g1: #261d3c; --g2: #1a2342; }
[data-theme="dark"] .game[data-world="0"] { --g1: #211a3d; --g2: #251b47; }
.bg-shapes { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.bg-shapes i {
  position: absolute; display: block; width: 90px; height: 90px; border-radius: 26px;
  background: color-mix(in srgb, #ffffff 40%, transparent); opacity: 0.55;
  animation: drift 28s ease-in-out infinite alternate;
}
[data-theme="dark"] .bg-shapes i { background: color-mix(in srgb, #ffffff 6%, transparent); }
.bg-shapes i:nth-child(1) { left: 6%; top: 12%; }
.bg-shapes i:nth-child(2) { left: 78%; top: 8%; width: 60px; height: 60px; border-radius: 50%; animation-duration: 34s; }
.bg-shapes i:nth-child(3) { left: 64%; top: 70%; width: 120px; height: 120px; animation-duration: 40s; animation-delay: -8s; }
.bg-shapes i:nth-child(4) { left: 14%; top: 78%; width: 70px; height: 70px; border-radius: 50%; animation-duration: 31s; animation-delay: -4s; }
.bg-shapes i:nth-child(5) { left: 44%; top: 4%; width: 46px; height: 46px; clip-path: polygon(50% 0, 100% 100%, 0 100%); border-radius: 0; animation-duration: 36s; }
.bg-shapes i:nth-child(6) { left: 88%; top: 44%; width: 54px; height: 54px; animation-duration: 29s; animation-delay: -12s; }
.bg-shapes i:nth-child(7) { left: 2%; top: 46%; width: 40px; height: 40px; clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); border-radius: 0; animation-duration: 38s; }
.bg-shapes i:nth-child(8) { left: 36%; top: 86%; width: 64px; height: 64px; border-radius: 50%; animation-duration: 33s; animation-delay: -16s; }
@keyframes drift { from { transform: translate3d(0, 0, 0) rotate(0deg); } to { transform: translate3d(26px, -34px, 0) rotate(28deg); } }

.game-bar {
  position: relative; z-index: 3; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px;
  padding: calc(8px + var(--safe-t)) calc(12px + var(--safe-r)) 4px calc(12px + var(--safe-l));
}
.g-title { text-align: center; min-width: 0; line-height: 1.15; }
.g-label { display: inline-flex; align-items: center; gap: 8px; font-weight: 900; font-size: 20px; letter-spacing: 0.01em; }
.g-dots { display: inline-flex; gap: 3px; }
.g-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.g-dots i.on { background: var(--text); }
.g-count { font-size: 15px; font-weight: 700; color: var(--muted); display: flex; justify-content: center; gap: 5px; align-items: baseline; }
.g-count #g-moves { color: var(--text); font-size: 17px; font-weight: 800; }
.g-count #g-moves.bump { animation: bump 0.22s var(--spring); }
@keyframes bump { 50% { transform: scale(1.18); } }
.g-sub { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.g-right { display: flex; align-items: center; gap: 6px; }
#g-hint.thinking .ico { animation: think 0.9s ease-in-out infinite; }
@keyframes think { 50% { transform: scale(0.85); opacity: 0.6; } }
#g-hint.shake { animation: shake 0.42s ease-in-out; }
@keyframes shake { 20% { transform: rotate(-12deg); } 40% { transform: rotate(10deg); } 60% { transform: rotate(-8deg); } 80% { transform: rotate(5deg); } }
#g-hint.used { color: #b77900; }
[data-theme="dark"] #g-hint.used { color: var(--amber); }
.g-stage { position: relative; z-index: 1; flex: 1; min-height: 0; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.g-stage.pointing { cursor: pointer; }
.g-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.g-controls {
  position: relative; z-index: 3; display: flex; justify-content: center; gap: 44px;
  padding: 8px calc(16px + var(--safe-r)) calc(14px + var(--safe-b)) calc(16px + var(--safe-l));
}
.round-btn {
  position: relative; width: 56px; height: 56px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: var(--card); color: var(--text); box-shadow: 0 5px 0 -1px color-mix(in srgb, var(--indigo) 40%, transparent), var(--shadow-s);
  transition: transform 0.16s var(--spring), opacity 0.25s; touch-action: manipulation;
}
.round-btn .ico { width: 26px; height: 26px; }
.round-btn:active { transform: translateY(3px) scale(0.95); box-shadow: 0 2px 0 -1px color-mix(in srgb, var(--indigo) 40%, transparent); }
.round-btn.faded { opacity: 0.4; }
.round-btn.pulse { animation: soft-pulse 1.2s ease-in-out infinite; }
@keyframes soft-pulse { 0%, 100% { box-shadow: 0 5px 0 -1px color-mix(in srgb, var(--indigo) 40%, transparent), 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); } 50% { box-shadow: 0 5px 0 -1px color-mix(in srgb, var(--indigo) 40%, transparent), 0 0 0 10px color-mix(in srgb, var(--accent) 0%, transparent); transform: scale(1.06); } }
.round-btn.badge::after { content: ""; position: absolute; top: 2px; right: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 3px var(--card); }
.g-undo-arrow { position: absolute; z-index: 4; bottom: calc(80px + var(--safe-b)); left: calc(50% - 50px - 20px); width: 40px; height: 40px; color: var(--accent); opacity: 0.75; pointer-events: none; animation: arrow-bob 0.9s ease-in-out infinite; }
[data-theme="dark"] .g-undo-arrow { color: var(--mint); }
@keyframes arrow-bob { 50% { transform: translateY(8px); } }
.g-egg, .g-error { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; font-weight: 700; color: var(--text); padding: 20px; }
.egg { width: 86px; height: 96px; animation: wobble 1.1s ease-in-out infinite; transform-origin: 50% 90%; }
.egg-shell { fill: #fff7e8; stroke: var(--indigo); stroke-width: 3; }
.egg-crack { fill: none; stroke: var(--indigo); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.egg-eye { fill: var(--indigo); }
@keyframes wobble { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-8deg); } 75% { transform: rotate(8deg); } }

/* ---- sheets ---------------------------------------------------------------------------------- */
dialog { color: var(--text); }
.sheet, .panel-sheet {
  border: 0; padding: 0; background: var(--card); color: var(--text); box-shadow: var(--shadow);
  max-width: min(560px, 100vw); width: 100%; max-height: min(88dvh, 820px); overflow: hidden;
  opacity: 0; transform: translateY(24px) scale(0.985); transition: opacity 0.2s var(--out), transform 0.28s var(--out);
}
.sheet { border-radius: 26px; margin: auto; }
.sheet.in, .panel-sheet.in { opacity: 1; transform: none; }
.sheet.out, .panel-sheet.out { opacity: 0; transform: translateY(18px); }
.sheet::backdrop, .panel-sheet::backdrop { background: var(--scrim); -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); }
.sheet.small { max-width: 380px; }
.sheet-in { display: flex; flex-direction: column; max-height: inherit; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 18px 8px 22px; }
.sheet-head h2 { margin: 0; font-size: 21px; font-weight: 850; letter-spacing: -0.01em; }
.sheet-body { overflow-y: auto; padding: 6px 22px calc(22px + var(--safe-b)); overscroll-behavior: contain; }
@media (max-width: 600px) {
  .sheet { margin: auto 0 0; max-width: 100vw; border-radius: 26px 26px 0 0; max-height: 92dvh; transform: translateY(40px); }
  .sheet.small { margin: auto 0 0; max-width: 100vw; }
}
.row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); min-height: 56px; }
.row:last-child { border-bottom: 0; }
.row > label, .row > .row-label { font-weight: 700; flex: 1; min-width: 0; }
.row .hint { display: block; font-weight: 500; font-size: 13px; color: var(--muted); }
.row .seg { flex-wrap: wrap; justify-content: flex-end; }
.range { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 0 1 230px; }
.range output { min-width: 4.5ch; text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; color: var(--muted); }
input[type="range"] { flex: 1; min-width: 90px; accent-color: var(--accent); height: 32px; }
.switch { position: relative; width: 56px; height: 34px; flex: none; appearance: none; -webkit-appearance: none; border-radius: 999px; background: var(--line); transition: background 0.2s; cursor: pointer; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 28px; height: 28px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25); transition: transform 0.25s var(--spring); }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(22px); }
select.select { min-height: 44px; padding: 0 12px; border-radius: 12px; border: 0; background: var(--card2); font-weight: 700; }
.about { margin-top: 10px; padding: 16px; border-radius: 18px; background: var(--card2); display: grid; gap: 10px; }
.about p { margin: 0; color: var(--muted); font-size: 14.5px; }
.about .ver { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--text); }
.about .btns { display: flex; flex-wrap: wrap; gap: 8px; }

/* menu (Esc) */
.menu-list { display: grid; gap: 10px; }
.menu-list .btn { justify-content: flex-start; width: 100%; }

/* ---- the result panel ------------------------------------------------------------------------- */
.panel-sheet { border-radius: 28px; margin: auto auto calc(10px + var(--safe-b)); max-width: min(440px, calc(100vw - 20px)); overflow-y: auto; }
.panel-sheet::backdrop { background: color-mix(in srgb, var(--scrim) 55%, transparent); -webkit-backdrop-filter: none; backdrop-filter: none; }
.panel { position: relative; padding: 20px 20px 18px; display: grid; gap: 12px; text-align: center; overflow: hidden; }
.panel h2 { margin: 0; font-size: 24px; font-weight: 900; }
.panel .stars { display: flex; justify-content: center; gap: 10px; height: 54px; align-items: flex-end; }
.panel .stars .ico { width: 46px; height: 46px; color: var(--line); transition: none; }
.panel .stars .ico.on { color: var(--gold); filter: drop-shadow(0 3px 0 rgba(120, 80, 0, 0.25)); }
.panel .stars .ico:nth-child(2) { width: 54px; height: 54px; }
.panel .stars .ico.pop { animation: star-pop 0.42s var(--spring) both; }
@keyframes star-pop { 0% { transform: scale(0) rotate(-40deg); } 100% { transform: none; } }
.panel .result { display: flex; justify-content: center; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 18px; font-weight: 800; }
.panel .result .diff { color: var(--muted); font-weight: 700; }
.par-badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; background: var(--gold); color: #3d2a00; font-weight: 900; font-size: 15px; letter-spacing: 0.04em; }
.par-badge.pop { animation: star-pop 0.4s var(--spring) both; }
.panel .hinted { display: flex; align-items: center; justify-content: center; gap: 6px; color: var(--muted); font-size: 14px; font-weight: 600; }
.panel .hinted .ico { width: 18px; height: 18px; color: #b77900; flex: none; }
.panel .late { color: var(--muted); font-size: 14px; }
.panel .daily-info { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.panel .info-box { background: var(--card2); border-radius: 14px; padding: 8px; }
.panel .info-box b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.panel .info-box span { font-size: 13px; color: var(--muted); font-weight: 600; }
.panel .actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.panel .actions .btn { flex: 1 1 auto; min-width: 0; padding: 0 14px; }
.panel .actions .btn.primary { flex: 2 1 auto; }
.panel .sweep { position: absolute; inset: 0; pointer-events: none; background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.65) 48%, transparent 66%); transform: translateX(-120%); }
.panel .sweep.go { animation: sweep 1.2s ease-in-out 1; }
@keyframes sweep { to { transform: translateX(120%); } }
.skin-card { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 18px; background: var(--card2); text-align: left; animation: rise 0.5s var(--spring) both; }
.skin-card canvas { width: 64px; height: 64px; flex: none; }
.skin-card .t { flex: 1; min-width: 0; }
.skin-card .t b { display: block; font-size: 17px; }
.skin-card .t span { color: var(--muted); font-size: 14px; }
.panel .watch { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.panel .watch .btn { min-height: 40px; font-size: 14px; padding: 0 14px; }

/* ---- friends' boards ------------------------------------------------------------------------- */
.friends h3 { margin: 4px 0 6px; font-size: 14px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); display: flex; justify-content: center; gap: 8px; align-items: center; }
.friends h3 .tag { text-transform: none; letter-spacing: 0; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--card2); }
.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; min-height: 120px; align-content: start; }
.rows li { display: grid; grid-template-columns: 26px 32px minmax(64px, 1fr) auto auto; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 12px; text-align: left; min-height: 44px; }
.rows li.with-act { grid-template-columns: 26px 32px minmax(64px, 1fr) auto auto auto; }
.rows li.me { background: color-mix(in srgb, var(--accent) 14%, var(--card)); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 45%, transparent); }
.rows li.gap { min-height: 10px; padding: 0; display: block; text-align: center; color: var(--muted); line-height: 1; }
.rows .rank { font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.rows .ava { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 15px; background: var(--c, #6b5fd6); }
.rows .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 700; }
.rows .name .heart { display: inline-block; width: 14px; height: 14px; vertical-align: -2px; color: #e2475a; margin-left: 4px; }
.rows .score { font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rows .rstars { display: inline-flex; }
.rows .rstars .ico { width: 14px; height: 14px; color: var(--line); }
.rows .rstars .ico.on { color: var(--gold); }
.rows .rtick .ico { width: 18px; height: 18px; color: #1f9d64; }
.rows .act { width: 36px; height: 36px; border-radius: 10px; border: 0; background: var(--card2); display: grid; place-items: center; color: var(--text); }
.rows .act .ico { width: 18px; height: 18px; }
.rows .act[aria-disabled="true"] { opacity: 0.55; cursor: default; }
.rows.loading li.sk { background: var(--card2); animation: sk 1.2s ease-in-out infinite; }
@keyframes sk { 50% { opacity: 0.5; } }
.board-msg { display: grid; justify-items: center; gap: 8px; padding: 14px 6px; color: var(--muted); font-weight: 600; text-align: center; min-height: 120px; align-content: center; }
.board-msg .btn { min-height: 40px; }
.board-msg svg.happy { width: 96px; height: 64px; }
.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--card2); margin-bottom: 12px; overflow-x: auto; }
.tabs button { flex: 1 0 auto; border: 0; background: none; min-height: 40px; padding: 0 12px; border-radius: 11px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.tabs button[aria-selected="true"] { background: var(--card); color: var(--text); box-shadow: var(--shadow-s); }
.picker { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.picker b { font-size: 17px; text-align: center; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picker .icon-btn { box-shadow: none; background: var(--card2); }
.board-note { font-size: 13px; color: var(--muted); text-align: center; margin: 12px 0 0; }
.par-run { display: flex; justify-content: center; margin-top: 10px; }

/* ---- skins ------------------------------------------------------------------------------------- */
.skins-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.skin {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 6px 10px; border-radius: 18px; border: 0;
  background: var(--card2); color: var(--text); text-align: center; min-height: 150px; transition: transform 0.2s var(--spring), box-shadow 0.2s;
}
.skin:hover { transform: translateY(-2px); }
.skin canvas { width: 74px; height: 74px; }
.skin b { font-size: 15px; }
.skin small { font-size: 12px; color: var(--muted); line-height: 1.25; }
.skin .prog { font-size: 12.5px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--text); }
.skin.worn { box-shadow: inset 0 0 0 3px var(--accent); }
.skin.locked canvas { filter: grayscale(1) brightness(0.55) contrast(0.6); opacity: 0.55; }
[data-theme="dark"] .skin.locked canvas { filter: grayscale(1) brightness(1.6) contrast(0.4); opacity: 0.4; }
.skin .worn-tag { position: absolute; top: 8px; right: 8px; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; }
.skin .worn-tag .ico { width: 14px; height: 14px; }
.skin .lock-tag { position: absolute; top: 8px; right: 8px; color: var(--muted); }
.skin .lock-tag .ico { width: 16px; height: 16px; }
.skin.hop canvas { animation: hop 0.6s var(--spring) 2; }
@keyframes hop { 40% { transform: translateY(-12px) scaleY(1.06); } 70% { transform: translateY(0) scaleY(0.92); } }

/* ---- statistics --------------------------------------------------------------------------------- */
.stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat { background: var(--card2); border-radius: 18px; padding: 14px; display: grid; gap: 2px; }
.stat b { font-size: 26px; font-weight: 900; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat b small { font-size: 15px; color: var(--muted); font-weight: 700; }
.stat span { color: var(--muted); font-size: 14px; font-weight: 600; }

/* ---- help --------------------------------------------------------------------------------------- */
.loops { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.loop { border-radius: 18px; overflow: hidden; background: linear-gradient(170deg, var(--g1, #f6f3cc), var(--g2, #d9efc2)); aspect-ratio: 4 / 3; position: relative; }
.loop canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.loop:nth-child(2) { --g1: #e3e8f8; --g2: #c7d1ee; }
.loop:nth-child(3) { --g1: #faebcf; --g2: #f0d1a2; }
.loop:nth-child(4) { --g1: #e6f7fc; --g2: #c6e9f5; }
[data-theme="dark"] .loop { --g1: #1d2a31; --g2: #142a22; }
[data-theme="dark"] .loop:nth-child(2) { --g1: #151c3c; --g2: #0c1230; }
[data-theme="dark"] .loop:nth-child(3) { --g1: #2c1e19; --g2: #321f10; }
[data-theme="dark"] .loop:nth-child(4) { --g1: #102536; --g2: #0b2b3c; }
.help h3 { margin: 16px 0 8px; font-size: 17px; }
.ctrl { display: grid; gap: 12px; }
.ctrl section { background: var(--card2); border-radius: 16px; padding: 12px 14px; }
.ctrl h4 { margin: 0 0 6px; font-size: 14px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.ctrl ul { margin: 0; padding-left: 18px; display: grid; gap: 4px; font-size: 15px; }
.faq details { border-bottom: 1px solid var(--line); padding: 10px 0; }
.faq summary { font-weight: 700; cursor: pointer; min-height: 32px; display: flex; align-items: center; }
.faq p { margin: 6px 0 2px; color: var(--muted); }
@media (min-width: 720px) { .ctrl { grid-template-columns: repeat(3, minmax(0, 1fr)); } .loops { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* ---- small screens --------------------------------------------------------------------------------- */
@media (max-width: 359px) {
  .brand-sub, .brand-title { display: none; }
  .g-label .g-id { font-size: 16px; }
  .icon-btn { width: 40px; height: 40px; }
  .star-count { padding: 0 8px; }
  .game-bar { gap: 4px; }
}
@media (max-width: 420px) { .brand-sub { display: none; } }
@media (max-width: 460px) { .map .brand-text { display: none; } }
@media (max-height: 480px) and (orientation: landscape) {
  .game { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto 1fr; }
  .game-bar { grid-column: 1 / -1; }
  .g-stage { grid-column: 1; grid-row: 2; }
  .g-controls { grid-column: 2; grid-row: 2; flex-direction: column; justify-content: center; gap: 28px; padding: 8px calc(14px + var(--safe-r)) calc(10px + var(--safe-b)) 6px; }
  .g-undo-arrow { display: none; }
  .island { height: 700px; }
}

/* ---- reduced motion: crossfades instead of travel, nothing drifts --------------------------------- */
.reduced *, .reduced *::before, .reduced *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.12s !important; transition-property: opacity, background, color !important; }
.reduced .bg-shapes { display: none; }
.reduced .land-stills canvas { animation: still-fade 12s infinite !important; animation-duration: 12s !important; animation-iteration-count: infinite !important; }
.reduced .sheet, .reduced .panel-sheet { transform: none !important; }
@media (prefers-reduced-motion: reduce) { html:not(.motion-full) .bg-shapes { display: none; } }
