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

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

:root {
  --navy: #174a7e;
  --navy-deep: #0b3158;
  --ink: #263849;
  --snow: #fffdf5;
  --snow-blue: #eefbff;
  --frost: rgb(244 252 255 / 88%);
  --wood: #b9773d;
  --wood-deep: #70431f;
  --gold: #f2c141;
  --gold-pale: #ffe49b;
  --amber: #b96b24;
  --green: #258650;
  --green-dark: #145d36;
  --pebble-target: clamp(56px, 7.6vh, 84px);
  --safe-top: max(8px, env(safe-area-inset-top));
  --safe-right: max(10px, env(safe-area-inset-right));
  --safe-bottom: max(8px, env(safe-area-inset-bottom));
  --safe-left: max(10px, env(safe-area-inset-left));
  color: var(--navy);
  font-family: "Fredoka", "Trebuchet MS", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #bfeafa;
}

body {
  min-width: 280px;
  min-height: 320px;
  overscroll-behavior: none;
}

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

button {
  font: inherit;
}

button:focus-visible,
a:focus-visible {
  outline: 4px solid #ffd766;
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.app,
.game,
.intro {
  width: 100%;
  height: 100%;
  min-height: 100dvh;
}

.app {
  position: relative;
  overflow: hidden;
}

.intro {
  position: relative;
  isolation: isolate;
  overflow: hidden;
}

.intro-bg {
  position: absolute;
  inset: 0;
  z-index: -2;
}

.intro-bg img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  background: #cfeefa;
}

.intro::after {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(180deg, rgb(255 255 255 / 10%), transparent 32%),
    linear-gradient(90deg, rgb(7 45 72 / 5%), transparent 40%);
  content: "";
  pointer-events: none;
}

.intro-title {
  position: absolute;
  top: clamp(18px, 4vh, 42px);
  left: clamp(16px, 4vw, 64px);
  max-width: min(76vw, 760px);
  padding: clamp(10px, 1.5vh, 17px) clamp(16px, 2.6vw, 30px) clamp(13px, 1.8vh, 19px);
  border: 2px solid rgb(255 255 255 / 75%);
  border-radius: 32px 18px 28px 16px;
  background:
    radial-gradient(circle at 92% 10%, rgb(255 255 255 / 85%) 0 6%, transparent 20%),
    linear-gradient(140deg, rgb(255 255 255 / 93%), rgb(231 249 255 / 86%));
  box-shadow: 0 12px 28px rgb(22 76 109 / 16%);
  backdrop-filter: blur(5px);
}

