@font-face {
  font-family: Fredoka;
  src: url("assets/fredoka-400.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: Fredoka;
  src: url("assets/fredoka-600.woff2") format("woff2");
  font-style: normal;
  font-weight: 600;
  font-display: swap;
}

:root {
  --wm-cream-1: #fff8e6;
  --wm-cream-2: #f6e7c8;
  --wm-wood-1: #c98f5a;
  --wm-wood-2: #8a552c;
  --wm-gold: #f2c141;
  --wm-sage: #879a63;
  --wm-plum: #8d6197;
  --wm-ink: #3d3226;
  --wm-amber: #d8893d;
  --wm-ok: #2f8a4d;
  --world-ice: #1f7580;
  --world-deep: #174b57;
  --world-snow: #e8f3ef;
  --world-stone: #617c8d;
  --wm-radius-card: 22px;
  --wm-radius-panel: 30px;
  --wm-touch-min: 48px;
  --stone-size: 64px;
  --touch-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--world-ice);
}

body {
  color: var(--wm-ink);
  font-family: Fredoka, "Trebuchet MS", sans-serif;
  font-size: 17px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}

button {
  color: inherit;
  font: inherit;
}

button,
[role="button"] {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--wm-gold);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.game-shell {
  position: relative;
  display: grid;
  grid-template-rows: 56px 40px minmax(0, 1fr);
  gap: 4px;
  width: 100%;
  height: 100dvh;
  padding:
    max(4px, var(--safe-top))
    max(8px, var(--safe-right))
    max(4px, var(--safe-bottom))
    max(8px, var(--safe-left));
  overflow: hidden;
  isolation: isolate;
  background: var(--world-ice);
}

.world-bg,
.world-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.world-bg {
  z-index: -2;
  pointer-events: none;
}

.world-image {
  object-fit: cover;
  object-position: center 72%;
  opacity: 0.98;
}

.bg-portrait {
  display: none;
}

.opening {
  position: absolute;
  inset: 0;
  z-index: 80;
  overflow: hidden;
  background: var(--world-ice);
}

.intro-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.intro-portrait {
  display: none;
}

.intro-scrim {
  position: absolute;
  inset: 0;
  background: rgba(16, 54, 62, 0.2);
  pointer-events: none;
}

.title-frame {
  position: absolute;
  top: max(22px, var(--safe-top));
  left: 50%;
  width: min(680px, calc(100% - 32px));
  padding: 13px 20px 15px;
  transform: translateX(-50%);
  background: rgba(255, 248, 230, 0.94);
  border: 4px solid var(--wm-wood-2);
  border-radius: 24px;
  box-shadow: 0 10px 24px rgba(29, 45, 48, 0.25);
  text-align: center;
}

.title-frame h1 {
  margin: 0;
  color: var(--world-deep);
  font-size: clamp(1.75rem, 5vw, 3.35rem);
  font-weight: 600;
  line-height: 1.02;
  letter-spacing: -0.025em;
}

.intro-action {
  position: absolute;
  bottom: max(28px, calc(var(--safe-bottom) + 18px));
  left: 50%;
  display: grid;
  justify-items: center;
  gap: 14px;
  width: min(430px, calc(100% - 32px));
  padding: 18px 20px 20px;
  transform: translateX(-50%);
  background: rgba(255, 248, 230, 0.94);
  border: 3px solid var(--wm-wood-1);
  border-radius: 28px;
  box-shadow: 0 12px 28px rgba(24, 52, 58, 0.28);
  text-align: center;
}

.intro-action p {
  margin: 0;
  color: var(--world-deep);
  font-size: clamp(1rem, 2.4vw, 1.25rem);
}

.play-button,
.primary-button,
.quiet-button,
.ok-button,
.demo-bar button {
  min-height: 56px;
  border-radius: 999px;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 120ms ease, background-color 120ms ease;
}

.play-button:active,
.primary-button:active,
.quiet-button:active,
.ok-button:active,
.demo-bar button:active {
  transform: scale(0.96);
}

.play-button {
  position: relative;
  display: inline-grid;
  grid-template-columns: 86px auto;
  align-items: center;
  justify-content: start;
  gap: 8px;
  min-width: 210px;
  min-height: 86px;
  padding: 0 16px 0 0;
  color: var(--world-deep);
  background: transparent;
  border: 0;
  box-shadow: none;
  font-size: 1.3rem;
  font-weight: 600;
}

.play-button::before,
.play-button::after {
  position: absolute;
  top: 50%;
  left: 0;
  width: 86px;
  height: 86px;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  content: "";
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%);
}

.play-button::before {
  background-image: url("assets/ui/button-play-pressed.webp");
}

.play-button::after {
  background-image: url("assets/ui/button-play-disabled.webp");
}

.play-button:active:not(:disabled) .play-art,
.play-button:disabled .play-art {
  opacity: 0;
}

.play-button:active:not(:disabled)::before,
.play-button:disabled::after {
  opacity: 1;
}

.play-art {
  display: block;
  width: 86px;
  height: 86px;
  object-fit: contain;
  transition: opacity 80ms ease;
}

.game-controls {
  position: relative;
  z-index: 400;
  display: flex;
  grid-row: 1;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  width: max-content;
  max-width: 100%;
  margin-inline: auto;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.control-button {
  --control-pressed-image: none;
  --control-disabled-image: none;
  position: relative;
  display: block;
  flex: 0 0 56px;
  width: 56px;
  height: 56px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  touch-action: manipulation;
}

.control-button::before,
.control-button::after {
  position: absolute;
  inset: 0;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  content: "";
  opacity: 0;
  pointer-events: none;
}

.control-button::before {
  background-image: var(--control-pressed-image);
}

.control-button::after {
  background-image: var(--control-disabled-image);
}

.control-button:active:not(:disabled) {
  transform: scale(0.96);
}

.control-button:active:not(:disabled) .control-art,
.control-button:disabled .control-art {
  opacity: 0;
}

.control-button:active:not(:disabled)::before,
.control-button:disabled::after {
  opacity: 1;
}

.control-button:disabled {
  cursor: default;
}

.control-button:focus-visible {
  outline-offset: 1px;
}

.control-art {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  transition: opacity 80ms ease;
}

#pauseButton {
  --control-pressed-image: url("assets/ui/button-pause-pressed.webp");
  --control-disabled-image: url("assets/ui/button-pause-disabled.webp");
}

#pauseButton.is-resume {
  --control-pressed-image: url("assets/ui/button-play-pressed.webp");
  --control-disabled-image: url("assets/ui/button-play-disabled.webp");
}

#soundButton[aria-pressed="false"] {
  --control-pressed-image: url("assets/ui/button-volume-pressed.webp");
  --control-disabled-image: url("assets/ui/button-volume-disabled.webp");
}

#soundButton[aria-pressed="true"] {
  --control-pressed-image: url("assets/ui/button-mute-pressed.webp");
  --control-disabled-image: url("assets/ui/button-mute-disabled.webp");
}

#restartButton {
  --control-pressed-image: url("assets/ui/button-replay-pressed.webp");
  --control-disabled-image: url("assets/ui/button-replay-disabled.webp");
}

#homeButton {
  --control-pressed-image: url("assets/ui/button-home-pressed.webp");
  --control-disabled-image: url("assets/ui/button-home-disabled.webp");
}

#helpButton {
  --control-pressed-image: url("assets/ui/button-help-normal.webp");
  --control-disabled-image: url("assets/ui/button-help-normal.webp");
}

#helpButton:active:not(:disabled)::before {
  opacity: 0.82;
}

#helpButton:disabled::after {
  opacity: 0.48;
}

.top-hud {
  z-index: 15;
  display: flex;
  grid-row: 2;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  width: 100%;
  padding: 3px 9px;
  background: rgba(96, 61, 37, 0.68);
  border: 2px solid rgba(255, 248, 230, 0.46);
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(23, 53, 58, 0.16);
}

