@font-face {
  font-family: "Fredoka";
  src: url("assets/fonts/fredoka-400.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Fredoka";
  src: url("assets/fonts/fredoka-600.woff2") format("woff2");
  font-style: normal;
  font-weight: 600;
  font-display: swap;
}

:root {
  --dock-navy: #174a7e;
  --dock-ice: #d2f9f6;
  --dock-water: #2aa9c2;
  --dock-white: #fffdf6;
  --dock-gold: #f2c141;
  --dock-shadow: #29445d;
  --dock-ink-soft: #4f5f67;
  --dock-focus: 0 0 0 4px rgb(255 253 246 / 0.96), 0 0 0 8px rgb(242 193 65 / 0.94);
  --actor-light:
    drop-shadow(0 0 2px rgb(255 250 228 / 0.95))
    drop-shadow(0 0 7px rgb(255 215 111 / 0.38))
    drop-shadow(0 4px 9px rgb(221 244 255 / 0.32));
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--dock-navy);
  color: var(--wm-ink);
  font-family: "Fredoka", "Trebuchet MS", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  overscroll-behavior: none;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button:disabled {
  cursor: default;
}

[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;
}

.app {
  position: fixed;
  inset: 0;
  isolation: isolate;
  overflow: hidden;
  background: var(--dock-navy);
  color: var(--dock-white);
}

.world {
  position: absolute;
  inset: 0;
  z-index: -3;
  display: block;
}

.world img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.app::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgb(12 49 79 / 0.08), transparent 20%, transparent 72%, rgb(16 54 80 / 0.2)),
    radial-gradient(circle at 50% 42%, transparent 35%, rgb(12 39 61 / 0.12) 100%);
}

.screen {
  position: absolute;
  inset: 0;
}

.loader {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  color: var(--dock-white);
  background: var(--dock-navy);
}

.loader p {
  padding: 16px 24px;
  border: 3px solid rgb(255 253 246 / 0.24);
  border-radius: 16px;
  background: rgb(23 74 126 / 0.9);
  font-size: 1.08rem;
}

.image-button {
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
}

.image-button img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.image-button:focus-visible,
.wood-button:focus-visible,
.candidate:focus-visible,
.sign-socket:focus-visible,
.level-button:focus-visible {
  outline: none;
  box-shadow: var(--dock-focus);
}

.image-button:active:not(:disabled) {
  transform: translateY(2px) scale(0.96);
}

.image-button:disabled {
  filter: saturate(0.6) brightness(1.08);
}

.wood-button {
  min-height: 48px;
  padding: 9px 18px;
  border: 3px solid #593316;
  border-radius: 15px;
  background:
    linear-gradient(180deg, rgb(255 248 230 / 0.15), transparent 45%),
    var(--wm-wood-2);
  color: var(--dock-white);
  box-shadow: 0 4px 0 #593316, 0 8px 14px rgb(61 50 38 / 0.2);
  font-size: 1rem;
  font-weight: 600;
}

.wood-button:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--wm-wood-2);
}

.intro {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  padding: 0;
}

.story-frame {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  pointer-events: none;
}

.story-art {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
}

.story-art[data-loaded="true"] {
  opacity: 1;
}

.intro-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(90px, 1fr) minmax(110px, 0.76fr) minmax(90px, 1fr);
  align-items: end;
  gap: 10px;
  padding: 15% 5% 7%;
  background:
    linear-gradient(180deg, #b7ecff 0 48%, #76c6df 48% 63%, #bbcfd2 63% 100%);
  pointer-events: none;
}

.story-frame.media-ready .intro-fallback {
  display: none;
}

.story-figure {
  position: relative;
  align-self: end;
  height: min(56vh, 460px);
  margin: 0;
  background: transparent;
}

.story-figure img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: bottom;
}

.story-figure figcaption {
  position: absolute;
  right: 8%;
  bottom: 7%;
  padding: 3px 9px;
  border: 2px solid var(--wm-wood-2);
  border-radius: 8px;
  background: var(--wm-cream-1);
  color: var(--dock-navy);
  font-size: 0.78rem;
  font-weight: 600;
}

.story-figure--sopo {
  transform: rotate(-2deg);
}

.story-figure--penguin {
  transform: rotate(2deg);
}

.fallback-sign {
  align-self: center;
  display: grid;
  gap: 6px;
  padding: 12px 16px;
  border: 4px solid var(--wm-wood-2);
  border-radius: 16px;
  background: var(--wm-cream-1);
  color: var(--dock-navy);
  box-shadow: 0 7px 0 rgb(138 85 44 / 0.32);
  font-size: clamp(2.2rem, 8vw, 4.8rem);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  line-height: 0.92;
  text-align: center;
}

.sign-divider {
  height: 3px;
  border-radius: 3px;
  background: var(--wm-wood-1);
}

.intro-copy {
  position: absolute;
  z-index: 2;
  top: max(18px, env(safe-area-inset-top));
  left: 50%;
  width: min(660px, calc(100% - 28px));
  padding: 10px 18px 13px;
  transform: translateX(-50%);
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  text-align: center;
  pointer-events: none;
}