.intro-title h1 {
  margin: 0;
  color: var(--navy-deep);
  font-size: clamp(29px, 5.2vw, 66px);
  font-weight: 600;
  line-height: 0.97;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

.intro-action {
  position: absolute;
  right: clamp(20px, 8vw, 120px);
  bottom: clamp(30px, 12vh, 120px);
  display: grid;
  justify-items: center;
}

.play-btn {
  position: relative;
  display: grid;
  width: clamp(104px, 10vw, 134px);
  aspect-ratio: 1;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: var(--snow);
  background: transparent;
  cursor: pointer;
  filter: drop-shadow(0 12px 13px rgb(54 35 11 / 22%));
  font-size: clamp(31px, 3vw, 43px);
  font-weight: 600;
  transition: transform 150ms ease, filter 150ms ease;
}

.play-btn:hover {
  filter: drop-shadow(0 14px 16px rgb(54 35 11 / 28%));
  transform: translateY(-2px) scale(1.02);
}

.play-btn:active {
  transform: translateY(1px) scale(0.98);
}

.play-btn img {
  position: absolute;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.play-btn span {
  text-shadow: 0 2px 0 #73491c, 0 4px 9px rgb(46 27 4 / 34%);
}

.intro-action p {
  margin: 5px 0 0;
  padding: 5px 13px;
  border: 1px solid rgb(255 255 255 / 80%);
  border-radius: 999px;
  color: var(--navy-deep);
  background: rgb(255 253 245 / 90%);
  box-shadow: 0 5px 12px rgb(25 67 91 / 13%);
  font-size: clamp(15px, 1.7vw, 20px);
  font-weight: 600;
  white-space: nowrap;
}

.game {
  position: fixed;
  inset: 0;
  isolation: isolate;
  overflow: hidden;
  background: #c9eefb;
}

.game[data-mode="demo"] {
  --pebble-target: clamp(72px, 11vh, 100px);
}

.board {
  position: absolute;
  inset: 0;
  z-index: 0;
  isolation: isolate;
  overflow: hidden;
}

.board-bg {
  position: absolute;
  inset: 0;
  z-index: -3;
}

.board-bg img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.board::after {
  position: absolute;
  inset: 0;
  z-index: -2;
  background:
    linear-gradient(180deg, rgb(255 255 255 / 9%), transparent 23%),
    linear-gradient(0deg, rgb(77 129 156 / 8%), transparent 34%);
  content: "";
  pointer-events: none;
}

.water-glints {
  position: absolute;
  top: 25%;
  right: 11%;
  left: 37%;
  z-index: -1;
  height: 8%;
  pointer-events: none;
}

.water-glints span {
  position: absolute;
  width: clamp(12px, 1.7vw, 24px);
  height: 3px;
  border-radius: 999px;
  background: rgb(255 255 255 / 0%);
  box-shadow: 0 0 9px 2px rgb(255 255 255 / 0%);
  animation: water-glint 8s ease-in-out infinite;
}

.water-glints span:nth-child(1) {
  top: 16%;
  left: 15%;
}

.water-glints span:nth-child(2) {
  top: 62%;
  left: 57%;
  animation-delay: 2.7s;
}

.water-glints span:nth-child(3) {
  top: 28%;
  left: 83%;
  animation-delay: 5.4s;
}

.topbar {
  position: absolute;
  z-index: 30;
  top: var(--safe-top);
  right: var(--safe-right);
  left: var(--safe-left);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
}

.controls {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: clamp(3px, 0.6vw, 8px);
  pointer-events: auto;
}

.control-btn {
  position: relative;
  display: grid;
  flex: 0 0 56px;
  width: 56px;
  height: 56px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  filter: drop-shadow(0 5px 6px rgb(39 35 19 / 20%));
  text-decoration: none;
  transition: transform 130ms ease, filter 130ms ease;
}

.control-btn:hover {
  filter: drop-shadow(0 6px 8px rgb(39 35 19 / 25%));
  transform: translateY(-1px);
}

.control-btn:active {
  transform: translateY(1px) scale(0.97);
}

.control-btn img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.help-control span {
  position: relative;
  color: #fffdf4;
  font-size: 29px;
  font-weight: 600;
  line-height: 1;
  text-shadow: 0 2px 0 #835417;
}

.control-btn.is-muted::after {
  position: absolute;
  width: 30px;
  height: 5px;
  border-radius: 4px;
  background: #ffefc5;
  box-shadow: 0 0 0 2px #724228;
  content: "";
  transform: rotate(-45deg);
}

.progress {
  display: grid;
  min-width: 0;
  grid-template-columns: auto auto;
  grid-template-areas:
    "heading tokens"
    "levels stars";
  align-items: center;
  justify-items: end;
  gap: 4px 10px;
  padding: 7px 10px 8px;
  border: 1px solid rgb(255 255 255 / 70%);
  border-radius: 18px 11px 18px 12px;
  background: rgb(241 251 254 / 79%);
  box-shadow: 0 7px 18px rgb(13 58 82 / 14%);
  backdrop-filter: blur(7px);
  pointer-events: auto;
}

.progress-heading {
  display: flex;
  grid-area: heading;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
}

.level-badge {
  color: var(--navy-deep);
  font-size: clamp(13px, 1.1vw, 16px);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.task-count {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.level-props,
.task-star-row,
.token-area,
.reward-tokens,
.final-tokens {
  display: flex;
  align-items: center;
  gap: 4px;
}

.level-props {
  grid-area: levels;
  min-width: 0;
}

.level-prop {
  position: relative;
  display: inline-grid;
  width: 30px;
  height: 34px;
  place-items: center;
  border: 0;
  color: #fff;
  background: url("assets/ui/level-crystal.webp") center / contain no-repeat;
  text-shadow: 0 1px 2px rgb(4 52 82 / 82%);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
}

.level-prop.is-current {
  filter: brightness(1.08);
  transform: translateY(-1px) scale(1.03);
}

.level-prop.is-done {
  filter: brightness(1.12) saturate(1.08);
}

.task-stars {
  grid-area: stars;
}

.star-icon,
.reward-star,
.reward-token,
.token {
  display: inline-block;
  width: clamp(19px, 1.9vw, 25px);
  aspect-ratio: 1;
  background: center / contain no-repeat url("assets/ui/ui-reward-star-empty.webp");
}

.star-icon.is-filled,
.reward-star.is-filled,
.reward-token.is-filled,
.token {
  background-image: url("assets/ui/ui-reward-star.webp");
}

.reward-token.is-empty,
.token.is-empty {
  background-image: url("assets/ui/ui-reward-star-empty.webp");
  opacity: 0.58;
}

.session-tokens {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.session-tokens .token {
  width: 16px;
}

.skip-demo-btn {
  position: absolute;
  top: 64px;
  left: 50%;
  min-height: 48px;
  padding: 8px 20px;
  border: 2px solid #fff0b5;
  border-radius: 999px;
  color: #fff;
  background: var(--navy);
  box-shadow: 0 4px 0 var(--navy-deep), 0 7px 14px rgb(8 45 69 / 20%);
  cursor: pointer;
  font-size: clamp(14px, 1.3vw, 18px);
  font-weight: 600;
  pointer-events: auto;
  transform: translateX(-50%);
}

.guide {
  position: absolute;
  z-index: 8;
  bottom: 3.4%;
  left: 2.4%;
  width: 31%;
  height: clamp(255px, 43vh, 370px);
  pointer-events: none;
}

.guide-portrait {
  position: absolute;
  bottom: 0;
  left: 0;
  height: clamp(220px, 35vh, 300px);
  aspect-ratio: 1.25;
  filter: drop-shadow(0 10px 12px rgb(17 64 85 / 15%));
}

.sopo-guide {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: bottom left;
}

.speech {
  position: absolute;
  top: 2%;
  left: 36%;
  width: min(16vw, 205px);
  min-height: 72px;
  padding: 9px 12px 11px;
  border: 2px solid rgb(255 255 255 / 90%);
  border-radius: 28px 18px 25px 17px;
  color: var(--navy-deep);
  background:
    radial-gradient(circle at 84% 14%, rgb(255 255 255 / 88%) 0 7%, transparent 19%),
    rgb(255 253 245 / 91%);
  box-shadow: 0 8px 20px rgb(5 42 65 / 14%);
  backdrop-filter: blur(4px);
}

.speech::after {
  position: absolute;
  bottom: -12px;
  left: 24%;
  width: 22px;
  height: 18px;
  border-bottom: 2px solid rgb(255 255 255 / 90%);
  border-left: 2px solid rgb(255 255 255 / 90%);
  border-radius: 0 0 0 10px;
  background: #fffdf5;
  content: "";
  transform: rotate(-30deg) skewX(20deg);
}

.speech strong {
  display: block;
  margin-bottom: 2px;
  color: #9a641f;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.speech p {
  margin: 0;
  font-size: clamp(13px, 1.15vw, 17px);
  font-weight: 600;
  line-height: 1.2;
  text-wrap: balance;
}

.game[data-mode="demo"] .guide {
  width: 34%;
  height: clamp(310px, 50vh, 420px);
}

.game[data-mode="demo"] .guide-portrait {
  height: clamp(260px, 43vh, 355px);
}

.game[data-mode="demo"] .speech {
  top: 0;
  left: 39%;
}

.pebble-stage {
  position: absolute;
  z-index: 5;
  top: 40%;
  right: 3.5%;
  bottom: max(20%, 190px);
  left: 35.5%;
  min-width: 0;
  min-height: 0;
}

.game[data-mode="demo"] .pebble-stage {
  top: 43%;
  right: 24%;
  bottom: 23%;
  left: 42%;
}

.pebble {
  position: absolute;
  display: grid;
  width: var(--pebble-target);
  height: var(--pebble-target);
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  filter: drop-shadow(0 6px 5px rgb(22 59 76 / 18%));
  transform: translate(-50%, -50%);
}

.pebble::before {
  position: absolute;
  inset: 8%;
  border: 2px solid transparent;
  border-radius: 48%;
  content: "";
  transition: border-color 130ms ease, background-color 130ms ease;
}

.pebble:hover::before,
.pebble:focus-visible::before {
  border-color: rgb(255 242 182 / 82%);
  background: rgb(255 255 255 / 9%);
}

.pebble-img {
  position: relative;
  z-index: 1;
  display: block;
  width: 88%;
  height: 88%;
  object-fit: contain;
  pointer-events: none;
  transform-origin: center;
}

.pebble.size-small .pebble-img {
  width: 74%;
  height: 74%;
}

.pebble.size-large .pebble-img {
  width: 98%;
  height: 98%;
}

.pebble.is-tapped .pebble-img {
  animation: pebble-punch 230ms cubic-bezier(0.22, 0.9, 0.3, 1.2);
}

.pebble.is-acknowledged .pebble-img {
  animation: gentle-acknowledge 300ms ease-out;
}

.pebble.is-emphasized .pebble-img {
  filter: drop-shadow(0 0 8px rgb(255 210 86 / 95%)) brightness(1.12);
  animation: recount-pulse 620ms ease-out;
}

.pebble.is-marked {
  filter: drop-shadow(0 6px 5px rgb(22 59 76 / 17%));
}

.mark-badge {
  position: absolute;
  z-index: 2;
  top: 1px;
  right: -3px;
  display: inline-flex;
  min-width: 26px;
  height: 20px;
  padding: 0 4px;
  align-items: center;
  justify-content: center;
  border: 1px solid #ffe9a7;
  border-radius: 999px;
  color: #ffe7a4;
  background: rgb(10 45 66 / 82%);
  box-shadow: 0 2px 5px rgb(7 32 47 / 30%);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.mark-badge::before {
  margin-right: 2px;
  content: "✓";
}

.whole-bracket {
  position: absolute;
  right: auto;
  bottom: auto;
  left: 2%;
  width: 96%;
  height: 4px;
  border-bottom: 3px solid #efbd3f;
  border-radius: 0;
  filter: drop-shadow(0 2px 2px rgb(107 69 11 / 22%));
  pointer-events: none;
}

.bracket-corner {
  position: absolute;
  bottom: -2px;
  width: 18px;
  height: 9px;
  border-bottom: 3px solid #efbd3f;
}

.bracket-corner.tl,
.bracket-corner.bl {
  left: 0;
  border-left: 3px solid #efbd3f;
  border-radius: 9px 0 0 9px;
}

.bracket-corner.tr,
.bracket-corner.br {
  right: 0;
  border-right: 3px solid #efbd3f;
  border-radius: 0 9px 9px 0;
}

.bracket-corner.bl,
.bracket-corner.br {
  display: none;
}

.tutorial-hand {
  position: absolute;
  z-index: 18;
  width: clamp(58px, 6.2vw, 88px);
  height: auto;
  pointer-events: none;
  filter: drop-shadow(0 6px 7px rgb(40 30 12 / 25%));
  transform: translate(-25%, -82%);
  transform-origin: 30% 85%;
}

.answer-area {
  position: absolute;
  z-index: 20;
  right: 3.5%;
  bottom: 1.4%;
  left: auto;
  display: grid;
  width: min(480px, calc(100% - 8%));
  min-height: 112px;
  max-height: none;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "heading heading"
    "choices ok"
    "tools tools";
  align-items: center;
  gap: 2px 10px;
  padding: 6px 10px 8px;
  border: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}

.answer-area::before {
  position: absolute;
  right: -10px;
  bottom: -6px;
  left: -10px;
  z-index: 0;
  height: clamp(84px, 16vh, 128px);
  background: url("assets/ui/answer-ledge.webp") center bottom / 100% auto no-repeat;
  content: "";
  pointer-events: none;
}

.answer-area > *,
.answer-row > * {
  position: relative;
  z-index: 1;
}

.answer-heading {
  grid-area: heading;
  align-self: end;
  text-align: center;
}

.answer-prompt,
.whole-caption {
  margin: 0;
  color: var(--navy-deep);
  font-size: clamp(14px, 1.35vw, 19px);
  font-weight: 600;
  line-height: 1.1;
  text-align: center;
}

.whole-caption {
  color: #7c5210;
}

.whole-caption:not([hidden]) + .answer-prompt {
  display: none;
}

.answer-row {
  display: contents;
}

.answer-choices {
  display: flex;
  grid-area: choices;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 0.8vw, 10px);
}

.answer-choice {
  position: relative;
  display: inline-flex;
  isolation: isolate;
  width: clamp(72px, 6.4vw, 80px);
  height: clamp(72px, 6.4vw, 80px);
  min-width: 48px;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 13px 10px 14px 9px;
  color: var(--navy-deep);
  background: url("assets/ui/number-tile.webp") center / contain no-repeat;
  box-shadow: none;
  cursor: pointer;
  font-family: inherit;
  font-size: clamp(26px, 2.9vw, 35px);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.035em;
  line-height: 1;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.answer-choice:hover {
  filter: drop-shadow(0 5px 5px rgb(81 50 19 / 20%));
  transform: translateY(-1px);
}

.answer-choice:active {
  transform: translateY(2px);
  filter: brightness(0.98);
}

.answer-choice[aria-pressed="true"] {
  color: #fff;
  background: url("assets/ui/number-tile.webp") center / contain no-repeat;
  box-shadow:
    inset 0 0 0 999px rgb(15 53 83 / 84%),
    inset 0 5px 10px rgb(2 24 42 / 40%),
    inset 0 0 0 2px rgb(233 249 255 / 34%);
  filter: drop-shadow(0 2px 3px rgb(4 35 59 / 24%));
  transform: translateY(2px);
}

.ok-btn {
  display: grid;
  grid-area: ok;
  width: 72px;
  min-width: 0;
  height: 72px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
  font-family: inherit;
}

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

.ok-btn:disabled {
  cursor: default;
  filter: grayscale(1) saturate(0);
  opacity: 0.58;
}

.answer-tools {
  display: flex;
  grid-area: tools;
  min-height: 0;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.answer-tools:has(button:not([hidden])) {
  min-height: 48px;
}

.recount-btn,
.continue-btn {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 14px;
  border: 2px solid #b8d7e2;
  border-radius: 999px;
  color: var(--navy-deep);
  background: rgb(255 255 255 / 91%);
  box-shadow: 0 3px 6px rgb(19 66 91 / 11%);
  cursor: pointer;
  font-size: clamp(12px, 1.15vw, 16px);
  font-weight: 600;
}

.recount-btn img {
  width: 25px;
  height: 25px;
  object-fit: contain;
}

.continue-btn {
  border-color: #d5a442;
  background: #ffe4a2;
}

.board.answer-wrong .answer-area {
  border: 0;
  box-shadow: none;
}

.board.answer-wrong .answer-prompt {
  color: var(--amber);
}

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

.fx-tap {
  position: absolute;
  width: 44px;
  height: 44px;
  border: 3px solid rgb(255 226 139 / 85%);
  border-radius: 50%;
  box-shadow: 0 0 12px rgb(255 216 110 / 46%);
  transform: translate(-50%, -50%) scale(0.35);
  animation: tap-ripple 380ms ease-out forwards;
}

.fx-particle {
  position: absolute;
  width: var(--size, 6px);
  height: var(--size, 6px);
  border-radius: 50% 42% 55% 48%;
  background: var(--tone, #f6c94f);
  box-shadow: 0 0 7px rgb(255 220 120 / 62%);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.55);
  animation: particle-burst var(--life, 560ms) ease-out forwards;
}

.global-rune {
  position: fixed;
  z-index: 1000;
  bottom: 2px;
  left: 7px;
  width: clamp(36px, 4.2vw, 62px);
  height: auto;
  pointer-events: none;
}

.modal {
  width: min(92vw, 650px);
  max-height: 92dvh;
  padding: 0;
  overflow: visible;
  border: 0;
  border-radius: 28px;
  color: var(--navy);
  background: transparent;
}

.modal::backdrop {
  background: rgb(8 45 69 / 48%);
  backdrop-filter: blur(5px);
}

.modal-card {
  position: relative;
  max-height: 92dvh;
  overflow: auto;
  padding: clamp(24px, 4vw, 44px);
  border: 3px solid rgb(255 255 255 / 82%);
  border-radius: 34px 20px 30px 22px;
  background:
    radial-gradient(circle at 82% 8%, #e1f8ff 0, transparent 26%),
    linear-gradient(145deg, #fffdf5, #fff5dc);
  box-shadow: 0 24px 70px rgb(4 36 58 / 34%);
  text-align: center;
}

.modal-card h2 {
  margin: 0 0 18px;
  color: var(--navy-deep);
  font-size: clamp(30px, 5vw, 50px);
  font-weight: 600;
  line-height: 1;
}

.modal-sopo {
  width: 115px;
  height: 92px;
  object-fit: contain;
}

.primary-btn,
.song-btn {
  min-width: 180px;
  min-height: 54px;
  padding: 12px 24px;
  border: 3px solid #ffe7a2;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(#2e95cf, #176aa1);
  box-shadow: 0 5px 0 #0c4c75, 0 8px 16px rgb(9 55 86 / 20%);
  cursor: pointer;
  font-size: 19px;
  font-weight: 600;
}

.primary-btn:active,
.song-btn:active {
  box-shadow: 0 3px 0 #0c4c75;
  transform: translateY(2px);
}

.dialog-close {
  position: absolute;
  z-index: 3;
  top: 10px;
  right: 12px;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 2px solid #d5e2e8;
  border-radius: 50%;
  color: var(--navy);
  background: #fff;
  cursor: pointer;
  font-size: 31px;
  font-weight: 600;
  line-height: 1;
}

#pause-dialog {
  width: min(calc(100vw - 32px), 900px);
  max-height: calc(100dvh - 32px);
  overflow: visible;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

#pause-dialog::backdrop {
  background:
    radial-gradient(circle at 50% 44%, rgb(195 244 255 / 16%), transparent 45%),
    rgb(6 39 61 / 58%);
  backdrop-filter: blur(7px) saturate(0.84);
}

#pause-dialog .pause-card {
  position: relative;
  display: grid;
  min-height: 438px;
  max-height: calc(100dvh - 32px);
  grid-template-columns: minmax(250px, 0.86fr) minmax(390px, 1.14fr);
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
  border: 2px solid rgb(255 255 255 / 94%);
  border-radius: 46px 28px 42px 32px;
  color: var(--navy-deep);
  background:
    radial-gradient(circle at 91% 2%, rgb(255 255 255 / 98%) 0 4%, transparent 24%),
    linear-gradient(138deg, #d9f7ff 0%, #f8feff 56%, #ffffff 100%);
  box-shadow:
    0 28px 80px rgb(2 29 49 / 42%),
    0 8px 24px rgb(5 53 79 / 24%),
    inset 0 0 0 4px rgb(224 249 255 / 62%);
  text-align: left;
}

#pause-dialog .pause-card::before {
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: inherit;
  background:
    radial-gradient(circle at 12% 10%, rgb(255 255 255 / 60%) 0 1.5%, transparent 9%),
    radial-gradient(circle at 76% 12%, rgb(255 255 255 / 48%) 0 1%, transparent 7%),
    radial-gradient(circle at 94% 72%, rgb(102 207 230 / 12%) 0 2%, transparent 12%);
  content: "";
  pointer-events: none;
}

#pause-dialog .pause-sopo-stage {
  position: relative;
  z-index: 1;
  display: grid;
  min-width: 0;
  min-height: 100%;
  place-items: end center;
  isolation: isolate;
  overflow: hidden;
  padding: 24px 18px 34px 8px;
  border-radius: 44px 0 0 30px;
  background:
    radial-gradient(ellipse at 52% 74%, rgb(255 255 255 / 86%) 0 24%, transparent 58%),
    radial-gradient(circle at 77% 18%, rgb(255 255 255 / 74%) 0 2%, transparent 20%),
    linear-gradient(148deg, #12698b 0%, #55bfd9 48%, #dff9fb 100%);
}

#pause-dialog .pause-sopo-stage::before {
  position: absolute;
  inset: 8% -16% auto auto;
  z-index: -1;
  width: 82%;
  aspect-ratio: 1;
  border: 1px solid rgb(234 254 255 / 58%);
  border-radius: 47% 53% 61% 39%;
  box-shadow:
    0 0 0 18px rgb(210 247 255 / 10%),
    0 0 0 46px rgb(203 246 255 / 7%);
  content: "";
  transform: rotate(18deg);
}

#pause-dialog .pause-sopo-stage::after {
  position: absolute;
  right: -14%;
  bottom: -3%;
  left: -14%;
  z-index: 0;
  height: 24%;
  background: url("assets/ui/answer-ledge.webp") center bottom / 100% auto no-repeat;
  content: "";
  filter: drop-shadow(0 -3px 8px rgb(10 76 102 / 14%));
  pointer-events: none;
}

#pause-dialog .pause-sopo {
  position: relative;
  z-index: 1;
  display: block;
  width: min(100%, 350px);
  height: auto;
  max-height: 360px;
  object-fit: contain;
  object-position: center bottom;
  filter: drop-shadow(0 14px 12px rgb(7 57 79 / 22%));
  pointer-events: none;
}

#pause-dialog .pause-panel {
  position: relative;
  z-index: 1;
  display: grid;
  min-width: 0;
  align-content: center;
  justify-items: center;
  gap: clamp(14px, 2.2vh, 22px);
  padding: clamp(24px, 4vw, 44px);
  border-radius: 0 26px 40px 0;
  background:
    linear-gradient(90deg, rgb(151 224 240 / 12%), transparent 12%),
    linear-gradient(165deg, rgb(255 255 255 / 48%), rgb(225 249 255 / 60%));
  box-shadow: inset 1px 0 0 rgb(255 255 255 / 88%);
  text-align: center;
}

#pause-dialog .pause-heading {
  display: grid;
  justify-items: center;
  gap: 5px;
}

#pause-dialog .pause-heading h2 {
  margin: 0;
  color: #0a3d61;
  font-size: clamp(38px, 5vw, 58px);
  font-weight: 600;
  letter-spacing: -0.045em;
  line-height: 0.94;
  text-shadow: 0 2px 0 rgb(255 255 255 / 76%);
}

#pause-dialog .pause-note {
  margin: 2px 0 0;
  color: #3d6b80;
  font-size: clamp(13px, 1.35vw, 16px);
  font-weight: 400;
  line-height: 1.2;
}