.level-path {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 4px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.level-token {
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  color: var(--world-deep);
  background: rgba(255, 248, 230, 0.92);
  border: 2px solid rgba(255, 248, 230, 0.78);
  border-radius: 11px;
}

.level-token svg {
  width: 23px;
  height: 23px;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.level-token.is-current {
  background: var(--wm-cream-1);
  border-color: var(--wm-gold);
  box-shadow: 0 0 0 3px rgba(242, 193, 65, 0.42);
}

.level-token.is-complete {
  color: var(--wm-wood-2);
  background: var(--wm-gold);
}

.level-token.is-locked {
  opacity: 0.46;
}

.round-progress {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.task-meta {
  overflow: hidden;
  color: var(--wm-cream-1);
  font-size: 0.73rem;
  font-weight: 600;
  text-overflow: ellipsis;
  text-shadow: 0 1px 1px rgba(16, 54, 62, 0.8);
  white-space: nowrap;
}

.task-stars {
  display: flex;
  align-items: center;
  gap: 2px;
}

.task-star {
  width: 22px;
  height: 22px;
}

.task-star path {
  fill: rgba(255, 248, 230, 0.38);
  stroke: var(--wm-cream-1);
  stroke-width: 2.5;
  stroke-linejoin: round;
}

.task-star.is-earned path {
  fill: var(--wm-gold);
  stroke: var(--wm-wood-2);
}

.playfield {
  position: relative;
  z-index: 8;
  display: block;
  grid-row: 3;
  min-width: 0;
  min-height: 0;
  isolation: isolate;
}

.playfield::before {
  position: absolute;
  z-index: 0;
  right: -12%;
  bottom: -12%;
  left: -12%;
  height: 74%;
  background:
    radial-gradient(ellipse at 50% 100%, rgba(255, 250, 237, 0.96) 0 44%, rgba(237, 248, 247, 0.75) 68%, transparent 74%),
    linear-gradient(180deg, transparent 0 12%, rgba(238, 248, 246, 0.2) 38%, rgba(255, 249, 235, 0.54) 100%);
  content: "";
  pointer-events: none;
}

.scene-snow {
  position: absolute;
  z-index: 1;
  right: -5%;
  bottom: -8%;
  left: -5%;
  height: 46%;
  background:
    radial-gradient(ellipse at 30% 38%, rgba(255, 255, 255, 0.92) 0 32%, transparent 33%),
    radial-gradient(ellipse at 72% 48%, rgba(226, 244, 244, 0.9) 0 40%, transparent 41%),
    linear-gradient(180deg, rgba(255, 251, 239, 0.08), rgba(255, 248, 230, 0.82));
  clip-path: polygon(0 20%, 18% 8%, 38% 16%, 57% 3%, 82% 13%, 100% 0, 100% 100%, 0 100%);
  pointer-events: none;
}

.character-card {
  position: absolute;
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: end center;
  margin: 0;
  pointer-events: none;
}

.sopo-card {
  z-index: 4;
  top: 148px;
  left: 1%;
  width: clamp(158px, 30%, 218px);
  height: clamp(174px, 25%, 228px);
}

.walrus-card {
  z-index: 3;
  top: -18px;
  right: -5%;
  width: clamp(270px, 52%, 370px);
  height: clamp(280px, 38%, 386px);
}

.character-image,
.character-idle {
  position: relative;
  z-index: 2;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  filter: drop-shadow(0 7px 5px rgba(20, 57, 64, 0.3));
}

.character-image.is-missing,
.character-idle.is-missing {
  display: none;
}

.character-idle {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  margin-inline: auto;
}

.character-card.is-cheering {
  animation: character-joy 680ms var(--touch-ease) 1;
}

.character-card.has-active-idle .character-image {
  visibility: hidden;
}

.character-card.is-paused .character-idle {
  display: none;
}

.character-fallback {
  display: none;
  padding: 9px 7px;
  color: var(--wm-cream-1);
  background: var(--world-deep);
  border: 2px solid var(--wm-cream-1);
  border-radius: 16px;
  font-size: 0.82rem;
  font-weight: 600;
}

.character-card.is-missing .character-fallback {
  display: block;
}

.guide-speech {
  position: absolute;
  z-index: 7;
  top: 22px;
  left: 15px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  width: min(272px, calc(100% - 190px));
  min-height: 78px;
  min-width: 0;
  align-items: center;
  gap: 8px;
  padding: 12px 12px 12px 16px;
  background: rgba(255, 250, 238, 0.96);
  border: 3px solid var(--wm-wood-1);
  border-radius: 26px 31px 30px 12px;
  box-shadow: 0 7px 16px rgba(25, 58, 65, 0.22);
}

.guide-speech::before {
  position: absolute;
  bottom: -15px;
  left: 6px;
  width: 25px;
  height: 22px;
  background: rgba(255, 250, 238, 0.96);
  border-bottom: 3px solid var(--wm-wood-1);
  border-left: 3px solid var(--wm-wood-1);
  content: "";
  clip-path: polygon(0 0, 100% 0, 34% 100%);
  transform: rotate(-9deg);
}

.guide-speech p {
  min-width: 0;
  margin: 0;
  line-height: 1.05;
  font-size: clamp(0.92rem, 2.2vw, 1.18rem);
  font-weight: 600;
}

.target-chip {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 4px;
  padding: 3px 7px 3px 9px;
  color: var(--wm-cream-1);
  background: var(--world-deep);
  border-radius: 999px;
  font-size: 0.72rem;
}

.target-chip output {
  min-width: 25px;
  color: var(--wm-gold);
  font-size: 1.18rem;
  font-weight: 600;
  text-align: center;
}

.game-board {
  position: absolute;
  z-index: 6;
  top: clamp(228px, 28%, 272px);
  left: 50%;
  display: block;
  width: min(calc(100% - 20px), 620px);
  min-width: 0;
  min-height: 0;
  transform: translateX(-50%);
}

.supply-zone {
  position: absolute;
  z-index: 3;
  top: calc(100% - 8px);
  left: 1%;
  width: min(calc(100% - 122px), 404px);
  min-height: calc(var(--stone-size) + var(--stone-size) + var(--stone-size) + 22px);
  min-width: 0;
  height: max-content;
  overflow: visible;
  padding: 10px 12px 12px;
  background: transparent;
  border: 0;
  border-radius: 28px;
  box-shadow: none;
}

.supply-zone::before {
  position: absolute;
  z-index: -1;
  inset: -11px -15px auto -17px;
  /* The transparent drop target stays stable; the visible patch follows real rows. */
  height: calc(var(--stone-size) + 45px);
  background:
    radial-gradient(ellipse at 24% 36%, #fffdf2 0 30%, transparent 31%),
    radial-gradient(ellipse at 72% 56%, #f5fbf7 0 46%, transparent 47%),
    linear-gradient(150deg, rgba(255, 253, 244, 0.98), rgba(226, 242, 241, 0.92));
  border: 0;
  border-radius: 46% 54% 38% 62% / 42% 35% 65% 58%;
  box-shadow: 0 9px 16px rgba(36, 75, 84, 0.14);
  content: "";
  transform: rotate(-1.2deg);
  pointer-events: none;
}

.supply-zone[data-rows="2"]::before {
  height: calc(var(--stone-size) + var(--stone-size) + 51px);
}

.supply-zone[data-rows="3"]::before {
  height: calc(var(--stone-size) + var(--stone-size) + var(--stone-size) + 57px);
}

.game-board.has-overflow .supply-zone {
  top: calc(100% + 66px);
}

.crate-zone {
  position: relative;
  display: block;
  grid-area: crate;
  width: 100%;
  aspect-ratio: 2 / 1;
  min-width: 0;
  overflow: visible;
  transition: box-shadow 600ms ease, filter 600ms ease;
}

.crate-zone.has-overflow {
  margin-bottom: 0;
}

.crate-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.crate-zone::after {
  position: absolute;
  z-index: 1;
  inset: 12% 9% 14%;
  background: radial-gradient(ellipse, rgba(255, 223, 105, 0.82), rgba(255, 193, 43, 0.18) 50%, transparent 72%);
  border-radius: 38%;
  content: "";
  opacity: 0;
  pointer-events: none;
  transition: opacity 600ms ease;
}

.crate-art.is-missing {
  display: none;
}

.zone-heading,
.crate-heading {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 26px;
}

.zone-heading {
  justify-content: space-between;
}

.crate-heading {
  position: absolute;
  top: 4%;
  right: 5%;
  left: 35%;
  justify-content: flex-end;
}

.zone-heading h3,
.crate-heading h3 {
  margin: 0;
  color: var(--wm-wood-2);
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1;
}

.zone-heading output {
  min-width: 31px;
  padding: 2px 7px;
  color: var(--wm-cream-1);
  background: var(--world-deep);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
}

.live-count {
  display: flex;
  align-items: baseline;
  gap: 4px;
  min-height: 34px;
  padding: 3px 11px;
  color: var(--world-deep);
  background: rgba(255, 248, 230, 0.82);
  border: 1px solid rgba(138, 85, 44, 0.24);
  box-shadow: 0 3px 8px rgba(67, 43, 24, 0.14);
  border-radius: 999px;
}

.live-count output {
  min-width: 28px;
  color: var(--wm-wood-2);
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1;
  text-align: right;
}

.live-count span {
  font-size: 0.68rem;
  white-space: nowrap;
}

.pebble-grid,
.crate-row {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(5, var(--stone-size));
  gap: 6px;
  justify-content: space-between;
}

.pebble-grid {
  grid-auto-rows: var(--stone-size);
  align-content: start;
  margin-top: 0;
}

.crate-row {
  min-height: var(--stone-size);
}

.stone-button,
.slot {
  position: relative;
  display: grid;
  width: var(--stone-size);
  height: var(--stone-size);
  min-width: 48px;
  min-height: 48px;
  place-items: center;
  margin: 0;
  padding: 0;
  border-radius: 19px;
}

.stone-button {
  background: transparent;
  border: 0;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.stone-button:active {
  cursor: grabbing;
}

.stone-button.dragging {
  z-index: 50;
  opacity: 0.25;
}

.stone-button.need-remove {
  outline: 3px dashed var(--wm-amber);
  outline-offset: -1px;
}

.stone-button .stone {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  filter: drop-shadow(0 3px 2px rgba(38, 53, 58, 0.24));
  transition: transform 180ms var(--touch-ease), filter 180ms var(--touch-ease);
  pointer-events: none;
}

.stone-button .stone img {
  display: block;
  width: 92%;
  height: 92%;
  object-fit: contain;
  transform: rotate(var(--stone-tilt, 0deg));
}

.stone-button .stone.is-missing::before {
  width: 78%;
  height: 70%;
  background: var(--world-stone);
  border: 2px solid #425d6d;
  border-radius: 52% 48% 47% 53%;
  box-shadow: inset 3px 3px 0 rgba(255, 255, 255, 0.18);
  content: "";
}

.stone-button:hover .stone,
.stone-button:focus-visible .stone {
  filter: drop-shadow(0 4px 3px rgba(38, 53, 58, 0.3));
  transform: translateY(-2px) scale(1.05);
}

.stone-button.is-arriving .stone {
  animation: stone-settle 260ms var(--touch-ease) 1;
}

.slot {
  background: #e8dec5;
  border: 1px solid rgba(169, 129, 85, 0.42);
  border-radius: 50%;
  box-shadow: inset 0 4px 7px rgba(89, 61, 33, 0.17);
}

.slot::after {
  width: 9px;
  height: 9px;
  background: rgba(138, 85, 44, 0.24);
  border-radius: 50%;
  content: "";
}

.slot.need-add {
  border: 3px dashed var(--wm-amber);
  background: #fff2d3;
}

.slot.need-add::after {
  width: 17px;
  height: 17px;
  background: var(--wm-amber);
  box-shadow: 0 0 0 5px rgba(216, 137, 61, 0.18);
}

.five-rows {
  position: absolute;
  z-index: 2;
  top: 25%;
  right: 7%;
  bottom: 17%;
  left: 7%;
  display: grid;
  align-content: center;
  gap: 4px;
  border-radius: 14px;
  transition: filter 600ms ease, outline-color 600ms ease;
}

.crate-row-wrap {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 16px;
  align-items: center;
  gap: 3px;
}

.row-of-five {
  color: #7d4d25;
  font-size: 0.66rem;
  font-weight: 600;
  text-align: center;
}

.overflow-block {
  position: absolute;
  z-index: 4;
  top: calc(100% + 1px);
  right: 7%;
  left: 7%;
  padding: 2px 10px 7px;
  background: rgba(233, 199, 149, 0.98);
  border: 3px solid var(--wm-wood-2);
  border-radius: 0 0 16px 16px;
  box-shadow: 0 5px 12px rgba(21, 53, 60, 0.2);
}

.overflow-block p {
  margin: 0 0 2px;
  color: #6d4522;
  font-size: 0.68rem;
  font-weight: 600;
  text-align: center;
}

.overflow-block .crate-row {
  grid-template-columns: repeat(5, var(--stone-size));
  justify-content: space-between;
}

.math-cue {
  position: absolute;
  z-index: 4;
  right: 12%;
  bottom: 7%;
  left: 12%;
  padding: 7px 10px;
  color: var(--wm-wood-2);
  background: linear-gradient(180deg, #ffdc72, var(--wm-gold));
  border: 2px solid var(--wm-wood-2);
  border-radius: 999px;
  box-shadow: 0 0 18px rgba(255, 205, 74, 0.74);
  font-weight: 600;
  text-align: center;
}

.crate-zone.is-one-ten {
  filter: drop-shadow(0 0 13px rgba(255, 211, 88, 0.86));
  box-shadow:
    0 0 0 4px rgba(242, 193, 65, 0.42),
    0 5px 12px rgba(21, 53, 60, 0.2);
}

.crate-zone.is-one-ten::after {
  opacity: 1;
  animation: gold-wash 600ms ease-out 1;
}

.crate-zone.is-one-ten .five-rows {
  filter: drop-shadow(0 0 7px rgba(255, 225, 120, 0.95));
  outline: 3px solid rgba(255, 210, 76, 0.78);
  outline-offset: 4px;
}

.crate-zone.is-one-ten .crate-row .stone {
  filter: drop-shadow(0 0 6px rgba(255, 208, 66, 0.9));
}

.answer-area {
  position: absolute;
  z-index: 9;
  top: calc(clamp(228px, 28%, 272px) + min(calc(50vw - 18px), 310px) + var(--stone-size) + var(--stone-size) + var(--stone-size) + 26px);
  right: 7px;
  bottom: auto;
  display: grid;
  grid-template-columns: minmax(0, 230px) auto;
  gap: 8px;
  align-items: center;
  max-width: calc(100% - 14px);
  min-width: 0;
}

.feedback {
  width: max-content;
  max-width: min(230px, 44vw);
  min-width: 0;
  margin: 0;
  overflow: hidden;
  padding: 7px 11px;
  background: rgba(61, 52, 39, 0.72);
  border: 1px solid rgba(255, 248, 230, 0.32);
  border-radius: 14px;
  color: var(--wm-cream-1);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.15;
  text-overflow: ellipsis;
  text-shadow: 0 1px 2px rgba(16, 54, 62, 0.72);
  white-space: nowrap;
}

.feedback:empty {
  display: none;
}

.feedback.is-amber {
  color: #ffe0ae;
}

.ok-button {
  position: relative;
  display: grid;
  grid-template-rows: 78px auto;
  width: 86px;
  min-width: 86px;
  min-height: 96px;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0;
  color: var(--wm-cream-1);
  background: transparent;
  border: 0;
  box-shadow: none;
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(16, 54, 62, 0.82);
}

.ok-button::before,
.ok-button::after {
  position: absolute;
  top: 0;
  left: 50%;
  width: 78px;
  height: 78px;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  content: "";
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%);
}

.ok-button::before {
  background-image: url("assets/ui/button-check-pressed.webp");
}

.ok-button::after {
  background-image: url("assets/ui/button-check-disabled.webp");
}

.ok-button:active:not(:disabled) .ok-art,
.ok-button:disabled .ok-art {
  opacity: 0;
}

.ok-button:active:not(:disabled)::before,
.ok-button:disabled::after {
  opacity: 1;
}

.ok-button:disabled {
  cursor: default;
}

.ok-button:disabled .ok-label {
  opacity: 0.7;
}

.ok-art {
  display: block;
  width: 78px;
  height: 78px;
  object-fit: contain;
  transition: opacity 80ms ease;
}

.ok-label {
  display: block;
  justify-self: center;
  margin-top: -2px;
}

.demo-bar {
  position: absolute;
  z-index: 70;
  top: 22px;
  left: 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: min(272px, calc(100% - 190px));
  min-height: 78px;
  min-width: 0;
  max-width: none;
  padding: 8px 8px 8px 14px;
  color: var(--wm-cream-1);
  background: var(--world-deep);
  border: 2px solid var(--wm-cream-1);
  border-radius: 25px 30px 30px 11px;
  box-shadow: 0 5px 12px rgba(18, 48, 55, 0.28);
  font-size: 0.74rem;
  font-weight: 600;
}

.demo-bar::before {
  position: absolute;
  bottom: -14px;
  left: 7px;
  width: 24px;
  height: 20px;
  background: var(--world-deep);
  border-left: 2px solid var(--wm-cream-1);
  clip-path: polygon(0 0, 100% 0, 34% 100%);
  content: "";
  transform: rotate(-10deg);
}

.demo-bar > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.demo-bar button {
  flex: 0 0 auto;
  min-width: 98px;
  min-height: 48px;
  padding: 5px 14px;
  color: var(--wm-wood-2);
  background: var(--wm-gold);
  border: 2px solid var(--wm-wood-2);
  font-size: 0.78rem;
  font-weight: 600;
}

.game[data-state="demo"] .guide-speech {
  visibility: hidden;
}

.tutorial-hand {
  position: fixed;
  z-index: 260;
  top: 0;
  left: 0;
  width: 82px;
  height: 82px;
  transform: translate3d(10px, 10px, 0);
  transition: transform 430ms cubic-bezier(0.2, 0.8, 0.2, 1);
  pointer-events: none;
  filter: drop-shadow(0 5px 4px rgba(38, 45, 46, 0.3));
  will-change: transform;
}

.tutorial-hand img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.tutorial-hand.is-pointing img {
  animation: hand-point 700ms ease-in-out 1;
}

.drag-layer,
.fx-layer {
  position: fixed;
  inset: 0;
  z-index: 250;
  overflow: hidden;
  pointer-events: none;
}

.drag-layer .stone-clone {
  position: fixed;
  display: grid;
  width: var(--stone-size);
  height: var(--stone-size);
  place-items: center;
  transition: transform 430ms cubic-bezier(0.2, 0.8, 0.2, 1);
  filter: drop-shadow(0 6px 4px rgba(38, 53, 58, 0.28));
  pointer-events: none;
}

.drag-layer .stone-clone img {
  display: block;
  width: 92%;
  height: 92%;
  object-fit: contain;
}

.fx-layer {
  z-index: 270;
}

.firework-burst {
  position: absolute;
  width: 0;
  height: 0;
  isolation: isolate;
  pointer-events: none;
}

.firework-flare {
  position: absolute;
  top: 0;
  left: 0;
  width: calc(var(--firework-radius, 72px) * 1.8);
  height: calc(var(--firework-radius, 72px) * 1.8);
  margin: calc(var(--firework-radius, 72px) * -0.9) 0 0 calc(var(--firework-radius, 72px) * -0.9);
  background: radial-gradient(
    circle,
    transparent 0 43%,
    rgba(255, 248, 230, 0.14) 45%,
    rgba(242, 193, 65, 0.3) 49%,
    transparent 58%
  );
  border: 2px solid rgba(255, 248, 230, 0.5);
  border-radius: 50%;
  opacity: 0;
  animation: firework-flare var(--firework-life, 1800ms) var(--burst-delay, 0ms) ease-out both;
}

.firework-trail {
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: var(--trail-height, 46px);
  margin: calc(var(--trail-height, 46px) * -1) 0 0 -2px;
  background: linear-gradient(180deg, #fff8e6, #f2c141 70%, transparent);
  border-radius: 999px;
  box-shadow:
    0 0 5px rgba(255, 248, 230, 0.95),
    0 0 12px rgba(242, 193, 65, 0.72);
  opacity: 0;
  pointer-events: none;
  transform-origin: 50% 100%;
  animation: firework-trail var(--firework-life, 1800ms) var(--burst-delay, 0ms) ease-out both;
}

.firework-trail::after {
  position: absolute;
  top: -3px;
  left: 50%;
  width: 9px;
  height: 9px;
  background: #fff8e6;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(242, 193, 65, 0.9);
  content: "";
  transform: translateX(-50%);
}

.firework-particle,
.firework-confetti {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  opacity: 0;
  pointer-events: none;
  transform-origin: 50% 50%;
  animation: firework-spark var(--firework-life, 1800ms) var(--burst-delay, 0ms) ease-out both;
  will-change: transform, opacity;
}

.firework-particle {
  width: var(--spark-length, 17px);
  height: var(--spark-width, 3px);
  background: var(--fx-color, #f2c141);
  border-radius: 999px;
  box-shadow:
    0 0 4px rgba(255, 248, 230, 0.78),
    0 0 9px rgba(242, 193, 65, 0.66);
}

.firework-confetti {
  width: 7px;
  height: 13px;
  background: var(--fx-color, #fff8e6);
  border: 1px solid rgba(61, 50, 38, 0.16);
  border-radius: 2px;
  clip-path: polygon(14% 0, 100% 8%, 86% 100%, 0 90%);
  animation-name: firework-confetti;
}

.ice-drift {
  position: absolute;
  width: var(--drift-size, 7px);
  height: var(--drift-size, 7px);
  background: #e8f3ef;
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: 50%;
  box-shadow: 0 0 7px rgba(232, 243, 239, 0.8);
  opacity: 0;
  pointer-events: none;
  animation: ice-drift var(--drift-duration, 14000ms) linear var(--drift-delay, 0ms) infinite;
}

.snow-fleck {
  position: absolute;
  width: 7px;
  height: 7px;
  background: #fffdf3;
  border: 1px solid rgba(121, 169, 177, 0.42);
  border-radius: 50%;
  opacity: 0;
  animation: snow-fleck 420ms var(--touch-ease) var(--fleck-delay, 0ms) 1 forwards;
}

.crate-zone.is-nudging {
  animation: gentle-nudge 380ms ease-in-out 1;
}

.stone-button.demo-watch {
  outline: 4px solid var(--wm-gold);
  outline-offset: 2px;
}

.ok-button.is-demo-press {
  transform: scale(0.94);
}

.ok-button.is-demo-press::after {
  background-image: url("assets/ui/button-check-pressed.webp");
  opacity: 1;
}

.ok-button.is-demo-press .ok-art {
  opacity: 0;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding:
    max(16px, var(--safe-top))
    max(16px, var(--safe-right))
    max(16px, calc(var(--safe-bottom) + 48px))
    max(16px, calc(var(--safe-left) + 48px));
  background: rgba(19, 53, 61, 0.68);
}

#roundOverlay,
#levelOverlay,
#finalOverlay {
  background: rgba(19, 53, 61, 0.28);
}

.dialog {
  position: relative;
  width: min(620px, 100%);
  max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 76px);
  overflow: auto;
  padding: 24px;
  color: var(--wm-ink);
  background: var(--wm-cream-1);
  border: 4px solid var(--wm-wood-1);
  border-radius: var(--wm-radius-panel);
  box-shadow: 0 16px 38px rgba(18, 43, 48, 0.35);
  scrollbar-color: var(--wm-wood-1) transparent;
}

.success-dialog > .gold-mark,
.level-dialog > .high-five-frame,
.final-dialog > .one-ten-badge {
  animation: reward-enter 520ms var(--touch-ease) 1 both;
}

.success-dialog > h2,
.level-dialog > h2,
.final-dialog > h2 {
  animation: reward-title-enter 440ms var(--touch-ease) 1 both;
}

.dialog h2 {
  margin: 0 0 8px;
  color: var(--world-deep);
  font-size: clamp(1.65rem, 4vw, 2.35rem);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.dialog p {
  margin: 0 0 14px;
}

.dialog-kicker {
  color: var(--wm-wood-2) !important;
  font-size: 0.82rem;
  font-weight: 600;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.primary-button,
.quiet-button {
  min-width: 144px;
  padding: 10px 22px;
  border: 3px solid var(--wm-wood-2);
  font-weight: 600;
}

.primary-button {
  color: var(--wm-cream-1);
  background: var(--wm-wood-2);
  box-shadow: 0 4px 0 #623b1c;
}

.illustrated-next {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 20px 10px 12px;
  color: var(--world-deep);
  background: none;
  border: 0;
  box-shadow: none;
  white-space: nowrap;
}

.illustrated-next::before,
.illustrated-next::after {
  position: absolute;
  top: 50%;
  left: 12px;
  width: 44px;
  height: 44px;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  content: "";
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%);
}

.illustrated-next::before {
  background-image: url("assets/ui/button-next-pressed.webp");
}

.illustrated-next::after {
  background-image: url("assets/ui/button-next-disabled.webp");
}

.illustrated-next:active:not(:disabled) .next-art,
.illustrated-next:disabled .next-art {
  opacity: 0;
}

.illustrated-next:active:not(:disabled)::before,
.illustrated-next:disabled::after {
  opacity: 1;
}

.next-art {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  object-fit: contain;
  transition: opacity 80ms ease;
}

.quiet-button {
  color: var(--wm-wood-2);
  background: var(--wm-cream-2);
}

.level-menu {
  display: grid;
  gap: 7px;
  margin-top: 16px;
}

.level-choice {
  display: flex;
  min-height: 50px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 12px;
  color: var(--world-deep);
  background: var(--wm-cream-2);
  border: 2px solid var(--wm-wood-1);
  border-radius: 15px;
  cursor: pointer;
}

.level-choice:disabled {
  opacity: 0.48;
  cursor: default;
}

.level-choice.is-complete {
  background: #f7df9c;
}

.level-choice svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.success-dialog,
.level-dialog,
.final-dialog {
  text-align: center;
}

.gold-mark {
  display: grid;
  width: 84px;
  height: 84px;
  margin: 0 auto 12px;
  place-items: center;
  color: var(--wm-wood-2);
  background: var(--wm-gold);
  border: 3px solid var(--wm-wood-2);
  border-radius: 50%;
  box-shadow: 0 6px 0 rgba(108, 69, 33, 0.3);
}

.gold-mark svg {
  width: 53px;
  height: 53px;
  fill: var(--wm-cream-1);
  stroke: var(--wm-wood-2);
  stroke-width: 2.5;
  stroke-linejoin: round;
}

.success-dialog .primary-button,
.level-dialog .primary-button,
.final-dialog .primary-button,
.final-dialog .quiet-button {
  margin: 4px auto 0;
}

.high-five-frame {
  display: grid;
  min-height: 170px;
  place-items: center;
  margin: 6px 0 14px;
  overflow: hidden;
  background: #eed6a9;
  border: 3px solid var(--wm-wood-1);
  border-radius: 24px;
}

.high-five-frame > img {
  display: block;
  width: min(100%, 420px);
  max-height: 230px;
  object-fit: contain;
}

.pair-fallback {
  align-items: end;
  justify-content: center;
  gap: 18px;
  width: 100%;
  height: 170px;
}

.pair-fallback:not([hidden]) {
  display: flex;
}

.pair-fallback img {
  width: 42%;
  max-width: 170px;
  height: 150px;
  object-fit: contain;
}

.one-ten-badge {
  position: relative;
  display: grid;
  width: min(280px, 90%);
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
  margin: 0 auto 18px;
  padding: 18px 18px 44px;
  background: var(--wm-wood-1);
  border: 4px solid var(--wm-wood-2);
  border-radius: 22px;
  box-shadow: 0 7px 0 rgba(88, 51, 25, 0.32);
}

.one-ten-badge span {
  aspect-ratio: 1;
  background: var(--world-stone);
  border: 2px solid #425d6d;
  border-radius: 52% 48% 46% 54%;
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.18);
}

.one-ten-badge strong {
  position: absolute;
  right: 10px;
  bottom: 7px;
  left: 10px;
  padding: 3px 8px;
  color: var(--wm-wood-2);
  background: var(--wm-gold);
  border: 2px solid var(--wm-wood-2);
  border-radius: 999px;
  font-size: 1rem;
}

.final-equation {
  color: var(--wm-wood-2);
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-weight: 600;
}

.audio-status {
  min-height: 1.3em;
  margin: 10px 0 0 !important;
  color: #6b5135;
  font-size: 0.82rem;
}

.help-dialog {
  width: min(760px, 100%);
}

.dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  padding: 0;
  color: var(--wm-wood-2);
  background: var(--wm-cream-2);
  border: 2px solid var(--wm-wood-1);
  border-radius: 50%;
  cursor: pointer;
}

.dialog-close svg {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
}

.parent-help {
  max-width: 68ch;
  color: #5a4630;
  font-size: 0.93rem;
}

.help-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  padding: 0;
  margin: 12px 0;
  list-style: none;
}

.help-steps li {
  display: grid;
  grid-template-rows: 112px auto;
  gap: 6px;
  padding: 9px;
  background: var(--wm-cream-2);
  border: 2px solid var(--wm-wood-1);
  border-radius: 19px;
}

.help-steps p {
  margin: 0;
  font-size: 0.86rem;
  font-weight: 600;
  text-align: center;
}

.help-picture {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #e5d1ad;
  border-radius: 14px;
}

.help-picture img.is-missing,
.mini-demo img.is-missing {
  visibility: hidden;
}

.help-pebble {
  width: 54px;
  height: 54px;
  object-fit: contain;
}

.help-hand {
  position: absolute;
  right: 8px;
  bottom: -2px;
  width: 64px;
  height: 64px;
  object-fit: contain;
}

.help-crate {
  width: 86px;
  height: 86px;
  object-fit: contain;
}

.help-target {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: var(--wm-gold);
  background: var(--world-deep);
  border-radius: 50%;
  font-weight: 600;
}

.help-ok {
  display: block;
  width: 78px;
  height: 78px;
  object-fit: contain;
}

.mini-demo {
  position: relative;
  height: 94px;
  margin: 12px 0;
  overflow: hidden;
  background: #decaa5;
  border: 2px solid var(--wm-wood-1);
  border-radius: 18px;
}

.mini-crate {
  position: absolute;
  top: 8px;
  right: 28px;
  width: 91px;
  height: 78px;
  object-fit: contain;
}

.mini-source,
.mini-target {
  position: absolute;
  width: 28px;
  height: 24px;
  background: var(--world-stone);
  border: 2px solid #425d6d;
  border-radius: 52% 48% 46% 54%;
}

.mini-source {
  top: 46px;
  left: 32px;
}

.mini-target {
  top: 27px;
  right: 57px;
  opacity: 0.35;
}

.mini-hand {
  position: absolute;
  top: 30px;
  left: 38px;
  width: 52px;
  height: 52px;
  object-fit: contain;
}

.mini-demo.is-playing .mini-hand {
  animation: mini-hand-demo 1700ms ease-in-out 1;
}

.help-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.corner-rune {
  position: fixed;
  z-index: 500;
  bottom: max(4px, var(--safe-bottom));
  left: max(4px, var(--safe-left));
  width: 38px;
  height: auto;
  pointer-events: none;
  opacity: 0.94;
  filter: drop-shadow(0 2px 2px rgba(44, 36, 29, 0.25));
}

noscript {
  position: fixed;
  z-index: 999;
  inset: 12px;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--wm-ink);
  background: var(--wm-cream-1);
  border: 4px solid var(--wm-wood-1);
  border-radius: 24px;
  text-align: center;
}

@media (orientation: portrait) {
  .bg-portrait,
  .intro-portrait {
    display: block;
  }

  .bg-landscape,
  .intro-landscape {
    display: none;
  }

  .game-shell.fallback-landscape .bg-landscape,
  .opening.fallback-landscape .intro-landscape {
    display: block;
  }
}

@media (orientation: landscape) {
  .intro-image {
    bottom: 86px;
    height: calc(100% - 86px);
  }

  .intro-action {
    bottom: max(12px, calc(var(--safe-bottom) + 8px));
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    width: min(560px, calc(100% - 32px));
    padding: 9px 14px;
  }

  .play-button {
    min-height: 56px;
    padding: 8px 24px;
    font-size: 1.25rem;
  }

  .game-shell {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: 64px minmax(0, 1fr);
    grid-template-areas:
      "controls hud"
      "play play";
    gap: 6px;
    padding:
      max(6px, var(--safe-top))
      max(8px, var(--safe-right))
      max(6px, var(--safe-bottom))
      max(8px, var(--safe-left));
  }

  .game-controls {
    grid-area: controls;
    justify-content: flex-start;
  }

  .top-hud {
    grid-area: hud;
    justify-content: flex-end;
    padding: 0;
  }

  .level-token {
    width: 34px;
    height: 34px;
  }

  .task-meta {
    font-size: 0.82rem;
  }

  .task-star {
    width: 25px;
    height: 25px;
  }

  .playfield {
    grid-area: play;
    justify-content: center;
    grid-template-areas:
      "sopo speech walrus"
      "sopo board walrus"
      "sopo answer walrus";
    grid-template-columns: clamp(150px, 18vw, 230px) minmax(0, 640px) clamp(150px, 18vw, 230px);
    grid-template-rows: 62px minmax(0, 1fr) 58px;
    column-gap: 16px;
    row-gap: 6px;
  }

  .zone-heading,
  .crate-heading {
    min-height: 29px;
  }

  .guide-speech,
  .demo-bar {
    justify-self: center;
    width: min(100%, 620px);
  }

  .character-card {
    align-self: end;
  }

  .character-image,
  .character-idle {
    width: min(100%, 240px);
    height: min(100%, 320px);
    object-position: center bottom;
  }

  .answer-area {
    justify-self: center;
    width: min(100%, 700px);
  }

  .feedback {
    font-size: 0.9rem;
  }

  .ok-button {
    min-width: 126px;
  }

  .corner-rune {
    width: 48px;
  }
}

@media (min-width: 900px) and (orientation: landscape) {
  :root {
    --stone-size: 56px;
  }
}

@media (orientation: landscape) and (max-height: 740px) {
  .playfield {
    grid-template-columns: clamp(128px, 15vw, 168px) minmax(0, 880px) clamp(128px, 15vw, 168px);
    column-gap: 12px;
  }

  .game-board {
    grid-template-areas: "crate supply";
    grid-template-columns: minmax(400px, 440px) minmax(calc(var(--stone-size) * 5 + 32px), 1fr);
    grid-template-rows: minmax(0, 1fr);
    width: min(100%, 880px);
    gap: 10px;
  }

  .crate-zone,
  .supply-zone {
    align-self: center;
  }

  .five-rows {
    top: 24%;
  }
}

@media (orientation: landscape) and (max-height: 680px) {
  .playfield {
    grid-template-areas:
      "sopo speech walrus"
      "board board board"
      "answer answer answer";
    grid-template-columns: minmax(64px, 0.7fr) minmax(0, 2fr) minmax(72px, 0.8fr);
    grid-template-rows: 54px minmax(0, 1fr) 54px;
    gap: 4px;
  }

  .character-image,
  .character-idle {
    height: 54px;
  }

  .guide-speech,
  .demo-bar {
    width: min(100%, 560px);
    min-height: 52px;
    padding-top: 5px;
    padding-bottom: 5px;
  }

  .demo-bar {
    min-height: 0;
    padding-top: 0;
    padding-bottom: 0;
  }

  .row-of-five {
    display: none;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .game-board {
    grid-template-columns: minmax(400px, 420px) minmax(calc(var(--stone-size) * 5 + 32px), 1fr);
  }

  .supply-zone {
    padding: 3px 5px 4px;
  }

  .zone-heading {
    min-height: 22px;
  }

  .pebble-grid {
    gap: 3px;
    margin-top: 0;
  }

  .crate-zone.has-overflow {
    margin-bottom: 0;
  }

  .overflow-block {
    top: calc(100% - 8px);
    padding-top: 2px;
    padding-bottom: 1px;
  }

  .overflow-block p {
    display: none;
  }
}

@media (max-width: 390px) and (orientation: portrait) {
  .five-rows {
    top: 24%;
  }

  .game-shell {
    padding-right: max(8px, var(--safe-right));
    padding-left: max(8px, var(--safe-left));
  }

  .game-controls {
    gap: 8px;
  }

  .control-button {
    flex-basis: 56px;
    width: 56px;
    height: 56px;
  }

  .round-progress {
    gap: 4px;
  }

  .task-meta {
    max-width: 112px;
  }

  .guide-speech {
    gap: 4px;
    padding: 5px 6px 5px 9px;
  }

  .demo-bar {
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    padding: 4px 6px;
    font-size: 0.66rem;
    line-height: 1.05;
  }

  .demo-bar button {
    width: 100%;
    min-width: 0;
  }

  .guide-speech p {
    font-size: 0.8rem;
  }

  .target-chip {
    padding-left: 7px;
  }

  .answer-area {
    gap: 5px;
  }

  .ok-button {
    min-width: 94px;
    padding-right: 14px;
    padding-left: 10px;
  }
}

@media (max-height: 680px) and (orientation: portrait) {
  .game-shell {
    grid-template-rows: 56px 37px minmax(0, 1fr);
  }

  .playfield {
    grid-template-rows: 86px minmax(0, 1fr) 54px;
    gap: 4px;
  }

  .character-card {
    max-height: 86px;
  }

  .guide-speech {
    min-height: 82px;
  }

  .answer-area {
    min-height: 54px;
  }

  .ok-button {
    min-height: 54px;
  }

  .dialog {
    padding: 18px;
  }

  .help-steps {
    grid-template-rows: 96px auto;
  }

  .help-steps li {
    grid-template-rows: 96px auto;
    padding: 7px;
  }

  .mini-demo {
    height: 80px;
  }
}

@media (max-width: 430px) {
  .help-steps {
    gap: 6px;
  }

  .help-steps li {
    padding: 6px;
  }

  .help-steps p {
    font-size: 0.76rem;
  }
}

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

  .tutorial-hand {
    transition: none;
  }

  .mini-demo.is-playing .mini-hand {
    top: 33px;
    left: calc(100% - 130px);
  }

}

@keyframes hand-point {
  0%,
  100% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.12) translate(-3px, -4px);
  }
}

@keyframes gentle-nudge {
  0%,
  100% {
    transform: translateX(0);
  }
  35% {
    transform: translateX(-4px);
  }
  70% {
    transform: translateX(3px);
  }
}

@keyframes firework-flare {
  0% {
    opacity: 0;
    transform: scale(0.18);
  }
  18% {
    opacity: 0.08;
  }
  35%,
  54% {
    opacity: 0.4;
    transform: scale(0.78);
  }
  100% {
    opacity: 0;
    transform: scale(1);
  }
}

@keyframes firework-trail {
  0% {
    opacity: 0;
    transform: translate3d(0, var(--trail-drop, 40px), 0) scaleY(0.24);
  }
  35% {
    opacity: 1;
    transform: translate3d(0, 0, 0) scaleY(1);
  }
  58% {
    opacity: 0.64;
    transform: translate3d(0, -3px, 0) scaleY(0.82);
  }
  100% {
    opacity: 0;
    transform: translate3d(0, -10px, 0) scaleY(0.16);
  }
}

@keyframes firework-spark {
  0% {
    opacity: 0;
    transform: rotate(var(--fx-angle, 0rad)) translateX(0) scaleX(0.28);
  }
  18% {
    opacity: 0.2;
  }
  35% {
    opacity: 0.98;
    transform: rotate(var(--fx-angle, 0rad)) translateX(calc(var(--fx-distance, 54px) * 0.7)) scaleX(1);
  }
  68% {
    opacity: 0.74;
    transform: rotate(var(--fx-angle, 0rad)) translateX(calc(var(--fx-distance, 54px) * 0.94)) scaleX(0.72);
  }
  100% {
    opacity: 0;
    transform: rotate(var(--fx-angle, 0rad)) translateX(var(--fx-distance, 54px)) scaleX(0.12);
  }
}

@keyframes firework-confetti {
  0% {
    opacity: 0;
    transform: rotate(var(--fx-angle, 0rad)) translateX(0) rotate(0) scale(0.35);
  }
  35% {
    opacity: 0.94;
  }
  100% {
    opacity: 0;
    transform:
      rotate(var(--fx-angle, 0rad))
      translateX(var(--fx-distance, 54px))
      rotate(var(--fx-spin, 270deg))
      scale(0.82);
  }
}

@keyframes ice-drift {
  0%,
  100% {
    opacity: 0;
    transform: translate3d(0, 0, 0) scale(0.76);
  }
  24%,
  72% {
    opacity: var(--drift-opacity, 0.5);
    transform: translate3d(var(--drift-x, 8px), var(--drift-y, -18px), 0) scale(1);
  }
}

@keyframes reward-enter {
  0% {
    opacity: 0;
    transform: translateY(12px) scale(0.94);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes reward-title-enter {
  0% {
    opacity: 0;
    transform: translateY(8px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes mini-hand-demo {
  0%,
  18% {
    transform: translate(0, 0) scale(1);
  }
  48%,
  58% {
    transform: translate(150px, -8px) scale(1.06);
  }
  100% {
    transform: translate(0, 0) scale(1);
  }
}

/* Close-up Ice Bay composition */
@media (orientation: portrait) and (min-width: 560px) and (max-width: 900px) {
  :root {
    --stone-size: clamp(64px, 11.63vw, 80px);
  }

  .world-image {
    object-position: center 72%;
  }

  .game-board {
    top: clamp(228px, 28%, 272px);
    width: min(calc(100% - 20px), 620px);
  }

  .supply-zone {
    left: 2%;
    width: min(calc(100% - 40px), 480px);
  }

  .five-rows {
    right: 14%;
    left: 14%;
  }

  .answer-area {
    top: calc(clamp(228px, 28%, 272px) + min(calc(50vw - 18px), 310px) + 64px + 64px + 64px + 26px);
  }
}

@media (orientation: portrait) and (max-width: 559px) {
  :root {
    --stone-size: 52px;
  }

  .playfield::before {
    height: 82%;
  }

  .character-card {
    max-height: none;
  }

  .character-image,
  .character-idle {
    width: 100%;
    height: 100%;
  }

  .sopo-card {
    top: 48px;
    left: -9px;
    width: min(170px, 43%);
    height: 180px;
  }

  .walrus-card {
    top: -22px;
    right: -8%;
    width: min(252px, 60%);
    height: 242px;
  }

  .guide-speech,
  .demo-bar {
    top: 9px;
    left: 8px;
    width: min(218px, 58%);
    min-height: 74px;
    padding: 8px 8px 8px 12px;
  }

  .guide-speech {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 5px;
  }

  .guide-speech p {
    font-size: 0.8rem;
  }

  .target-chip {
    padding: 2px 5px 2px 7px;
    font-size: 0.66rem;
  }

  .target-chip output {
    min-width: 22px;
    font-size: 1rem;
  }

  .demo-bar {
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    font-size: 0.66rem;
    line-height: 1.05;
  }

  .demo-bar button {
    width: 100%;
    min-width: 0;
  }

  .game-board {
    top: clamp(94px, 18%, 150px);
    width: calc(100% - 8px);
  }

  .supply-zone {
    left: 4%;
    width: 92%;
    min-height: calc(var(--stone-size) + var(--stone-size) + var(--stone-size) + 20px);
    padding: 8px 10px 10px;
  }

  .pebble-grid {
    gap: 4px;
  }

  .five-rows {
    top: 23%;
    right: 5%;
    bottom: 15%;
    left: 5%;
  }

  .crate-row {
    gap: 4px;
  }

  .crate-heading {
    top: 3%;
    right: 4%;
    left: 32%;
  }

  .live-count {
    min-height: 29px;
    padding: 2px 7px;
  }

  .live-count output {
    font-size: 1.12rem;
  }

  .row-of-five {
    display: none;
  }

  .answer-area {
    top: calc(clamp(94px, 18%, 150px) + min(calc(50vw - 8px), 310px) + var(--stone-size) + var(--stone-size) + var(--stone-size) + 26px);
    right: 4px;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 5px;
  }

  .feedback {
    max-width: 44vw;
    padding: 6px 8px;
    font-size: 0.7rem;
  }

  .ok-button {
    min-width: 98px;
    min-height: 55px;
    padding: 5px 12px 7px 10px;
    font-size: 1.12rem;
  }

}

@media (orientation: portrait) and (max-width: 430px) {
  :root {
    --stone-size: 48px;
  }

  .walrus-card {
    width: min(222px, 61%);
    height: 216px;
  }

  .sopo-card {
    width: min(150px, 43%);
    height: 164px;
  }

  .guide-speech,
  .demo-bar {
    width: min(205px, 58%);
  }

  .answer-area {
    top: calc(clamp(94px, 18%, 150px) + min(calc(50vw - 8px), 310px) + var(--stone-size) + var(--stone-size) + var(--stone-size) + 26px);
  }
}

@media (orientation: portrait) and (max-width: 430px) and (min-height: 720px) {
  .game-board {
    top: clamp(145px, 26%, 205px);
  }

  .answer-area {
    top: calc(clamp(145px, 26%, 205px) + min(calc(50vw - 8px), 310px) + var(--stone-size) + var(--stone-size) + var(--stone-size) + 26px);
  }
}

@media (orientation: portrait) and (min-width: 700px) and (min-height: 1100px) {
  .game-board {
    top: clamp(280px, 34%, 360px);
  }

  .answer-area {
    top: calc(clamp(280px, 34%, 360px) + min(calc(50vw - 18px), 310px) + 64px + 64px + 64px + 26px);
  }
}

@media (orientation: landscape) {
  :root {
    --stone-size: 48px;
  }

  .game-shell {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: 64px minmax(0, 1fr);
    grid-template-areas:
      "controls hud"
      "play play";
    gap: 6px;
  }

  .game-controls {
    grid-area: controls;
    justify-content: flex-start;
    margin-inline: 0;
  }

  .top-hud {
    grid-area: hud;
    justify-content: flex-end;
    padding: 3px 9px;
  }

  .playfield {
    grid-area: play;
  }

  .character-card {
    max-height: none;
  }

  .character-image,
  .character-idle {
    width: 100%;
    height: 100%;
  }

  .sopo-card {
    top: 58px;
    left: 8px;
    width: clamp(128px, 18vw, 190px);
    height: clamp(140px, 24vw, 220px);
  }

  .walrus-card {
    top: -22px;
    right: 1%;
    width: clamp(210px, 24vw, 320px);
    height: clamp(222px, 28vw, 350px);
  }

  .guide-speech,
  .demo-bar {
    top: 6px;
    left: 12px;
    width: min(220px, 27vw);
    min-height: 62px;
    padding: 7px 9px 7px 11px;
  }

  .guide-speech p {
    font-size: 0.8rem;
  }

  .target-chip {
    padding: 2px 5px 2px 7px;
    font-size: 0.67rem;
  }

  .target-chip output {
    min-width: 22px;
    font-size: 1rem;
  }

  .demo-bar {
    font-size: 0.7rem;
  }

  .demo-bar button {
    min-width: 92px;
    min-height: 48px;
    padding: 3px 9px;
    font-size: 0.7rem;
  }

  .game-board {
    top: clamp(74px, 12%, 100px);
    left: 4%;
    width: min(48vw, 520px);
    transform: none;
  }

  .supply-zone {
    top: 6px;
    left: calc(100% + 10px);
    width: max(calc(var(--stone-size) + var(--stone-size) + var(--stone-size) + var(--stone-size) + var(--stone-size) + 14px), min(31vw, 340px));
    min-height: calc(var(--stone-size) + var(--stone-size) + var(--stone-size) + 22px);
    padding: 5px 4px 7px;
  }

  .game-board.has-overflow .supply-zone {
    top: 6px;
  }

  .pebble-grid {
    gap: 1px;
  }

  .five-rows {
    top: 22%;
    right: 5%;
    bottom: 14%;
    left: 5%;
  }

  .crate-row {
    gap: 2px;
  }

  .row-of-five {
    display: none;
  }

  .crate-heading {
    left: 36%;
  }

  .live-count {
    min-height: 28px;
    padding: 2px 7px;
  }

  .live-count output {
    font-size: 1.05rem;
  }

  .live-count span {
    font-size: 0.58rem;
  }

  .overflow-block {
    top: calc(100% + 5px);
    right: 5%;
    left: 5%;
    padding: 1px 6px 4px;
  }

  .overflow-block p {
    display: none;
  }

  .answer-area {
    top: calc(clamp(74px, 12%, 100px) + var(--stone-size) + var(--stone-size) + var(--stone-size) + 32px);
    right: auto;
    left: calc(4% + min(48vw, 520px) + 10px);
    gap: 5px;
  }

  .feedback {
    max-width: min(190px, 21vw);
    padding: 5px 8px;
    font-size: 0.68rem;
  }

  .ok-button {
    min-width: 104px;
    min-height: 56px;
    padding: 4px 12px 6px 10px;
    font-size: 1.12rem;
  }

  .corner-rune {
    width: 44px;
  }
}

@media (orientation: landscape) and (min-width: 900px) and (min-height: 650px) {
  :root {
    --stone-size: 64px;
  }

  .walrus-card {
    width: clamp(300px, 23vw, 350px);
    height: clamp(320px, 26vw, 390px);
  }

  .sopo-card {
    width: clamp(170px, 13vw, 215px);
    height: clamp(200px, 16vw, 250px);
  }

  .answer-area {
    top: calc(clamp(74px, 12%, 100px) + var(--stone-size) + var(--stone-size) + var(--stone-size) + 32px);
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .game-shell {
    grid-template-rows: 56px minmax(0, 1fr);
    gap: 4px;
  }

  .control-button {
    width: 56px;
    height: 56px;
  }

  .game-board {
    width: min(46vw, 520px);
  }

  .answer-area {
    top: auto;
    bottom: 8px;
    left: calc(4% + min(46vw, 520px) + 10px);
  }

  .overflow-block {
    top: calc(100% - 4px);
    padding: 0 6px 2px;
  }

  .guide-speech,
  .demo-bar {
    min-height: 56px;
  }

  .walrus-card {
    top: -20px;
    width: clamp(190px, 23vw, 230px);
    height: 220px;
  }

  .sopo-card {
    top: 48px;
    width: 122px;
    height: 134px;
  }

  .feedback {
    display: none;
  }
}

@media (orientation: landscape) and (min-height: 501px) and (max-height: 649px) {
  .answer-area {
    grid-template-columns: minmax(0, 1fr);
    width: min(104px, 100%);
  }

  .feedback {
    display: none;
  }
}

/* Final stage: one snow floor, a shallow perspective tray, and one compact shore. */
:root {
  --scene-supply-gap: 4px;
  --scene-five-width:
    calc(
      var(--stone-size) + var(--stone-size) + var(--stone-size) +
      var(--stone-size) + var(--stone-size) +
      var(--scene-supply-gap) + var(--scene-supply-gap) +
      var(--scene-supply-gap) + var(--scene-supply-gap)
    );
  --scene-three-width:
    calc(
      var(--stone-size) + var(--stone-size) + var(--stone-size) +
      var(--scene-supply-gap) + var(--scene-supply-gap)
    );
  --scene-three-rows:
    calc(
      var(--stone-size) + var(--stone-size) + var(--stone-size) +
      var(--scene-supply-gap) + var(--scene-supply-gap)
    );
  --scene-board-width: min(calc(100% - 12px), 620px);
  --scene-board-height: min(calc(50vw - 6px), 310px);
  --scene-board-left: 50%;
  --scene-board-top: 280px;
  --scene-board-transform: translateX(-50%);
  --scene-supply-left: 8px;
  --scene-supply-top: calc(100% + 12px);
  --scene-char-baseline: 280px;
}

.game-shell {
  grid-template-rows: 56px 32px minmax(0, 1fr);
  gap: 4px;
}

.game-controls {
  position: relative;
  display: flex;
  width: max-content;
  max-width: 100%;
  min-width: 0;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-inline: auto;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.control-button {
  flex: 0 0 56px;
  width: 56px;
  height: 56px;
}

.control-button:disabled .control-art {
  opacity: 1;
}

.control-button:disabled::after {
  opacity: 0;
}

.top-hud {
  grid-row: 2;
  align-self: center;
  justify-content: center;
  gap: 28px;
  width: 100%;
  height: 32px;
  padding: 0 6px;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.level-path {
  flex: 0 0 auto;
  gap: 3px;
}

.level-token {
  width: 26px;
  height: 26px;
  color: var(--world-deep);
  background: rgba(255, 250, 238, 0.88);
  border: 1px solid rgba(23, 75, 87, 0.28);
  border-radius: 9px;
  box-shadow: 0 2px 5px rgba(23, 75, 87, 0.14);
}

.level-token svg {
  width: 19px;
  height: 19px;
}

.level-token.is-current {
  border-color: var(--wm-gold);
  box-shadow: 0 0 0 2px rgba(242, 193, 65, 0.34);
}

.round-progress {
  flex: 0 0 auto;
  gap: 8px;
}

.task-meta {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
}

.task-stars {
  gap: 2px;
}

.task-star {
  width: 20px;
  height: 20px;
}

.task-star path {
  fill: rgba(23, 75, 87, 0.18);
  stroke: rgba(23, 75, 87, 0.86);
}

.task-star.is-earned path {
  fill: var(--wm-gold);
  stroke: var(--wm-wood-2);
}

.world-image {
  object-position: center bottom;
}

.playfield {
  overflow: visible;
}

.playfield::before,
.scene-snow {
  display: none;
}

.character-card {
  position: absolute;
  z-index: 5;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  align-self: auto;
  margin: 0;
  pointer-events: none;
  filter: drop-shadow(0 6px 3px rgba(44, 61, 67, 0.22));
}

.character-image,
.character-idle {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  object-fit: contain;
  object-position: center bottom;
}

.guide-speech,
.demo-bar {
  z-index: 7;
  display: grid;
  align-items: center;
  color: var(--world-deep);
  background: rgba(255, 250, 238, 0.96);
  border: 2px solid rgba(151, 103, 61, 0.72);
  border-radius: 22px 26px 24px 10px;
  box-shadow: 0 5px 12px rgba(40, 66, 72, 0.16);
}

.guide-speech {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px;
  padding: 7px 8px 7px 11px;
}

.guide-speech::before {
  bottom: -11px;
  left: 7px;
  width: 20px;
  height: 16px;
  background: rgba(255, 250, 238, 0.96);
  border-bottom: 2px solid rgba(151, 103, 61, 0.72);
  border-left: 2px solid rgba(151, 103, 61, 0.72);
}

.guide-speech p {
  font-size: 0.94rem;
  line-height: 1.02;
}

.target-chip {
  padding: 2px 6px 2px 7px;
  color: var(--wm-cream-1);
  background: var(--world-deep);
}

.target-chip output {
  min-width: 22px;
  font-size: 1rem;
}

.game-board,
.game-board.has-overflow {
  position: absolute;
  z-index: 6;
  top: var(--scene-board-top);
  left: var(--scene-board-left);
  width: var(--scene-board-width);
  transform: var(--scene-board-transform);
}

.crate-zone {
  width: 100%;
  overflow: visible;
  filter: drop-shadow(0 9px 6px rgba(49, 66, 70, 0.22));
}

.crate-art {
  object-fit: contain;
}

.crate-heading {
  top: 5%;
  right: 5%;
}

.live-count {
  min-height: 27px;
  padding: 2px 8px;
  background: rgba(255, 250, 238, 0.9);
}

.live-count output {
  font-size: 1.05rem;
}

.five-rows {
  top: 20%;
  right: 15%;
  bottom: 22%;
  left: 15%;
  display: grid;
  align-content: center;
  gap: 2px;
}

.crate-row-wrap {
  display: block;
}

.row-of-five {
  display: none;
}

.crate-row {
  width: 100%;
  min-height: var(--stone-size);
  grid-template-columns: repeat(5, var(--stone-size));
  gap: 0;
  justify-content: space-between;
  justify-self: stretch;
}

.slot,
.slot::before,
.slot::after {
  border: 0;
  background: transparent;
  box-shadow: none;
  content: none;
}

.slot {
  outline: 0;
}

.slot.need-add,
.slot.need-add::before,
.slot.need-add::after {
  border: 0;
  background: transparent;
  box-shadow: none;
  content: none;
}

.slot.need-add {
  outline: 3px dashed var(--wm-amber);
  outline-offset: -3px;
}

.overflow-block {
  top: calc(100% + 4px);
  right: auto;
  left: 8px;
  width: var(--scene-five-width);
  min-width: 0;
  padding: 0;
  color: var(--world-deep);
  background: transparent;
  border: 0;
  box-shadow: none;
}

.overflow-block p {
  margin: 0 0 2px;
  color: var(--world-deep);
  font-size: 0.7rem;
  font-weight: 600;
  text-shadow: 0 1px 0 rgba(255, 250, 238, 0.9);
}

.overflow-block .crate-row {
  width: var(--scene-five-width);
  grid-template-columns: repeat(5, var(--stone-size));
  gap: var(--scene-supply-gap);
  justify-content: start;
}

.supply-zone,
.supply-zone::before {
  background: transparent;
  border: 0;
  box-shadow: none;
}

.supply-zone::before {
  content: none;
}

.supply-zone,
.game-board .supply-zone,
.game-board.has-overflow .supply-zone {
  top: var(--scene-supply-top);
  left: var(--scene-supply-left);
  width: calc(var(--scene-five-width) + 8px);
  min-width: 0;
  min-height: 64px;
  height: max-content;
  padding: 0;
  overflow: visible;
}

.game-board.has-overflow .supply-zone {
  top: calc(100% + var(--stone-size) + 16px);
}

.supply-zone[data-count="1"],
.supply-zone[data-count="2"],
.supply-zone[data-count="3"],
.supply-zone[data-count="4"],
.supply-zone[data-count="5"],
.supply-zone[data-count="6"],
.supply-zone[data-count="7"],
.supply-zone[data-count="8"],
.supply-zone[data-count="9"] {
  width: calc(var(--scene-three-width) + 8px);
}

.supply-zone .pebble-grid {
  width: var(--scene-five-width);
  min-height: 64px;
  grid-template-columns: repeat(5, var(--stone-size));
  grid-auto-rows: var(--stone-size);
  column-gap: var(--scene-supply-gap);
  row-gap: var(--scene-supply-gap);
  justify-content: space-between;
}

.supply-zone[data-count="1"] .pebble-grid,
.supply-zone[data-count="2"] .pebble-grid,
.supply-zone[data-count="3"] .pebble-grid,
.supply-zone[data-count="4"] .pebble-grid,
.supply-zone[data-count="5"] .pebble-grid,
.supply-zone[data-count="6"] .pebble-grid,
.supply-zone[data-count="7"] .pebble-grid,
.supply-zone[data-count="8"] .pebble-grid,
.supply-zone[data-count="9"] .pebble-grid {
  width: var(--scene-three-width);
  grid-template-columns: repeat(3, var(--stone-size));
}

.answer-area {
  position: absolute;
  z-index: 9;
  display: flex;
  width: max-content;
  max-width: calc(100% - 16px);
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.answer-area .feedback {
  max-width: 145px;
  padding: 5px 8px;
  color: var(--world-deep);
  background: rgba(255, 250, 238, 0.9);
  border-radius: 12px;
}

.stone-button.demo-watch {
  border-radius: 16px;
  outline: 3px solid var(--wm-gold);
  outline-offset: 2px;
}

#crateZone.demo-watch,
#supplyZone.demo-watch {
  outline: 0;
}

@media (orientation: portrait) {
  :root {
    --scene-supply-gap: 4px;
    --scene-board-width: min(calc(100% - 12px), clamp(560px, 75vw, 620px));
    --scene-board-height: clamp(280px, 37.5vw, 310px);
    --scene-board-left: 50%;
    --scene-board-top: calc(clamp(290px, 36vh, 370px) + 12px);
    --scene-board-transform: translateX(-50%);
    --scene-supply-left: 8px;
    --scene-supply-top: calc(100% + 12px);
    --scene-char-baseline: clamp(290px, 36vh, 370px);
    --stone-size: 64px;
    --sopo-size: clamp(190px, 30vw, 260px);
    --walrus-size: clamp(280px, 40vw, 350px);
  }

  .walrus-card {
    top: var(--scene-char-baseline);
    right: 4%;
    left: auto;
    width: var(--walrus-size);
    height: var(--walrus-size);
    translate: 0 -100%;
    transform: none;
  }

  .sopo-card {
    top: var(--scene-char-baseline);
    right: auto;
    left: 4%;
    width: var(--sopo-size);
    height: var(--sopo-size);
    translate: 0 -100%;
    transform: none;
  }

  .guide-speech,
  .demo-bar {
    left: 4%;
    width: min(218px, 43vw);
    min-height: 56px;
  }

  .guide-speech {
    top: calc(var(--scene-char-baseline) - var(--sopo-size) - 64px);
  }

  .demo-bar {
    top: calc(var(--scene-char-baseline) - var(--sopo-size) - 64px);
    grid-template-columns: minmax(0, 1fr) auto;
    height: 56px;
  }

  .answer-area {
    top:
      calc(
        var(--scene-char-baseline) + 12px + var(--scene-board-height) +
        12px + var(--scene-three-rows) - 78px
      );
    right: 4%;
    bottom: auto;
    left: auto;
  }

  .answer-area .feedback {
    max-width: 132px;
  }

  .corner-rune {
    right: auto;
    bottom: 4px;
    left: 4px;
    width: clamp(52px, 8vw, 64px);
    height: auto;
  }
}

@media (orientation: portrait) and (max-width: 559px) {
  :root {
    --scene-supply-gap: 4px;
    --scene-board-width: min(calc(100vw - 12px), 380px);
    --scene-board-height: min(calc(50vw - 6px), 190px);
    --scene-board-left: 50%;
    --scene-board-top: calc(var(--scene-char-baseline) + 8px);
    --scene-board-transform: translateX(-50%);
    --scene-supply-left: 2px;
    --scene-supply-top: calc(100% + 8px);
    --scene-char-baseline: 146px;
    --scene-three-rows: calc(var(--stone-size) + var(--stone-size) + var(--stone-size) + 4px);
    --stone-size: 48px;
    --sopo-size: 100px;
    --walrus-size: 145px;
  }

  .walrus-card {
    top: var(--scene-char-baseline);
    right: 8px;
    width: var(--walrus-size);
    height: var(--walrus-size);
  }

  .sopo-card {
    top: var(--scene-char-baseline);
    left: 8px;
    width: var(--sopo-size);
    height: var(--sopo-size);
  }

  .guide-speech {
    top: calc(var(--scene-char-baseline) - var(--sopo-size) - 44px);
    left: 8px;
    width: min(180px, calc(100vw - 190px));
    height: 40px;
    min-height: 40px;
    padding: 3px 5px 3px 8px;
    border-width: 2px;
    border-radius: 17px 20px 19px 9px;
  }

  .guide-speech::before {
    bottom: -8px;
    width: 15px;
    height: 11px;
  }

  .guide-speech p {
    font-size: 0.72rem;
  }

  .target-chip {
    padding: 1px 4px;
  }

  .target-chip span {
    display: none;
  }

  .target-chip output {
    min-width: 18px;
    font-size: 0.9rem;
  }

  .supply-zone .pebble-grid {
    row-gap: 2px;
  }

  .supply-zone {
    width: calc(var(--scene-five-width) + 8px);
    min-height: 64px;
  }

  .supply-zone[data-count="1"],
  .supply-zone[data-count="2"],
  .supply-zone[data-count="3"],
  .supply-zone[data-count="4"],
  .supply-zone[data-count="5"],
  .supply-zone[data-count="6"],
  .supply-zone[data-count="7"],
  .supply-zone[data-count="8"],
  .supply-zone[data-count="9"] {
    width: calc(var(--scene-three-width) + 8px);
  }

  .game-board.has-overflow .supply-zone {
    top: calc(100% + var(--stone-size) + 12px);
  }

  .answer-area {
    top:
      calc(
        var(--scene-char-baseline) + 8px + var(--scene-board-height) +
        8px + var(--scene-three-rows) - 78px
      );
    right: 8px;
    bottom: auto;
    left: auto;
    display: block;
    width: 78px;
  }

  .answer-area .feedback {
    display: none;
  }

  .ok-button {
    width: 78px;
    min-width: 78px;
    min-height: 78px;
  }

  .demo-bar {
    top: auto;
    right: auto;
    bottom: 4px;
    left: 50px;
    display: flex;
    width: auto;
    height: 48px;
    min-height: 48px;
    padding: 0;
    justify-content: flex-start;
    background: transparent;
    border: 0;
    box-shadow: none;
  }

  #demoCaption {
    display: none;
  }

  #skipDemo {
    min-width: 112px;
    min-height: 48px;
    height: 48px;
    padding: 0 14px;
    color: var(--world-deep);
    background: rgba(255, 250, 238, 0.94);
    border: 2px solid rgba(151, 103, 61, 0.78);
    box-shadow: 0 3px 8px rgba(40, 66, 72, 0.12);
  }

  .corner-rune {
    right: auto;
    bottom: 4px;
    left: 4px;
    width: 28px;
    height: auto;
  }
}

@media (orientation: portrait) and (max-width: 559px) and (min-height: 681px) {
  :root {
    --scene-char-baseline: clamp(146px, calc(100dvh - 514px), 260px);
    --sopo-size: clamp(100px, 32vw, 120px);
    --walrus-size: clamp(145px, 45vw, 180px);
  }
}

@media (orientation: portrait) and (min-width: 768px) {
  :root {
    --scene-supply-gap: 8px;
    --scene-board-width: min(calc(100% - 12px), 620px);
    --scene-board-height: 310px;
    --stone-size: 72px;
  }
}

@media (orientation: landscape) {
  :root {
    --scene-supply-gap: 4px;
    --scene-board-width: min(50vw, 600px);
    --scene-board-height: min(25vw, 300px);
    --scene-board-left: 4%;
    --scene-board-top: 86px;
    --scene-board-transform: none;
    --scene-supply-left: 8px;
    --scene-supply-top: calc(100% + 12px);
    --scene-char-baseline: 280px;
    --stone-size: 64px;
    --sopo-size: clamp(170px, 15vw, 190px);
    --walrus-size: clamp(220px, 22vw, 240px);
  }

  .game-shell {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: 64px minmax(0, 1fr);
    grid-template-areas:
      "controls hud"
      "play play";
    gap: 6px;
  }

  .game-controls {
    grid-area: controls;
    grid-row: 1;
    justify-content: flex-start;
    margin-inline: 0;
  }

  .top-hud {
    grid-area: hud;
    grid-row: 1;
    justify-content: flex-end;
    gap: 12px;
  }

  .playfield {
    grid-area: play;
    grid-row: 2;
    min-height: 0;
  }

  .walrus-card {
    top: var(--scene-char-baseline);
    right: max(12px, 3vw);
    left: auto;
    width: var(--walrus-size);
    height: 220px;
    translate: 0 -100%;
    transform: none;
  }

  .sopo-card {
    top: var(--scene-char-baseline);
    right: calc(max(12px, 3vw) + var(--walrus-size) + 16px);
    left: auto;
    width: var(--sopo-size);
    height: 190px;
    translate: 0 -100%;
    transform: none;
  }

  .guide-speech,
  .demo-bar {
    top: 4px;
    left: 4%;
    width: min(250px, 28vw);
    min-height: 62px;
  }

  .guide-speech {
    height: 62px;
  }

  .demo-bar {
    grid-template-columns: minmax(0, 1fr) auto;
    height: 62px;
  }

  .answer-area {
    top:
      calc(
        var(--scene-board-top) + var(--scene-board-height) +
        12px + var(--scene-three-rows) - 78px
      );
    right: auto;
    bottom: auto;
    left: calc(4% + min(50vw, 600px) + 18px);
    display: flex;
    width: max-content;
  }

  .answer-area .feedback {
    display: block;
    max-width: 142px;
  }

  .corner-rune {
    right: auto;
    bottom: 4px;
    left: 4px;
    width: clamp(40px, 4vw, 52px);
    height: auto;
  }
}

@media (orientation: landscape) and (max-height: 650px) {
  :root {
    --scene-supply-gap: 4px;
    --scene-board-top: 68px;
    --scene-supply-top: calc(100% + 10px);
    --scene-char-baseline: 220px;
    --stone-size: 48px;
    --sopo-size: 170px;
    --walrus-size: 220px;
  }

  .walrus-card {
    height: 200px;
  }

  .sopo-card {
    height: 170px;
  }

  .guide-speech,
  .demo-bar {
    min-height: 56px;
  }

  .guide-speech,
  .demo-bar {
    height: 56px;
  }
}

@media (orientation: landscape) and (min-height: 651px) and (max-height: 740px) {
  :root {
    --scene-char-baseline: 260px;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  :root {
    --scene-board-width: 380px;
    --scene-board-height: 190px;
    --scene-board-left: 5%;
    --scene-board-top: 40px;
    --scene-supply-left: calc(100% + 5px);
    --scene-supply-top: 86px;
    --scene-char-baseline: 118px;
    --stone-size: 48px;
    --sopo-size: 100px;
    --walrus-size: 140px;
  }

  .walrus-card {
    top: var(--scene-char-baseline);
    right: 16px;
    width: var(--walrus-size);
    height: 110px;
  }

  .sopo-card {
    top: var(--scene-char-baseline);
    right: calc(16px + var(--walrus-size) + 38px);
    width: var(--sopo-size);
    height: 94px;
  }

  .guide-speech,
  .demo-bar {
    top: 2px;
    left: 10px;
    width: min(210px, 27vw);
    height: 34px;
    min-height: 34px;
    padding: 3px 6px;
  }

  .guide-speech p {
    font-size: 0.74rem;
  }

  .guide-speech::before {
    bottom: -7px;
    width: 14px;
    height: 9px;
  }

  .demo-bar {
    left: calc(5% + 380px);
    display: flex;
    justify-content: flex-start;
    width: auto;
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
  }

  #demoCaption {
    display: none;
  }

  #skipDemo {
    min-height: 48px;
    padding: 0 13px;
  }

  .overflow-block {
    top: calc(100% + 4px);
    right: auto;
    left: 38px;
    width: var(--scene-five-width);
  }

  .overflow-block p {
    margin-bottom: 1px;
  }

  .game-board.has-overflow .supply-zone {
    top: var(--scene-supply-top);
  }

  .answer-area {
    top: 160px;
    right: 12px;
    bottom: auto;
    left: auto;
    display: block;
    width: 78px;
  }

  .answer-area .feedback {
    display: none;
  }

  .ok-button {
    width: 78px;
    min-width: 78px;
    min-height: 78px;
  }

  .corner-rune {
    right: auto;
    bottom: 4px;
    left: 4px;
    width: 44px;
    height: auto;
  }
}

.help-picture .help-pebble {
  filter: drop-shadow(0 3px 2px rgba(38, 53, 58, 0.25));
}

.mini-source {
  background: url("assets/pebble-warm.webp") center / contain no-repeat;
  border: 0;
}

@keyframes stone-settle {
  0% {
    opacity: 0.6;
    transform: translateY(-8px) scale(1.12);
  }
  70% {
    opacity: 1;
    transform: translateY(2px) scale(1.05, 0.95);
  }
  100% {
    transform: translateY(0) scale(1);
  }
}

@keyframes gold-wash {
  0% {
    opacity: 0;
    transform: scale(0.84);
  }
  45% {
    opacity: 1;
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes character-joy {
  0%,
  100% {
    transform: translateY(0) rotate(0);
  }
  38% {
    transform: translateY(-5px) rotate(-1deg);
  }
  68% {
    transform: translateY(-2px) rotate(1deg);
  }
}

@keyframes snow-fleck {
  0% {
    opacity: 0;
    transform: translate(0, 0) scale(0.7);
  }
  24% {
    opacity: 0.95;
  }
  100% {
    opacity: 0;
    transform: translate(var(--fleck-x, 8px), var(--fleck-y, -20px)) scale(1.15);
  }
}

@media (prefers-reduced-motion: reduce) {
  .character-card.is-cheering,
  .stone-button.is-arriving .stone,
  .snow-fleck,
  .firework-flare,
  .firework-trail,
  .firework-particle,
  .firework-confetti,
  .ice-drift,
  .success-dialog > .gold-mark,
  .level-dialog > .high-five-frame,
  .final-dialog > .one-ten-badge,
  .success-dialog > h2,
  .level-dialog > h2,
  .final-dialog > h2 {
    animation: none;
  }

  .snow-fleck,
  .ice-drift {
    display: none;
  }

  .crate-zone,
  .five-rows,
  .crate-zone::after {
    transition: none;
  }

  .crate-zone.is-one-ten::after {
    animation: none;
  }
}

/* Shared illustrated controls: keep the approved art at every viewport. */
#playButton {
  min-height: 86px;
  padding: 0 16px 0 0;
}

#okButton {
  grid-template-rows: 78px;
  width: 78px;
  height: 78px;
  min-width: 78px;
  max-width: 78px;
  min-height: 78px;
  max-height: 78px;
  margin: 0;
  padding: 0;
}

#okButton .ok-art,
#okButton::before,
#okButton::after {
  width: 78px;
  height: 78px;
}

@media (orientation: landscape) and (min-width: 900px) and (min-height: 650px) {
  .control-button {
    flex-basis: 56px;
    width: 56px;
    height: 56px;
  }
}

/* One cream caption pill, with a separate secondary Skip demo action. */
.guide-speech,
.demo-bar {
  color: #5b3a22;
  border: 0;
  box-shadow: 0 3px 8px rgba(91, 58, 34, 0.16);
}

.guide-speech {
  background: #fff8e6;
  border-radius: 999px;
}

.guide-speech p {
  color: inherit;
  line-height: 1.2;
}

.guide-speech .target-chip {
  color: #5b3a22;
  background: #f6e7c8;
}

.guide-speech .target-chip output {
  color: #5b3a22;
}

.guide-speech::before,
.guide-speech::after,
.demo-bar::before,
.demo-bar::after {
  content: none;
  display: none;
}

.demo-bar {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

#demoCaption {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 48px;
  padding: 6px 14px;
  color: #5b3a22;
  background: #fff8e6;
  border-radius: 999px;
  box-shadow: 0 3px 8px rgba(91, 58, 34, 0.16);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  overflow-wrap: normal;
}

#skipDemo {
  flex: 0 0 auto;
  min-width: 98px;
  min-height: 48px;
  padding: 4px 12px;
  color: #5b3a22;
  background: #fff8e6;
  border: 2px solid #a56b42;
  border-radius: 999px;
  box-shadow: 0 3px 8px rgba(91, 58, 34, 0.14);
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.2;
}

#game[data-state="demo"] .guide-speech {
  visibility: hidden;
}

@media (orientation: portrait) and (min-width: 560px),
  (orientation: landscape) and (min-height: 501px) {
  .demo-bar {
    display: flex;
    flex-flow: row nowrap;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    width: min(300px, calc(100% - 32px));
    height: 62px;
    min-height: 62px;
    max-height: 62px;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  #demoCaption {
    display: flex;
    flex: 1 1 auto;
    width: auto;
    height: 48px;
  }

  #skipDemo {
    width: auto;
    height: 48px;
  }
}

@media (orientation: portrait) and (max-width: 559px),
  (orientation: landscape) and (max-height: 500px) {
  #demoCaption {
    display: none;
  }

  .demo-bar {
    flex-direction: row;
    gap: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  #skipDemo {
    min-width: 98px;
    min-height: 48px;
    height: 48px;
  }
}

/* Readability pass: larger instructions without changing the illustrated scene. */
#instruction {
  font-size: 22px;
  line-height: 1.2;
}

.guide-speech {
  min-height: 62px;
}

.guide-speech .target-chip {
  min-height: 32px;
  padding: 3px 7px 3px 9px;
}

.live-count {
  display: flex;
  width: max-content;
  min-width: 116px;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px 9px;
  color: #5b3a22;
  background: #fff8e6;
  border-radius: 999px;
  white-space: nowrap;
}

.live-count output {
  min-width: 2ch;
  color: #5b3a22;
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
}

.live-count > span {
  color: #6d4522;
  font-size: 16px;
  line-height: 1;
  white-space: nowrap;
}

#demoCaption {
  min-height: 62px;
  height: 62px;
  max-height: 62px;
  padding: 4px 12px;
  font-size: 22px;
  line-height: 1.2;
  white-space: normal;
  overflow-wrap: normal;
  word-break: normal;
}