.brand {
  margin: 0 0 1px;
  color: var(--dock-navy);
  font-size: 0.84rem;
  font-weight: 600;
}

.intro h1 {
  margin: 0;
  color: var(--dock-navy);
  font-size: clamp(1.9rem, 4.8vw, 4rem);
  line-height: 0.98;
  letter-spacing: -0.025em;
  text-shadow: 0 1px 2px rgb(255 255 255 / 0.82);
  text-wrap: balance;
}

.intro-copy > p:last-child {
  margin: 6px 0 0;
  color: var(--dock-navy);
  font-size: clamp(0.94rem, 1.7vw, 1.2rem);
}

.play-button {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: max(22px, env(safe-area-inset-bottom));
  width: clamp(82px, 10vw, 112px);
  height: clamp(82px, 10vw, 112px);
  transform: translateX(-50%);
  filter: drop-shadow(0 7px 5px rgb(23 74 126 / 0.42));
  pointer-events: auto;
}

.play-button:active:not(:disabled) {
  transform: translate(-50%, 3px) scale(0.95);
}

.game {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 6px;
  padding: max(6px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right))
    max(6px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
}

.topbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.controls {
  display: flex;
  flex: 0 0 auto;
  flex-flow: row nowrap;
  gap: 4px;
  min-width: 0;
}

.control {
  flex: 0 0 56px;
  width: 56px;
  height: 56px;
  min-width: 56px;
  min-height: 56px;
  filter: drop-shadow(0 3px 2px rgb(41 68 93 / 0.38));
}

.hud {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  min-width: 0;
  padding: 4px 8px;
  border: 2px solid rgb(138 85 44 / 0.56);
  border-radius: 14px;
  background: rgb(255 248 230 / 0.9);
  box-shadow: 0 3px 0 rgb(138 85 44 / 0.22), 0 7px 16px rgb(31 38 42 / 0.16);
}

.level-path {
  display: flex;
  align-items: flex-start;
  gap: 3px;
  min-height: 28px;
}

.dock-level-prop {
  position: relative;
  display: grid;
  place-items: center;
  width: 27px;
  height: 18px;
  margin-top: 3px;
  background: url("assets/sign-plaque.webp") center / 100% 100% no-repeat;
  color: var(--dock-navy);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  opacity: 0.68;
}

.dock-level-prop::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  width: 3px;
  height: 6px;
  border-radius: 0 0 2px 2px;
  background: var(--wm-wood-2);
  transform: translateX(-50%);
}

.dock-level-prop[data-completed="true"] {
  color: var(--dock-navy);
  opacity: 1;
}

.dock-level-prop[data-current="true"] {
  width: 31px;
  height: 21px;
  margin-top: 0;
  filter: drop-shadow(0 0 4px rgb(242 193 65 / 0.95));
  opacity: 1;
}

.level-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 3px solid var(--wm-wood-2);
  border-radius: 13px;
  background: var(--wm-cream-2);
  color: var(--wm-wood-2);
  font-size: 0.92rem;
  font-weight: 600;
}

.level-button[data-current="true"] {
  background: var(--dock-gold);
  box-shadow: 0 0 0 3px var(--dock-white), 0 0 0 5px var(--dock-gold);
}

.level-button[data-unlocked="true"]:not([data-current="true"]) {
  background: var(--dock-ice);
}

.level-button:disabled {
  opacity: 0.55;
}

.round-progress {
  display: grid;
  gap: 2px;
  min-width: 118px;
}

.level-label {
  margin: 0;
  color: var(--dock-navy);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.25;
  text-align: right;
  white-space: nowrap;
}

.round-track {
  display: flex;
  justify-content: flex-end;
  gap: 2px;
}

.round-track img {
  width: 22px;
  height: 22px;
  object-fit: contain;
  opacity: 0;
  transition: opacity 140ms ease-out;
}

.round-track img[data-loaded="true"],
.round-track img:not([data-loaded]) {
  opacity: 1;
}

.stage {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 3px;
  min-width: 0;
  min-height: 0;
}

.speech-row {
  grid-row: 1;
  position: relative;
  z-index: 8;
  display: grid;
  justify-items: center;
  min-width: 0;
  padding: 0 5px;
}

.speech-layout {
  display: grid;
  justify-items: center;
  gap: 4px;
  width: min(690px, 100%);
  min-width: 0;
}

.speech-wrap {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 7px;
  width: 100%;
  min-width: 0;
}

.speech {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 48px;
  margin: 0;
  padding: 7px 18px;
  border: 3px solid rgb(138 85 44 / 0.78);
  border-radius: 16px;
  background: rgb(255 248 230 / 0.96);
  color: var(--dock-navy);
  box-shadow: 0 4px 0 rgb(138 85 44 / 0.2), 0 8px 18px rgb(31 38 42 / 0.14);
  font-size: clamp(1.25rem, 1.4vw, 1.375rem);
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-wrap: balance;
}

.listen-button {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 48px;
  min-height: 48px;
  margin: 0;
  padding: 7px 12px;
  font-size: 1rem;
}

