:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #344e5c;
  background: #f8fbf5;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: #f8fbf5;
  overscroll-behavior: none;
}
.game {
  width: min(100%, 480px);
  height: 100svh;
  min-height: 0;
  margin: 0 auto;
  padding: max(22px, env(safe-area-inset-top)) 12px max(16px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
  background: #fbf7e9;
}
body.is-playing { height: 100svh; overflow: hidden; }
.header { display: flex; align-items: center; justify-content: space-between; padding: 2px 2px 6px; }
.eyebrow { margin: 0 0 8px; font-size: 9px; font-weight: 650; letter-spacing: 1.7px; color: #607681; }
h1 { margin: 0; font-size: clamp(28px, 8vw, 34px); line-height: 1; letter-spacing: -1.6px; font-weight: 800; }
.title-dot { color: #a4ee70; }
.slime-mark { width: 44px; height: 20px; border-radius: 9px; background: #a4ee70; display: flex; gap: 5px; align-items: center; justify-content: center; transform: rotate(-8deg); }
.slime-mark i { width: 4px; height: 5px; border-radius: 50%; background: #20361b; }
.level-bar { display: flex; justify-content: space-between; align-items: center; padding: 0 2px; color: #607681; font-size: 10px; letter-spacing: 1.5px; }
.level-bar b { color: #344e5c; font-weight: 600; }
.divider { padding: 0 10px; color: #8ba7b1; }
.goal-key { display: inline-flex; align-items: center; gap: 7px; font-size: 11px; letter-spacing: 0; }
.goal-key i { width: 7px; height: 7px; border: 1px solid #a47826; background: #f5ce75; transform: rotate(45deg); }
.board-slot { min-width: 0; min-height: 0; display: flex; justify-content: center; align-items: center; }
.board-wrap { overflow: hidden; border-radius: 14px; background: transparent; }
canvas { display: block; width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; outline: none; }
.footer { padding: 0 2px; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.moves { display: flex; align-items: baseline; gap: 7px; font-size: 12px; color: #607681; }
.moves strong { color: #344e5c; font-size: 25px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -1px; }
.actions { display: flex; gap: 8px; }
button { min-height: 44px; padding: 0 12px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid #c9dde1; border-radius: 12px; color: #344e5c; background: #ffffffb3; font: inherit; font-size: 12px; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: background 120ms; }
button:hover:enabled { background: #e2f1f3; }
button:active:enabled { background: #d3e8ed; }
button:focus { outline: none; }
button:focus-visible { outline: 2px solid #8ba451; outline-offset: 3px; }
button:disabled { opacity: .35; cursor: default; }
button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.status { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.status.won { color: #87621e; }
@media (max-height: 650px) {
  .game { gap: 8px; padding-top: max(12px, env(safe-area-inset-top)); padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .eyebrow { display: none; }
  h1 { font-size: 27px; }
}
@media (prefers-reduced-motion: reduce) { button { transition: none; } }

/* Menus are HTML/CSS first: visible before JavaScript or forest images load. */
[hidden] { display: none !important; }
.menu-screen {
  min-height: 100svh;
  padding: max(36px, env(safe-area-inset-top)) 26px max(24px, env(safe-area-inset-bottom));
  background: radial-gradient(ellipse at 15% 10%, #f9dca36b, transparent 52%),
    radial-gradient(ellipse at 90% 85%, #cbd79730, transparent 52%), #fbf7e9;
  color: #3e4c30;
}
.home-screen { position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; padding-bottom: max(76px, env(safe-area-inset-bottom)); }
.menu-content { position: relative; width: min(100%, 360px); text-align: center; }
.menu-kicker { margin: 0 0 12px; color: #8a7751; font-size: 9px; font-weight: 650; letter-spacing: 2px; }
.menu-title { position: relative; font-size: clamp(38px, 10.6vw, 53px); line-height: 1.1; letter-spacing: -2.6px; }
.menu-title span { color: #9fbe35; }
.menu-title:focus, .section-title:focus { outline: none; }
.menu-subtitle { position: relative; margin: 14px 0 0; font-size: 13px; color: #81785e; line-height: 1.7; }
.menu-character { position: relative; height: 184px; margin: 22px -6px 18px; }
#menu-slime { pointer-events: none; touch-action: auto; position: absolute; width: 320px; height: auto; max-width: 100%; left: 50%; top: 12px; transform: translateX(-50%); }
#menu-slime.hero-entering { animation: squish-arrive 1400ms both; will-change: transform; }
@keyframes squish-arrive {
  0% { transform: translateX(calc(-50% - var(--arrival-distance, 100vw))); animation-timing-function: cubic-bezier(.18, .62, .32, 1); }
  70% { transform: translateX(calc(-50% - 3px)); animation-timing-function: cubic-bezier(.2, .8, .3, 1); }
  86% { transform: translateX(calc(-50% + 2px)); animation-timing-function: ease-out; }
  100% { transform: translateX(-50%); }
}
.menu-leaves { position: absolute; inset: 0; pointer-events: none; }
.menu-leaf { position: absolute; width: 55px; height: 55px; background: url('assets/menu-leaves.webp') no-repeat; background-size: 400% 100%; filter: drop-shadow(1px 3px 2px #9e6b2320); }
.leaf-one { left: 5px; top: -67px; transform: rotate(-28deg); background-position: 0% 0; }
.leaf-two { right: -15px; top: 83px; width: 43px; height: 43px; transform: rotate(24deg); background-position: 33.3333% 0; }
.leaf-three { left: -19px; top: 237px; width: 62px; height: 62px; transform: rotate(-42deg); background-position: 100% 0; }
.leaf-four { right: 3px; top: 181px; width: 50px; height: 50px; transform: rotate(17deg); background-position: 66.6667% 0; }
.menu-actions { position: relative; display: grid; gap: 13px; }
.menu-button {
  min-height: 60px; width: 100%; padding: 0 23px; justify-content: center;
  border: 1px solid #d6d4b0; border-radius: 23px 27px 24px 26px / 26px 24px 28px 23px;
  background: linear-gradient(175deg, #fffef8, #f8f5e5);
  color: #536039; font-size: 18px; font-weight: 700;
  box-shadow: 0 4px 0 #d9d4ad80, 0 6px 11px #9b864f0d, inset 0 2px 1px #fff9;
  transform-origin: center; transition: transform 190ms cubic-bezier(.2, 1.5, .45, 1), box-shadow 190ms ease, background 150ms ease;
}
.menu-button.primary { background: linear-gradient(175deg, #d0e96b, #b7d448 65%, #abc83f); border-color: #a5c238; color: #344b1c; box-shadow: 0 5px 0 #8da63266, 0 9px 15px #8e9e2420, inset 0 2px 1px #eff6ae99; }
.menu-button:hover:enabled { background: linear-gradient(175deg, #fffef9, #f4f1da); }
.menu-button.primary:hover:enabled { background: linear-gradient(175deg, #d9ed7b, #c3dd59 65%, #b4ce49); }
.menu-button:active:enabled { transform: translateY(2px) scale(1.012, .97); box-shadow: 0 1px 0 #b1b27a80, 0 3px 5px #8e9e2416, inset 0 1px 1px #fff6; }
.menu-button small { margin-left: 14px; font-size: 10px; font-weight: 500; letter-spacing: .3px; }
.settings-button:disabled { opacity: .45; box-shadow: none; }
.home-footer { position: absolute; left: 0; right: 0; bottom: max(24px, env(safe-area-inset-bottom)); color: #9a8b70; font-size: 11px; text-align: center; }
.storage-note { font-size: 11px; color: #866029; }
.back-button { flex-shrink: 0; }
.levels-content { width: min(100%, 440px); margin: 0 auto; padding-top: 12px; }
.levels-content > .back-button { margin-bottom: 32px; }
.section-title { color: #3e4c30; font-size: clamp(30px, 8vw, 39px); letter-spacing: -1.5px; }
.level-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-top: 24px; }
.level-tile {
  position: relative; aspect-ratio: 1; min-width: 0; min-height: 0; padding: 4px;
  flex-direction: column; gap: 4px; border-radius: 16px;
  background: linear-gradient(165deg, #f6f0e2, #eee5d1);
  border: 1px solid #e1d7bf; color: #ad9e80;
  box-shadow: 0 3px 0 #dfd3b978, inset 0 1px 0 #fff8;
}
.level-tile:disabled { opacity: 1; cursor: default; }
.level-tile:disabled .level-number { color: #bbad91; }
.level-tile:disabled .level-mark { color: #c4b79c; }
.level-tile .level-number { font-size: clamp(22px, 6vw, 30px); line-height: 1; font-weight: 750; }
.level-tile .level-label { font-size: 8px; line-height: 1; font-weight: 700; letter-spacing: 1px; }
.level-tile.available {
  color: #3e5723; border-color: #afc756;
  background: linear-gradient(165deg, #d6e990, #bfd967);
  box-shadow: 0 4px 0 #a7be5280, inset 0 1px 0 #f7ffd4b3;
}
.level-tile:hover:enabled { background: linear-gradient(165deg, #dfee9d, #c7df75); }
.level-tile:active:enabled { background: #bed568; animation: level-squash 180ms ease-out; }
@keyframes level-squash {
  0%, 100% { transform: scale(1); }
  40% { transform: scale(1.025, .95); }
  75% { transform: scale(.995, 1.012); }
}
.level-mark { position: absolute; top: 6px; right: 6px; display: flex; color: #b7a98c; }
.level-mark svg { width: 10px; height: 10px; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.level-tile.completed .level-mark { color: #678436; }
.level-tile.current {
  background: linear-gradient(165deg, #d9ed8c, #bdd85c); border-color: #94b345;
  box-shadow: 0 0 0 2px #b9d36b55, 0 4px 0 #9cb44980, inset 0 1px 0 #f7ffd4b3;
}
.level-bar { text-transform: uppercase; }
.board-wrap { position: relative; }
.tutorial-guide-space { position: absolute; pointer-events: none; }
/* A single group on the solid lower terrain keeps the cue beside its gesture.
   It shares the renderer's world-space wrapper and never intercepts a swipe. */
.tutorial-guide {
  position: absolute; left: 8px; right: 8px; bottom: calc(2% + 20px);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  pointer-events: none; user-select: none; text-align: center; color: #634b29;
}
.tutorial-guide p {
  position: relative; box-sizing: border-box; margin: 0;
  width: max-content; max-width: min(100%, 285px); padding: 7px 13px;
  border: 1px solid #d8c391; border-radius: 19px 21px 18px 20px;
  background: linear-gradient(155deg, #fff7e2, #f3e2bf);
  box-shadow: inset 0 1px 0 #fffaf0, 0 2px 0 #b79b6538, 0 3px 7px #60421f18;
  font-size: clamp(14px, 3.9vw, 16px); line-height: 1.3; font-weight: 750;
}
.tutorial-guide[data-direction]:not([data-direction="none"]) p { max-width: calc(100% - 94px); }
.tutorial-guide[data-direction]:not([data-direction="none"]) p::before {
  content: ''; position: absolute; left: -6px; top: calc(50% - 5px);
  width: 9px; height: 9px; transform: rotate(45deg);
  background: #faedd4; border-left: 1px solid #d8c391; border-bottom: 1px solid #d8c391;
}
.swipe-gesture { position: relative; order: -1; flex: 0 0 86px; height: 42px; }
@media (max-height: 520px) {
  .tutorial-guide p { padding: 3.5px 10px; }
}
.swipe-hand { position: relative; width: auto; height: 90%; max-height: 45px; overflow: visible;
  fill: #ffe4b6; stroke: #a97943; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
  filter: drop-shadow(1px 2px 1px #69421d33); animation: hint-left 2300ms ease-in-out infinite; }
.hand-crease { fill: none; stroke: #c69b64; }
.swipe-arrow { position: absolute; width: 70px; height: 18px; left: calc(50% - 35px); top: 2px;
  fill: none; stroke: #fff0b9; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tutorial-guide[data-direction="up"] .swipe-hand { animation-name: hint-up; }
.tutorial-guide[data-direction="up"] .swipe-arrow { transform: rotate(90deg); }
.tutorial-guide[data-direction="down"] .swipe-hand { animation-name: hint-down; }
.tutorial-guide[data-direction="down"] .swipe-arrow { transform: rotate(-90deg); }
.tutorial-guide[data-direction="right"] .swipe-hand { animation-name: hint-right; }
.tutorial-guide[data-direction="right"] .swipe-arrow { transform: rotate(180deg); }
@keyframes hint-down {
  0%, 100% { transform: translateY(-12px); opacity: 0; }
  18% { transform: translateY(-12px); opacity: 1; }
  68%, 82% { transform: translateY(8px); opacity: 1; }
  92% { transform: translateY(8px); opacity: 0; }
}
@keyframes hint-left {
  0%, 100% { transform: translateX(24px) rotate(7deg); opacity: 0; }
  18% { transform: translateX(24px) rotate(7deg); opacity: 1; }
  68%, 82% { transform: translateX(-24px) rotate(-5deg); opacity: 1; }
  92% { transform: translateX(-24px) rotate(-5deg); opacity: 0; }
}
@keyframes hint-up {
  0%, 100% { transform: translateY(14px) rotate(4deg); opacity: 0; }
  18% { transform: translateY(14px) rotate(4deg); opacity: 1; }
  68%, 82% { transform: translateY(-22px) rotate(-4deg); opacity: 1; }
  92% { transform: translateY(-22px) rotate(-4deg); opacity: 0; }
}
@keyframes hint-right {
  0%, 100% { transform: translateX(-24px) rotate(-5deg); opacity: 0; }
  18% { transform: translateX(-24px) rotate(-5deg); opacity: 1; }
  68%, 82% { transform: translateX(24px) rotate(7deg); opacity: 1; }
  92% { transform: translateX(24px) rotate(7deg); opacity: 0; }
}
/* A native modal sits above the whole viewport, outside the clipped board.
   Its backdrop is only composited while the completion card is open. */
.tutorial-complete { width: min(calc(100% - 40px), 340px); max-height: calc(100svh - 32px);
  margin: auto; padding: 26px 24px 30px; border: 1px solid #fff0cd; border-radius: 29px;
  background: #fff8e9; color: #536039; box-shadow: 0 18px 65px #44331840, inset 0 2px 0 #fffc;
  text-align: center; }
.tutorial-complete::backdrop { background: #302b1c59; -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.tutorial-complete[open] { animation: complete-pop 300ms ease-out; }
.tutorial-complete h2 { margin: 0; font-size: clamp(27px, 8vw, 34px); letter-spacing: -1.2px; }
.tutorial-complete p { margin: 10px 0 25px; font-size: 14px; color: #8d805f; }
.tutorial-complete .menu-button { min-height: 54px; font-size: 17px; }
.completion-score { display: grid; gap: 5px; margin: 0 0 22px; font-variant-numeric: tabular-nums; }
.completion-score strong { color: #536039; font-size: 24px; line-height: 1.15; font-weight: 750; }
.completion-score span { color: #938365; font-size: 12px; line-height: 1.4; }
.completion-links { display: flex; align-items: center; justify-content: center; gap: 3px; margin: 10px auto -10px; color: #a59b7b; }
.completion-link { display: flex; align-items: center; justify-content: center; min-height: 44px; margin: 0; padding: 0 8px; white-space: nowrap;
  border: 0; background: transparent; color: #7c815f; font-size: 13px;
  text-decoration: underline; text-underline-offset: 3px; touch-action: manipulation; }
.completion-link:hover:enabled, .completion-link:active:enabled { background: transparent; color: #536039; }
.completion-jewel { position: relative; width: 120px; height: 110px; margin: 0 auto 12px; perspective: 420px;
  background: radial-gradient(ellipse, #f9df7952, #ffefb400 68%); }
.completion-jewel svg { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.tutorial-complete[open] .completion-gem { transform-origin: center; animation: jewel-turn 10s linear infinite; }
.completion-spark { opacity: .65; }
.tutorial-complete[open] .completion-spark { transform-box: fill-box; transform-origin: center; animation: jewel-spark 3.7s ease-in-out infinite; }
.tutorial-complete .completion-spark:nth-child(2) { animation-duration: 4.6s; animation-delay: -1.8s; }
.tutorial-complete .completion-spark:nth-child(3) { animation-duration: 3.2s; animation-delay: -.8s; }
@keyframes jewel-turn { from { transform: rotateY(-18deg); } to { transform: rotateY(342deg); } }
@keyframes complete-pop {
  0% { opacity: 0; transform: translateY(8px) scale(.93, .9); }
  55% { opacity: 1; transform: translateY(0) scale(1.025, .975); }
  80% { transform: scale(.995, 1.008); }
  100% { transform: scale(1); }
}
@keyframes jewel-spark {
  0%, 100% { opacity: .05; transform: scale(.7) rotate(-6deg); }
  45% { opacity: .9; transform: scale(1.08) rotate(4deg); }
  70% { opacity: .3; transform: scale(.9) rotate(0); }
}
@media (max-height: 480px) {
  .tutorial-complete { padding: 16px 24px 20px; }
  .completion-jewel { width: 90px; height: 80px; margin-bottom: 8px; }
  .tutorial-complete h2 { font-size: 28px; }
  .tutorial-complete p { margin: 8px 0 18px; }
  .completion-score { gap: 3px; margin-bottom: 12px; }
  .completion-score strong { font-size: 22px; }
  .completion-links { margin-top: 6px; }
  .tutorial-complete .menu-button { min-height: 48px; }
}
@media (max-width: 350px) { .menu-screen { padding-left: 20px; padding-right: 20px; } .level-grid { gap: 7px; } .level-tile { border-radius: 12px; } }
@media (max-height: 650px) {
  .menu-screen { padding-top: 24px; }
  .home-screen { padding-bottom: 60px; }
  .menu-character { height: 142px; margin-top: 8px; margin-bottom: 8px; }
  #menu-slime { top: -5px; }
  .menu-button { min-height: 48px; }
  .leaf-one { top: -45px; width: 44px; height: 44px; }
  .leaf-two { top: 70px; right: -8px; width: 38px; height: 38px; }
  .leaf-three { top: 183px; left: -9px; width: 48px; height: 48px; }
  .leaf-four { top: 125px; right: -4px; width: 42px; height: 42px; }
  .home-footer { bottom: max(17px, env(safe-area-inset-bottom)); font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  #menu-slime.hero-entering { animation: none; }
  .level-tile:active:enabled { animation: none; }
  .swipe-hand, .tutorial-guide[data-direction] .swipe-hand,
  .tutorial-complete[open], .tutorial-complete[open] .completion-gem,
  .tutorial-complete[open] .completion-spark { animation: none; }
  .menu-button { transition: none; }
  .menu-button:active:enabled { transform: none; }
}

/* Play-only controls: compact, tactile and separate from the menu styles. */
.game {
  width: min(100%, 480px); display: flex; flex-direction: column; justify-content: center;
  padding: max(10px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  gap: 6px;
}
.play-header { width: var(--terrain-controls-width, 100%); align-self: center; flex: 0 0 48px; display: grid; grid-template-columns: 48px minmax(0, 1fr) 48px; align-items: center; padding: 0; }
.play-wordmark { grid-column: 2; justify-self: center; width: min(100%, 190px); margin: 0; line-height: 0; }
.play-wordmark img { display: block; width: 100%; height: auto; filter: drop-shadow(0 1px 0 #ffffffb3); }
.game .board-slot { flex: 0 1 auto; width: 100%; aspect-ratio: 424 / 664; min-height: 0; }
.game .footer { flex: 0 0 48px; width: var(--terrain-controls-width, 100%); align-self: center; padding: 0; }
.game .toolbar { height: 48px; display: grid; grid-template-columns: 48px minmax(0, 1fr) 48px; align-items: center; }
.game .toolbar .actions { grid-column: 3; justify-self: end; }
.game-control {
  position: relative; width: 48px; height: 48px; min-height: 48px; padding: 0; flex-shrink: 0;
  border: 0; border-radius: 18px 20px 17px 19px;
  background: linear-gradient(165deg, #fff8df, #e8d9af);
  color: #6e7443; box-shadow: inset 0 2px 0 #fffdf1, 0 3px 0 #c2ad7e, 0 5px 8px #77603a16;
  transform-origin: center 65%; touch-action: manipulation;
  transition: transform 180ms cubic-bezier(.2, 1.5, .4, 1), box-shadow 180ms ease;
}
.game-control svg { width: 24px; height: 24px; stroke-width: 1.9; stroke-linejoin: round; fill: none; }
.game-control:hover:enabled { background: linear-gradient(165deg, #fffbe9, #eee0bd); }
.game-control:active:enabled { background: linear-gradient(165deg, #f9efcf, #e8d9af); transform: translateY(2px) scale(1.012, .97); box-shadow: inset 0 1px 0 #fffdf1, 0 1px 0 #c2ad7e, 0 2px 4px #77603a12; }
.restart-control { background: linear-gradient(165deg, #e1edb5, #c6d98c); color: #536c32; box-shadow: inset 0 2px 0 #f4f8d7, 0 3px 0 #9db568, 0 5px 8px #61752a17; }
.restart-control:hover:enabled { background: linear-gradient(165deg, #e9f2c6, #d2e2a1); }
.restart-control:active:enabled { background: linear-gradient(165deg, #dce9ae, #c6d98c); box-shadow: inset 0 1px 0 #f4f8d7, 0 1px 0 #9db568, 0 2px 4px #61752a12; }
.game .moves { grid-column: 2; justify-self: center; min-height: 48px; padding: 0; border-radius: 0; background: transparent; box-shadow: none; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: #8b805e; text-align: center; }
.game .moves strong { color: #596b3e; font-size: 30px; line-height: 1; font-weight: 750; letter-spacing: -.6px; }
.game .moves span { font-size: 11px; line-height: 1.15; }
@media (max-height: 650px) { .game { gap: 4px; padding-top: max(6px, env(safe-area-inset-top)); padding-bottom: max(6px, env(safe-area-inset-bottom)); } }
@media (prefers-reduced-motion: reduce) { .game-control { transition: none; } .game-control:active:enabled { transform: none; } }



/* Ambient scenery belongs to the screen, never to the collision world.
   The raised board keeps its own clear silhouette and shadows. */
body.is-playing {
  background:
    radial-gradient(ellipse at 14% 8%, #f4dfac88, transparent 58%),
    radial-gradient(ellipse at 88% 92%, #b8c18d55, transparent 60%),
    #e9e8cf;
}
body.is-playing .game { position: relative; isolation: isolate; background: transparent; }
body.is-playing .game::before {
  content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  /* Existing painting's grass half is 480px wide at this fixed texture size.
     Decorative backdrop only: no paths, targets, moving objects or hitboxes. */
  background: url('assets/game-backdrop.webp') left center / 480px 640px repeat-y;
  opacity: .075; filter: saturate(.55);
  mask-image: linear-gradient(to bottom, #0008, #000 20%, #000 80%, #0008);
  -webkit-mask-image: linear-gradient(to bottom, #0008, #000 20%, #000 80%, #0008);
}


/* Hints and results share the existing warm, tactile game controls. */
.game .hint-control { grid-column: 1; grid-row: 1; justify-self: start; color: #8a6e32; }
.game .moves, .game .actions { grid-row: 1; }
.game-control:disabled { opacity: .5; cursor: default; }
.game-hint { position: absolute; inset: 0 auto auto 0; z-index: 4; pointer-events: none; width: 0; height: 0; }
.hint-bubble { position: absolute; width: 42px; height: 42px; left: -21px; top: -21px; display: grid; place-items: center; border-radius: 48% 52% 46% 54%; background: #fff5d7ed; color: #708634; box-shadow: 0 3px 8px #69461e32, inset 0 1px #fffdf2; animation: hint-breathe 1600ms ease-in-out infinite; }
.hint-bubble svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.game-hint[data-direction="left"] .hint-arrow { transform: rotate(180deg); }
.game-hint[data-direction="up"] .hint-arrow { transform: rotate(-90deg); }
.game-hint[data-direction="down"] .hint-arrow { transform: rotate(90deg); }
.game-hint .hint-restart, .hint-restart-label, .game-hint[data-kind="restart"] .hint-arrow { display: none; }
.game-hint[data-kind="restart"] .hint-restart { display: block; }
.game-hint[data-kind="restart"] .hint-restart-label { display: block; position: absolute; top: 22px; left: -30px; width: 60px; text-align: center; font-size: 11px; font-weight: 700; color: #705b39; background: #fff5d7ed; border-radius: 9px; padding: 2px 0; }
@keyframes hint-breathe { 50% { transform: translateY(-2px) scale(1.055); } }
.rating-stars { display: flex; align-items: center; justify-content: center; }
.rating-star { fill: none; stroke: #bfb8a6; stroke-width: 1.6; stroke-linejoin: round; }
.rating-star.earned { stroke: #cf972c; }
.completion-stars { gap: 10px; margin: 2px 0 18px; }
.completion-stars .rating-star { width: 58px; height: 58px; }
.completion-stars .earned { overflow: visible; transform-origin: 50% 60%; filter: drop-shadow(0 3px 2px #bb812b30); animation: star-reward 560ms cubic-bezier(.2, .75, .3, 1) both; animation-delay: calc(90ms + var(--star-index) * 175ms); }
@keyframes star-reward {
  0% { opacity: 0; transform: translateY(5px) scale(.45) rotate(-6deg); }
  55% { opacity: 1; transform: translateY(-3px) scale(1.13) rotate(2deg); }
  78% { transform: translateY(1px) scale(.97) rotate(-1deg); }
  100% { opacity: 1; transform: none; }
}
.star-glint { opacity: 0; }
.completion-stars .star-glint { transform-box: fill-box; transform-origin: center; animation: star-glint 480ms ease-out both; animation-delay: calc(250ms + var(--star-index) * 175ms); }
@keyframes star-glint { 0%, 100% { opacity: 0; transform: scale(.45); } 35% { opacity: .9; transform: scale(1); } }
.level-stars .star-glint { display: none; }
.tutorial-complete #complete-title { font-size: 25px; margin-bottom: 15px; }
.completion-score { gap: 5px; }
.completion-totals { font-size: 17px; color: #5c693f; }
.completion-totals strong { font-size: inherit; font-weight: 700; }
#complete-minimum { color: #908366; font-size: 13px; }
.level-stars { gap: 1px; }
.level-stars .rating-star { width: clamp(9px, 2.7vw, 13px); height: clamp(9px, 2.7vw, 13px); }
.level-tile.completed { gap: 3px; }
@media (prefers-reduced-motion: reduce) { .hint-bubble, .completion-stars .earned, .completion-stars .star-glint { animation: none; } }
.completion-score .completion-totals strong { font-size: 17px; }

#complete-rating-note { color: #8a683a; font-size: 12px; max-width: 240px; margin: 2px auto 0; }

.board-wrap.has-load-error::after { content: 'Het herfstbos wordt klaargezet…'; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: max-content; max-width: 85%; padding: 12px 16px; border-radius: 16px; background: #fff8e9eb; color: #6c784b; font-size: 13px; box-shadow: 0 4px 16px #67412124; pointer-events: none; }

.board-wrap.has-load-error::after { content: 'Dit level kon niet laden. Tik op Opnieuw om het nog eens te proberen.'; text-align: center; }

/* Resolve local progress before revealing the final home composition. */
.home-screen:not(.is-ready) .menu-content { visibility: hidden; }
.settings-content { width: min(100%, 400px); margin: 0 auto; padding-top: 12px; }
.settings-content > .back-button { margin-bottom: 24px; }
.settings-list { display: grid; gap: 14px; margin-top: 30px; }
.setting-row {
  width: 100%; min-height: 88px; padding: 18px; justify-content: flex-start; gap: 16px;
  text-align: left; border: 1px solid #e0d9bd; border-radius: 22px 25px 23px 24px;
  background: linear-gradient(165deg, #fffdf4, #f4efdc); color: #596642;
  box-shadow: 0 3px 0 #d9d4ad55, inset 0 1px 0 #fff9;
}
.setting-row svg { width: 25px; height: 25px; flex-shrink: 0; }
.setting-copy { display: grid; gap: 6px; }
.setting-copy strong { font-size: 16px; font-weight: 700; line-height: 1.3; }
.setting-copy small { font-size: 12px; font-weight: 400; line-height: 1.6; color: #8a8066; }
.setting-row:disabled { opacity: 1; color: #b1ad9d; background: #f3f0e5; border-color: #e5e0d0; box-shadow: inset 0 1px 0 #fff8; }
.setting-row:disabled small { color: #aaa696; }
.setting-placeholder { margin-left: auto; color: #bcb6a5; }
.setting-row:first-child .setting-placeholder { width: 30px; height: 18px; border-radius: 12px; background: #d9d5c8; flex-shrink: 0; }
.setting-row:first-child .setting-placeholder::before { content: ''; display: block; width: 12px; height: 12px; margin: 3px; border-radius: 50%; background: #f5f2e9; }
.reset-setting { margin-top: 8px; color: #78633b; }
.reset-setting:hover:enabled { background: #f5eed7; }
.reset-setting:active:enabled { transform: translateY(2px); box-shadow: 0 1px 0 #d9d4ad55; }
.reset-dialog {
  width: min(calc(100% - 32px), 360px); max-height: calc(100svh - 32px); overflow: auto;
  padding: 28px 24px 24px; border: 1px solid #e0d7b5; border-radius: 28px;
  color: #3e4c30; background: #fbf7e9; box-shadow: 0 16px 50px #3e321e40;
}
.reset-dialog::backdrop { background: #302b1c59; -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.reset-dialog h2 { margin: 0; font-size: clamp(23px, 6.5vw, 27px); letter-spacing: -.8px; line-height: 1.2; }
.reset-dialog p { margin: 14px 0 22px; color: #81765b; font-size: 14px; line-height: 1.65; }
.reset-actions { display: grid; gap: 12px; }
.reset-actions .menu-button { min-height: 48px; font-size: 15px; }
.reset-actions .reset-confirm { color: #80643c; font-weight: 600; background: #f3ebd7; box-shadow: 0 3px 0 #d9d4ad66, inset 0 1px 0 #fff8; }
.reset-dialog .reset-error { font-size: 12px; color: #80643c; }
@media (max-height: 650px) {
  .settings-content { padding-top: 0; }
  .settings-list { margin-top: 22px; gap: 12px; }
  .setting-row { min-height: 78px; padding: 15px; }
}

/* Layout-only measurement for one home-scene preload; hidden remains hidden to AT. */
.game.is-measuring[hidden] { display: flex !important; position: fixed; left: 0; top: 0; visibility: hidden; pointer-events: none; z-index: -1; }

/* Shared, lightweight interaction feedback; navigation does not wait for it. */
.level-tile { transition: transform 170ms cubic-bezier(.2, 1.35, .4, 1), box-shadow 170ms ease; }
.level-tile:active:enabled { animation: none; transform: translateY(2px) scale(1.012, .97); box-shadow: 0 1px 0 #a7be5255, inset 0 1px 0 #f7ffd4b3; }
.menu-button:active:enabled, .game-control:active:enabled { transition-duration: 70ms; }
.awaiting-world > canvas, .awaiting-world > .tutorial-guide-space, .awaiting-world > #game-hint { visibility: hidden; }
.completion-departure { position: fixed; z-index: 100; margin: 0; pointer-events: none; overflow: hidden; }
.completion-departure * { animation: none !important; pointer-events: none !important; }
@media (prefers-reduced-motion: reduce) {
  .level-tile, .menu-button:active:enabled, .game-control:active:enabled { transition: none; }
  .level-tile:active:enabled, .reset-setting:active:enabled { transform: none; }
}

/* One lightweight indicator, mounted once; hidden until loading exceeds 200ms. */
.level-loading { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; pointer-events: none; color: #746344; font-size: 14px; font-weight: 600; animation: loading-arrive 120ms ease-out; }
.loading-squish { position: relative; display: flex; justify-content: center; align-items: center; gap: 4px; width: 70px; height: 25px; border-radius: 48% 45% 42% 46% / 65% 60% 55% 50%; background: linear-gradient(155deg, #d9f386, #b9d956 55%, #99b940); box-shadow: inset 0 1px 0 #f2ffc1, 0 3px 5px #78613724; transform-origin: 50% 80%; animation: loading-squish 1200ms ease-in-out infinite; }
.loading-squish::before { content: ''; position: absolute; width: 17px; height: 4px; top: 3px; left: 10px; border-radius: 50%; background: #f9ffd2a8; transform: rotate(-8deg); }
.loading-squish i { width: 7px; height: 9px; border-radius: 50%; background: radial-gradient(circle at 55% 60%, #39451f 0 2px, #fffbd8 2.5px); box-shadow: 0 1px 1px #607a3733; }
@keyframes loading-squish { 0%, 100% { transform: translateY(0) scale(1); } 45% { transform: translateY(-2px) scale(.96, 1.06); } 75% { transform: translateY(1px) scale(1.04, .96); } }
@keyframes loading-arrive { from { opacity: .9; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .level-loading, .loading-squish { animation: none; } }