#skipDemo {
  min-width: 98px;
  min-height: 48px;
  font-size: 18px;
  line-height: 1.2;
}

.feedback {
  overflow: visible;
  font-size: 18px;
  line-height: 1.2;
  text-overflow: clip;
  white-space: normal;
}

.overflow-block p {
  font-size: 18px;
  line-height: 1.2;
}

.help-dialog h2 {
  font-size: 24px;
  line-height: 1.2;
}

.help-dialog .dialog-kicker {
  font-size: 16px;
}

.parent-help,
.help-steps p {
  font-size: 18px;
  line-height: 1.35;
}

.help-dialog .quiet-button {
  font-size: 18px;
}

.drag-layer .stone-clone {
  max-width: none;
  width: var(--stone-size);
  height: var(--stone-size);
  transition-duration: 520ms;
  transform: translate3d(0, 0, 0);
}

.demo-target-hidden {
  visibility: hidden !important;
}

.stone-button.demo-target-flash {
  outline: 3px solid var(--wm-gold);
  outline-offset: 2px;
}

.stone-button.demo-result-stone .stone {
  filter: drop-shadow(0 0 5px rgba(255, 208, 66, 0.88));
}

.crate-zone.demo-result .live-count.is-demo-ten {
  background: #ffe8a2;
  box-shadow: 0 0 0 3px rgba(242, 193, 65, 0.3);
}

@media (orientation: portrait) and (min-width: 560px),
  (orientation: landscape) and (min-height: 501px) {
  .guide-speech {
    width: min(300px, calc(100vw - 32px));
  }

  .demo-bar {
    width: min(310px, calc(100vw - 32px));
  }
}

@media (orientation: portrait) and (max-width: 559px),
  (orientation: landscape) and (max-height: 500px) {
  #instruction {
    font-size: 18px;
  }

  .guide-speech {
    width: min(208px, calc(100vw - 24px));
  }

  .guide-speech .target-chip {
    min-width: 32px;
    min-height: 28px;
    padding: 1px 4px;
  }

  .guide-speech .target-chip > span {
    display: none;
  }

  .feedback {
    font-size: 18px;
  }

  .overflow-block p {
    font-size: 16px;
  }

  #demoCaption {
    display: none;
  }
}

@media (orientation: portrait) and (max-width: 559px) {
  .guide-speech {
    width: 180px;
    gap: 4px;
    padding: 3px 4px 3px 6px;
    height: 40px;
    min-height: 40px;
    max-height: 40px;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .guide-speech {
    height: 34px;
    min-height: 34px;
    max-height: 34px;
  }
}
