@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 {
  --ink: #3b2a22;
  --ink-soft: #71594a;
  --cream: #fff4d7;
  --cream-deep: #efdcb8;
  --wood: #a76736;
  --wood-dark: #6f4027;
  --wood-light: #d59b5e;
  --gold: #f4ba3d;
  --gold-light: #ffe6a2;
  --sage: #6f927e;
  --green: #4fa928;
  --green-dark: #237c21;
  --ice: #dff3f7;
  --muted-yellow: #f4d476;
  --shadow: 0 18px 44px rgb(39 47 54 / 28%);
  --button-size: clamp(56px, 6.4vh, 64px);
  --shell-size: 56px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

html {
  overflow: hidden;
  background: #bce7ee;
}

body {
  min-height: 100dvh;
  overflow: hidden;
  color: var(--ink);
  font-family: "Fredoka", "Trebuchet MS", sans-serif;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  user-select: none;
}

button {
  font: inherit;
}

button:focus-visible {
  outline: 4px solid #2d6170;
  outline-offset: 4px;
}

[hidden] {
  display: none !important;
}

.world-background,
.world-background img {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

.world-background img {
  object-fit: cover;
}

.world-background::after {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(180deg, rgb(20 82 108 / 20%), transparent 24%),
    radial-gradient(circle at 50% 70%, transparent 35%, rgb(17 71 87 / 13%));
  pointer-events: none;
}

.ambient-glints {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.ambient-glints i {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgb(255 246 201 / 75%);
  box-shadow: 0 0 16px 5px rgb(255 248 214 / 35%);
  animation: drift 8s ease-in-out infinite alternate;
}

.ambient-glints i:nth-child(1) { left: 12%; top: 32%; animation-delay: -2s; }
.ambient-glints i:nth-child(2) { left: 25%; top: 78%; animation-delay: -5s; }
.ambient-glints i:nth-child(3) { left: 70%; top: 26%; animation-delay: -1s; }
.ambient-glints i:nth-child(4) { left: 83%; top: 64%; animation-delay: -6s; }
.ambient-glints i:nth-child(5) { left: 55%; top: 86%; animation-delay: -3s; }

@keyframes drift {
  from { transform: translate3d(-8px, 6px, 0) scale(.7); opacity: .35; }
  to { transform: translate3d(14px, -20px, 0) scale(1.15); opacity: .9; }
}

.app-shell {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: 100%;
  height: 100dvh;
  min-height: 0;
  padding:
    max(10px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right))
    max(10px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
}

.topbar {
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(190px, 1fr) auto auto;
  align-items: center;
  gap: 18px;
  min-width: 0;
  padding: 4px 8px 8px;
  color: #fffdf3;
  text-shadow: 0 2px 8px rgb(25 66 80 / 55%);
}

.brand-block {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  width: fit-content;
  padding: 5px 10px;
  border-radius: 12px;
  background: #fff4d7;
  color: #174a7e;
  text-shadow: none;
}

.eyebrow {
  margin: 0 0 2px;
  font-size: clamp(.72rem, 1.25vw, .9rem);
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.brand-block h1 {
  display: block;
  overflow: hidden;
  min-width: 0;
  max-width: 100%;
  margin: 0;
  font-size: clamp(1.05rem, 2.05vw, 1.75rem);
  line-height: 1.02;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-hud {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 12px;
  min-width: 0;
  max-width: 100%;
  padding: 5px 10px;
  border: 1px solid rgb(255 255 255 / 35%);
  border-radius: 999px;
  background: rgb(35 93 108 / 35%);
  box-shadow: inset 0 1px rgb(255 255 255 / 28%);
  backdrop-filter: blur(8px);
}

.level-shells,
.task-stars,
.reward-stars {
  display: flex;
  align-items: center;
}

.level-shells,
.task-stars {
  gap: 4px;
}

.level-shell,
.task-star {
  display: block;
  width: clamp(19px, 2.2vw, 30px);
  height: clamp(19px, 2.2vw, 30px);
  object-fit: contain;
}

.level-shell {
  opacity: .35;
  filter: grayscale(.8);
}

.level-shell.earned {
  opacity: 1;
  filter: drop-shadow(0 0 5px rgb(255 215 98 / 80%));
}

.task-star {
  width: clamp(21px, 2.6vw, 34px);
  height: clamp(21px, 2.6vw, 34px);
}

.control-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.control {
  position: relative;
  flex: 0 0 var(--button-size);
  width: var(--button-size);
  height: var(--button-size);
  min-width: 56px;
  min-height: 56px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  filter: drop-shadow(0 5px 5px rgb(42 51 47 / 26%));
  cursor: pointer;
  transition: transform .13s ease, filter .13s ease;
}

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

.control:hover {
  transform: translateY(-2px);
}

.control:active {
  transform: translateY(2px) scale(.96);
  filter: brightness(.92) drop-shadow(0 2px 3px rgb(42 51 47 / 22%));
}

.control[aria-pressed="false"] .mute-slash {
  position: absolute;
  left: 14%;
  top: 47%;
  width: 72%;
  height: 5px;
  border-radius: 9px;
  background: #733d27;
  box-shadow: 0 1px #ffd895;
  transform: rotate(-43deg);
}

.playfield {
  display: grid;
  grid-template-columns: minmax(110px, .35fr) minmax(440px, 2.1fr) minmax(110px, .35fr);
  align-items: stretch;
  gap: clamp(8px, 1.5vw, 22px);
  min-height: 0;
  padding: 0 clamp(4px, 2vw, 34px) 8px;
}

.guide-column,
.hero-column {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
  overflow: visible;
}

.guide-column {
  align-self: end;
}

.hero-column {
  align-self: end;
  justify-self: end;
}

.character-art {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  object-position: center bottom;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  filter: drop-shadow(0 5px 4px rgb(24 67 78 / 20%));
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: 100% 100%;
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: 100% 100%;
}

.fiko {
  width: min(100%, 180px);
  aspect-ratio: 1;
  -webkit-mask-image: url("assets/fiko-cutout.webp");
  mask-image: url("assets/fiko-cutout.webp");
}

.sopo {
  width: min(100%, 205px);
  aspect-ratio: 5 / 4;
  -webkit-mask-image: url("assets/sopo-cutout.webp");
  mask-image: url("assets/sopo-cutout.webp");
}

.speech-card {
  position: relative;
  z-index: 2;
  width: min(100%, 205px);
  margin: 0 0 2px;
  padding: 13px 14px 14px;
  border: 2px solid #8d5a38;
  border-radius: 24px 24px 24px 7px;
  background: #fff4d9;
  box-shadow: var(--shadow);
}

.speech-card::after {
  content: "";
  position: absolute;
  left: 12px;
  bottom: -14px;
  width: 26px;
  height: 24px;
  background: #fff4d9;
  clip-path: polygon(0 0, 100% 0, 22% 100%);
}

.speech-label,
.hero-name {
  margin: 0 0 2px;
  color: #8d5a38;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.speech-card p:last-child {
  margin: 0;
  font-size: clamp(.86rem, 1.2vw, 1rem);
  line-height: 1.15;
}

.hero-name {
  margin-top: 8px;
  color: #fffdf4;
  text-shadow: 0 2px 8px rgb(25 66 80 / 60%);
}

.game-center {
  position: relative;
  display: flex;
  flex-direction: column;
  align-self: stretch;
  width: 100%;
  min-width: 0;
  min-height: 0;
  max-width: 860px;
  justify-self: center;
}

.task-ribbon {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: max-content;
  max-width: 100%;
  margin: 0 auto 5px;
  padding: 5px 14px;
  border: 1px solid rgb(255 255 255 / 52%);
  border-radius: 999px;
  background: rgb(54 105 112 / 50%);
  color: #fffdf3;
  font-size: clamp(.72rem, 1.15vw, .88rem);
  font-weight: 600;
  letter-spacing: .04em;
  text-shadow: 0 1px 5px rgb(26 63 74 / 55%);
  backdrop-filter: blur(7px);
}

.task-ribbon span + span::before {
  content: "•";
  margin-right: 8px;
  opacity: .6;
}

.board {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  width: 100%;
  min-height: 0;
  padding: clamp(9px, 1.6vh, 16px) clamp(12px, 2vw, 24px) clamp(10px, 1.8vh, 17px);
  border: 3px solid #d5bea0;
  border-radius: clamp(20px, 2.5vw, 30px);
  background: #fff9ed;
  box-shadow: 0 12px 28px rgb(34 82 93 / 24%);
  transition: box-shadow .25s ease, background-color .25s ease;
}

.board::before {
  content: "";
  position: absolute;
  inset: 6px;
  pointer-events: none;
  border: 1px solid rgb(157 126 83 / 16%);
  border-radius: calc(clamp(20px, 2.5vw, 30px) - 5px);
}

.board.success {
  box-shadow: 0 0 0 6px rgb(255 217 94 / 42%), 0 22px 50px rgb(83 63 31 / 30%), inset 0 0 34px rgb(255 211 88 / 30%);
}

.board.mistake {
  box-shadow: 0 0 0 6px rgb(244 212 118 / 36%), 0 22px 50px rgb(83 63 31 / 28%);
}

.board.paused {
  filter: saturate(.8);
}

.board-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: clamp(7px, 1.2vh, 12px);
}

.instruction {
  margin: 0;
  font-size: clamp(1rem, 1.55vw, 1.26rem);
  font-weight: 600;
  line-height: 1.15;
}

.quantity-note {
  flex: 0 0 auto;
  margin: 0;
  padding: 4px 10px;
  border-radius: 999px;
  background: #e7c994;
  color: #644329;
  font-size: clamp(.72rem, 1vw, .86rem);
  font-weight: 600;
}

.board-work {
  display: grid;
  flex: 1 1 auto;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, .75fr);
  grid-template-areas:
    "ten ones"
    "number number";
  grid-template-rows: auto auto;
  align-content: space-evenly;
  align-items: stretch;
  gap: clamp(6px, .8vw, 10px) clamp(7px, 1vw, 12px);
  min-width: 0;
}

.ten-zone,
.ones-zone {
  align-self: stretch;
  min-width: 0;
  padding: clamp(5px, .8vw, 9px);
  border: 1px solid #b8d4da;
  border-radius: 16px;
  background: #e5f2f4;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 55%);
}

.ten-zone {
  grid-area: ten;
}

.ones-zone {
  grid-area: ones;
}

.card-heading,
.loose-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 23px;
  margin-bottom: 6px;
  color: #654a39;
  font-size: clamp(.68rem, .9vw, .8rem);
  font-weight: 600;
  letter-spacing: .045em;
  text-transform: uppercase;
}

.card-heading strong,
.loose-heading strong {
  color: #3b2a22;
  font-size: clamp(1.25rem, 2vw, 1.7rem);
  font-family: "Trebuchet MS", Arial, sans-serif;
  font-variant-numeric: lining-nums tabular-nums;
  font-weight: 700;
  line-height: 1;
}

.ten-frame {
  display: grid;
  grid-template-columns: repeat(5, minmax(24px, 1fr));
  grid-template-rows: repeat(2, minmax(var(--shell-size), 1fr));
  align-content: center;
  gap: clamp(2px, .4vw, 5px);
  min-height: calc(var(--shell-size) * 2 + 6px);
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.frame-cell {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.shell {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 2px 1px rgb(77 40 27 / 25%));
  pointer-events: none;
}

.frame-cell .shell {
  width: min(100%, var(--shell-size));
  height: min(100%, var(--shell-size));
}

.join-mark,
.equals-mark {
  display: none;
}

.ones-zone {
  display: flex;
  flex-direction: column;
}

.loose-shelf {
  position: relative;
  display: grid;
  place-items: center;
  flex: 1;
  min-height: calc(var(--shell-size) * 3 + 4px + 20px);
  padding: 10px;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.loose-shelf[data-layout="grid"] {
  grid-template-columns: repeat(3, minmax(28px, 1fr));
  grid-template-rows: repeat(3, minmax(var(--shell-size), 1fr));
  align-content: center;
  gap: 2px;
}

.loose-shelf[data-layout="rows"] {
  grid-template-columns: repeat(5, minmax(22px, 1fr));
  grid-auto-rows: minmax(var(--shell-size), 1fr);
  align-content: center;
  gap: 1px;
}

.loose-shelf[data-layout="arc"] {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-auto-rows: minmax(var(--shell-size), 1fr);
  align-items: center;
  justify-content: center;
  align-content: center;
  gap: 1px;
}

.loose-shelf[data-layout="arc"] .loose-shell:nth-child(odd) {
  transform: translateY(-7px) rotate(-5deg);
}

.loose-shelf[data-layout="arc"] .loose-shell:nth-child(even) {
  transform: translateY(5px) rotate(4deg);
}

.loose-shelf[data-layout="cluster"] {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(var(--shell-size), 1fr));
  align-content: center;
  gap: 2px;
}

.loose-shelf[data-layout="cluster"] .loose-shell {
  position: static;
  width: min(100%, var(--shell-size));
  height: min(100%, var(--shell-size));
  max-width: var(--shell-size);
  max-height: var(--shell-size);
  transform: rotate(var(--r));
}

.loose-shell {
  display: block;
  width: min(100%, var(--shell-size));
  height: min(100%, var(--shell-size));
  max-width: var(--shell-size);
  max-height: var(--shell-size);
  object-fit: contain;
  filter: drop-shadow(0 3px 2px rgb(78 37 24 / 26%));
}

.number-build {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  grid-area: number;
  justify-self: center;
  gap: 0;
  width: clamp(220px, 30vw, 280px);
  min-width: 220px;
  min-height: clamp(80px, 13vh, 118px);
  padding: 5px 12px;
  overflow: visible;
  border: 3px solid #98613a;
  border-radius: 14px;
  background: #e6b574;
  box-shadow: 0 4px 0 #8c5b38, 0 8px 12px rgb(67 41 25 / 17%);
}

.zero-slot {
  position: relative;
  z-index: 1;
  flex: 1 1 0;
  min-width: 56px;
  min-height: 56px;
  overflow: visible;
}

.digit-tile {
  position: relative;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: max(.65em, 56px);
  height: 100%;
  min-width: 56px;
  min-height: 56px;
  padding: 0;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #4a2e20;
  font-family: "Trebuchet MS", Arial, sans-serif;
  font-size: clamp(90px, 10vh, 112px);
  font-variant-numeric: lining-nums tabular-nums;
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 1px #f7d29d;
  box-shadow: none;
}

.tens-digit {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.zero-slot {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
}

.under-zero {
  color: #4a2e20;
  opacity: 1;
  line-height: 1;
  text-shadow: 0 1px #f7d29d;
}

.placed-digit {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 3px;
  background: #e6b574;
  color: #4a2e20;
  font: inherit;
  font-variant-numeric: lining-nums tabular-nums;
  line-height: 1;
  text-shadow: 0 1px #f7d29d;
  box-shadow: inset 0 0 0 1px rgb(152 97 58 / 18%);
  animation: tile-place .22s ease-out;
}

@keyframes tile-place {
  from { transform: scale(1.16) rotate(-4deg); }
  to { transform: scale(1) rotate(0); }
}

.answer-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 1.7vw, 18px);
  margin-top: clamp(8px, 1.3vh, 13px);
}

.choice-area {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  margin: 0;
  padding: 0;
}

.choice-label {
  margin: 0;
  color: #795336;
  font-size: clamp(.7rem, .9vw, .82rem);
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.choices {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 1.3vw, 15px);
  min-height: 62px;
}

.choice {
  position: relative;
  display: grid;
  place-items: center;
  width: clamp(58px, 6.2vw, 72px);
  height: clamp(58px, 6.2vw, 72px);
  min-width: 58px;
  min-height: 58px;
  padding: 0;
  border: 2px solid #96603a;
  border-radius: 14px;
  background: #e6b574;
  color: #492a1d;
  font-family: "Trebuchet MS", Arial, sans-serif;
  font-size: clamp(2.2rem, 4vw, 3rem);
  font-variant-numeric: lining-nums tabular-nums;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 4px 0 #8c5b38, 0 6px 10px rgb(72 45 27 / 16%);
  cursor: grab;
  touch-action: none;
  transition: transform .14s ease, filter .14s ease, box-shadow .14s ease;
}

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

.choice:active {
  cursor: grabbing;
  transform: translateY(3px);
  box-shadow: 0 2px 0 #6e4025, 0 4px 8px rgb(72 45 27 / 20%);
}

.choice.selected {
  border-color: #5e8a9e;
  box-shadow: 0 0 0 4px #d9eef2, 0 4px 0 #6f827e, 0 7px 11px rgb(72 45 27 / 20%);
  transform: translateY(-3px);
}

.choice.dragging {
  opacity: .35;
}

.drag-ghost {
  position: fixed;
  z-index: 160;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border: 2px solid #96603a;
  border-radius: 14px;
  background: #e6b574;
  color: #492a1d;
  font-family: "Trebuchet MS", Arial, sans-serif;
  font-size: 2.4rem;
  font-variant-numeric: lining-nums tabular-nums;
  font-weight: 700;
  pointer-events: none;
  transform: translate(-50%, -50%) rotate(3deg);
  box-shadow: 0 12px 24px rgb(38 48 53 / 28%);
}

.ok-button {
  position: static;
  flex: 0 0 auto;
  width: clamp(66px, 7vw, 82px);
  height: clamp(66px, 7vw, 82px);
  min-width: 64px;
  min-height: 64px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  filter: drop-shadow(0 7px 6px rgb(49 73 35 / 26%));
  cursor: pointer;
  touch-action: manipulation;
  transform: none;
  transition: transform .14s ease, filter .14s ease;
}

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

.ok-button:hover:not(:disabled) {
  transform: scale(1.04);
}

.ok-button:active:not(:disabled) {
  transform: scale(.96);
}

.ok-button:disabled {
  cursor: default;
  filter: grayscale(1) brightness(1.08) opacity(.4) drop-shadow(0 4px 4px rgb(49 73 35 / 15%));
}

.hint {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 14px;
  margin: 10px auto 0;
  padding: 8px 12px;
  border: 2px solid #c69a42;
  border-radius: 16px;
  background: #ffefad;
  box-shadow: 0 6px 14px rgb(87 60 26 / 13%);
}

.hint[hidden] {
  display: none !important;
}

.hint-picture {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: "Trebuchet MS", Arial, sans-serif;
  font-size: clamp(1.3rem, 2.2vw, 2rem);
  font-variant-numeric: lining-nums tabular-nums;
  font-weight: 700;
}

.mini-ten,
.mini-ones,
.mini-total {
  display: grid;
  place-items: center;
  min-width: 42px;
  min-height: 38px;
  border-radius: 9px;
  background: #e1b16b;
  color: #4e301e;
  box-shadow: inset 0 0 0 2px #ad7138;
}

.mini-total {
  background: #f8d77d;
}

.hint p {
  margin: 0;
  font-size: clamp(.77rem, 1vw, .92rem);
  line-height: 1.17;
}

.demo-layer {
  position: absolute;
  z-index: 35;
  inset: 0;
  pointer-events: none;
}

.demo-hand {
  position: absolute;
  left: 0;
  top: 0;
  width: clamp(56px, 7vw, 84px);
  height: clamp(56px, 7vw, 84px);
  filter: drop-shadow(0 5px 5px rgb(45 62 62 / 30%));
  transform: translate(-50%, -90%);
  transition: left .65s cubic-bezier(.22, .74, .24, 1), top .65s cubic-bezier(.22, .74, .24, 1), opacity .2s ease;
}

.demo-note {
  width: max-content;
  max-width: 100%;
  margin: 5px auto 0;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgb(255 246 217 / 90%);
  color: #62452f;
  font-size: clamp(.74rem, 1vw, .88rem);
  font-weight: 600;
  box-shadow: 0 4px 10px rgb(48 57 52 / 14%);
}

.text-button {
  border: 0;
  background: transparent;
  color: #fffbea;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-shadow: 0 2px 5px rgb(32 58 66 / 60%);
  cursor: pointer;
}

.demo-skip {
  display: block;
  min-height: 56px;
  margin: 2px auto 0;
  padding: 5px 10px;
}

.overlay {
  position: fixed;
  z-index: 80;
  inset: 0;
  display: grid;
  place-items: center;
  padding:
    max(12px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
  background: rgb(18 52 64 / 38%);
  backdrop-filter: blur(5px);
}

.intro-overlay {
  z-index: 75;
  display: block;
  background:
    linear-gradient(180deg, #68caf0 0 62%, #f2fbff 62% 100%);
}

.intro-story,
.intro-story img {
  position: absolute;
  z-index: -1;
  inset: 0;
  width: 100%;
  height: 100%;
}

.intro-story img {
  object-fit: cover;
}

.intro-overlay::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgb(13 56 74 / 12%) 0 22%,
    transparent 30% 72%,
    rgb(13 56 74 / 18%) 100%
  );
  pointer-events: none;
}

.intro-title-card {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  width: min(620px, calc(100% - 24px));
  padding: 8px 20px;
  border: 2px solid rgb(255 242 203 / 60%);
  border-radius: 22px 34px 22px 34px;
  background: rgb(255 246 216 / 94%);
  box-shadow: 0 12px 34px rgb(19 52 63 / 26%);
  color: var(--ink);
  text-align: center;
  transform: translateX(-50%);
}

.intro-title-card h2 {
  margin: 0;
  font-size: clamp(1.15rem, 3.2vw, 2.2rem);
  line-height: 1;
  letter-spacing: -.02em;
}

.intro-actions {
  position: absolute;
  bottom: max(12px, env(safe-area-inset-bottom));
  left: 50%;
  display: grid;
  justify-items: center;
  gap: 8px;
  width: min(520px, calc(100% - 24px));
  transform: translateX(-50%);
}

.play-button {
  display: inline-flex;
  align-items: center;
  gap: 15px;
  min-width: 196px;
  min-height: 80px;
  padding: 8px 26px 8px 9px;
  border: 0;
  border-radius: 999px;
  background: #c96632;
  color: #fffdf5;
  font-size: clamp(1.35rem, 2.3vw, 2rem);
  font-weight: 600;
  box-shadow: 0 8px 0 #873b22, 0 16px 28px rgb(45 38 28 / 28%);
  cursor: pointer;
  transition: transform .14s ease, box-shadow .14s ease;
}

.play-button img {
  width: 64px;
  height: 64px;
  object-fit: contain;
}

.play-button:hover {
  transform: translateY(-2px);
}

.play-button:active {
  transform: translateY(4px);
  box-shadow: 0 4px 0 #873b22, 0 9px 16px rgb(45 38 28 / 22%);
}

.intro-caption {
  width: max-content;
  max-width: 100%;
  margin: 0;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgb(23 66 79 / 72%);
  color: #fffdf3;
  font-size: .9rem;
  line-height: 1.2;
  text-align: center;
}

.panel-overlay {
  z-index: 90;
  overflow-y: auto;
}

.panel {
  position: relative;
  width: min(760px, 95vw);
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  padding: clamp(18px, 3vw, 34px);
  border: 4px solid #b77940;
  border-radius: 28px;
  background:
    radial-gradient(circle at 8% 12%, rgb(255 255 255 / 84%) 0 2px, transparent 3px),
    linear-gradient(145deg, #fffaf0, #f5dcb2);
  background-size: 30px 30px, auto;
  color: var(--ink);
  box-shadow: 0 28px 74px rgb(26 55 65 / 42%), inset 0 0 0 4px #f2cf8e;
}

.panel h2 {
  margin: 2px 0 8px;
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 1;
}

.panel p {
  line-height: 1.3;
}

.panel .eyebrow {
  color: #8e5b36;
}

.panel-close {
  position: absolute;
  z-index: 2;
  right: 12px;
  top: 12px;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 2px solid #8d5834;
  border-radius: 50%;
  background: #f1c67e;
  color: #5c3724;
  font-size: 2rem;
  line-height: 1;
  box-shadow: 0 4px 0 #8d5834;
  cursor: pointer;
}

.primary-button,
.secondary-button {
  min-height: 56px;
  border: 0;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
}

.primary-button {
  margin: 8px 0 12px;
  padding: 11px 24px;
  background: #b85a30;
  color: #fffdf5;
  font-size: 1.14rem;
  box-shadow: 0 6px 0 #7d351d;
}

.secondary-button {
  padding: 8px 16px;
  border: 2px solid #9a6440;
  background: #fff2cf;
  color: #5b3d2d;
}

.primary-button:active,
.secondary-button:active {
  transform: translateY(3px);
}

.section-label {
  margin-top: 17px !important;
  color: #825437;
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.level-menu {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.level-button {
  display: grid;
  justify-items: center;
  gap: 2px;
  min-width: 56px;
  min-height: 80px;
  padding: 8px 5px;
  border: 2px solid #a56b40;
  border-radius: 15px;
  background: #fff0ca;
  color: #523829;
  font-weight: 600;
  cursor: pointer;
}

.level-button img {
  width: 38px;
  height: 38px;
  object-fit: contain;
}

.level-button:disabled {
  cursor: not-allowed;
  opacity: .38;
  filter: grayscale(.8);
}

.parent-copy {
  max-width: 62ch;
}

.help-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 15px 0;
}

.help-step {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 7px;
  min-width: 0;
  padding: 24px 10px 10px;
  border: 2px solid #b47b48;
  border-radius: 17px;
  background: #ffeac0;
  text-align: center;
}

.help-step p {
  margin: 0;
  font-size: clamp(.82rem, 1.2vw, 1rem);
  font-weight: 600;
  line-height: 1.12;
}

.step-number {
  position: absolute;
  left: 7px;
  top: 7px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #6c927e;
  color: white;
  font-size: .75rem;
  font-weight: 600;
}

.step-picture {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
  min-height: 70px;
}

.step-picture .mini-number {
  display: grid;
  place-items: center;
  width: 42px;
  height: 46px;
  border: 2px solid #8a552f;
  border-radius: 10px;
  background: linear-gradient(145deg, #f4c98c, #cf8c4f);
  color: #492b1e;
  font-size: 1.8rem;
  font-weight: 600;
}

.step-picture img {
  width: 46px;
  height: 46px;
  object-fit: contain;
  filter: drop-shadow(0 3px 2px rgb(62 49 37 / 30%));
}

.place-picture .mini-zero {
  position: relative;
  display: grid;
  place-items: center;
  width: 53px;
  height: 63px;
  border: 2px solid #8a552f;
  border-radius: 10px;
  background: #8c5a36;
  color: #efd5a7;
  font-size: 2rem;
  font-weight: 600;
}

.mini-zero small {
  position: absolute;
  inset: 4px;
  display: grid;
  place-items: center;
  border: 2px solid #80502e;
  border-radius: 7px;
  background: #efbe78;
  color: #4a2c1e;
  font-size: 2rem;
}

.place-picture img {
  position: absolute;
  right: 7px;
  bottom: -9px;
}

.ok-picture > img:first-child {
  width: 66px;
  height: 66px;
}

.ok-picture .small-hand {
  position: absolute;
  right: 36px;
  bottom: -2px;
}

.narration-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.audio-note {
  margin-bottom: 0;
  color: #735846;
  font-size: .8rem;
}

.reward-panel,
.complete-panel {
  width: min(640px, 94vw);
  text-align: center;
}

.reward-stars {
  justify-content: center;
  gap: 6px;
  margin: 8px 0;
}

.finale-controls {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 14px;
}

.reward-stars img {
  width: 60px;
  height: 60px;
}

.high-five {
  display: grid;
  place-items: center;
  min-height: 150px;
  margin: 5px 0 8px;
}

.high-five img {
  display: block;
  width: min(100%, 470px);
  max-height: 190px;
  object-fit: contain;
  filter: drop-shadow(0 8px 12px rgb(67 57 42 / 16%));
}

.final-medal {
  display: grid;
  place-items: center;
  width: 150px;
  height: 150px;
  margin: 15px auto;
  border-radius: 50%;
  background: radial-gradient(circle, #fff6b8, #e8b13e 62%, #b77925);
  box-shadow: 0 0 0 10px rgb(255 233 137 / 42%), 0 0 55px 25px rgb(255 221 98 / 38%);
}

.final-medal img {
  width: 100px;
  height: 100px;
  object-fit: contain;
}

.corner-rune {
  position: fixed;
  z-index: 130;
  left: max(7px, env(safe-area-inset-left));
  bottom: max(7px, env(safe-area-inset-bottom));
  width: clamp(30px, 3vw, 44px);
  height: auto;
  opacity: .92;
  filter: drop-shadow(0 5px 6px rgb(31 58 66 / 25%));
  pointer-events: none;
}

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

body[data-state="demo"] .control[data-action="restart"],
body[data-state="intro"] .control[data-action="pause"] {
  filter: grayscale(.55) opacity(.68);
}

body[data-state="paused"] .ambient-glints,
body[data-state="help"] .ambient-glints {
  animation-play-state: paused;
}

@media (max-height: 650px) and (orientation: landscape) {
  :root {
    --shell-size: clamp(38px, 4.1vw, 48px);
  }

  .app-shell {
    padding-top: 6px;
    padding-bottom: 6px;
  }

  .topbar {
    gap: 8px;
    padding: 0 4px 4px;
  }

  .progress-hud {
    padding: 3px 8px;
  }

  .playfield {
    padding-bottom: 2px;
  }

  .speech-card {
    padding: 8px 10px;
  }

  .speech-card p:last-child {
    font-size: .78rem;
  }

  .sopo {
    width: min(100%, 135px);
  }

  .fiko {
    width: min(100%, 120px);
  }

  .board {
    padding: 6px 12px 7px;
  }

  .board-heading {
    margin-bottom: 3px;
  }

  .instruction {
    font-size: .82rem;
  }

  .quantity-note {
    padding: 2px 8px;
    font-size: .68rem;
  }

  .ten-frame,
  .loose-shelf {
    min-height: var(--shell-size);
  }

  .ten-frame {
    grid-template-rows: repeat(2, minmax(var(--shell-size), 1fr));
  }

  .card-heading,
  .loose-heading {
    min-height: 18px;
    margin-bottom: 3px;
  }

  .board-work {
    row-gap: 4px;
  }

  .number-build {
    width: min(46vw, 220px);
    min-width: 220px;
    min-height: 76px;
    padding: 0 8px;
  }

  .digit-tile {
    width: max(.65em, 56px);
    min-height: 56px;
    font-size: clamp(72px, 11vh, 82px);
  }

  .answer-controls {
    margin-top: 4px;
  }

  .choices {
    min-height: 56px;
  }

  .choice-label {
    display: none;
  }

  .ok-button {
    width: 62px;
    height: 62px;
  }

  .hint {
    margin-top: 4px;
    padding: 4px 8px;
  }

  .hint-picture {
    font-size: .95rem;
  }

  .hint p {
    font-size: .72rem;
  }
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: minmax(130px, 1fr) auto;
    gap: 8px;
  }

  .progress-hud {
    justify-self: end;
  }

  .control-row {
    grid-column: 1 / -1;
    justify-self: center;
  }

  :root {
    --button-size: 56px;
  }

  .playfield {
    grid-template-columns: minmax(72px, .26fr) minmax(360px, 2fr) minmax(72px, .26fr);
  }

  .speech-card {
    font-size: .9rem;
  }
}

@media (max-width: 900px) and (max-height: 650px) and (orientation: landscape) {
  .topbar {
    grid-template-columns: minmax(150px, 1fr) auto auto;
  }

  .control-row {
    grid-column: auto;
    justify-self: end;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  :root {
    --shell-size: clamp(28px, 3.8vw, 32px);
  }

  .app-shell {
    padding: 4px 8px;
  }

  .topbar {
    gap: 6px;
    padding: 0 2px 2px;
  }

  .brand-block {
    padding: 2px 8px;
  }

  .brand-block h1 {
    font-size: 1rem;
  }

  .brand-block .eyebrow {
    display: none;
  }

  .progress-hud {
    gap: 5px;
    padding: 2px 6px;
  }

  .playfield {
    gap: 6px;
    padding: 0 4px 2px;
  }

  .speech-card {
    padding: 5px 7px;
  }

  .speech-label,
  .hero-name {
    margin-bottom: 0;
    font-size: .62rem;
  }

  .speech-card p:last-child {
    font-size: .67rem;
  }

  .task-ribbon {
    margin-bottom: 2px;
    padding: 2px 8px;
    font-size: .62rem;
  }

  .board {
    padding: 4px 7px;
  }

  .board-heading {
    gap: 5px;
    margin-bottom: 2px;
  }

  .instruction {
    font-size: .72rem;
    line-height: 1.05;
  }

  .quantity-note {
    padding: 1px 6px;
    font-size: .6rem;
  }

  .board-work {
    grid-template-columns: minmax(0, 1.35fr) minmax(0, .65fr) 220px;
    grid-template-areas: "ten ones number";
    grid-template-rows: minmax(0, 1fr);
    align-content: stretch;
    gap: 4px;
  }

  .ten-zone,
  .ones-zone {
    padding: 3px;
  }

  .card-heading,
  .loose-heading {
    min-height: 14px;
    margin-bottom: 1px;
    font-size: .56rem;
  }

  .card-heading strong,
  .loose-heading strong {
    font-size: .84rem;
  }

  .ten-frame {
    gap: 1px;
    min-height: calc(var(--shell-size) * 2 + 2px);
    grid-template-rows: repeat(2, minmax(var(--shell-size), 1fr));
  }

  .loose-shelf,
  .loose-shelf[data-layout="grid"],
  .loose-shelf[data-layout="rows"],
  .loose-shelf[data-layout="arc"],
  .loose-shelf[data-layout="cluster"] {
    min-height: calc(var(--shell-size) * 3 + 4px);
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: repeat(3, minmax(var(--shell-size), 1fr));
    gap: 1px;
  }

  .loose-shelf[data-layout="arc"] .loose-shell:nth-child(odd) {
    transform: rotate(-2deg);
  }

  .loose-shelf[data-layout="arc"] .loose-shell:nth-child(even) {
    transform: rotate(2deg);
  }

  .number-build {
    width: 220px;
    min-width: 220px;
    min-height: 100%;
    padding: 2px;
  }

  .digit-tile {
    width: max(.65em, 56px);
    min-height: 56px;
    font-size: 56px;
  }

  .answer-controls {
    gap: 10px;
    margin-top: 2px;
  }

  .choices {
    gap: 6px;
    min-height: 56px;
  }

  .choice,
  .ok-button {
    width: 56px;
    height: 56px;
    min-width: 56px;
    min-height: 56px;
  }

  .choice {
    width: 58px;
    height: 58px;
    min-width: 58px;
    min-height: 58px;
    font-size: clamp(2.2rem, 4vw, 3rem);
  }

  .hint {
    gap: 6px;
    margin-top: 2px;
    padding: 2px 6px;
  }

  .hint-picture {
    gap: 3px;
    font-size: .8rem;
  }

  .mini-ten,
  .mini-ones,
  .mini-total {
    min-width: 24px;
    min-height: 24px;
  }

  .hint p {
    font-size: .62rem;
    line-height: 1.05;
  }

  .demo-note {
    margin-top: 2px;
    padding: 2px 8px;
    font-size: .64rem;
  }

  .demo-skip {
    margin-top: 0;
    padding: 0 8px;
    font-size: .72rem;
  }
}

@media (orientation: portrait) {
  .app-shell {
    grid-template-rows: auto minmax(0, 1fr);
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 8px;
    padding: 2px 2px 5px;
  }

  .brand-block h1 {
    font-size: clamp(.98rem, 4.3vw, 1.32rem);
  }

  .brand-block {
    width: 100%;
  }

  .brand-block .eyebrow {
    display: none;
  }

  .progress-hud {
    gap: 6px;
    padding: 3px 7px;
  }

  .control-row {
    grid-column: 1 / -1;
    width: 100%;
    justify-content: center;
    gap: clamp(3px, 2vw, 8px);
  }

  .playfield {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    align-content: stretch;
    align-items: end;
    gap: 2px 8px;
    padding: 0 3px 3px;
  }

  .guide-column {
    grid-column: 1;
    grid-row: 2;
    z-index: 2;
    align-self: end;
    justify-self: start;
    flex-direction: column;
    align-items: flex-start;
  }

  .guide-column .speech-card {
    position: relative;
    width: min(100%, 205px);
    margin: 0 0 2px;
    padding: 8px 12px;
    font-size: .84rem;
  }

  .sopo {
    width: min(29vw, 180px);
  }

  .game-center {
    grid-column: 1 / -1;
    grid-row: 1;
    align-self: stretch;
  }

  .hero-column {
    grid-column: 2;
    grid-row: 2;
    z-index: 2;
    align-self: end;
    justify-self: end;
  }

  .fiko {
    width: min(34vw, 210px);
  }

  .task-ribbon {
    margin-bottom: 3px;
    padding: 4px 10px;
    font-size: .7rem;
  }

  .board {
    padding: 8px 10px 10px;
    border-width: 3px;
    border-radius: 23px;
  }

  .board-heading {
    display: block;
    margin-bottom: 5px;
  }

  .instruction {
    font-size: clamp(.83rem, 3.35vw, .97rem);
  }

  .quantity-note {
    width: max-content;
    margin-top: 3px;
    padding: 2px 8px;
    font-size: .68rem;
  }

  .board-work {
    grid-template-columns: minmax(0, 1.25fr) minmax(0, .75fr);
    grid-template-areas:
      "ten ones"
      "number number";
    gap: 4px;
  }

  .ten-zone,
  .ones-zone {
    padding: 5px;
    border-width: 1px;
    border-radius: 12px;
    box-shadow: inset 0 0 0 1px rgb(255 255 255 / 55%);
  }

  .card-heading,
  .loose-heading {
    min-height: 17px;
    margin-bottom: 3px;
    font-size: .57rem;
  }

  .card-heading strong,
  .loose-heading strong {
    font-size: 1rem;
  }

  .ten-frame {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(var(--shell-size), 1fr));
    gap: 1px;
    min-height: calc(var(--shell-size) * 2 + 2px);
    padding: 0;
  }

  .frame-cell .shell {
    width: min(100%, var(--shell-size));
    height: min(100%, var(--shell-size));
    max-width: 100%;
    max-height: 100%;
  }

  .loose-shelf {
    min-height: calc(var(--shell-size) * 3 + 4px + 12px);
    padding: 6px;
  }

  .loose-shelf[data-layout="grid"] {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .loose-shelf[data-layout="rows"] {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .loose-shelf[data-layout="arc"] {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: repeat(3, minmax(var(--shell-size), 1fr));
  }

  .loose-shell,
  .loose-shelf[data-layout="cluster"] .loose-shell {
    width: min(100%, var(--shell-size));
    height: min(100%, var(--shell-size));
    max-width: var(--shell-size);
    max-height: var(--shell-size);
  }

  .loose-shelf[data-layout="cluster"] .loose-shell {
    transform: rotate(var(--r));
  }

  .number-build {
    width: clamp(220px, 68vw, 280px);
    min-width: 220px;
    min-height: clamp(100px, 13vh, 118px);
    padding: 5px 10px;
    gap: 0;
  }

  .digit-tile {
    width: max(.65em, 56px);
    height: 100%;
    min-height: 56px;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .answer-controls {
    gap: 8px;
    margin-top: 5px;
  }

  .choice-area {
    gap: 1px;
    margin: 0;
    padding: 0;
  }

  .choice-label {
    font-size: .6rem;
  }

  .choices {
    gap: 8px;
    min-height: 56px;
  }

  .choice {
    width: clamp(58px, 10vw, 72px);
    height: clamp(58px, 10vw, 72px);
    min-width: 58px;
    min-height: 58px;
    border-width: 2px;
    border-radius: 13px;
    font-size: clamp(2.2rem, 4vw, 3rem);
    box-shadow: 0 4px 0 #6e4025;
  }

  .ok-button {
    width: clamp(64px, 10vw, 78px);
    height: clamp(64px, 10vw, 78px);
  }

  .hint {
    grid-template-columns: 1fr;
    gap: 3px;
    margin-top: 6px;
    padding: 5px 7px;
    border-width: 1.5px;
  }

  .hint-picture {
    justify-content: center;
    gap: 4px;
    font-size: 1rem;
  }

  .mini-ten,
  .mini-ones,
  .mini-total {
    min-width: 32px;
    min-height: 28px;
  }

  .hint p {
    font-size: .72rem;
    text-align: center;
  }

  .demo-note {
    font-size: .68rem;
  }

  .intro-title-card {
    padding: 7px 14px;
    border-radius: 18px 28px 18px 28px;
  }

  .intro-title-card h2 {
    font-size: clamp(1.12rem, 5.2vw, 1.65rem);
  }

  .intro-actions {
    gap: 6px;
  }

  .play-button {
    min-height: 68px;
    font-size: 1.42rem;
  }

  .play-button img {
    width: 54px;
    height: 54px;
  }

  .intro-caption {
    font-size: .78rem;
  }

  .panel {
    width: calc(100vw - 16px);
    padding: 18px 14px;
    border-width: 3px;
    border-radius: 23px;
  }

  .panel h2 {
    padding-right: 44px;
  }

  .panel-close {
    width: 56px;
    height: 56px;
  }

  .level-menu {
    gap: 5px;
  }

  .level-button {
    min-height: 74px;
    padding: 5px 2px;
    font-size: .76rem;
  }

  .level-button img {
    width: 33px;
    height: 33px;
  }

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

  .help-step {
    grid-template-columns: 1fr 2fr;
    align-items: center;
    justify-items: start;
    padding: 8px 8px 8px 35px;
    text-align: left;
  }

  .step-picture {
    min-height: 54px;
  }

  .step-picture .mini-number {
    width: 35px;
    height: 40px;
    font-size: 1.4rem;
  }

  .step-picture img {
    width: 37px;
    height: 37px;
  }

  .place-picture .mini-zero {
    width: 45px;
    height: 53px;
  }

  .narration-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .narration-controls .secondary-button:last-child {
    grid-column: 1 / -1;
  }

  .high-five {
    min-height: 125px;
  }

  .high-five img {
    max-height: 145px;
  }

  .reward-stars img {
    width: 48px;
    height: 48px;
  }

  .final-medal {
    width: 120px;
    height: 120px;
  }
}

@media (orientation: portrait) and (max-width: 430px) {
  :root {
    --shell-size: clamp(30px, 8vw, 34px);
  }

  .progress-hud {
    gap: 3px;
    padding: 2px 5px;
  }

  .level-shells,
  .task-stars {
    gap: 2px;
  }

  .level-shell {
    width: 16px;
    height: 16px;
  }

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

  .loose-shelf[data-layout="grid"],
  .loose-shelf[data-layout="rows"] {
    align-content: center;
  }

  .loose-shelf[data-layout="grid"] .loose-shell,
  .loose-shelf[data-layout="rows"] .loose-shell {
    width: min(100%, var(--shell-size));
    height: min(100%, var(--shell-size));
    max-width: var(--shell-size);
    max-height: var(--shell-size);
  }

  .loose-shelf[data-layout="arc"] {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: repeat(3, minmax(var(--shell-size), 1fr));
    gap: 2px;
    align-content: center;
    min-height: calc(var(--shell-size) * 3 + 4px + 12px);
    padding: 6px;
  }

  .loose-shelf[data-layout="arc"] .loose-shell {
    width: min(100%, var(--shell-size));
    height: min(100%, var(--shell-size));
    max-width: var(--shell-size);
    max-height: var(--shell-size);
    margin: 0;
  }

  .loose-shelf[data-layout="arc"] .loose-shell:nth-child(odd) {
    transform: translateY(-1px) rotate(-2deg);
  }

  .loose-shelf[data-layout="arc"] .loose-shell:nth-child(even) {
    transform: translateY(1px) rotate(2deg);
  }

  .loose-shelf[data-layout="cluster"] .loose-shell {
    width: min(100%, var(--shell-size));
    height: min(100%, var(--shell-size));
    max-width: var(--shell-size);
    max-height: var(--shell-size);
    transform: rotate(var(--r));
  }

  .number-build {
    width: clamp(220px, 72vw, 280px);
    min-width: 220px;
    min-height: 104px;
  }

  .digit-tile {
    width: max(.65em, 56px);
    font-size: clamp(72px, 20vw, 86px);
  }
}

@media (orientation: portrait) and (max-height: 700px) {
  .guide-column .speech-card {
    display: none;
  }

  .sopo {
    width: min(25vw, 92px);
  }

  .fiko {
    width: min(28vw, 100px);
  }

  .board {
    padding-top: 6px;
  }

  .instruction {
    font-size: .8rem;
  }

  .quantity-note,
  .choice-label {
    display: none;
  }

  .number-build {
    min-height: 88px;
  }

  .answer-controls {
    margin-top: 4px;
  }

  .demo-skip {
    padding-top: 2px;
    padding-bottom: 2px;
  }
}

@media (orientation: portrait) and (max-width: 390px) {
  .board {
    padding-right: 6px;
    padding-left: 6px;
  }

  .board-work {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr);
    grid-template-areas:
      "ten ones"
      "number number";
    gap: 2px;
  }

  .ten-frame {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .number-build {
    width: clamp(220px, 72vw, 280px);
    min-width: 220px;
    gap: 0;
    padding: 3px 7px;
    border-width: 2px;
  }

  .number-build .tens-digit,
  .number-build .zero-slot {
    width: max(.65em, 56px);
  }
}

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

  .ambient-glints {
    display: none;
  }

  .demo-hand {
    transition: none !important;
  }
}
