:root {
  --ink: oklch(36% 0.075 156);
  --ink-soft: oklch(47% 0.06 156);
  --paper: oklch(98% 0.025 91);
  --sun: oklch(83% 0.155 88);
  --coral: oklch(67% 0.17 28);
  --leaf: oklch(70% 0.12 151);
  --leaf-deep: oklch(56% 0.11 151);
  --sky: oklch(90% 0.064 212);
  --path: oklch(80% 0.065 72);
  --path-deep: oklch(66% 0.075 70);
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 0.75rem;
  --space-lg: 1rem;
  --space-xl: 1.5rem;
  --space-2xl: 2rem;
  --stone-size: clamp(3.7rem, 12vmin, 7rem);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  font-family: "Avenir Next Rounded", "Nunito Sans", ui-rounded, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--paper);
}

body {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: none;
  user-select: none;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.parent-playland-link {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.75rem;
  padding: 0.65rem 0.9rem;
  color: var(--ink);
  background: oklch(98% 0.025 91 / 92%);
  border: 2px solid oklch(56% 0.11 151 / 35%);
  border-radius: 999px;
  font-weight: 900;
  text-decoration: none;
}

.parent-playland-link:focus-visible {
  outline: 4px solid var(--sun);
  outline-offset: 3px;
}

.game {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: 100%;
  height: 100vh;
  height: 100svh;
  min-height: 28rem;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(circle at 14% 8%, oklch(100% 0.02 88 / 82%) 0 4rem, transparent 4.05rem),
    var(--paper);
}

.game-header {
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding:
    max(var(--space-md), env(safe-area-inset-top))
    max(var(--space-lg), env(safe-area-inset-right))
    var(--space-sm)
    max(var(--space-lg), env(safe-area-inset-left));
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  color: var(--ink);
  font-family: "Cooper Black", "Bookman Old Style", ui-rounded, serif;
  font-size: clamp(1rem, 3.4vmin, 1.55rem);
  letter-spacing: -0.025em;
  white-space: nowrap;
}

.brand-mark {
  width: clamp(2rem, 6vmin, 2.75rem);
  overflow: visible;
}

.brand-mark path {
  fill: none;
  stroke: var(--leaf-deep);
  stroke-linecap: round;
  stroke-width: 6;
}

.brand-mark circle {
  fill: var(--coral);
}

.trail-badge {
  padding: 0.48rem 0.78rem;
  border: 2px solid color-mix(in oklch, var(--leaf) 50%, var(--paper));
  border-radius: 999px;
  color: var(--ink-soft);
  background: color-mix(in oklch, var(--paper) 88%, var(--leaf));
  font-size: clamp(0.72rem, 2.5vmin, 0.92rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.play-field {
  position: relative;
  min-height: 0;
  overflow: hidden;
}

.prompt {
  position: absolute;
  z-index: 7;
  top: 0;
  left: 50%;
  display: flex;
  align-items: baseline;
  gap: 0.18em;
  transform: translateX(-50%);
  color: var(--ink);
  font-size: clamp(1.05rem, 3.7vmin, 1.65rem);
  font-weight: 750;
  white-space: nowrap;
}

.prompt strong {
  display: inline-grid;
  min-width: 0.85em;
  place-items: center;
  color: var(--coral);
  font-family: "Cooper Black", "Bookman Old Style", ui-rounded, serif;
  font-size: 1.65em;
  line-height: 0.9;
  transform-origin: center bottom;
}

.prompt strong.is-changing {
  animation: prompt-pop 420ms var(--ease-out);
}

.trail {
  position: absolute;
  z-index: 5;
  inset: clamp(2.8rem, 9vmin, 4.8rem) 0.3rem 0;
}

.trail-map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.trail-shadow,
.trail-path,
.trail-done {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.trail-shadow {
  stroke: color-mix(in oklch, var(--path-deep) 32%, transparent);
  stroke-width: 15;
  transform: translateY(1.2px);
}

.trail-path {
  stroke: var(--path);
  stroke-dasharray: 1 16;
  stroke-width: 8;
}

.trail-done {
  stroke: var(--leaf-deep);
  stroke-dasharray: 1 16;
  stroke-width: 8;
  transition: stroke-dashoffset 480ms var(--ease-out);
}

.number-stone {
  --stone: var(--sun);
  position: absolute;
  z-index: 3;
  left: var(--x);
  top: var(--y);
  display: grid;
  width: var(--stone-size);
  height: var(--stone-size);
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50% 46% 52% 45%;
  transform: translate(-50%, -50%) rotate(var(--tilt, -2deg));
  color: var(--ink);
  background: var(--stone);
  box-shadow:
    0 0.45rem 0 color-mix(in oklch, var(--stone) 66%, var(--ink)),
    0 0.7rem 1.2rem oklch(47% 0.05 80 / 16%);
  cursor: pointer;
  touch-action: manipulation;
  transition:
    transform 220ms var(--ease-out),
    opacity 260ms var(--ease-out),
    filter 260ms var(--ease-out);
}

.number-stone::before {
  position: absolute;
  inset: 8%;
  border: 2px solid oklch(100% 0.015 90 / 58%);
  border-radius: inherit;
  content: "";
}

.number-stone span {
  position: relative;
  font-family: "Cooper Black", "Bookman Old Style", ui-rounded, serif;
  font-size: calc(var(--stone-size) * 0.51);
  line-height: 1;
  text-shadow: 0 2px 0 oklch(100% 0.01 90 / 42%);
}

.number-stone.is-double-digit span {
  font-size: calc(var(--stone-size) * 0.42);
}

.number-stone:nth-of-type(4n + 1) {
  --stone: oklch(82% 0.15 87);
  --tilt: -3deg;
}

.number-stone:nth-of-type(4n + 2) {
  --stone: oklch(76% 0.13 153);
  --tilt: 2deg;
}

.number-stone:nth-of-type(4n + 3) {
  --stone: oklch(77% 0.13 32);
  --tilt: -1deg;
}

.number-stone:nth-of-type(4n) {
  --stone: oklch(79% 0.105 223);
  --tilt: 3deg;
}

.number-stone.is-target {
  z-index: 4;
  animation: target-breathe 1.55s ease-in-out infinite;
  outline: max(4px, 0.5vmin) solid oklch(100% 0.025 90 / 88%);
  outline-offset: max(4px, 0.5vmin);
}

.number-stone.is-found {
  z-index: 2;
  opacity: 0.56;
  filter: saturate(0.55);
  transform: translate(-50%, -50%) rotate(var(--tilt)) scale(0.76);
  pointer-events: none;
}

.number-stone.is-found span {
  opacity: 0.72;
}

.number-stone.correct {
  animation: correct-tap 520ms var(--ease-out);
}

.number-stone.nudge {
  animation: friendly-nudge 520ms var(--ease-out);
}

.celebration {
  position: absolute;
  z-index: 8;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.confetti {
  --confetti: var(--coral);
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: clamp(0.45rem, 1.5vmin, 0.8rem);
  height: clamp(0.45rem, 1.5vmin, 0.8rem);
  border-radius: 50% 0 50% 50%;
  background: var(--confetti);
  animation: float-away 760ms var(--ease-out) forwards;
}

.sky-shape {
  position: absolute;
  z-index: -2;
  width: 8rem;
  height: 3rem;
  border-radius: 50%;
  background: color-mix(in oklch, var(--sky) 66%, transparent);
  filter: blur(0.2px);
}

.sky-shape::before,
.sky-shape::after {
  position: absolute;
  border-radius: 50%;
  background: inherit;
  content: "";
}

.sky-shape::before {
  top: -1.25rem;
  left: 1.3rem;
  width: 3.4rem;
  height: 3.4rem;
}

.sky-shape::after {
  top: -0.6rem;
  right: 1rem;
  width: 2.6rem;
  height: 2.6rem;
}

.sky-shape-one {
  top: 18%;
  left: -2rem;
}

.sky-shape-two {
  top: 7%;
  right: -3rem;
  transform: scale(0.72);
}

.hill {
  position: absolute;
  z-index: -3;
  bottom: -35%;
  border-radius: 50% 50% 0 0;
}

.hill-far {
  right: -20%;
  width: 90%;
  height: 58%;
  background: oklch(89% 0.075 151);
  transform: rotate(-4deg);
}

.hill-near {
  bottom: -46%;
  left: -22%;
  width: 105%;
  height: 72%;
  background: oklch(84% 0.1 151);
  transform: rotate(5deg);
}

.sun {
  position: absolute;
  z-index: -4;
  top: 9%;
  right: 8%;
  width: clamp(3.4rem, 10vmin, 6rem);
  aspect-ratio: 1;
  border-radius: 50%;
  background: color-mix(in oklch, var(--sun) 72%, var(--paper));
}

.sun span,
.sun::before,
.sun::after {
  position: absolute;
  content: "";
}

.sun span {
  top: 44%;
  left: 29%;
  width: 8%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--ink-soft);
  box-shadow: 1.55rem 0 0 var(--ink-soft);
}

.sun::before {
  bottom: 26%;
  left: 35%;
  width: 30%;
  height: 14%;
  border-bottom: 3px solid var(--ink-soft);
  border-radius: 50%;
}

.game-footer {
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
  padding:
    var(--space-sm)
    max(var(--space-lg), env(safe-area-inset-right))
    max(var(--space-md), env(safe-area-inset-bottom))
    max(3.6rem, env(safe-area-inset-left));
  color: var(--ink-soft);
}

.game-footer p {
  margin: 0;
  font-size: clamp(0.8rem, 2.5vmin, 1rem);
  font-weight: 750;
}

.trail-steps {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.step {
  display: grid;
  width: clamp(1.8rem, 5vmin, 2.3rem);
  aspect-ratio: 1;
  place-items: center;
  border-radius: 50%;
  color: var(--ink-soft);
  background: color-mix(in oklch, var(--leaf) 24%, var(--paper));
  font-size: 0.72rem;
  font-weight: 900;
}

.step.is-current {
  color: var(--paper);
  background: var(--leaf-deep);
  transform: scale(1.08);
}

.step.is-complete {
  color: var(--ink);
  background: var(--sun);
}

.parent-lock {
  position: fixed;
  z-index: 20;
  display: grid;
  width: 3rem;
  height: 3rem;
  padding: 0.72rem;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: color-mix(in oklch, var(--leaf-deep) 68%, var(--paper));
  background: transparent;
  opacity: 0.42;
  touch-action: none;
}

.parent-lock svg {
  width: 100%;
  overflow: visible;
}

.parent-lock path:first-child {
  fill: currentColor;
}

.parent-lock path:last-child {
  fill: none;
  stroke: var(--paper);
  stroke-linecap: round;
  stroke-width: 1.7;
}

.parent-lock-top {
  top: max(0.1rem, env(safe-area-inset-top));
  right: max(0.1rem, env(safe-area-inset-right));
}

.parent-lock-bottom {
  bottom: max(0.05rem, env(safe-area-inset-bottom));
  left: max(0.05rem, env(safe-area-inset-left));
  transform: rotate(180deg);
}

.parent-lock.is-held {
  opacity: 0.82;
  background: color-mix(in oklch, var(--leaf) 24%, transparent);
}

.parent-dialog {
  width: min(92vw, 34rem);
  max-height: min(90vh, 46rem);
  padding: 0;
  overflow: auto;
  border: 0;
  border-radius: 1.6rem 1.6rem 1.25rem 1.25rem;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 1.5rem 5rem oklch(26% 0.05 155 / 30%);
  user-select: text;
}

.parent-dialog::backdrop {
  background: oklch(28% 0.055 155 / 58%);
}

.parent-sheet {
  display: grid;
  gap: var(--space-xl);
  padding:
    clamp(1.25rem, 5vw, 2rem)
    clamp(1.15rem, 5vw, 2rem)
    max(1.5rem, env(safe-area-inset-bottom));
}

.parent-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: var(--space-xl);
}

.eyebrow {
  margin: 0 0 var(--space-xs);
  color: var(--leaf-deep);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.parent-heading h1 {
  margin: 0;
  font-family: "Cooper Black", "Bookman Old Style", ui-rounded, serif;
  font-size: clamp(1.65rem, 6vw, 2.25rem);
  letter-spacing: -0.035em;
}

.close-button {
  display: grid;
  width: 2.75rem;
  aspect-ratio: 1;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: var(--ink);
  background: color-mix(in oklch, var(--path) 48%, var(--paper));
  font-size: 1.8rem;
  line-height: 1;
}

.parent-intro {
  max-width: 42ch;
  margin: calc(var(--space-sm) * -1) 0 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
  line-height: 1.5;
}

.setting-list {
  display: grid;
  gap: var(--space-sm);
}

.setting-row {
  display: flex;
  min-height: 4.6rem;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-xl);
  padding: var(--space-md) var(--space-lg);
  border: 2px solid color-mix(in oklch, var(--leaf) 30%, var(--paper));
  border-radius: 1rem;
  background: color-mix(in oklch, var(--paper) 93%, var(--leaf));
}

.setting-row span {
  display: grid;
  gap: 0.16rem;
}

.setting-row strong {
  font-size: 1rem;
}

.setting-row small {
  color: var(--ink-soft);
  font-size: 0.8rem;
  line-height: 1.3;
}

.setting-row input {
  width: 3.2rem;
  height: 1.8rem;
  flex: 0 0 auto;
  appearance: none;
  border: 2px solid var(--leaf-deep);
  border-radius: 999px;
  background: color-mix(in oklch, var(--ink-soft) 14%, var(--paper));
  cursor: pointer;
}

.setting-row input::before {
  display: block;
  width: 1.25rem;
  aspect-ratio: 1;
  margin: 0.14rem;
  border-radius: 50%;
  background: var(--ink-soft);
  content: "";
  transition: transform 180ms var(--ease-out), background 180ms var(--ease-out);
}

.setting-row input:checked {
  background: color-mix(in oklch, var(--leaf) 45%, var(--paper));
}

.setting-row input:checked::before {
  transform: translateX(1.35rem);
  background: var(--leaf-deep);
}

.offline-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
  padding: var(--space-lg);
  border-radius: 1.1rem;
  background: color-mix(in oklch, var(--sky) 45%, var(--paper));
}

.offline-box h2 {
  margin: 0 0 var(--space-xs);
  font-size: 1rem;
}

.offline-box p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.82rem;
  line-height: 1.35;
}

.small-button,
.reset-button {
  min-height: 2.75rem;
  border-radius: 999px;
  font-weight: 850;
  cursor: pointer;
}

.small-button {
  padding: 0.5rem 1rem;
  border: 2px solid var(--leaf-deep);
  color: var(--ink);
  background: var(--paper);
}

.install-help {
  color: var(--ink-soft);
  font-size: 0.86rem;
  line-height: 1.5;
}

.install-help summary {
  color: var(--ink);
  font-weight: 850;
  cursor: pointer;
}

.install-help p {
  margin: var(--space-sm) 0 0;
}

.parent-actions {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.reset-button {
  padding: 0.55rem 1.1rem;
  border: 2px solid color-mix(in oklch, var(--coral) 72%, var(--ink));
  color: color-mix(in oklch, var(--coral) 70%, var(--ink));
  background: transparent;
}

.parent-actions span {
  color: var(--leaf-deep);
  font-size: 0.82rem;
  font-weight: 800;
}

.extra-calm .number-stone.is-target {
  animation-duration: 3.2s;
}

.extra-calm .confetti:nth-child(n + 3) {
  display: none;
}

.extra-calm .sky-shape {
  opacity: 0.45;
}

button:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 4px solid var(--coral);
  outline-offset: 3px;
}

@keyframes target-breathe {
  0%,
  100% {
    filter: brightness(1);
    transform: translate(-50%, -50%) rotate(var(--tilt)) scale(1);
  }
  50% {
    filter: brightness(1.08);
    transform: translate(-50%, -50%) rotate(var(--tilt)) scale(1.075);
  }
}

@keyframes correct-tap {
  0% {
    transform: translate(-50%, -50%) rotate(var(--tilt)) scale(1);
  }
  44% {
    transform: translate(-50%, -58%) rotate(calc(var(--tilt) + 4deg)) scale(1.16);
  }
  100% {
    transform: translate(-50%, -50%) rotate(var(--tilt)) scale(0.76);
  }
}

@keyframes friendly-nudge {
  0%,
  100% {
    transform: translate(-50%, -50%) rotate(var(--tilt));
  }
  35% {
    transform: translate(-50%, -50%) rotate(calc(var(--tilt) - 5deg)) scale(1.08);
  }
  70% {
    transform: translate(-50%, -50%) rotate(calc(var(--tilt) + 4deg)) scale(1.08);
  }
}

@keyframes prompt-pop {
  0% {
    opacity: 0.25;
    transform: scale(0.7);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes float-away {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.45) rotate(0deg);
  }
  18% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.15) rotate(120deg);
  }
}

@media (orientation: landscape) and (max-height: 34rem) {
  :root {
    --stone-size: clamp(3.4rem, 16vh, 5.2rem);
  }

  .game {
    min-height: 0;
  }

  .game-header {
    padding-top: max(var(--space-sm), env(safe-area-inset-top));
  }

  .brand {
    font-size: 0.95rem;
  }

  .brand-mark {
    width: 1.8rem;
  }

  .trail {
    top: 2.2rem;
  }

  .game-footer {
    padding-top: 0;
  }
}

@media (max-width: 24rem) {
  .trail-badge {
    max-width: 42vw;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .game-footer {
    gap: var(--space-sm);
    padding-right: max(var(--space-sm), env(safe-area-inset-right));
  }

  .game-footer p {
    font-size: 0.75rem;
    white-space: nowrap;
  }

  .trail-steps {
    gap: var(--space-xs);
  }

  .step {
    width: 1.5rem;
    font-size: 0.62rem;
  }
}

@media (max-height: 36rem) {
  .parent-dialog {
    max-height: 94vh;
  }

  .parent-sheet {
    gap: var(--space-lg);
  }
}

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