#pause-dialog .level-menu {
  display: grid;
  justify-items: center;
  gap: 8px;
  width: 100%;
}

#pause-dialog .level-menu p {
  margin: 0;
  color: #225d76;
  font-size: clamp(13px, 1.35vw, 16px);
  font-weight: 600;
  line-height: 1.2;
}

#pause-dialog .level-menu-buttons {
  display: flex;
  width: 100%;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: clamp(5px, 1vw, 12px);
  overflow: visible;
}

#pause-dialog .level-choice {
  position: relative;
  display: grid;
  flex: 0 1 64px;
  width: clamp(48px, 5.2vw, 64px);
  min-width: 48px;
  max-width: 64px;
  height: clamp(48px, 5.2vw, 64px);
  min-height: 48px;
  max-height: 64px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 16px 10px 15px 11px;
  color: #143f59;
  background:
    linear-gradient(180deg, rgb(231 252 255 / 18%), rgb(0 91 126 / 8%)),
    url("assets/ui/number-tile.webp") center / 100% 100% no-repeat;
  box-shadow: 0 4px 7px rgb(11 72 96 / 18%);
  cursor: pointer;
  font-size: clamp(20px, 2.2vw, 27px);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  line-height: 1;
  text-shadow: 0 1px 0 rgb(255 255 255 / 72%);
  transition: transform 130ms ease, filter 130ms ease;
}