.speaker-mark {
  position: relative;
  display: inline-block;
  width: 16px;
  height: 12px;
  background: var(--dock-white);
  clip-path: polygon(0 34%, 37% 34%, 78% 0, 78% 100%, 37% 66%, 0 66%);
}

.speaker-mark::after {
  content: "";
  position: absolute;
  left: 13px;
  top: -3px;
  width: 7px;
  height: 18px;
  border-right: 3px solid var(--dock-white);
  border-radius: 50%;
}

.skip-demo {
  position: static;
  min-height: 48px;
  padding: 6px 10px;
  font-size: 1rem;
}

.tutorial-steps {
  grid-row: 2;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tutorial-steps li {
  display: grid;
  place-items: center;
  width: 38px;
  height: 34px;
  border: 2px solid var(--wm-wood-2);
  border-radius: 10px;
  background: rgb(255 248 230 / 0.94);
  box-shadow: 0 3px 0 rgb(138 85 44 / 0.22);
}

.tutorial-icon {
  display: block;
  width: 24px;
  height: 24px;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
}

.tutorial-icon--listen {
  position: relative;
  width: 25px;
  height: 17px;
  background: var(--dock-navy);
  clip-path: polygon(0 32%, 39% 32%, 80% 0, 80% 100%, 39% 68%, 0 68%);
}

.tutorial-icon--listen::after {
  content: "";
  position: absolute;
  left: 19px;
  top: -5px;
  width: 8px;
  height: 25px;
  border-right: 3px solid var(--dock-navy);
  border-radius: 50%;
}

.tutorial-icon--sign {
  background-image: url("assets/sign-plaque.webp");
}

.tutorial-icon--ok {
  background-image: url("assets/ui/button-check-normal.webp");
}

.dock-span {
  grid-row: 3;
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 3px;
  min-width: 0;
  min-height: 0;
}

.dock-span::before {
  content: "";
  position: absolute;
  z-index: 0;
  left: 2%;
  right: 2%;
  top: 58%;
  bottom: -3%;
  background: url("assets/dock-platform.webp") center bottom / 100% 100% no-repeat;
  filter: drop-shadow(0 8px 6px rgb(16 54 80 / 0.28));
  pointer-events: none;
}

.scene-group {
  grid-row: 1;
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(110px, 0.82fr) minmax(170px, 1.1fr) minmax(110px, 0.82fr);
  align-items: end;
  min-width: 0;
  min-height: 0;
  max-width: 1040px;
  width: 100%;
  margin: 0 auto;
  isolation: isolate;
}

.scene-actor {
  position: relative;
  z-index: 2;
  align-self: end;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  margin: 0;
  background: transparent;
  pointer-events: none;
}

.scene-actor img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  opacity: 0;
  filter: var(--actor-light);
  transform: scaleX(-1);
  pointer-events: none;
  transition: opacity 180ms ease-out;
}

.scene-actor .actor-static,
.scene-actor .actor-loop {
  opacity: 1;
}

.scene-actor.has-loop .actor-static {
  opacity: 0;
}

.scene-actor.has-loop .actor-loop {
  opacity: 1;
}

.scene-actor--sopo {
  transform: translate(3%, 1%) rotate(-1deg) scale(1.08);
  transform-origin: 70% 90%;
}

.scene-actor--piko {
  transform: translate(-3%, 1%) rotate(1deg) scale(1.08);
  transform-origin: 30% 90%;
}

.app[data-state="paused"] .actor-loop,
.app[data-state="help"] .actor-loop,
.app[data-state="reward"] .actor-loop,
.app[data-state="finale"] .actor-loop {
  opacity: 0;
}

.app[data-state="paused"] .scene-actor.has-loop .actor-static,
.app[data-state="help"] .scene-actor.has-loop .actor-static,
.app[data-state="reward"] .scene-actor.has-loop .actor-static,
.app[data-state="finale"] .scene-actor.has-loop .actor-static {
  opacity: 1;
}

.sign-assembly {
  position: relative;
  z-index: 3;
  align-self: stretch;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  container-type: size;
}

.sign-post {
  position: relative;
  width: min(100%, 340px, 76cqh);
  height: auto;
  min-height: 150px;
  aspect-ratio: 515 / 673;
  transition: transform 150ms ease-out;
}

.sign-asset {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  filter: drop-shadow(0 8px 8px rgb(16 54 80 / 0.26));
}

.sign-socket {
  position: absolute;
  z-index: 3;
  left: 12.5%;
  top: 20%;
  container-type: size;
  display: grid;
  place-items: center;
  width: 75%;
  height: 23%;
  padding: 3px 8px;
  border: 3px solid rgb(255 248 230 / 0.62);
  border-radius: 8px;
  background:
    linear-gradient(rgb(68 39 20 / 0.34), rgb(68 39 20 / 0.14)),
    url("assets/sign-plaque.webp") center / 100% 100% no-repeat;
  box-shadow: inset 0 4px 8px rgb(30 25 20 / 0.38), 0 1px 0 rgb(255 237 185 / 0.34);
  color: var(--dock-white);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-shadow: 0 1px 1px rgb(45 26 14 / 0.72);
  transition: transform 140ms ease-out, filter 140ms ease-out;
}

.sign-socket.has-choice {
  border-color: var(--dock-gold);
  padding: 0 4px;
  color: var(--dock-navy);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 0 rgb(255 248 230 / 0.56);
}

.sign-socket.has-choice #socketText {
  display: block;
  font-size: min(88cqh, 68cqw);
  line-height: 1;
}

.sign-socket:not(.has-choice) #socketText {
  white-space: nowrap;
}

.sign-socket.is-target {
  border-color: var(--dock-gold);
  box-shadow: inset 0 4px 8px rgb(30 25 20 / 0.24), 0 0 0 5px rgb(242 193 65 / 0.72);
}

.sign-post.is-fixed .sign-socket {
  filter: drop-shadow(0 0 10px rgb(242 193 65 / 0.9));
}

.demo-label {
  position: absolute;
  z-index: 6;
  top: 1%;
  left: 50%;
  margin: 0;
  padding: 4px 10px;
  transform: translateX(-50%);
  border: 2px solid rgb(138 85 44 / 0.68);
  border-radius: 9px;
  background: rgb(255 248 230 / 0.94);
  color: var(--wm-wood-2);
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
}

.snow-rosette {
  position: absolute;
  z-index: 5;
  top: 9%;
  right: 10%;
  width: 28px;
  height: 28px;
  background: var(--dock-gold);
  clip-path: polygon(
    50% 0, 59% 35%, 87% 13%, 68% 41%, 100% 50%, 68% 59%,
    87% 87%, 59% 65%, 50% 100%, 41% 65%, 13% 87%, 32% 59%,
    0 50%, 32% 41%, 13% 13%, 41% 35%
  );
  filter: drop-shadow(0 0 7px rgb(242 193 65 / 0.9));
  opacity: 0;
  transform: scale(0.2) rotate(-25deg);
  pointer-events: none;
}

.app[data-state="round-complete"] .snow-rosette,
.app[data-state="finale"] .snow-rosette {
  animation: rosette-pop 760ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.count-area {
  grid-row: 2;
  position: relative;
  z-index: 2;
  display: grid;
  justify-items: center;
  gap: 2px;
  width: 100%;
  max-width: 760px;
  min-width: 0;
  min-height: 0;
  margin: 0 auto;
  padding: 0 5px;
}

.count-heading {
  margin: 0;
  padding: 2px 10px;
  border: 2px solid rgb(138 85 44 / 0.55);
  border-radius: 8px;
  background: rgb(255 248 230 / 0.9);
  color: var(--dock-navy);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.25;
}

.count-frames {
  display: flex;
  flex-flow: row nowrap;
  justify-content: center;
  gap: clamp(5px, 1vw, 10px);
  width: 100%;
  min-width: 0;
}

.ten-frame {
  --fish-cell: clamp(28px, 7vw, 54px);
  display: grid;
  position: relative;
  flex: 0 1 auto;
  grid-template-columns: repeat(5, var(--fish-cell));
  grid-template-rows: repeat(2, var(--fish-cell));
  gap: clamp(1px, 0.38vw, 4px) clamp(1px, 0.36vw, 4px);
  width: min-content;
  padding: clamp(7px, 1.4vw, 14px) clamp(8px, 1.5vw, 16px);
  border: 0;
  border-radius: 8px;
  background: url("assets/fish-tray.webp") center / 100% 100% no-repeat;
  filter: drop-shadow(0 5px 4px rgb(61 50 38 / 0.24));
}

.fish-cell {
  position: absolute;
  display: grid;
  place-items: center;
  width: 10.5%;
  height: 22%;
  overflow: visible;
  transform: translate(-50%, -50%);
}

.fish-cell:nth-child(1) { left: 18%; top: 27%; }
.fish-cell:nth-child(2) { left: 34%; top: 27%; }
.fish-cell:nth-child(3) { left: 50%; top: 27%; }
.fish-cell:nth-child(4) { left: 66%; top: 27%; }
.fish-cell:nth-child(5) { left: 82%; top: 27%; }
.fish-cell:nth-child(6) { left: 15.7%; top: 62.5%; }
.fish-cell:nth-child(7) { left: 32.8%; top: 62.5%; }
.fish-cell:nth-child(8) { left: 50%; top: 62.5%; }
.fish-cell:nth-child(9) { left: 67%; top: 62.5%; }
.fish-cell:nth-child(10) { left: 84%; top: 62.5%; }

.fish-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 1px 1px rgb(16 54 80 / 0.28));
  pointer-events: none;
}

.fish-cell.is-fallback::before {
  content: "";
  width: 66%;
  height: 36%;
  border-radius: 50% 42% 42% 50%;
  background: #f6b844;
}