#pause-dialog .level-choice:hover {
  filter: brightness(1.04);
  transform: translateY(-2px);
}

#pause-dialog .level-choice:active {
  transform: translateY(1px) scale(0.97);
}

#pause-dialog .level-choice[aria-current="true"] {
  color: #fff;
  background:
    linear-gradient(rgb(10 86 117 / 88%), rgb(7 58 91 / 91%)),
    url("assets/ui/number-tile.webp") center / 100% 100% no-repeat;
  box-shadow:
    0 0 0 2px #f4feff,
    0 0 0 5px #36b3ca,
    0 5px 10px rgb(6 62 86 / 30%);
  text-shadow: 0 1px 2px rgb(3 34 54 / 64%);
}

#pause-dialog .level-choice[aria-current="true"]::after {
  position: absolute;
  bottom: 4px;
  left: 50%;
  width: 7px;
  height: 7px;
  border: 1px solid #fff;
  border-radius: 50%;
  background: #8cecff;
  box-shadow: 0 0 0 2px rgb(8 67 91 / 48%);
  content: "";
  transform: translateX(-50%);
}

#pause-dialog #resume-btn {
  min-width: min(210px, 100%);
  min-height: 52px;
  padding: 12px 30px;
  border: 2px solid #e9fdff;
  color: #fff;
  background:
    linear-gradient(90deg, rgb(255 255 255 / 0%) 32%, rgb(255 255 255 / 18%) 50%, rgb(255 255 255 / 0%) 68%),
    linear-gradient(145deg, #1a8caf, #07557d);
  box-shadow:
    0 5px 0 #063d5b,
    0 10px 18px rgb(5 53 78 / 22%),
    inset 0 0 0 2px rgb(120 223 243 / 30%);
  font-size: 18px;
  letter-spacing: 0.015em;
  text-shadow: 0 1px 2px rgb(1 37 57 / 42%);
}

#pause-dialog #resume-btn:active {
  box-shadow:
    0 2px 0 #063d5b,
    0 6px 12px rgb(5 53 78 / 18%),
    inset 0 0 0 2px rgb(120 223 243 / 30%);
  transform: translateY(3px);
}

#pause-dialog button:focus-visible {
  outline: 4px solid #fff0a8;
  outline-offset: 3px;
  box-shadow:
    0 0 0 2px #0a5272,
    0 0 18px rgb(255 240 168 / 72%);
}

.help-card {
  width: 100%;
  max-width: 100%;
}

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

.help-steps li {
  min-width: 0;
  padding: 11px;
  border: 1px solid #cfe6ee;
  border-radius: 18px 12px 17px 13px;
  background: rgb(255 255 255 / 82%);
}

.help-steps p {
  margin: 8px 0 0;
  font-size: clamp(13px, 1.4vw, 16px);
  font-weight: 400;
  line-height: 1.28;
}

.help-picture {
  display: grid;
  height: 72px;
  place-items: center;
  border-radius: 14px 9px 13px 10px;
  background: #e4f6fc;
}

.help-picture img {
  width: 72px;
  height: 72px;
  object-fit: contain;
}

.hand-picture img {
  width: 61px;
  height: 61px;
}

.ok-picture img {
  width: 56px;
  height: 56px;
}

.narrator-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.narrator-controls button {
  min-width: 48px;
  min-height: 48px;
  flex-shrink: 0;
  padding: 8px 14px;
  border: 2px solid #b9d6e4;
  border-radius: 999px;
  color: var(--navy);
  background: #fff;
  cursor: pointer;
  font-weight: 600;
}

.narration-status {
  min-height: 18px;
  margin: 9px 0 14px;
  color: #46687f;
  font-size: 13px;
}

.reward-card {
  padding-top: 20px;
}

.reward-sopo {
  width: 155px;
  height: 130px;
  object-fit: contain;
}

.reward-stars,
.reward-tokens,
.final-tokens {
  justify-content: center;
}

.reward-star {
  width: 54px;
}

.reward-stars {
  margin: 0 0 8px;
}

.reward-tokens {
  margin: 0 0 20px;
}

.reward-tokens .reward-token {
  width: 34px;
}

.final-card {
  overflow: hidden;
}

.final-sopo {
  height: 150px;
  margin-top: -18px;
}

.final-sopo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.final-card p {
  font-size: 18px;
  font-weight: 400;
}

.song-btn {
  display: block;
  margin: 0 auto 14px;
  color: #3b2404;
  background: linear-gradient(#f6ca63, #dc941e);
  box-shadow: 0 5px 0 #9d6410, 0 8px 16px rgb(92 53 7 / 16%);
  text-shadow: 0 1px 0 rgb(255 239 184 / 72%);
}

.help-modal {
  width: min(calc(100vw - 16px), 760px);
  max-height: calc(100dvh - 16px);
  overflow: hidden;
}

.help-modal .help-card {
  max-height: calc(100dvh - 16px);
}

@keyframes water-glint {
  0%,
  77%,
  100% {
    opacity: 0;
    transform: translateX(-4px) scaleX(0.7);
  }
  83%,
  89% {
    opacity: 0.72;
    transform: translateX(2px) scaleX(1);
  }
}

@keyframes pebble-punch {
  0% { transform: scale(1); }
  45% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

@keyframes gentle-acknowledge {
  45% { transform: scale(1.07); }
  100% { transform: scale(1); }
}

@keyframes recount-pulse {
  0%,
  100% { transform: scale(1); }
  42% { transform: scale(1.14); }
}

@keyframes tap-ripple {
  0% {
    opacity: 0.82;
    transform: translate(-50%, -50%) scale(0.35);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.28);
  }
}

@keyframes particle-burst {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.45);
  }
  22% {
    opacity: 0.95;
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.1) rotate(var(--spin, 90deg));
  }
}