.group-equation {
  margin: 0;
  padding: 2px 9px;
  border: 2px solid var(--wm-wood-2);
  border-radius: 8px;
  background: var(--dock-gold);
  color: var(--dock-navy);
  font-size: clamp(0.78rem, 1.1vw, 0.96rem);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.answer-bar {
  position: relative;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  justify-self: center;
  gap: 10px;
  width: min(980px, 100%);
  min-height: 82px;
  padding: 10px 18px;
  background: url("assets/dock-platform.webp") center / 100% 100% no-repeat;
  filter: drop-shadow(0 8px 6px rgb(16 54 80 / 0.24));
}

.choices {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 1.8vw, 18px);
  min-width: 0;
}

.candidate {
  display: grid;
  place-items: center;
  width: clamp(84px, 8.4vw, 108px);
  height: clamp(56px, 6.2vw, 68px);
  padding: 0 4px;
  border: 0;
  border-radius: 8px;
  background: url("assets/sign-plaque.webp") center / 100% 100% no-repeat;
  color: var(--dock-navy);
  filter: drop-shadow(0 5px 3px rgb(61 38 20 / 0.36));
  font-size: clamp(2.5rem, 4.5vw, 3.25rem);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  line-height: 1;
  user-select: none;
  touch-action: none;
  transition: transform 130ms ease-out, filter 130ms ease-out;
}

.candidate:nth-child(2n) {
  transform: rotate(0.5deg);
}

.candidate:nth-child(2n + 1) {
  transform: rotate(-0.5deg);
}

.candidate:hover {
  transform: translateY(-3px) rotate(0);
  filter: drop-shadow(0 7px 4px rgb(61 38 20 / 0.4));
}

.candidate.is-dragging {
  opacity: 0.76;
}

.drag-ghost {
  position: fixed;
  z-index: 145;
  left: 0;
  top: 0;
  display: grid;
  place-items: center;
  width: clamp(84px, 8.4vw, 108px);
  height: clamp(56px, 6.2vw, 68px);
  border-radius: 8px;
  background: url("assets/sign-plaque.webp") center / 100% 100% no-repeat;
  color: var(--dock-navy);
  filter: drop-shadow(0 7px 4px rgb(61 38 20 / 0.4));
  font-size: clamp(2.5rem, 4.5vw, 3.25rem);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  line-height: 1;
  opacity: 0.94;
  pointer-events: none;
  transition: transform 70ms linear;
  will-change: transform;
}

.candidate[aria-pressed="true"] {
  transform: translateY(-4px) rotate(0);
  filter: drop-shadow(0 0 0.4rem rgb(242 193 65 / 0.95)) drop-shadow(0 7px 4px rgb(61 38 20 / 0.38));
}

.ok-button {
  width: clamp(64px, 7vw, 74px);
  height: clamp(64px, 7vw, 74px);
  filter: drop-shadow(0 5px 3px rgb(41 68 93 / 0.34));
}

.tutorial-hand {
  position: fixed;
  z-index: 150;
  left: 0;
  top: 0;
  width: clamp(58px, 6.4vw, 76px);
  pointer-events: none;
  filter: drop-shadow(0 5px 3px rgb(23 74 126 / 0.38));
  transition: left 320ms ease-out, top 320ms ease-out, transform 120ms ease-out;
}

.tutorial-hand.is-pressing {
  transform: translateY(4px) scale(0.92);
}

.tutorial-hand img {
  display: block;
  width: 100%;
  height: auto;
}

.rune {
  position: fixed;
  z-index: 600;
  left: max(4px, env(safe-area-inset-left));
  bottom: max(4px, env(safe-area-inset-bottom));
  width: 28px;
  height: 44px;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 2px 2px rgb(23 74 126 / 0.38));
}

.overlay {
  position: fixed;
  z-index: 400;
  inset: 0;
  display: grid;
  place-items: center;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right))
    max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  background:
    radial-gradient(circle at 50% 42%, rgb(255 248 230 / 0.08), transparent 42%),
    rgb(18 57 88 / 0.72);
}

.panel {
  width: min(700px, 100%);
  max-height: calc(100dvh - 20px);
  padding: clamp(12px, 2.1vw, 24px);
  border: 4px solid var(--wm-wood-2);
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgb(255 255 255 / 0.24), transparent 32%),
    var(--wm-cream-1);
  box-shadow: 0 9px 0 rgb(23 74 126 / 0.26), 0 22px 52px rgb(24 29 31 / 0.46);
  color: var(--dock-navy);
  text-align: center;
  overflow: auto;
}

.panel h2 {
  margin: 3px 0 6px;
  color: var(--wm-wood-2);
  font-size: clamp(1.55rem, 3vw, 2.45rem);
  line-height: 1.02;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.panel-note,
.audio-note {
  margin: 0 0 10px;
  color: var(--dock-navy);
  font-size: clamp(0.92rem, 1.25vw, 1.08rem);
}

.audio-note {
  min-height: 1.2em;
  font-size: 0.84rem;
}

.pause-card {
  width: min(680px, 100%);
}

.pause-illustration,
.high-five-fallback {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 10px;
  height: clamp(92px, 17vh, 160px);
}

.pause-illustration {
  gap: 0;
  background: url("assets/dock-platform.webp") center bottom / 92% 25% no-repeat;
}

.panel-figure {
  width: clamp(84px, 12vw, 136px);
  height: 100%;
  margin: 0;
}

.panel-figure img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  filter: var(--actor-light);
}