@media (orientation: landscape) {
  .intro-action {
    right: clamp(24px, 7vw, 104px);
    bottom: clamp(170px, 44vh, 360px);
    left: auto;
    transform: none;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .intro-action {
    right: clamp(14px, 4vw, 34px);
    bottom: clamp(116px, 37vh, 160px);
  }
}

@media (orientation: portrait) {
  .intro-bg img {
    object-fit: contain;
    object-position: center;
    background: #cfeefa;
  }

  .intro-title {
    top: max(12px, env(safe-area-inset-top));
    right: 12px;
    left: 12px;
    max-width: none;
    padding: 10px 14px 13px;
    border-radius: 26px 17px 24px 14px;
    text-align: center;
  }

  .intro-title h1 {
    font-size: clamp(28px, 8.2vw, 52px);
  }

  .intro-action {
    right: 50%;
    bottom: clamp(10px, 2vh, 24px);
    transform: translateX(50%);
  }

  .play-btn {
    width: 108px;
  }

  .topbar {
    display: grid;
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 3px;
  }

  .controls {
    justify-self: start;
    justify-content: flex-start;
  }

  .progress {
    width: min(100%, 342px);
    grid-template-columns: auto auto;
    grid-template-areas:
      "heading heading"
      "levels stars";
    justify-items: center;
    padding: 4px 8px 5px;
    border-radius: 13px 10px 14px 9px;
  }

  .progress-heading {
    justify-content: center;
  }

  .task-count {
    font-size: 11px;
  }

  .level-prop {
    width: 24px;
    height: 28px;
    font-size: 10px;
  }

  .star-icon {
    width: 18px;
  }

  .session-tokens {
    margin: 0;
  }

  .session-tokens .token {
    width: 13px;
  }

  .skip-demo-btn {
    position: fixed;
    top: 27vh;
    right: 12px;
    left: auto;
    width: auto;
    min-width: 80px;
    min-height: 48px;
    height: auto;
    padding: 8px 14px;
    font-size: 14px;
    line-height: normal;
    white-space: nowrap;
    transform: none;
  }

  .guide {
    top: clamp(120px, 17vh, 136px);
    right: 4%;
    bottom: auto;
    left: 4%;
    display: flex;
    width: auto;
    height: clamp(108px, 21vh, 178px);
    align-items: flex-start;
    gap: 8px;
  }

  .guide-portrait {
    position: relative;
    bottom: auto;
    left: auto;
    isolation: isolate;
    flex: 0 0 min(38vw, 190px);
    width: min(38vw, 190px);
    height: clamp(100px, 22vh, 178px);
    min-width: 124px;
  }

  .guide-portrait::before {
    position: absolute;
    right: 0;
    bottom: -1px;
    left: 0;
    z-index: 0;
    height: 22%;
    background: url("assets/ui/answer-ledge.webp") center bottom / 100% 100% no-repeat;
    content: "";
    opacity: 0.9;
    pointer-events: none;
  }

  .speech {
    position: relative;
    top: auto;
    left: auto;
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    min-height: 58px;
    padding: 7px 9px 9px;
    border-radius: 19px 14px 18px 12px;
  }

  .speech::after {
    top: 27%;
    bottom: auto;
    left: -10px;
    width: 17px;
    height: 20px;
    border: 0;
    border-bottom: 2px solid rgb(255 255 255 / 90%);
    border-left: 2px solid rgb(255 255 255 / 90%);
    border-radius: 0 0 0 10px;
    transform: rotate(40deg) skewX(16deg);
  }

  .speech strong {
    font-size: 10px;
  }

  .speech p {
    font-size: clamp(11px, 3.2vw, 14px);
  }

  .game[data-mode="demo"] .guide {
    top: clamp(120px, 16vh, 134px);
    right: 4%;
    bottom: auto;
    left: 4%;
    width: auto;
    height: clamp(116px, 23vh, 190px);
  }

  .game[data-mode="demo"] .guide-portrait {
    position: relative;
    flex: 0 0 min(52vw, 205px);
    flex-basis: min(52vw, 205px);
    width: min(52vw, 205px);
    height: clamp(120px, 23vh, 180px);
  }

  .game[data-mode="demo"] .speech {
    top: auto;
    left: auto;
  }

  .pebble-stage,
  .game[data-mode="demo"] .pebble-stage {
    top: 40%;
    right: 4%;
    bottom: 20%;
    left: 4%;
  }

  .game[data-mode="demo"] .pebble-stage {
    right: 7%;
    bottom: 24%;
    left: 7%;
  }

  .answer-area {
    right: 4%;
    bottom: max(0px, env(safe-area-inset-bottom));
    left: auto;
    width: min(480px, calc(100% - 8%));
    min-height: 122px;
    max-height: none;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "heading"
      "choices"
      "tools";
    gap: 1px;
    padding: 2px 6px 4px;
    border: 0;
    border-radius: 0;
  }

  .answer-heading {
    align-self: center;
  }

  .answer-prompt,
  .whole-caption {
    font-size: 13px;
  }

  .answer-row {
    display: flex;
    grid-area: choices;
    align-items: center;
    justify-content: center;
    gap: 5px;
  }

  .answer-choice {
    width: clamp(48px, 8vw, 72px);
    height: clamp(48px, 8vw, 72px);
    font-size: clamp(20px, 5vw, 32px);
  }

  .ok-btn {
    width: 56px;
    min-width: 0;
    height: 56px;
    padding: 0;
    border-radius: 50%;
  }

  .ok-btn img {
    display: block;
  }

  .recount-btn,
  .continue-btn {
    min-height: 48px;
    padding: 3px 10px;
    font-size: 12px;
  }

  .recount-btn img {
    width: 23px;
    height: 23px;
  }

  .global-rune {
    bottom: 1px;
    width: 33px;
  }

  .help-steps {
    grid-template-columns: 1fr;
  }

  .help-steps li {
    display: grid;
    grid-template-columns: 68px minmax(0, 1fr);
    align-items: center;
    gap: 9px;
  }

  .help-steps p {
    margin: 0;
    text-align: left;
  }
}

@media (orientation: portrait) and (max-height: 700px) {
  .intro-action {
    bottom: 8px;
  }

  .play-btn {
    width: 88px;
    height: 88px;
    font-size: 28px;
  }

  .intro-action p {
    font-size: 14px;
    white-space: nowrap;
  }
}

@media (orientation: portrait) and (max-width: 379px) {
  .controls {
    gap: 1px;
  }

  .control-btn {
    flex-basis: 56px;
  }

  .progress {
    width: calc(100vw - 16px);
  }

  .guide {
    right: 3%;
    left: 3%;
  }

  .guide-portrait {
    flex-basis: 130px;
    width: 130px;
    min-width: 130px;
  }

  .game[data-mode="demo"] .guide {
    height: 108px;
  }

  .game[data-mode="demo"] .guide-portrait {
    flex: 0 0 130px;
    flex-basis: 130px;
    width: 130px;
    height: 108px;
  }

  .game[data-mode="demo"] .speech {
    flex: 0 1 112px;
  }

  .pebble-stage,
  .game[data-mode="demo"] .pebble-stage {
    right: 3%;
    left: 3%;
  }

  .game[data-mode="demo"] .pebble-stage {
    top: 248px;
  }

  .answer-area {
    right: 3%;
    left: auto;
    width: calc(100% - 15%);
  }
}

@media (orientation: landscape) and (min-height: 501px) and (max-height: 650px) {
  .guide {
    right: auto;
    bottom: 3%;
    left: 1.5%;
    width: 23%;
    height: 248px;
  }

  .game[data-mode="demo"] .guide {
    right: auto;
    bottom: 2%;
    left: 1.5%;
    width: 23%;
    height: 278px;
  }

  .guide-portrait {
    width: min(278px, calc(30vw - 16px));
    height: 220px;
  }

  .game[data-mode="demo"] .guide-portrait {
    width: min(307px, calc(31vw - 16px));
    height: 246px;
  }

  .speech,
  .game[data-mode="demo"] .speech {
    top: 0;
    left: 43%;
    width: 148px;
  }

  .pebble-stage {
    top: 35%;
    right: 30%;
    bottom: 4%;
    left: 30%;
  }

  .game[data-mode="demo"] .pebble-stage {
    top: 38%;
    right: 30%;
    bottom: 9%;
    left: 31%;
  }

  .answer-area {
    top: 35%;
    right: 2%;
    bottom: 4%;
    left: auto;
    width: 24%;
    max-height: none;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "heading"
      "choices"
      "tools";
    padding: 7px;
  }

  .answer-row {
    display: flex;
    flex-wrap: wrap;
    grid-area: choices;
    gap: 4px;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .topbar {
    align-items: flex-start;
  }

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

  .progress {
    max-width: 330px;
    grid-template-areas:
      "heading tokens"
      "levels stars";
    padding: 4px 8px 5px;
  }

  .level-prop {
    width: 24px;
    height: 28px;
    font-size: 10px;
  }

  .star-icon {
    width: 17px;
  }

  .session-tokens .token {
    width: 12px;
  }

  .skip-demo-btn {
    top: 68px;
    left: 26%;
    min-height: 48px;
    font-size: 13px;
  }

  .guide {
    right: auto;
    bottom: 4%;
    left: 1.5%;
    display: block;
    width: 21.5%;
    height: 155px;
  }

  .guide-portrait,
  .game[data-mode="demo"] .guide-portrait {
    position: absolute;
    bottom: 0;
    left: 0;
    width: min(100%, 165px);
    height: 140px;
    min-width: 0;
    aspect-ratio: auto;
  }

  .speech,
  .game[data-mode="demo"] .speech {
    position: absolute;
    top: 0;
    right: 0;
    left: 38%;
    width: auto;
    min-height: 58px;
    padding: 6px 8px;
  }

  .speech p {
    font-size: 11px;
  }

  .speech strong {
    font-size: 9px;
  }

  .speech::after {
    top: auto;
    bottom: -9px;
    left: 18%;
    width: 16px;
    height: 14px;
    border: 0;
    border-bottom: 2px solid rgb(255 255 255 / 90%);
    border-left: 2px solid rgb(255 255 255 / 90%);
    transform: rotate(-30deg) skewX(20deg);
  }

  .game[data-mode="demo"] .guide {
    right: auto;
    bottom: 3%;
    left: 1.5%;
    width: 21.5%;
    height: 168px;
  }

  .pebble-stage {
    top: 35%;
    right: 29%;
    bottom: 4%;
    left: 24%;
  }

  .game[data-mode="demo"] .pebble-stage {
    top: 38%;
    right: 29%;
    bottom: 9%;
    left: 25%;
  }

  .answer-area {
    top: 35%;
    right: 2%;
    bottom: 4%;
    left: auto;
    width: 24%;
    min-height: 0;
    max-height: none;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "heading"
      "choices"
      "tools";
    gap: 4px;
    padding: 5px 7px;
  }

  .answer-prompt,
  .whole-caption {
    font-size: 12px;
  }

  .answer-row {
    display: flex;
    flex-wrap: wrap;
    grid-area: choices;
    gap: 4px;
  }

  .answer-choices {
    gap: 4px;
  }

  .answer-choice {
    width: 56px;
    height: 56px;
    font-size: 25px;
  }

  .ok-btn {
    width: 48px;
    min-width: 0;
    height: 48px;
    padding: 0;
    border-radius: 50%;
  }

  .ok-btn img {
    display: block;
  }

  .recount-btn,
  .continue-btn {
    min-height: 48px;
    padding: 3px 8px;
    font-size: 11px;
  }

  .recount-btn img {
    width: 22px;
    height: 22px;
  }

  .tutorial-hand {
    width: 58px;
  }

  .final-modal {
    width: min(94vw, 700px);
    max-height: calc(100dvh - 8px);
  }

  .final-modal .final-card {
    display: grid;
    max-height: calc(100dvh - 8px);
    grid-template-columns: minmax(110px, 150px) minmax(0, 1fr);
    grid-template-rows: auto auto auto auto auto;
    column-gap: 16px;
    row-gap: 2px;
    overflow: hidden;
    padding: 10px 20px 12px;
  }

  .final-modal .final-sopo {
    height: 100%;
    min-height: 180px;
    grid-column: 1;
    grid-row: 1 / -1;
    margin: 0;
  }

  .final-modal .final-card h2 {
    grid-column: 2;
    grid-row: 1;
    margin: 0;
    font-size: clamp(23px, 3.6vw, 32px);
  }

  .final-modal .final-card p {
    grid-column: 2;
    grid-row: 2;
    margin: 0;
    font-size: 13px;
    line-height: 1.15;
  }

  .final-modal .final-tokens {
    grid-column: 2;
    grid-row: 3;
    margin: 2px 0;
  }

  .final-modal .song-btn {
    grid-column: 2;
    grid-row: 4;
  }

  .final-modal .primary-btn {
    grid-column: 2;
    grid-row: 5;
  }

  .final-modal .song-btn,
  .final-modal .primary-btn {
    width: 100%;
    min-width: 0;
    min-height: 48px;
    margin: 0;
    padding: 4px 10px;
    font-size: 15px;
  }
}

@media (max-width: 480px) and (max-height: 700px) {
  .help-modal {
    width: calc(100vw - 12px);
    max-height: calc(100dvh - 12px);
  }

  .help-modal .help-card {
    max-height: calc(100dvh - 12px);
    overflow: hidden;
    padding: 10px 12px;
  }

  .help-card .modal-sopo {
    width: 64px;
    height: 46px;
  }

  .help-card h2 {
    margin: 0 0 6px;
    font-size: 27px;
  }

  .help-steps {
    gap: 5px;
    margin: 6px 0 8px;
  }

  .help-steps li {
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 7px;
    padding: 3px 6px;
  }

  .help-picture {
    width: 48px;
    height: 48px;
  }

  .help-picture img,
  .hand-picture img,
  .ok-picture img {
    width: 44px;
    height: 44px;
  }

  .help-steps p {
    font-size: 12px;
    line-height: 1.15;
  }

  .narrator-controls {
    flex-wrap: nowrap;
    gap: 5px;
  }

  .narrator-controls button {
    min-height: 48px;
    padding: 4px 7px;
    font-size: 12px;
    white-space: nowrap;
  }

  .narration-status {
    min-height: 14px;
    margin: 2px 0 4px;
    font-size: 11px;
    line-height: 1.1;
  }

  .help-card .primary-btn {
    min-height: 48px;
    padding: 6px 18px;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  .help-modal {
    width: min(calc(100vw - 16px), 760px);
    max-height: calc(100dvh - 8px);
    overflow: hidden;
  }

  .help-modal .help-card {
    max-height: calc(100dvh - 8px);
    overflow: hidden;
    padding: 8px 16px;
  }

  .help-card .dialog-close {
    top: 8px;
    right: 8px;
  }

  .help-card .modal-sopo {
    display: inline-block;
    width: 54px;
    height: 40px;
    margin: 0 8px 0 0;
    vertical-align: middle;
  }

  .help-card h2 {
    display: inline-block;
    margin: 0 0 4px;
    font-size: 26px;
    line-height: 1;
    vertical-align: middle;
  }

  .help-card .help-steps {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin: 4px 0 6px;
  }

  .help-card .help-steps li {
    display: grid;
    min-width: 0;
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
    padding: 4px 6px;
    border-radius: 10px;
  }

  .help-card .help-picture {
    width: 100%;
    height: 40px;
    border-radius: 8px;
  }

  .help-card .help-picture img,
  .help-card .hand-picture img,
  .help-card .ok-picture img {
    width: 40px;
    height: 40px;
  }

  .help-card .help-steps p {
    margin: 2px 0 0;
    font-size: 12px;
    line-height: 1.1;
    text-align: center;
  }

  .help-card .narrator-controls {
    flex-wrap: nowrap;
    gap: 6px;
    margin: 0 0 2px;
  }

  .help-card .narrator-controls button {
    min-width: 48px;
    min-height: 48px;
    padding: 4px 8px;
    font-size: 12px;
    line-height: 1;
  }

  .help-card .narration-status {
    min-height: 14px;
    margin: 0 0 3px;
    font-size: 11px;
    line-height: 1.1;
  }

  .help-card .primary-btn {
    min-width: 180px;
    min-height: 48px;
    margin: 0;
    padding: 4px 16px;
    font-size: 16px;
    line-height: 1;
  }
}

@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;
  }

  .water-glints {
    display: none;
  }
}

@media (orientation: portrait) {
  #pause-dialog {
    width: min(calc(100vw - 20px), 620px);
    max-height: calc(100dvh - 20px);
  }

  #pause-dialog .pause-card {
    min-height: 0;
    max-height: calc(100dvh - 20px);
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: clamp(150px, 29dvh, 250px) auto;
    border-radius: 38px 24px 34px 27px;
  }

  #pause-dialog .pause-sopo-stage {
    min-height: 0;
    padding: 10px 16px 20px;
    border-radius: 36px 22px 0 0;
  }

  #pause-dialog .pause-sopo-stage::before {
    top: -34%;
    right: 9%;
    width: 58%;
  }

  #pause-dialog .pause-sopo-stage::after {
    right: -8%;
    bottom: -5%;
    left: -8%;
    height: 31%;
  }

  #pause-dialog .pause-sopo {
    width: min(78%, 300px);
    max-height: 100%;
  }

  #pause-dialog .pause-panel {
    align-content: center;
    gap: clamp(9px, 1.8vh, 18px);
    padding: clamp(14px, 3.6vw, 28px) clamp(12px, 4vw, 28px) clamp(16px, 4vw, 30px);
    border-radius: 0 0 32px 25px;
    box-shadow: inset 0 1px 0 rgb(255 255 255 / 88%);
  }

  #pause-dialog .pause-heading h2 {
    font-size: clamp(38px, 9vw, 50px);
  }

  #pause-dialog .pause-note {
    max-width: 32ch;
  }

  #pause-dialog .level-menu {
    gap: 7px;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  #pause-dialog {
    width: min(calc(100vw - 16px), 820px);
    max-height: calc(100dvh - 8px);
  }

  #pause-dialog .pause-card {
    height: min(356px, calc(100dvh - 12px));
    min-height: 0;
    max-height: calc(100dvh - 12px);
    grid-template-columns: minmax(180px, 0.72fr) minmax(0, 1.28fr);
    border-radius: 30px 20px 28px 22px;
  }

  #pause-dialog .pause-sopo-stage {
    min-height: 0;
    padding: 6px 12px 18px 4px;
    border-radius: 28px 0 0 20px;
  }

  #pause-dialog .pause-sopo-stage::after {
    right: -12%;
    left: -12%;
    height: 25%;
  }

  #pause-dialog .pause-sopo {
    width: min(100%, 238px);
    max-height: 228px;
  }

  #pause-dialog .pause-panel {
    align-content: center;
    gap: 7px;
    padding: 10px clamp(14px, 2.6vw, 24px);
    border-radius: 0 18px 26px 0;
  }

  #pause-dialog .pause-heading {
    gap: 2px;
  }

  #pause-dialog .pause-heading h2 {
    font-size: clamp(30px, 4.4vw, 38px);
    line-height: 0.9;
  }

  #pause-dialog .pause-note {
    font-size: 12px;
    line-height: 1.1;
  }

  #pause-dialog .level-menu {
    gap: 4px;
  }

  #pause-dialog .level-menu p {
    font-size: 12px;
  }

  #pause-dialog .level-menu-buttons {
    gap: 6px;
  }

  #pause-dialog .level-choice {
    flex-basis: 48px;
    width: 48px;
    height: 48px;
    font-size: 20px;
  }

  #pause-dialog #resume-btn {
    min-height: 48px;
    padding: 7px 24px;
    font-size: 16px;
    line-height: 1;
  }
}