.pause-illustration .panel-figure:first-child img,
.pause-illustration .panel-figure:last-child img {
  transform: scaleX(-1);
}

.pause-levels {
  display: grid;
  grid-template-columns: repeat(5, minmax(48px, 1fr));
  gap: 7px;
  margin: 9px 0;
}

.pause-levels .level-button {
  width: 100%;
  height: 54px;
  border-radius: 12px;
  background: var(--wm-wood-1);
  box-shadow: 0 4px 0 var(--wm-wood-2);
  color: var(--wm-cream-1);
  font-size: 1rem;
}

.pause-levels .level-button[data-unlocked="true"]:not([data-current="true"]) {
  color: var(--dock-navy);
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.primary-button {
  border-color: #2d5835;
  background: #4e7c54;
  box-shadow: 0 4px 0 #2d5835, 0 8px 14px rgb(61 50 38 / 0.18);
}

.big-button {
  min-width: 188px;
  min-height: 56px;
  font-size: 1.06rem;
}

.help-card {
  width: min(960px, 100%);
  text-align: left;
}

.help-card h2 {
  text-align: center;
}

.help-audio {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 8px;
}

.help-audio .audio-note {
  flex-basis: 100%;
  margin: 0;
  text-align: center;
}

.help-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.help-steps li {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 8px;
  border: 2px solid rgb(138 85 44 / 0.54);
  border-radius: 14px;
  background: var(--wm-cream-2);
}

.help-steps h3,
.help-reading h3 {
  margin: 0 0 2px;
  color: var(--wm-wood-2);
  font-size: 0.96rem;
}

.help-steps p,
.help-reading p {
  margin: 0;
  font-size: 13px;
  line-height: 1.25;
}

.help-art {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border: 2px solid rgb(138 85 44 / 0.62);
  border-radius: 12px;
  background: var(--wm-cream-1);
  color: var(--dock-navy);
}

.help-art img {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.help-art--listen strong {
  font-size: 1.55rem;
}

.mini-speaker {
  position: relative;
  width: 22px;
  height: 15px;
  background: var(--dock-navy);
  clip-path: polygon(0 32%, 39% 32%, 80% 0, 80% 100%, 39% 68%, 0 68%);
}

.mini-speaker::after {
  content: "";
  position: absolute;
  left: 17px;
  top: -4px;
  width: 7px;
  height: 22px;
  border-right: 3px solid var(--dock-navy);
  border-radius: 50%;
}

.help-art--sign {
  grid-template-columns: 1fr;
  background: url("assets/sign-plaque.webp") center / 90% 66% no-repeat, var(--wm-cream-1);
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.help-reading {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgb(210 249 246 / 0.72);
}

.help-reading p + p {
  margin-top: 4px;
}

.close-button {
  display: block;
  min-width: 144px;
  margin: 10px auto 0;
}

.reward-card {
  width: min(640px, 100%);
}

.high-five-wrap {
  position: relative;
  min-height: clamp(88px, 16vh, 150px);
}

.high-five-art {
  display: block;
  width: 100%;
  max-height: clamp(110px, 25vh, 220px);
  margin: 0 auto;
  object-fit: contain;
  opacity: 0;
  pointer-events: none;
}

.high-five-art[data-loaded="true"] {
  opacity: 1;
}

.high-five-wrap.media-ready .high-five-fallback {
  display: none;
}

.high-five-fallback {
  pointer-events: none;
}

.high-five-spark {
  align-self: center;
  width: 25px;
  height: 25px;
  background: var(--dock-gold);
  clip-path: polygon(
    50% 0, 59% 35%, 87% 13%, 68% 41%, 100% 50%, 68% 59%,
    87% 87%, 59% 65%, 50% 100%, 41% 65%, 13% 87%, 32% 59%,
    0 50%, 32% 41%, 13% 13%, 41% 35%
  );
  animation: spark-turn 1.8s ease-in-out infinite alternate;
}

.finale-card {
  position: relative;
  border-color: var(--dock-gold);
  box-shadow: 0 10px 0 rgb(138 85 44 / 0.38), 0 0 0 5px var(--wm-cream-1), 0 24px 60px rgb(24 29 31 / 0.46);
}

.finale-badge {
  display: grid;
  place-items: center;
  width: clamp(82px, 14vh, 116px);
  height: clamp(82px, 14vh, 116px);
  margin: -16px auto 6px;
  border: 6px solid var(--wm-wood-2);
  border-radius: 50%;
  background: var(--dock-gold);
  color: var(--dock-navy);
  box-shadow: 0 7px 0 rgb(138 85 44 / 0.32), inset 0 0 0 5px var(--wm-cream-1);
  font-size: clamp(1.9rem, 4vw, 2.8rem);
  font-weight: 600;
}

button:not(.control) {
  min-height: 48px;
}

.help-audio .audio-note:empty {
  display: none;
}

#helpPanel button {
  min-width: 48px;
  min-height: 48px;
}

@keyframes rosette-pop {
  0% {
    opacity: 0;
    transform: scale(0.2) rotate(-25deg);
  }
  42% {
    opacity: 1;
    transform: scale(1.15) rotate(8deg);
  }
  100% {
    opacity: 0.92;
    transform: scale(1) rotate(0);
  }
}

@keyframes spark-turn {
  from {
    transform: rotate(-14deg) scale(0.9);
  }
  to {
    transform: rotate(16deg) scale(1.12);
  }
}

@media (min-width: 900px) and (orientation: landscape) {
  .topbar {
    grid-template-columns: auto max-content;
    justify-content: space-between;
  }

  .control {
    flex-basis: 62px;
    width: 62px;
    height: 62px;
    min-width: 62px;
    min-height: 62px;
  }

  .scene-group {
    grid-template-columns: minmax(150px, 0.9fr) minmax(210px, 0.94fr) minmax(150px, 0.9fr);
  }
}

@media (orientation: portrait) {
  .scene-actor {
    z-index: 4;
  }

  .scene-actor--sopo {
    transform: translate(0, 1%) rotate(-1deg) scale(1.65);
    transform-origin: left bottom;
  }

  .scene-actor--piko {
    transform: translate(0, 1%) rotate(1deg) scale(1.65);
    transform-origin: right bottom;
  }

  .sign-assembly {
    align-items: flex-start;
    padding: 0;
  }

  .sign-post {
    position: absolute;
    inset-inline: 0;
    bottom: 20%;
    margin-inline: auto;
  }
}

@media (max-width: 700px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr);
    gap: 3px;
  }

  .controls {
    justify-content: center;
  }

  .hud {
    justify-content: space-between;
  }
}

@media (max-width: 560px) {
  .game {
    gap: 4px;
    padding: 4px max(4px, env(safe-area-inset-right))
      max(4px, env(safe-area-inset-bottom)) max(4px, env(safe-area-inset-left));
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr);
    gap: 3px;
  }

  .controls {
    justify-content: center;
    gap: 3px;
  }

  .control {
    flex-basis: 56px;
    width: 56px;
    height: 56px;
  }

  .hud {
    justify-content: space-between;
    gap: 5px;
    min-height: 40px;
    padding: 2px 6px;
  }

  .level-label {
    font-size: 0.8125rem;
  }

  .round-track img {
    width: 19px;
    height: 19px;
  }

  .speech-wrap {
    gap: 4px;
  }

  .speech-layout {
    gap: 3px;
  }

  .speech {
    min-height: 50px;
    padding: 5px 9px;
    border-width: 2px;
    border-radius: 13px;
    font-size: 1.125rem;
  }

  .listen-button {
    min-width: 48px;
    min-height: 48px;
    padding: 4px 7px;
    font-size: 0.875rem;
  }

  .skip-demo {
    padding: 4px 7px;
    font-size: 0.875rem;
  }

  .tutorial-steps {
    gap: 5px;
  }

  .tutorial-steps li {
    width: 34px;
    height: 30px;
  }

  .scene-group {
    grid-template-columns: minmax(76px, 0.8fr) minmax(150px, 1.08fr) minmax(76px, 0.8fr);
  }

  .sign-post {
    min-height: 130px;
    bottom: 0;
  }

  .sign-socket {
    border-width: 2px;
    font-size: 0.8125rem;
  }

  .demo-label {
    top: 1%;
    padding: 2px 6px;
    font-size: 0.875rem;
  }

  .count-heading {
    padding: 1px 7px;
    font-size: 0.875rem;
  }

  .count-frames {
    gap: 4px;
  }

  .ten-frame {
    --fish-cell: clamp(28px, 8.2vw, 32px);
    gap: 1px;
    padding: 6px 7px;
  }

  .answer-bar {
    min-height: 122px;
    grid-template-columns: minmax(0, 1fr) 62px;
    gap: 6px;
    padding: 7px 5px 7px 36px;
  }

  .choices {
    display: grid;
    grid-template-columns: repeat(2, 64px);
    gap: 5px;
  }

  .candidate {
    width: 64px;
    min-width: 56px;
    height: 56px;
    padding: 0 2px;
    font-size: 2.5rem;
  }

  .ok-button {
    width: 62px;
    height: 62px;
  }

  .tutorial-hand {
    width: 58px;
  }

  .panel {
    padding: 10px;
    border-width: 3px;
  }

  .help-steps {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .help-steps li {
    grid-template-columns: 48px minmax(0, 1fr);
    padding: 5px 7px;
  }

  .help-art {
    width: 44px;
    height: 44px;
    border-width: 2px;
  }

  .help-art img {
    width: 40px;
    height: 40px;
  }

  .help-audio {
    gap: 4px;
    margin-bottom: 5px;
  }

  .help-reading {
    margin-top: 5px;
    padding: 6px 8px;
  }
}

@media (max-width: 700px) and (max-height: 720px) and (orientation: portrait) {
  .speech {
    min-height: 42px;
    padding-top: 3px;
    padding-bottom: 3px;
  }

  .listen-button {
    min-height: 48px;
  }

  .ten-frame {
    --fish-cell: 28px;
  }

  .answer-bar {
    min-height: 116px;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .game {
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 3px;
    padding: 4px max(5px, env(safe-area-inset-right))
      4px max(5px, env(safe-area-inset-left));
  }

  .topbar {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 5px;
  }

  .controls,
  .control {
    gap: 2px;
  }

  .control {
    flex-basis: 56px;
    width: 56px;
    height: 56px;
  }

  .hud {
    gap: 5px;
    padding: 2px 5px;
  }

  .level-path {
    gap: 2px;
  }

  .dock-level-prop {
    width: 24px;
    height: 16px;
  }

  .dock-level-prop[data-current="true"] {
    width: 27px;
    height: 18px;
  }

  .level-label {
    font-size: 0.875rem;
  }

  .round-track img {
    width: 18px;
    height: 18px;
  }

  .stage {
    grid-template-columns: minmax(145px, 0.31fr) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    grid-template-areas:
      "speech dock";
    column-gap: 6px;
    row-gap: 0;
  }

  .speech-row {
    grid-area: speech;
    align-items: center;
    padding: 3px;
  }

  .speech-layout {
    width: 100%;
    gap: 5px;
  }

  .speech-wrap {
    display: grid;
    grid-template-columns: 1fr;
    align-content: center;
    gap: 5px;
  }

  .speech {
    min-height: 48px;
    padding: 6px 8px;
    font-size: 1.125rem;
  }

  .listen-button {
    min-height: 48px;
    padding: 4px 6px;
    font-size: 0.875rem;
  }

  .skip-demo {
    position: static;
    justify-self: center;
    min-height: 48px;
    padding: 4px 7px;
    font-size: 0.875rem;
  }

  .dock-span {
    grid-area: dock;
    gap: 1px;
  }

  .dock-span::before {
    left: 0;
    right: 0;
    top: 28%;
    bottom: 0;
  }

  .tutorial-steps {
    position: absolute;
    z-index: 12;
    right: 7px;
    top: 4px;
    gap: 4px;
  }

  .tutorial-steps li {
    width: 30px;
    height: 28px;
  }

  .scene-group {
    grid-template-columns: minmax(78px, 0.72fr) minmax(138px, 0.96fr) minmax(78px, 0.72fr);
  }

  .sign-post {
    min-height: 102px;
  }

  .sign-socket {
    border-width: 2px;
    font-size: 0.8125rem;
  }

  .demo-label {
    top: 0;
    font-size: 0.875rem;
  }

  .count-area {
    grid-template-columns: auto auto auto;
    justify-content: center;
    align-items: center;
    gap: 4px;
    padding: 0;
  }

  .count-heading {
    font-size: 0.875rem;
  }

  .count-frames {
    width: auto;
    gap: 4px;
  }

  .ten-frame {
    --fish-cell: 28px;
    gap: 1px;
    padding: 5px 6px;
  }

  .group-equation {
    font-size: 0.72rem;
  }

  .answer-bar {
    min-height: 80px;
    padding: 5px 14px;
  }

  .choices {
    gap: 8px;
  }

  .candidate {
    width: clamp(76px, 10vw, 92px);
    height: 56px;
    font-size: 2.5rem;
  }

  .ok-button {
    width: 62px;
    height: 62px;
  }

  .intro-copy {
    top: 8px;
    padding: 5px 12px 7px;
  }

  .intro h1 {
    font-size: clamp(1.55rem, 4vw, 2.5rem);
  }

  .intro-copy > p:last-child {
    display: none;
  }

  .play-button {
    bottom: 8px;
    width: 68px;
    height: 68px;
  }

  .help-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "title audio close"
      "steps steps steps"
      "reading reading reading";
    column-gap: 8px;
    row-gap: 4px;
    padding: 8px 11px;
  }

  .help-card h2 {
    grid-area: title;
    margin: 0;
    font-size: 1.35rem;
    text-align: left;
  }

  .help-audio {
    grid-area: audio;
    margin: 0;
  }

  .help-steps {
    grid-area: steps;
    gap: 5px;
  }

  .help-steps li {
    grid-template-columns: 42px minmax(0, 1fr);
    padding: 4px 5px;
  }

  .help-art {
    width: 38px;
    height: 38px;
  }

  .help-art img {
    width: 34px;
    height: 34px;
  }

  .help-steps p,
  .help-reading p {
    font-size: 13px;
    line-height: 1.3;
  }

  .help-reading {
    grid-area: reading;
    margin: 0;
    padding: 4px 7px;
  }

  .close-button {
    grid-area: close;
    margin: 0;
    min-width: 88px;
  }

  .pause-card {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    grid-template-rows: repeat(4, auto);
    align-items: center;
    column-gap: 14px;
    width: min(780px, 100%);
    padding: 8px 14px;
  }

  .pause-illustration {
    grid-column: 1;
    grid-row: 1 / -1;
    height: 96px;
  }

  .pause-card > :not(.pause-illustration) {
    grid-column: 2;
  }

  .pause-card h2 {
    margin: 0 0 2px;
  }

  .pause-card .panel-note {
    margin-bottom: 4px;
  }

  .pause-levels {
    margin: 4px 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }


}
