:root {
  --ink: #113959;
  --blue: #087cc9;
  --teal: #0e9eb9;
  --gold: #ffc34d;
  --cell: 76px;
  --font: ui-rounded, 'Trebuchet MS', Arial, sans-serif;
  color-scheme: light;
  font-family: var(--font);
  color: var(--ink);
  font-size: 16px;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  background: #32b8de url('../images/backgrounds/island.webp') center/cover fixed no-repeat;
}
button,
input,
select {
  font: inherit;
}
button {
  cursor: pointer;
  transition:
    color 0.24s ease,
    background-color 0.24s ease,
    border-color 0.24s ease,
    box-shadow 0.24s ease,
    opacity 0.24s ease,
    filter 0.24s ease,
    transform 0.24s ease;
}
button:disabled {
  cursor: default;
}
button,
a,
input,
select {
  touch-action: manipulation;
}
button:focus-visible,
select:focus-visible,
.saves__import:has(input:focus-visible) {
  outline: 4px solid #f3980b;
  outline-offset: 4px;
}
button {
  color: inherit;
}
img {
  max-width: 100%;
  object-fit: contain;
}
h1,
h2,
h3,
p {
  margin: 0;
}
h1 {
  font-size: 32px;
  line-height: 1.1;
  letter-spacing: -0.6px;
}
h2 {
  font-size: 20px;
  line-height: 1.25;
}
h3 {
  font-size: 19px;
}
[hidden] {
  display: none !important;
}
.app {
  max-width: 1640px;
  margin: auto;
  padding: 16px 28px 22px;
  position: relative;
  z-index: 1;
}
.header {
  height: 88px;
  display: flex;
  align-items: center;
  gap: 24px;
  margin-bottom: 14px;
}
.header__logo {
  background: none;
  border: 0;
  padding: 0;
  width: 270px;
  flex-shrink: 0;
  transition: transform 0.2s;
}
.header__logo:hover {
  transform: rotate(-2deg);
}
.header__logo img {
  width: 100%;
  height: 108px;
  filter: drop-shadow(0 5px 4px #124c6b35);
}
.header__island {
  font-weight: 900;
  font-size: 22px;
  color: #fff;
  text-shadow: 0 2px 4px #166c91;
}
.header__island span {
  display: block;
  font-size: 14px;
  font-weight: 700;
  margin-top: 4px;
}
.header__tools {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
.header__stars {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #fff5d9;
  border: 3px solid white;
  border-radius: 28px;
  min-width: 90px;
  padding: 4px 14px 4px 7px;
  box-shadow: 0 4px 0 #137c9b55;
}
.header__stars img {
  width: 34px;
  height: 34px;
}
.header__stars strong {
  font-size: 24px;
}
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 22px;
  border: 2px solid white;
  border-radius: 22px;
  font-weight: 900;
  font-size: 18px;
  line-height: 1.1;
  text-decoration: none;
  box-shadow:
    0 5px 0 var(--shadow, #0a6b9959),
    0 7px 12px #08486720;
  transition:
    transform 0.24s ease,
    filter 0.24s ease,
    box-shadow 0.24s ease,
    color 0.24s ease,
    background-color 0.24s ease,
    border-color 0.24s ease;
  user-select: none;
}
.button:hover:not(:disabled) {
  filter: brightness(1.06);
  transform: translateY(-2px);
}
.button:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--shadow, #0a6b9959);
}
.button:disabled {
  opacity: 0.5;
  box-shadow: none;
}
.button--light {
  background: linear-gradient(#fff, #e2f3ff);
  --shadow: #7eb8d3;
  color: #145481;
}
.button--gold {
  background: linear-gradient(#ffe492, #ffbc3d);
  --shadow: #c58420;
  color: #754400;
}
.button--blue {
  background: linear-gradient(#2eb7f1, #087cce);
  --shadow: #075a9a;
  color: white;
}
.button--green {
  background: linear-gradient(#92d91d, #4ba200);
  --shadow: #357400;
  color: white;
  text-shadow: 0 1px 2px #2d7000;
}
.button--small {
  min-height: 40px;
  padding: 9px 15px;
  font-size: 15px;
}
.panel {
  background: linear-gradient(145deg, #fffffff7, #e9f8fff5);
  border: 3px solid #fff;
  border-radius: 30px;
  box-shadow:
    0 8px 0 #247da933,
    0 14px 30px #07547d24,
    inset 0 0 0 1px #82cbe5;
}
.eyebrow {
  font-size: 13px;
  letter-spacing: 1.1px;
  font-weight: 900;
  text-transform: uppercase;
  color: #21809f;
}
.welcome {
  min-height: calc(100dvh - 145px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 30px;
  position: relative;
}
.welcome__character {
  width: 380px;
  flex-shrink: 0;
  filter: drop-shadow(0 15px 10px #007b9633);
  animation: bob 5s ease-in-out infinite;
}
.welcome__character img {
  width: 100%;
  height: auto;
}
.welcome__panel {
  max-width: 520px;
  text-align: center;
  padding: 36px 42px;
  position: relative;
  z-index: 1;
}
.welcome h1 {
  font-size: clamp(38px, 4vw, 60px);
  margin: 10px 0 18px;
  color: #135381;
}
.welcome p {
  font-size: 20px;
  line-height: 1.5;
  margin-bottom: 24px;
}
.welcome__panel .button {
  display: flex;
  width: 100%;
  margin: 0 0 14px;
  min-height: 54px;
}
.welcome__help {
  border: 0;
  background: none;
  font-weight: 800;
  color: #146b9f;
  text-decoration: underline;
  text-underline-offset: 4px;
  padding: 8px;
}
.welcome__note {
  display: block;
  color: #4c6f81;
  font-size: 14px;
  margin-top: 14px;
  line-height: 1.4;
}
.welcome__friend {
  width: 210px;
  height: 390px;
  object-position: bottom;
  align-self: flex-end;
  margin-bottom: 20px;
  filter: drop-shadow(0 10px 10px #305e5433);
}
.adventure {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  max-width: 1430px;
  margin: auto;
}
.mentor {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  position: relative;
}
.mentor__hero {
  height: 340px;
  width: 100%;
  filter: drop-shadow(0 6px 7px #1d664c44);
  margin: 6px 0 10px;
  object-position: bottom;
}
.mentor .button {
  margin-bottom: 6px;
}
.game {
  padding: 22px 24px;
  display: grid;
  gap: 12px;
  position: relative;
}
.game__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.game__top h1 {
  margin-top: 4px;
}
.game__progress {
  text-align: right;
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 800;
}
.game__top > div:first-child {
  min-width: 0;
}
.game__progress {
  margin-left: auto;
}
.game__exit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 2px solid white;
  border-radius: 14px;
  background: #e1f1fa;
  color: #246482;
  box-shadow: 0 3px 0 #97c5da;
  font-size: 32px;
  line-height: 1;
}
.game__exit:hover {
  background: #c9e9f8;
  transform: translateY(-2px);
}
.game__exit:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #97c5da;
}
.game__dots {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.game__dot {
  width: 12px;
  height: 12px;
  border: 2px solid #b6d8e8;
  background: #e0edf4;
  border-radius: 50%;
}
.game__dot--done {
  border-color: #e0a12a;
  background: #ffd34d;
}
.game__dot--current {
  border-color: #1184bf;
  background: #2eb9f3;
}
.story {
  display: flex;
  gap: 14px;
  align-items: center;
  background: #dff5ff;
  border: 1px solid #acdcee;
  border-radius: 20px;
  padding: 8px 14px;
}
.story img {
  width: 72px;
  height: 65px;
  flex-shrink: 0;
}
.story h2 {
  font-size: 19px;
  margin-bottom: 4px;
}
.story p {
  font-size: 16px;
  line-height: 1.3;
  max-width: 380px;
}
.story__equation {
  margin-left: auto;
  font-size: clamp(29px, 3vw, 46px);
  font-weight: 900;
  white-space: nowrap;
  letter-spacing: -1px;
  color: #113d66;
}
.story__unknown {
  color: #dc8100;
}
.game__workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 218px;
  gap: 16px;
}
.game__objects {
  display: grid;
  gap: 12px;
  align-content: start;
}
.frame-panel,
.tray,
.answer-panel {
  background: #fffdf4;
  border: 2px solid #c1e2eb;
  border-radius: 22px;
  padding: 14px 16px;
  box-shadow: 0 3px 0 #92c5d333;
}
.frame-panel__heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.frame-panel__heading h2 {
  font-size: 16px;
}
.frame-panel__heading span {
  font-size: 13px;
  color: #5d7c89;
}
.ten-frame {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  max-width: 530px;
  margin: 0 auto;
}
.ten-frame__cell {
  height: var(--cell);
  padding: 4px;
  background: linear-gradient(#fff, #e0f5ff);
  border: 2px dashed #8dc8de;
  border-radius: 15px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-width: 0;
}
.ten-frame__cell img {
  height: 100%;
  max-width: 100%;
  pointer-events: none;
  user-select: none;
}
.ten-frame__cell--fixed {
  background: linear-gradient(#e9fcff, #c4efff);
  border-style: solid;
  border-color: #89cde7;
}
.ten-frame__cell--filled {
  background: #fff5cf;
  border-style: solid;
  border-color: #e8bb55;
}
.ten-frame__cell--filled img {
  animation: arrive 0.25s ease-out;
}
.ten-frame__cell--empty:hover {
  filter: brightness(0.97);
  border-color: #45a8d0;
}
.ten-frame__cell--hint {
  box-shadow: inset 0 0 0 3px #ffc443;
}
.ten-frame__cell--over {
  background: #fff1a8 !important;
  outline: 3px solid #e4a227;
}
.tray h2 {
  font-size: 16px;
  margin-bottom: 4px;
}
.tray__tokens {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 2px;
  align-items: center;
}
.tray__token {
  height: 55px;
  min-width: 0;
  padding: 3px;
  border: 0;
  border-radius: 12px;
  background: none;
  transition:
    transform 0.24s ease,
    background-color 0.24s ease;
}
.tray__token:hover:not(:disabled) {
  transform: translateY(-3px);
  background: #fff1c6;
}
.tray__token img {
  height: 100%;
  width: 100%;
  pointer-events: none;
  user-select: none;
}
.tray__token:disabled {
  opacity: 0.16;
}
.tray p {
  font-size: 13px;
  color: #567a8b;
  line-height: 1.3;
  margin-top: 4px;
}
.answer-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: #fff8e1;
  border-color: #e7d89b;
  padding: 12px;
}
.answer-panel h2 {
  font-size: 19px;
  line-height: 1.2;
  margin-bottom: 8px;
}
.answer-panel__label {
  font-size: 13px;
  color: #7c7049;
}
.answer-panel__input {
  width: 96px;
  height: 60px;
  background: white;
  border: 3px solid #e0bc61;
  border-radius: 16px;
  text-align: center;
  color: #11436a;
  font-size: 38px;
  font-weight: 900;
  margin: 4px 0 10px;
  box-shadow: inset 0 3px 5px #a9781120;
}
.answer-panel__input:read-only {
  background: #effad6;
  border-color: #95c633;
}
.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  width: 100%;
  max-width: 174px;
}
.keypad__key {
  border: 1px solid #b8d7e3;
  border-bottom: 3px solid #8fbfce;
  border-radius: 10px;
  background: linear-gradient(white, #e8f6fb);
  font-weight: 900;
  font-size: 22px;
  min-height: 36px;
  cursor: pointer;
}
.keypad__key:hover {
  filter: brightness(0.96);
  border-color: #79b5d0;
}
.keypad__key--delete {
  grid-column: span 2;
  font-size: 14px;
}
.answer-panel p {
  font-size: 13px;
  color: #75663e;
  line-height: 1.3;
  margin-top: 10px;
  max-width: 170px;
}
.feedback {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 8px 14px;
  background: #e7f5ff;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  color: #245d7c;
}
.feedback--hint {
  background: #fff1c9;
  color: #775111;
}
.feedback--correct {
  background: #e5f6c8;
  color: #386e0c;
}
.feedback--error {
  background: #fff0df;
  color: #835226;
}
.game__actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.game__actions .button {
  min-width: 145px;
}
.game__check {
  margin-left: auto;
  min-width: 200px !important;
}
.game__demo {
  border: 0;
  background: none;
  text-decoration: underline;
  text-underline-offset: 4px;
  color: #6e651d;
  font-size: 14px;
  justify-self: center;
  padding: 0;
}
.finish {
  min-height: calc(100dvh - 160px);
  display: grid;
  place-items: center;
}
.finish__panel {
  width: min(620px, 100%);
  padding: 28px;
  text-align: center;
}
.finish__treasure {
  display: block;
  margin: 0 auto 14px;
  height: 180px;
  width: 240px;
  animation: bob 5s ease-in-out infinite;
}
.finish h1 {
  font-size: 42px;
  margin: 12px 0 18px;
}
.finish p {
  font-size: 20px;
  line-height: 1.5;
}
.finish__actions {
  display: grid;
  gap: 14px;
  margin: 24px auto 0;
  max-width: 360px;
}
.storage-note {
  position: fixed;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: #fff7d9;
  border: 2px solid #d6ac39;
  border-radius: 12px;
  padding: 10px 18px;
  font-size: 14px;
  max-width: 90vw;
  width: max-content;
  z-index: 10;
}
.dialog {
  border: 3px solid white;
  border-radius: 26px;
  background: linear-gradient(#fffef8, #edf8ff);
  color: var(--ink);
  box-shadow: 0 15px 80px #123d6480;
  width: min(620px, calc(100% - 32px));
  max-height: 90dvh;
  padding: 28px;
  line-height: 1.5;
}
.dialog::backdrop {
  background: #0b3a5bb8;
  backdrop-filter: blur(5px);
}
.dialog h2 {
  font-size: 28px;
  margin-bottom: 16px;
  line-height: 1.2;
}
.dialog p {
  margin-bottom: 16px;
}
.dialog .button {
  margin: 4px;
}
.dialog__close {
  float: right;
  border: 0;
  background: #e1eff5;
  color: #38617b;
  border-radius: 12px;
  padding: 7px 12px;
  font-size: 14px;
  font-weight: 800;
  margin: -10px -10px 12px 15px;
}
.dialog__whale {
  float: right;
  margin: 0 0 14px 18px;
}
.help__steps {
  padding-left: 22px;
  font-size: 18px;
}
.help__steps li {
  padding: 0 0 14px 6px;
}
.dialog--parent {
  width: min(760px, calc(100% - 32px));
}
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 18px 0;
}
.stats__item {
  background: #e6f5fc;
  border-radius: 15px;
  padding: 12px;
  text-align: center;
}
.stats__item strong {
  display: block;
  font-size: 28px;
  color: #17668c;
}
.stats__item span {
  display: block;
  font-size: 13px;
  line-height: 1.3;
}
.parent__recommendation {
  padding: 12px 16px;
  background: #fff1c9;
  border-radius: 14px;
  font-size: 15px;
}
.settings {
  border: 1px solid #b7d8e8;
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 20px;
}
.settings legend {
  font-weight: 900;
  font-size: 20px;
  padding: 0 4px;
  margin-bottom: 10px;
}
.settings label {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 16px;
  font-weight: 700;
  flex: 1;
  min-width: 190px;
}
.settings select {
  border: 1px solid #a0c7da;
  border-radius: 10px;
  padding: 10px;
  color: var(--ink);
  background: white;
  font-size: 16px;
}
.saves h3 {
  margin-bottom: 8px;
}
.saves p {
  font-size: 14px;
}
.saves [data-import-status]:not(:empty) {
  margin-top: 18px;
}
.saves [data-import-status]:empty {
  display: none;
}
.saves__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.saves__import {
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.saves__import input {
  position: absolute;
  opacity: 0;
  inset: 0;
  width: 100%;
  cursor: pointer;
}
.import-preview {
  background: #fff3d5;
  border: 1px solid #dcb75a;
  border-radius: 16px;
  padding: 14px;
}
.parent__reset {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  background: none;
  border: 0;
  color: #9a4932;
  text-decoration: underline;
  text-underline-offset: 4px;
}
.parent__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 24px;
}
.parent__save {
  min-width: 160px;
}
.button__icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  pointer-events: none;
}
.parent__reset:hover {
  color: #77331f;
}
.dialog__close:hover {
  background: #cce5f1;
}
.welcome__help:hover {
  color: #064b80;
}
.game__demo:hover {
  color: #9a6a0a;
}
.drag-ghost {
  position: fixed;
  width: 64px;
  height: 64px;
  pointer-events: none;
  z-index: 1000;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 8px 4px #12384940);
}
[draggable='true'] {
  touch-action: none;
}
body.is-dragging .ten-frame__cell--empty {
  background: #e1f9ff;
}
body.has-reward .header__stars {
  animation: reward 280ms var(--ease-out);
}
@keyframes arrive {
  from {
    transform: scale(0.75);
  }
  to {
    transform: scale(1);
  }
}
@keyframes bob {
  50% {
    transform: translateY(-9px) rotate(1deg);
  }
}
@keyframes reward {
  50% {
    transform: scale(1.15);
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
@media (min-width: 1100px) and (max-height: 850px) {
  :root {
    --cell: 60px;
  }
  .app {
    padding: 10px 22px 16px;
  }
  .header {
    height: 76px;
    margin-bottom: 10px;
  }
  .header__logo {
    width: 240px;
  }
  .header__logo img {
    height: 90px;
  }
  .game {
    padding: 16px 18px;
    gap: 9px;
  }
  .game__top h1 {
    font-size: 27px;
  }
  .game__top .eyebrow {
    font-size: 12px;
  }
  .story {
    padding: 6px 12px;
    gap: 10px;
  }
  .story img {
    height: 56px;
    width: 62px;
  }
  .story h2 {
    font-size: 17px;
  }
  .story p {
    font-size: 15px;
    max-width: 300px;
  }
  .frame-panel,
  .tray {
    padding: 10px 12px;
  }
  .frame-panel__heading {
    margin-bottom: 8px;
  }
  .tray__token {
    height: 44px;
  }
  .game__objects {
    gap: 9px;
  }
  .answer-panel {
    padding: 10px;
  }
  .answer-panel h2 {
    font-size: 17px;
  }
  .answer-panel__input {
    height: 51px;
    margin-bottom: 8px;
  }
  .keypad__key {
    min-height: 31px;
    font-size: 20px;
  }
  .keypad__key--delete {
    font-size: 13px;
  }
  .answer-panel p {
    margin-top: 6px;
    font-size: 12px;
  }
  .feedback {
    min-height: 39px;
    font-size: 15px;
    padding: 7px 10px;
  }
  .game__actions .button {
    min-height: 43px;
    font-size: 17px;
    padding: 9px 18px;
  }
  .mentor__hero {
    height: 300px;
  }
  .welcome {
    min-height: calc(100dvh - 115px);
  }
  .welcome__panel {
    padding: 26px 34px;
  }
  .welcome__character {
    width: 300px;
  }
  .welcome__friend {
    width: 180px;
    height: 330px;
  }
  .welcome h1 {
    font-size: 46px;
  }
  .welcome p {
    font-size: 18px;
    margin-bottom: 18px;
  }
}
@media (min-width: 1100px) and (max-height: 740px) {
  :root {
    --cell: 51px;
  }
  .game {
    gap: 8px;
    padding: 14px 16px;
  }
  .header {
    height: 66px;
  }
  .header__logo img {
    height: 80px;
  }
  .game__top h1 {
    font-size: 25px;
  }
  .story img {
    height: 49px;
    width: 55px;
  }
  .story p {
    font-size: 14px;
  }
  .story h2 {
    font-size: 16px;
  }
  .frame-panel,
  .tray {
    padding: 8px 10px;
  }
  .ten-frame {
    gap: 6px;
  }
  .frame-panel__heading h2,
  .tray h2 {
    font-size: 15px;
  }
  .tray__token {
    height: 39px;
  }
  .tray p {
    font-size: 12px;
  }
  .answer-panel__input {
    height: 46px;
    font-size: 32px;
  }
  .answer-panel h2 {
    font-size: 16px;
  }
  .keypad {
    gap: 5px;
  }
  .keypad__key {
    min-height: 29px;
  }
  .answer-panel p {
    font-size: 12px;
  }
  .feedback {
    min-height: 36px;
    font-size: 14px;
  }
  .mentor__hero {
    height: 280px;
  }
  .adventure {
    grid-template-columns: 165px minmax(0, 1fr);
    gap: 14px;
  }
  .story__equation {
    font-size: 34px;
  }
  .game__demo {
    font-size: 12px;
  }
}
@media (max-width: 1199px) {
  .header__full {
    display: none;
  }
  .header__island span {
    display: none;
  }
  .adventure {
    grid-template-columns: 150px minmax(0, 1fr);
    gap: 12px;
  }
  .game__workspace {
    grid-template-columns: minmax(0, 1fr) 190px;
    gap: 12px;
  }
  .mentor__hero {
    height: 280px;
  }
  .story__equation {
    font-size: 32px;
  }
  .story p {
    max-width: 250px;
  }
  .game__actions .button {
    min-width: 120px;
    padding: 10px 12px;
    font-size: 16px;
  }
  .game__check {
    min-width: 170px !important;
  }
  .welcome__friend {
    display: none;
  }
}
@media (max-width: 1000px) {
  .app {
    padding: 12px 18px 22px;
  }
  .header {
    height: 76px;
    gap: 12px;
  }
  .header__logo {
    width: 220px;
  }
  .header__logo img {
    height: 86px;
  }
  .header__island {
    font-size: 17px;
  }
  .header__tools {
    gap: 8px;
  }
  .header__stars {
    min-width: 74px;
    padding-right: 10px;
  }
  .adventure {
    grid-template-columns: minmax(0, 1fr);
  }
  .mentor {
    display: none;
  }
  .game {
    padding: 18px;
    gap: 12px;
  }
  .game__workspace {
    grid-template-columns: minmax(0, 1fr) 210px;
  }
  .welcome {
    gap: 15px;
  }
  .welcome__character {
    width: 260px;
  }
  .welcome__panel {
    padding: 28px;
  }
  .welcome h1 {
    font-size: 43px;
  }
  .welcome p {
    font-size: 18px;
  }
  .story p {
    max-width: 340px;
  }
}
@media (max-width: 700px) {
  :root {
    --cell: 60px;
  }
  .app {
    padding: 8px 10px 20px;
  }
  .header {
    height: 70px;
    margin-bottom: 12px;
  }
  .header__logo {
    width: 175px;
  }
  .header__logo img {
    height: 75px;
  }
  .header__island {
    display: none;
  }
  .header__tools {
    gap: 5px;
  }
  .header__tools .button {
    font-size: 12px;
    padding: 8px 10px;
    min-height: 36px;
  }
  .header__stars {
    min-width: 58px;
    padding: 2px 8px 2px 4px;
    gap: 3px;
    border-width: 2px;
  }
  .header__stars img {
    width: 25px;
    height: 25px;
  }
  .header__stars strong {
    font-size: 19px;
  }
  .welcome {
    flex-direction: column;
    min-height: 0;
    gap: 0;
  }
  .welcome__character {
    width: 180px;
    height: 175px;
    z-index: 2;
    margin-bottom: -20px;
  }
  .welcome__panel {
    padding: 30px 22px 25px;
    max-width: 440px;
  }
  .welcome h1 {
    font-size: 38px;
  }
  .welcome p {
    font-size: 17px;
  }
  .welcome__note {
    font-size: 13px;
  }
  .game {
    padding: 13px;
    border-radius: 24px;
    gap: 10px;
  }
  .game__top h1 {
    font-size: 26px;
  }
  .game__top .eyebrow {
    font-size: 10px;
    letter-spacing: 0.8px;
  }
  .game__progress {
    font-size: 12px;
  }
  .game__dots {
    gap: 4px;
  }
  .game__dot {
    width: 9px;
    height: 9px;
  }
  .story {
    flex-wrap: wrap;
    padding: 10px;
    gap: 8px;
  }
  .story img {
    width: 45px;
    height: 45px;
  }
  .story > div:not(.story__equation) {
    flex: 1;
    min-width: 200px;
  }
  .story h2 {
    font-size: 17px;
  }
  .story p {
    font-size: 14px;
    max-width: none;
  }
  .story__equation {
    width: 100%;
    text-align: center;
    margin: 0;
    font-size: 35px;
  }
  .game__workspace {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .frame-panel,
  .tray {
    padding: 10px;
  }
  .frame-panel__heading h2 {
    font-size: 14px;
  }
  .frame-panel__heading span {
    font-size: 12px;
  }
  .ten-frame {
    gap: 6px;
  }
  .ten-frame__cell {
    border-radius: 12px;
  }
  .tray__token {
    height: 43px;
  }
  .answer-panel {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    column-gap: 14px;
    padding: 12px;
    text-align: center;
  }
  .answer-panel h2 {
    grid-column: 1/-1;
    margin-bottom: 10px;
    font-size: 18px;
  }
  .answer-panel__label {
    grid-column: 1;
    font-size: 12px;
  }
  .answer-panel__input {
    grid-column: 1;
    margin: 4px auto;
    width: 85px;
    height: 60px;
    grid-row: 3;
  }
  .keypad {
    grid-column: 2;
    grid-row: 2/5;
    max-width: none;
    gap: 5px;
  }
  .keypad__key {
    min-height: 33px;
    font-size: 20px;
  }
  .keypad__key--delete {
    font-size: 13px;
  }
  .answer-panel p {
    grid-column: 1;
    grid-row: 4;
    font-size: 11px;
    margin: 6px 0 0;
  }
  .game__actions {
    gap: 8px;
    flex-wrap: wrap;
  }
  .game__actions .button {
    min-width: 0;
    flex: 1;
    font-size: 14px;
    padding: 10px 8px;
    min-height: 44px;
  }
  .game__check {
    min-width: 100% !important;
  }
  .feedback {
    font-size: 14px;
    min-height: 48px;
  }
  .dialog {
    padding: 22px;
  }
  .dialog h2 {
    font-size: 24px;
  }
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .finish h1 {
    font-size: 34px;
  }
  .finish p {
    font-size: 18px;
  }
  .finish__panel {
    padding: 22px;
  }
  .finish__treasure {
    height: 140px;
  }
}
/* Keep the answer panel within the same height as the ten-frame and tray. */
.answer-panel {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto auto 1fr;
  justify-items: center;
  align-content: start;
  gap: 10px;
  position: relative;
}
.answer-panel h2 {
  margin: 0;
}
.answer-panel__input {
  margin: 0;
}
.answer-panel__label,
.answer-panel p {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.keypad {
  align-self: start;
}
@media (max-width: 700px) {
  .answer-panel {
    grid-template-columns: 100px minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    column-gap: 14px;
  }
  .answer-panel h2 {
    grid-column: 1/-1;
    margin-bottom: 0;
  }
  .answer-panel__input {
    grid-column: 1;
    grid-row: 2;
    align-self: center;
    margin: 0;
  }
  .keypad {
    grid-column: 2;
    grid-row: 2;
    max-width: none;
  }
  .answer-panel__label,
  .answer-panel p {
    position: absolute;
  }
}

@media (max-width: 700px) {
  .game__top {
    flex-wrap: wrap;
    gap: 10px;
  }
  .game__top > div:first-child {
    flex: 1;
  }
  .game__progress {
    order: 3;
    flex-basis: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0;
    gap: 8px;
  }
  .game__dots {
    margin-top: 0;
  }
  .game__exit {
    flex-basis: 40px;
    width: 40px;
    height: 40px;
  }
}

/* Island selection and addition through ten. Existing first-island styles remain. */
.header__island strong {
  font: inherit;
}
.islands {
  min-height: calc(100dvh - 145px);
  display: grid;
  place-items: center;
}
.islands__panel {
  width: min(880px, 100%);
  padding: 28px;
}
.islands__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}
.islands__header h1 {
  margin-top: 6px;
}
.islands__cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}
.island-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: linear-gradient(#fffdf2, #e8f8ff);
  border: 2px solid #b6dceb;
  border-radius: 24px;
  padding: 20px;
  gap: 10px;
}
.island-card > img {
  width: 180px;
  height: 150px;
  filter: drop-shadow(0 7px 5px #1556781c);
}
.island-card h2 {
  font-size: 25px;
}
.island-card p {
  line-height: 1.4;
  font-size: 16px;
}
.island-card .button {
  width: 100%;
  margin-top: auto;
}
.island-card .island-card__status {
  font-size: 13px;
  min-height: 37px;
  color: #496e84;
}
.game--addition .game__workspace {
  grid-template-columns: minmax(0, 1fr) 165px 180px;
  gap: 12px;
}
.game--addition .story p {
  max-width: none;
}
.game--addition .story > div:not(.story__equation) {
  flex: 1;
}
.game--addition .tray__tokens {
  justify-content: start;
  grid-template-columns: repeat(9, minmax(0, 1fr));
}
.split {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: linear-gradient(#fffef7, #f8f3e6);
  border: 2px solid #e6d49a;
  border-radius: 22px;
  padding: 12px 10px;
  box-shadow: 0 3px 0 #b5b47a26;
}
.split > .eyebrow {
  font-size: 11px;
  letter-spacing: 0.8px;
  margin-bottom: 4px;
}
.split h2 {
  font-size: 17px;
}
.split__number {
  font-size: 38px;
  font-weight: 900;
  line-height: 1.1;
  margin-top: 8px;
  color: #14496a;
}
.split__branches {
  position: relative;
  width: 110px;
  height: 28px;
  margin-top: 3px;
  flex-shrink: 0;
}
.split__branches::before,
.split__branches::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  width: 51px;
  height: 3px;
  transform-origin: left center;
  border-radius: 2px;
}
.split__branches::before {
  background: #d69c22;
  transform: rotate(155deg);
}
.split__branches::after {
  background: #ce65a1;
  transform: rotate(25deg);
}
.split__parts {
  display: flex;
  justify-content: center;
  gap: 12px;
  width: 100%;
}
.split__part {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.2;
}
.split__part--gold {
  color: #8f6510;
}
.split__part--pink {
  color: #a2487a;
}
.split__input {
  width: 56px;
  height: 48px;
  border: 3px solid #d9b351;
  border-radius: 13px;
  background: #fff9e7;
  color: #8f6510;
  font-size: 29px;
  font-weight: 900;
  text-align: center;
  box-shadow: inset 0 3px 5px #9a701015;
}
.split__part--pink .split__input {
  border-color: #d597ba;
  background: #fff0f7;
  color: #9c4473;
}
.split__input:read-only {
  background: #eef8dd;
  border-color: #a1bf68;
  color: #44731d;
}
.split__tip {
  font-size: 13px;
  line-height: 1.4;
  color: #726746;
  margin-top: 12px;
}
.split__proof {
  font-size: 15px;
  line-height: 1.5;
  font-weight: 900;
  color: #41721e;
  margin-top: 12px;
}
.game--addition .number-input--active {
  outline: 3px solid #37a7d3;
  outline-offset: 3px;
}
.game--addition .answer-panel {
  gap: 10px;
}
.game--addition .answer-panel h2 {
  font-size: 18px;
}
.game--addition .keypad {
  max-width: 156px;
}
@media (min-width: 1100px) and (max-height: 850px) {
  .game--addition {
    padding: 12px 14px;
    gap: 8px;
    --cell: 54px;
  }
  .game--addition .story {
    padding: 5px 10px;
  }
  .game--addition .story img {
    height: 44px;
    width: 50px;
  }
  .game--addition .story h2 {
    font-size: 16px;
  }
  .game--addition .story p {
    font-size: 14px;
  }
  .game--addition .game__objects {
    gap: 8px;
  }
  .game--addition .frame-panel,
  .game--addition .tray {
    padding: 8px 10px;
  }
  .game--addition .frame-panel__heading {
    margin-bottom: 6px;
  }
  .game--addition .tray__token {
    height: 40px;
  }
  .split > .eyebrow {
    display: none;
  }
  .split h2 {
    font-size: 16px;
  }
  .split__number {
    font-size: 35px;
    margin-top: 6px;
  }
  .split__branches {
    height: 25px;
  }
  .split__input {
    height: 44px;
    font-size: 27px;
  }
  .split__tip,
  .split__proof {
    font-size: 12px;
    line-height: 1.35;
    margin-top: 10px;
  }
  .game--addition .answer-panel h2 {
    font-size: 16px;
  }
  .game--addition .answer-panel {
    padding: 10px 8px;
  }
}
@media (min-width: 1100px) and (max-height: 740px) {
  .game--addition {
    --cell: 48px;
  }
  .game--addition .game__workspace {
    grid-template-columns: minmax(0, 1fr) 155px 165px;
    gap: 10px;
  }
  .game--addition .tray__token {
    height: 36px;
  }
  .game--addition .split {
    padding: 10px 8px;
  }
  .game--addition .split__number {
    font-size: 32px;
    margin-top: 4px;
  }
  .game--addition .split__branches {
    height: 23px;
  }
  .game--addition .split__input {
    height: 40px;
    font-size: 25px;
  }
  .game--addition .split__tip,
  .game--addition .split__proof {
    margin-top: 8px;
    font-size: 12px;
  }
}
@media (min-width: 901px) and (max-width: 1099px) {
  .game--addition .game__workspace {
    grid-template-columns: minmax(0, 1fr) 155px 175px;
    gap: 10px;
  }
  .game--addition .tray__token {
    height: 43px;
  }
  .game--addition .split {
    padding: 12px 8px;
  }
  .game--addition .split__parts {
    gap: 8px;
  }
}
@media (min-width: 701px) and (max-width: 900px) {
  .game--addition .game__workspace {
    grid-template-columns: minmax(0, 1fr) 175px;
    gap: 12px;
  }
  .game--addition .game__objects {
    grid-column: 1;
    grid-row: 1;
  }
  .game--addition .split {
    grid-column: 1;
    grid-row: 2;
    display: grid;
    grid-template-columns: 1fr 140px;
    grid-template-rows: auto auto;
    column-gap: 12px;
    align-items: center;
    padding: 12px;
  }
  .game--addition .split > .eyebrow,
  .game--addition .split__branches {
    display: none;
  }
  .game--addition .split h2 {
    grid-column: 1;
    grid-row: 1;
  }
  .game--addition .split__number {
    grid-column: 1;
    grid-row: 2;
    font-size: 32px;
    margin: 0;
  }
  .game--addition .split__parts {
    grid-column: 2;
    grid-row: 1/3;
  }
  .game--addition .split__tip,
  .game--addition .split__proof {
    grid-column: 1/-1;
    font-size: 13px;
    margin-top: 8px;
  }
  .game--addition .answer-panel {
    grid-column: 2;
    grid-row: 1/3;
    align-content: center;
  }
}
@media (max-width: 700px) {
  .islands__panel {
    padding: 18px;
  }
  .islands__header h1 {
    font-size: 25px;
  }
  .islands__cards {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .island-card {
    padding: 16px;
  }
  .island-card > img {
    height: 110px;
  }
  .island-card .island-card__status {
    min-height: 0;
  }
  .game--addition .game__workspace {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }
  .game--addition .story > div:not(.story__equation) {
    min-width: 180px;
  }
  .game--addition .split {
    padding: 14px;
  }
  .split__parts {
    gap: 24px;
  }
  .split__input {
    width: 70px;
    height: 48px;
  }
  .split__tip,
  .split__proof {
    margin-top: 8px;
  }
  .game--addition .answer-panel {
    grid-template-columns: 100px minmax(0, 1fr);
    grid-template-rows: auto 1fr;
  }
  .game--addition .keypad {
    max-width: none;
  }
}

.game--addition .tray__token--used {
  visibility: hidden;
}
.game--addition .tray__token:disabled:not(.tray__token--used) {
  opacity: 1;
}

/* Desktop welcome composition. */
@media (min-width: 1200px) {
  .welcome__friend {
    height: 490px;
    width: auto;
    flex-shrink: 0;
  }
  .welcome__character {
    align-self: start;
  }
}

/* Feedback is legible through shapes and colour even without reading or motion. */
:root {
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}
.answer-panel__input:focus-visible,
.split__input:focus-visible {
  outline: none;
}
.answer-panel__input:focus:not(:read-only) {
  border-color: #39a2bf;
}
.game--addition .number-input--active {
  outline: 3px solid #37a7d3;
  outline-offset: 3px;
}
.feedback {
  gap: 10px;
}
.feedback__icon {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
}
.feedback__retry {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border: 2px solid #d38e28;
  border-radius: 50%;
  background: #fff9eb;
  color: #945c11;
  font-size: 26px;
  font-weight: 900;
  line-height: 1;
}

.game__celebration {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: -27px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  pointer-events: none;
}
.game__celebration img {
  object-fit: contain;
  filter: drop-shadow(0 3px 3px #8f641d35);
}
.number-input--retry {
  border-color: #d9a547 !important;
  background: #fff1d5 !important;
}
.frame-panel--retry {
  border-color: #dca84c;
  background: #fff7e5;
}
@media (min-width: 1100px) and (max-height: 850px) {
  .feedback__icon {
    width: 27px;
    height: 27px;
  }
  .feedback__retry {
    width: 27px;
    height: 27px;
    flex-basis: 27px;
    font-size: 22px;
  }
  .feedback {
    padding-top: 5px;
    padding-bottom: 5px;
  }
}
@media (max-width: 700px) {
  .game__celebration {
    display: none;
  }
  .feedback__icon {
    width: 32px;
    height: 32px;
  }
  .feedback__retry {
    width: 30px;
    height: 30px;
    flex-basis: 30px;
  }
  .feedback {
    justify-content: flex-start;
    text-align: left;
  }
}
@media (prefers-reduced-motion: reduce) {
  .game::after {
    transition: none;
  }
}

/* Island 3 and feedback: only paint changes; response never changes the grid. */
.islands__cards {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.number-field {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
}
.number-field--answer {
  grid-column: 1;
  grid-row: 2;
}
.number-field__icon {
  position: absolute;
  right: -8px;
  top: -8px;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  background: #fff;
  color: #a44438;
  font-size: 18px;
  line-height: 23px;
  font-weight: 900;
  pointer-events: none;
  visibility: hidden;
  box-shadow: 0 1px 4px #143c4926;
}
.number-field[data-result='retry'] .number-field__icon {
  visibility: visible;
  background: #ffe6e0;
  color: #ab4338;
}
.number-field[data-result='correct'] .number-field__icon {
  visibility: visible;
  background: #e5f5ce;
  color: #367315;
}
.number-field input[data-result='retry'] {
  background: #fff0eb !important;
  border-color: #d7897c !important;
  box-shadow: inset 0 0 0 1px #d7897c;
}
.number-field input[data-result='correct'] {
  background: #eff9db !important;
  border-color: #8dbf4d !important;
}
.frame-panel[data-result='retry'],
.tray[data-result='retry'] {
  background: #fff0eb;
  box-shadow: inset 0 0 0 2px #d7897c;
}
.frame-panel[data-result='retry']::after,
.tray[data-result='retry']::after {
  content: '↻';
  position: absolute;
  right: 8px;
  bottom: 6px;
  width: 26px;
  height: 26px;
  line-height: 26px;
  text-align: center;
  border-radius: 50%;
  background: #fff0eb;
  color: #ab4338;
  font-size: 23px;
  pointer-events: none;
}
.frame-panel,
.tray {
  position: relative;
}
.feedback {
  height: 64px;
  min-height: 64px;
  max-height: 64px;
  padding: 8px 44px;
  position: relative;
  overflow: hidden;
}
.feedback__icon,
.feedback__retry {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
}
.feedback [data-feedback-text] {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.split__tip,
.split__proof {
  height: 46px;
  min-height: 46px;
  margin-top: 12px;
}
.game__demo[hidden] {
  display: block !important;
  visibility: hidden;
  pointer-events: none;
}
.game__actions [data-check],
.game__actions [data-next] {
  width: 230px;
  flex: 0 0 230px;
}
.subtraction-token--removed img {
  visibility: visible;
  opacity: 0.25;
  filter: saturate(0.5);
}
.subtraction-token--removed {
  background: #f3f8f9;
  border-style: dashed;
  opacity: 1 !important;
}
.game--addition .tray__token.subtraction-token--removed {
  visibility: visible;
  box-shadow: inset 0 0 0 1px #a5c9d6;
}
@media (max-width: 1000px) {
  .islands__cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 700px) {
  .islands__cards {
    grid-template-columns: 1fr;
  }
  .number-field--answer {
    grid-column: 1;
    grid-row: 2;
    align-self: center;
  }
  .number-field--answer .answer-panel__input {
    grid-column: auto;
    grid-row: auto;
  }
  .feedback {
    height: 76px;
    min-height: 76px;
    max-height: 76px;
  }
  .feedback [data-feedback-text] {
    -webkit-line-clamp: 3;
  }
  .game__actions [data-check],
  .game__actions [data-next] {
    width: 100%;
    flex-basis: 100%;
  }
}

.islands__panel {
  width: min(1180px, 100%);
}
.island-card__new {
  background: none;
  border: 0;
  color: #246482;
  text-decoration: underline;
  text-underline-offset: 4px;
  font-size: 14px;
  padding: 6px 12px;
  min-height: 32px;
}
.number-field--answer .answer-panel__input {
  grid-area: auto;
}

.game--addition .number-input--active[data-result='retry'] {
  outline-color: #d7897c;
}
.tray p {
  padding-right: 24px;
}

/* Larger reward stars pulse without participating in layout. */
.game__celebration {
  top: -42px;
  gap: 14px;
}
.game__celebration img {
  width: 56px;
  height: 56px;
  animation: celebration-pulse 1500ms ease-in-out infinite;
}
.game__celebration img:nth-child(2) {
  width: 80px;
  height: 80px;
  animation-delay: -250ms;
}
@keyframes celebration-pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.12);
  }
}
@media (prefers-reduced-motion: reduce) {
  .game__celebration img {
    animation: none;
  }
}

/* Treasure island: map, merchant stalls and personal collection. */
.market,
.treasure {
  max-width: 1280px;
  margin: 0 auto;
}
.market__panel {
  padding: 26px;
  background: linear-gradient(145deg, #fffdf4f7, #eaf9fff7);
}
.market__heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 18px;
}
.market__heading h1 {
  font-size: 36px;
  margin: 6px 0 8px;
}
.market__heading p {
  color: #4f7384;
  line-height: 1.4;
}
.market__nav {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}
.market-wallet {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 12px 0 18px;
}
.wallet-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid #b8dce8;
  background: #f0fbff;
  border-radius: 16px;
  font-size: 13px;
  color: #446b7c;
}
.wallet-chip img {
  width: 30px;
  height: 30px;
  object-fit: contain;
}
.wallet-chip b {
  font-size: 20px;
  color: #144a67;
}
.wallet-chip--stars {
  background: #fff1bd;
  border-color: #e2bb55;
}
.market-map {
  position: relative;
  aspect-ratio: 1672/941;
  border: 4px solid #fff;
  border-radius: 24px;
  overflow: hidden;
  background: #44c5e9;
  box-shadow: 0 5px 0 #2a95ad30;
}
.market-map__image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.market-map__pin {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: #fffcf3f5;
  border: 3px solid white;
  border-radius: 18px;
  padding: 5px 10px;
  box-shadow:
    0 4px 0 #125a7560,
    0 6px 12px #12435c35;
  font-size: 14px;
  font-weight: 900;
  max-width: 185px;
  line-height: 1.2;
  text-align: center;
  min-width: 72px;
}
.market-map__pin img {
  width: 44px;
  height: 44px;
  object-fit: contain;
}
.market-map__pin:hover {
  transform: translate(-50%, -55%);
  background: #fff0b6;
}
.market-map__pin:focus-visible {
  outline: 4px solid #f3980b;
  outline-offset: 3px;
}
.market-map__pin--chest {
  background: #fff0b8;
}
.market__directory {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 18px;
}
.market__directory button {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #c6dde6;
  background: #fffdf4;
  padding: 8px 12px;
  border-radius: 14px;
  font-weight: 800;
  font-size: 14px;
}
.market__directory button:hover {
  background: #fff0be;
}
.market__directory img {
  width: 32px;
  height: 32px;
}
.market__hint {
  text-align: center;
  color: #496f7e;
  line-height: 1.5;
  margin-top: 16px;
  font-size: 14px;
}
.dialog--shop {
  width: min(1020px, calc(100% - 32px));
  padding: 26px;
}
.shop__intro {
  display: flex;
  gap: 18px;
  align-items: center;
  margin-bottom: 12px;
}
.shop__intro > img {
  width: 104px;
  height: 104px;
  object-fit: contain;
  flex-shrink: 0;
}
.shop__intro h2 {
  margin: 4px 0 8px;
  font-size: 30px;
}
.shop__intro p {
  margin: 0;
  color: #527385;
}
.shop__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.shop-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  background: linear-gradient(#fffef8, #eefaff);
  border: 2px solid #c7e4e9;
  border-radius: 22px;
  padding: 18px 14px;
  min-width: 0;
}
.shop-card__art {
  height: 126px;
  display: grid;
  place-items: center;
  width: 100%;
}
.shop-card__art img {
  max-width: 100%;
  width: 140px;
  height: 120px;
  object-fit: contain;
  filter: drop-shadow(0 5px 4px #2a5b7020);
}
.shop-card h3 {
  font-size: 20px;
  line-height: 1.2;
}
.shop-card__type {
  font-size: 11px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #59808b;
  font-weight: 900;
}
.shop-card__price {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: auto;
  padding-top: 8px;
}
.price-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 14px;
  background: #fff1ce;
  border: 1px solid #e9d29c;
  padding: 5px 10px;
}
.price-chip img {
  width: 30px;
  height: 30px;
}
.price-chip b {
  font-size: 22px;
}
.dialog .shop-card p {
  margin: 0;
  font-size: 14px;
  color: #567784;
}
.shop-card .button {
  width: 100%;
  min-height: 44px;
  font-size: 16px;
  margin: 0;
}
.shop-card--owned {
  background: #f0f9df;
  border-color: #b5d98e;
}
.shop__status {
  color: #3a781d;
  background: #edf8dc;
  border-radius: 12px;
  padding: 10px 14px;
  min-height: 42px;
}
.shop__status:empty {
  display: none;
}
.shop__footer {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 22px;
}
.dialog--trade {
  width: min(560px, calc(100% - 32px));
  text-align: center;
}
.dialog--trade h2 {
  clear: both;
  margin: 8px 0 12px;
}
.trade__item {
  width: 140px;
  height: 130px;
  display: block;
  margin: 0 auto 14px;
}
.trade__quantity {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-weight: 800;
  margin: 12px 0 18px;
}
.trade__quantity select {
  padding: 7px 18px;
  background: white;
  border: 1px solid #9ac7d7;
  border-radius: 12px;
  color: var(--ink);
  font-weight: 900;
}
.dialog .trade__caption {
  font-size: 13px;
  text-transform: uppercase;
  color: #658391;
  font-weight: 900;
  letter-spacing: 1px;
  margin: 14px 0 8px;
}
.trade__cost {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.trade__receive {
  font-size: 21px;
  font-weight: 900;
  color: #2c7823;
}
.dialog .trade__status {
  font-size: 15px;
  color: #496e7b;
  line-height: 1.5;
  margin: 16px 0 0;
}
.treasure__summary {
  font-size: 15px;
  color: #5c7c88;
  margin-bottom: 18px;
}
.treasure__tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.treasure__tabs button {
  border: 1px solid #b5d5e2;
  background: #f3fbff;
  border-radius: 15px;
  padding: 10px 16px;
  font-weight: 800;
}
.treasure__tabs button[aria-pressed='true'] {
  background: #ffeb9b;
  border-color: #dfb44d;
  color: #77520b;
}
.treasure__grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}
.treasure-card p {
  font-size: 14px;
  color: #54798a;
}
.treasure-card .button {
  margin-top: auto;
}
.treasure-card--selected {
  border-color: #8dc03a;
  background: #f1fbdc;
}
.treasure-card--exchanged .shop-card__art {
  opacity: 0.35;
}
.treasure__empty {
  text-align: center;
  padding: 25px;
}
.treasure__empty p {
  margin: 12px auto 22px;
  line-height: 1.5;
}
.treasure__message {
  color: #347520;
  margin: 12px 0;
}
.treasure__message:empty {
  display: none;
}

@media (max-width: 1100px) {
  .header__market span {
    display: none;
  }
  .header__market {
    padding: 8px !important;
  }
  .market__panel {
    padding: 20px;
  }
  .market-map__pin {
    font-size: 12px;
    max-width: 150px;
  }
  .market-map__pin img {
    width: 36px;
    height: 36px;
  }
  .treasure__grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 700px) {
  .market__panel {
    padding: 14px;
  }
  .market__heading {
    align-items: flex-start;
    gap: 12px;
  }
  .market__heading h1 {
    font-size: 27px;
  }
  .market__heading p {
    font-size: 14px;
  }
  .market__nav {
    gap: 8px;
  }
  .market__nav .button {
    padding: 8px 10px;
    font-size: 13px;
    min-height: 40px;
  }
  .market-map {
    border-width: 2px;
    border-radius: 18px;
  }
  .market-map__pin {
    min-width: 36px;
    max-width: none;
    width: 40px;
    height: 40px;
    padding: 2px;
    border-width: 2px;
    border-radius: 13px;
  }
  .market-map__pin img {
    width: 32px;
    height: 32px;
  }
  .market-map__pin span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }
  .market__directory {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
  }
  .market__directory button {
    font-size: 12px;
    padding: 6px 8px;
    text-align: left;
  }
  .wallet-chip {
    padding: 4px 8px;
    gap: 4px;
  }
  .wallet-chip span {
    display: none;
  }
  .wallet-chip b {
    font-size: 17px;
  }
  .wallet-chip img {
    width: 25px;
    height: 25px;
  }
  .market-wallet {
    gap: 6px;
    margin: 10px 0 12px;
  }
  .dialog--shop {
    padding: 18px;
  }
  .shop__intro {
    gap: 10px;
  }
  .shop__intro > img {
    width: 70px;
    height: 70px;
  }
  .shop__intro h2 {
    font-size: 24px;
  }
  .shop__intro p {
    font-size: 14px;
  }
  .shop__grid,
  .treasure__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .shop-card {
    padding: 12px 9px;
    gap: 8px;
    border-radius: 17px;
  }
  .shop-card__art {
    height: 96px;
  }
  .shop-card__art img {
    height: 90px;
    width: 110px;
  }
  .shop-card h3 {
    font-size: 17px;
  }
  .shop-card .button {
    font-size: 13px;
    padding: 8px;
    min-height: 40px;
  }
  .price-chip {
    padding: 4px 7px;
    gap: 3px;
  }
  .price-chip b {
    font-size: 18px;
  }
  .price-chip img {
    width: 25px;
    height: 25px;
  }
  .treasure__tabs {
    gap: 6px;
  }
  .treasure__tabs button {
    padding: 8px 11px;
    font-size: 13px;
  }
  .header__logo {
    width: 135px;
  }
  .header__market {
    min-width: 36px;
    min-height: 36px !important;
    padding: 5px !important;
  }
  .header__market img {
    width: 25px;
  }
  .market__hint {
    font-size: 12px;
  }
  .trade__item {
    width: 120px;
    height: 110px;
  }
}
@media (max-width: 430px) {
  .header__logo {
    width: 100px;
  }
  .header__tools .button {
    font-size: 11px;
    padding: 7px;
  }
  .shop__footer .button {
    width: 100%;
  }
  .market__heading {
    flex-wrap: wrap;
  }
  .market__nav {
    margin-left: auto;
  }
  .treasure__summary {
    font-size: 13px;
  }
}

.trade__guidance {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
}
.trade__guidance .button {
  font-size: 13px;
}

/* Clear home navigation and aligned island footers. */
.welcome__panel .button {
  min-height: 80px;
  gap: 16px;
  justify-content: flex-start;
  padding-left: 22px;
  text-align: left;
}
.welcome__panel .button > img {
  width: 66px;
  height: 60px;
  flex: 0 0 66px;
  object-fit: contain;
}
.island-card__new[hidden] {
  display: block !important;
  visibility: hidden;
  pointer-events: none;
}
.island-card__status {
  width: 100%;
}
/* The illustrated stalls themselves are keyboard-accessible hit areas. */
.market-map__hotspot {
  position: absolute;
  display: block;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
  transition:
    background-color 0.2s ease,
    box-shadow 0.2s ease;
  touch-action: manipulation;
}
.market-map__hotspot:hover {
  background: transparent;
  box-shadow: none;
}
.market-map__hotspot:focus-visible {
  outline: none;
  background: #fff0a936;
  box-shadow: inset 0 0 0 5px #ffe16a;
}
/* Scrolling stays inside the active dialog, including nested purchase windows. */
body.has-dialog {
  overflow: hidden;
  overscroll-behavior: none;
}
.dialog,
.shop__catalog {
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #7e9da080 transparent;
}
.dialog::-webkit-scrollbar,
.shop__catalog::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
.dialog::-webkit-scrollbar-track,
.shop__catalog::-webkit-scrollbar-track {
  background: transparent;
  margin: 14px 0;
}
.dialog::-webkit-scrollbar-thumb,
.shop__catalog::-webkit-scrollbar-thumb {
  background: #6f8f9680;
  border: 2px solid transparent;
  border-radius: 20px;
  background-clip: padding-box;
}
.dialog::-webkit-scrollbar-thumb:hover,
.shop__catalog::-webkit-scrollbar-thumb:hover {
  background-color: #5e7b87b0;
}
.dialog::-webkit-scrollbar-button,
.shop__catalog::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}
.dialog::-webkit-scrollbar-corner,
.shop__catalog::-webkit-scrollbar-corner {
  background: transparent;
}
/* Characters flank the stall while only its content scrolls. */
.dialog--shop {
  padding: 0;
  overflow: visible;
  width: min(1020px, calc(100% - 360px));
  max-height: none;
}
.shop__scroll {
  max-height: calc(90dvh - 6px);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 26px;
  border-radius: inherit;
}
.shop__side {
  position: absolute;
  bottom: 12px;
  z-index: 3;
  width: 215px;
  height: min(470px, 66dvh);
  object-fit: contain;
  object-position: bottom;
  pointer-events: none;
  filter: drop-shadow(0 10px 8px #12374a40);
}
.shop__side--vendor {
  left: -190px;
}
.shop__side--hero {
  right: -190px;
}
.shop__portrait {
  display: none;
}
.shop__intro > div {
  min-width: 0;
}
.shop__intro {
  min-height: 90px;
  padding-right: 5px;
}
.dialog--shop .shop__close {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: 0 0 10px 12px;
  box-shadow: 0 2px 8px #17455d18;
}
@media (min-width: 1100px) and (max-width: 1499px) {
  .dialog--shop {
    width: calc(100% - 280px);
  }
  .shop__side {
    width: 165px;
    height: min(400px, 62dvh);
  }
  .shop__side--vendor {
    left: -145px;
  }
  .shop__side--hero {
    right: -145px;
  }
}
@media (max-width: 1099px) {
  .dialog--shop {
    width: min(880px, calc(100% - 32px));
    padding: 0;
  }
  .shop__side {
    display: none;
  }
  .shop__portrait {
    display: block;
  }
  .shop__intro > img {
    width: 80px;
    height: 80px;
  }
  .shop__scroll {
    padding: 22px;
  }
}
@media (max-width: 700px) {
  .welcome__panel .button {
    min-height: 68px;
    padding: 8px 14px;
    gap: 12px;
    font-size: 16px;
  }
  .welcome__panel .button > img {
    width: 48px;
    height: 46px;
    flex-basis: 48px;
  }
  .shop__scroll {
    padding: 16px;
  }
  .shop__intro > img {
    width: 60px;
    height: 60px;
  }
  .shop__intro {
    min-height: 76px;
    gap: 10px;
  }
  .shop__intro h2 {
    font-size: 23px;
  }
  .shop__intro .eyebrow {
    font-size: 10px;
  }
}

.dialog:not(.dialog--shop) {
  overflow: auto;
}

/* Family profiles: independent children and reports. */
.welcome {
  flex-wrap: wrap;
}
.family-picker {
  flex: 0 0 100%;
  width: 100%;
  max-width: 1050px;
  margin: 0 auto 20px;
  padding: 18px 24px;
}
.family-picker__heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.family-picker__heading h2 {
  margin: 0;
  font-size: 24px;
}
.family-picker__list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}
.family-picker__list button {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 155px;
  padding: 10px 18px;
  border: 2px solid #b2dce8;
  border-radius: 20px;
  background: #fff;
  color: #153f5c;
  text-align: left;
  cursor: pointer;
  transition:
    background-color 0.2s,
    border-color 0.2s,
    box-shadow 0.2s;
}
.family-picker__list button[aria-pressed='true'] {
  background: #fff4bc;
  border-color: #e2b43b;
  box-shadow: 0 3px 0 #e2b43b;
}
.family-picker__list img {
  width: 48px;
  height: 64px;
  object-fit: contain;
}
.family-picker__list span {
  display: grid;
  gap: 5px;
}
.family-picker__list small {
  font-size: 13px;
  color: #54798a;
}
.header__profile {
  border: 1px solid #fff;
  border-radius: 22px;
  background: #fff4c4;
  color: #164b6a;
  padding: 10px 16px;
  font: inherit;
  font-weight: 700;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.family__intro {
  line-height: 1.5;
}
.family__status {
  color: #a83d24;
  margin: 12px 0;
}
.family__status:empty {
  display: none;
}
.family__cards {
  display: grid;
  gap: 24px;
}
.family-card {
  border: 2px solid #b8dfe9;
  border-radius: 24px;
  padding: 22px;
  background: #ffffff75;
}
.family-card__title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.family-card__title h3 {
  margin: 0;
  font-size: 25px;
  overflow-wrap: anywhere;
}
.family-card__title span {
  font-size: 14px;
  color: #577b38;
}
.family-card__settings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 22px;
}
.family-card label,
.family__add label {
  display: grid;
  gap: 9px;
  font-weight: 700;
}
.family-card input,
.family-card select,
.family__add input {
  width: 100%;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid #99c9df;
  border-radius: 14px;
  background: #fff;
  color: #153f5c;
  font: inherit;
}
.family-card__heroes {
  grid-column: 1/-1;
  border: 0;
  padding: 0;
  margin: 0;
}
.family-card__heroes legend {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
}
.family-card__heroes button {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-right: 12px;
  padding: 10px 20px;
  border: 2px solid #bddde7;
  border-radius: 18px;
  background: #fff;
  cursor: pointer;
  font: inherit;
  color: #153f5c;
}
.family-card__heroes button[aria-pressed='true'] {
  border-color: #70af22;
  background: #effbd9;
}
.family-card__heroes img {
  width: 74px;
  height: 100px;
  object-fit: contain;
}
.family-card .stats {
  margin-top: 18px;
}
.family__table {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0;
  font-size: 15px;
}
.family__table th,
.family__table td {
  padding: 10px 8px;
  text-align: left;
  border-bottom: 1px solid #c5e2e9;
}
.family__mistakes {
  padding-left: 22px;
  line-height: 1.6;
}
.family__mistakes li {
  margin-bottom: 10px;
}
.family-card__note {
  font-size: 15px;
  line-height: 1.5;
  color: #52758a;
}
.family__add {
  margin: 24px 0;
  padding: 22px;
  border: 2px dashed #b4dbe6;
  border-radius: 22px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: end;
}
.family__add h3 {
  grid-column: 1/-1;
  margin: 0;
}
.family__add .button {
  font-size: 17px;
}
.family-card .recommendation {
  margin: 16px 0 0;
}
@media (max-width: 700px) {
  .family-picker {
    padding: 14px;
    margin-bottom: 12px;
  }
  .family-picker__heading {
    align-items: flex-start;
  }
  .family-picker__heading h2 {
    font-size: 19px;
  }
  .family-picker__list {
    gap: 8px;
  }
  .family-picker__list button {
    min-width: 135px;
    flex: 1;
    padding: 8px 12px;
  }
  .family-card {
    padding: 14px;
  }
  .family-card__settings {
    grid-template-columns: 1fr;
  }
  .family-card__heroes {
    grid-column: auto;
  }
  .family-card__title {
    flex-wrap: wrap;
  }
  .family__table {
    font-size: 13px;
  }
  .family__add {
    grid-template-columns: 1fr;
    padding: 16px;
  }
  .family__add h3 {
    grid-column: auto;
  }
  .header__profile {
    max-width: 110px;
    font-size: 12px;
    padding: 8px;
  }
  .family-card__heroes img {
    height: 85px;
  }
  .family-card__title h3 {
    font-size: 22px;
  }
}

.family__table-wrap {
  overflow-x: auto;
}
.family__mistakes li span,
.family__mistakes li small {
  display: block;
}
.family__mistakes small,
.family__empty-report {
  color: #52758a;
  font-size: 14px;
}
.family__balance {
  margin-top: 12px;
}
.family-card h4 {
  margin: 20px 0 10px;
}
.family__table th:first-child {
  min-width: 110px;
}

@media (max-width: 700px) {
  .header {
    height: auto;
    min-height: 70px;
    flex-wrap: wrap;
  }
  .header__tools {
    flex-wrap: wrap;
    justify-content: flex-end;
    max-width: 100%;
  }
  .family-picker {
    flex: none;
  }
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .family__intro {
    font-size: 15px;
  }
}

/* Full-height shop characters on wide screens, readable catalogue between them. */
@media (min-width: 1100px) and (min-aspect-ratio: 3/2) {
  .dialog--shop {
    --shop-height: min(90dvh, calc((100vw - 560px) * 0.75));
    --shop-side: calc(var(--shop-height) * 2/3);
    width: min(1020px, calc(100vw - var(--shop-side) * 2 + 48px));
  }
  .dialog--shop .shop__scroll {
    max-height: calc(var(--shop-height) - 6px);
  }
  .shop__side {
    display: block;
    bottom: 0;
    width: var(--shop-side);
    height: 100%;
    max-width: none;
    object-fit: contain;
    object-position: center bottom;
  }
  .shop__side--vendor {
    left: calc(40px - var(--shop-side));
  }
  .shop__side--hero {
    right: calc(40px - var(--shop-side) * 0.72);
    width: calc(var(--shop-side) * 0.72);
    height: 72%;
  }
  .dialog--shop .shop__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (min-width: 1100px) and (max-aspect-ratio: 3/2) {
  .dialog--shop {
    width: min(1020px, calc(100% - 32px));
  }
  .shop__side {
    display: none;
  }
  .shop__portrait {
    display: block;
  }
}
/* The header contains the profile picker; the home scene remains a single row. */
.dialog--profiles {
  width: min(650px, calc(100% - 32px));
}
.dialog--profiles .family-picker__list {
  margin: 20px 0 26px;
}
.welcome {
  flex-wrap: nowrap;
}
.welcome__character {
  order: 0;
}
.welcome__panel {
  order: 1;
}
.welcome__friend {
  order: 2;
}
.welcome__panel .button {
  position: relative;
  justify-content: center;
  text-align: center;
  padding: 12px 82px;
  min-height: 80px;
}
.welcome__panel .button > img {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 58px;
  height: 58px;
}
.welcome__panel .button > span {
  display: block;
  width: 100%;
}
.family-card__actions {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 22px;
}
.family-card__actions button {
  padding: 6px 0;
  background: none;
  border: 0;
  text-decoration: underline;
  text-underline-offset: 4px;
  color: #a84a32;
}
.family__table {
  width: 100%;
  border-collapse: collapse;
}
.family__table th,
.family__table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid #c7e1e9;
}
.family__table th:first-child {
  min-width: 150px;
}
@media (max-width: 700px) {
  .welcome {
    flex-wrap: nowrap;
  }
  .welcome__panel .button {
    padding: 12px 64px;
    min-height: 70px;
  }
  .welcome__panel .button > img {
    left: 10px;
    width: 44px;
    height: 44px;
  }
  .family__table th,
  .family__table td {
    padding: 10px 8px;
  }
}

/* Pick a complete appearance by clicking the current profile character. */
.family-card__heroes .family-card__appearance {
  display: flex;
  width: min(100%, 260px);
  margin: 0;
  padding: 14px 18px;
  gap: 8px;
  background: #fff9df;
  border-color: #dfc46b;
}
.family-card__appearance img {
  width: 100px;
  height: 150px;
}
.family-card__appearance strong {
  font-size: 16px;
}
.family-card__appearance span {
  font-size: 15px;
  color: #166c9e;
  text-decoration: underline;
  text-underline-offset: 4px;
}
.dialog--appearance {
  width: min(950px, calc(100% - 32px));
}
.appearance__intro {
  line-height: 1.5;
  color: #527789;
  margin: 12px 0 20px;
}
.appearance__options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.appearance__option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 10px;
  border: 2px solid #bbdfe9;
  border-radius: 22px;
  background: linear-gradient(#fff, #eaf8fe);
  color: var(--ink);
  min-width: 0;
}
.appearance__option img {
  width: 120px;
  height: 180px;
  object-fit: contain;
}
.appearance__option strong {
  font-size: 15px;
  line-height: 1.35;
}
.appearance__option small {
  font-size: 13px;
  line-height: 1.35;
  color: #527789;
  overflow-wrap: anywhere;
}
.appearance__option[aria-pressed='true'] {
  border-color: #83b831;
  background: #eff9d8;
  box-shadow: inset 0 0 0 1px #83b831;
}
.appearance__option:hover {
  background: #fff6d4;
}
.shop__side--hero {
  transform: scaleX(-1);
}
@media (max-width: 700px) {
  .appearance__options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .appearance__option {
    padding: 10px 8px;
  }
  .appearance__option img {
    width: 100px;
    height: 150px;
  }
  .appearance__option strong {
    font-size: 14px;
  }
  .family-card__appearance img {
    height: 130px;
  }
}

.welcome__friend {
  transform: scaleX(-1);
}

/* The wallet stays visible while only the catalogue scrolls. */
.dialog--shop .shop__scroll {
  display: flex;
  flex-direction: column;
  height: calc(var(--shop-height, 90dvh) - 6px);
  max-height: calc(var(--shop-height, 90dvh) - 6px);
  padding: 0;
  overflow: hidden;
}
.shop__header {
  flex: 0 0 auto;
  padding: 24px 26px 12px;
  background: #fffef8;
  border-bottom: 1px solid #cbe2e8;
  box-shadow: 0 4px 12px #17455d0c;
  z-index: 1;
}
.shop__header .market-wallet {
  margin: 12px 0 0;
  gap: 7px;
}
.shop__header .wallet-chip {
  padding: 5px 8px;
  gap: 5px;
}
.shop__header .wallet-chip img {
  width: 28px;
  height: 28px;
}
.shop__header .wallet-chip b {
  font-size: 18px;
}
.shop__header .wallet-chip span {
  font-size: 13px;
}
.shop__catalog {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 18px 26px 26px;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
.dialog--shop .shop__close {
  position: relative;
  top: auto;
}
.shop__header .shop__intro {
  min-height: 0;
}
.shop__header .shop__intro p {
  margin-bottom: 0;
}
/* A chosen pet has its own place to the right of the exercise. */
.adventure[data-has-pet='true'] {
  grid-template-columns: 190px minmax(0, 1fr) 180px;
  max-width: 1640px;
}
.adventure__pet {
  grid-column: 3;
  grid-row: 1;
  align-self: end;
  justify-self: center;
  width: 100%;
  height: 240px;
  object-fit: contain;
  object-position: center bottom;
  margin-bottom: 16px;
  pointer-events: none;
  filter: drop-shadow(0 7px 7px #164b6135);
}
@media (max-width: 1399px) and (min-width: 1001px) {
  .adventure[data-has-pet='true'] {
    grid-template-columns: 150px minmax(0, 1fr) 130px;
    gap: 12px;
  }
  .adventure__pet {
    height: 190px;
  }
}
@media (max-width: 1000px) {
  .adventure[data-has-pet='true'] {
    grid-template-columns: minmax(0, 1fr);
  }
  .adventure__pet {
    grid-column: 1;
    grid-row: 2;
    justify-self: end;
    width: 140px;
    height: 180px;
    margin: 0 8px 0 0;
  }
}
@media (max-width: 700px) {
  .shop__header {
    padding: 16px 16px 12px;
  }
  .shop__catalog {
    padding: 14px 16px 18px;
  }
  .shop__header .wallet-chip {
    padding: 4px 6px;
  }
  .shop__header .wallet-chip img {
    width: 24px;
    height: 24px;
  }
  .shop__header .wallet-chip b {
    font-size: 17px;
  }
  .adventure__pet {
    width: 120px;
    height: 160px;
  }
}

/* The left character replaces the repeated instruction bubble. */
@media (min-width: 1001px) {
  .adventure {
    grid-template-columns: 280px minmax(0, 1fr);
  }
  .adventure[data-has-pet='true'] {
    grid-template-columns: 280px minmax(0, 1fr) 180px;
  }
  .mentor {
    height: 100%;
    min-height: 0;
    justify-content: flex-end;
  }
  .mentor__hero {
    position: absolute;
    bottom: 64px;
    left: 0;
    width: 100%;
    height: 75%;
    margin: 0;
    object-fit: contain;
    object-position: center bottom;
  }
  .mentor > .button {
    margin-bottom: 6px;
  }
}
@media (min-width: 1001px) and (max-width: 1399px) {
  .adventure {
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 12px;
  }
  .adventure[data-has-pet='true'] {
    grid-template-columns: 220px minmax(0, 1fr) 130px;
  }
}

/* Pet height uses the drawn hero as its reference, never exceeding 100%. */
.adventure {
  --pet-height: 140px;
  --pet-visible-width: 180px;
}
.adventure__pet-space {
  grid-column: 3;
  grid-row: 1;
  align-self: stretch;
  position: relative;
  min-width: 0;
  width: var(--pet-visible-width);
  overflow: hidden;
  pointer-events: none;
}
.adventure__pet {
  position: absolute;
  left: 0;
  bottom: 16px;
  width: auto;
  max-width: none;
  height: var(--pet-height);
  margin: 0;
  object-fit: contain;
  object-position: left bottom;
}
/* Separate reflection from transform so the success bounce preserves the direction. */
.adventure__pet[data-facing='right'] {
  scale: -1 1;
}
@media (min-width: 1001px) {
  .mentor {
    z-index: 2;
  }
  .mentor__hero {
    left: 55px;
    z-index: 5;
    pointer-events: none;
  }
}
@media (max-width: 1000px) {
  .adventure__pet-space {
    grid-column: 1;
    grid-row: 2;
    justify-self: end;
    width: min(240px, 100%);
    height: calc(var(--pet-height) + 24px);
  }
  .adventure__pet {
    bottom: 8px;
  }
}

/* Keep the shells usable when a large companion narrows the exercise panel. */
.game {
  container-type: inline-size;
}
@container (max-width:780px) {
  .game--addition .game__workspace {
    grid-template-columns: minmax(0, 1fr) 175px;
    gap: 12px;
  }
  .game--addition .game__objects {
    grid-column: 1;
    grid-row: 1;
  }
  .game--addition .split {
    grid-column: 1;
    grid-row: 2;
    display: grid;
    grid-template-columns: 1fr 140px;
    grid-template-rows: auto auto;
    column-gap: 12px;
    align-items: center;
    padding: 12px;
  }
  .game--addition .split > .eyebrow,
  .game--addition .split__branches {
    display: none;
  }
  .game--addition .split h2 {
    grid-column: 1;
    grid-row: 1;
  }
  .game--addition .split__number {
    grid-column: 1;
    grid-row: 2;
    font-size: 32px;
    margin: 0;
  }
  .game--addition .split__parts {
    grid-column: 2;
    grid-row: 1/3;
  }
  .game--addition .split__tip,
  .game--addition .split__proof {
    grid-column: 1/-1;
    font-size: 13px;
    margin-top: 8px;
  }
  .game--addition .answer-panel {
    grid-column: 2;
    grid-row: 1/3;
    align-content: center;
  }
  .game--addition .story {
    flex-wrap: wrap;
  }
  .game--addition .story__equation {
    width: 100%;
    text-align: center;
    margin: 0;
  }
}
@container (max-width:520px) {
  .game__workspace,
  .game--addition .game__workspace {
    grid-template-columns: minmax(0, 1fr);
  }
  .game--addition .game__objects,
  .game--addition .answer-panel,
  .game--addition .split {
    grid-column: auto;
    grid-row: auto;
  }
  .game--addition .split {
    display: flex;
  }
  .game__actions {
    flex-wrap: wrap;
  }
  .game__check {
    min-width: 100% !important;
  }
  .story {
    flex-wrap: wrap;
  }
  .story__equation {
    width: 100%;
    text-align: center;
    margin: 0;
  }
}

/* Mobile: larger touch controls, compact fixed shop header and one product per row. */
@media (max-width: 700px) {
  .header {
    height: auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
    padding-top: env(safe-area-inset-top, 0px);
  }
  .header__logo {
    width: 220px;
    max-width: 70%;
    align-self: center;
  }
  .header__logo img {
    display: block;
    height: 96px;
  }
  .header__tools {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto 44px minmax(0, 1.25fr);
    width: 100%;
    max-width: 480px;
    margin: 0;
    gap: 6px;
    align-items: center;
  }
  .header__profile {
    width: 100%;
    max-width: none;
    min-width: 0;
    min-height: 44px;
    font-size: 14px;
    padding: 8px;
  }
  .header__stars {
    min-width: 0;
    min-height: 44px;
    padding: 4px 7px;
    gap: 4px;
  }
  .header__tools .button {
    min-height: 44px;
    font-size: 13px;
    padding: 8px 6px;
  }
  .header__tools .header__market {
    min-height: 44px !important;
    width: 44px;
    padding: 6px !important;
  }
  .header__market img {
    width: 28px;
    height: 28px;
  }
  .market__heading {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    margin-bottom: 14px;
  }
  .market__heading > div:first-child {
    display: contents;
  }
  .market__heading .eyebrow {
    grid-column: 1;
    grid-row: 1;
    align-self: center;
    font-size: 10px;
    line-height: 1.5;
    letter-spacing: 0.7px;
  }
  .market__nav {
    grid-column: 2;
    grid-row: 1;
    margin: 0;
    gap: 6px;
  }
  .market__nav .button {
    min-height: 44px;
    font-size: 14px;
    padding: 8px 10px;
  }
  .market__nav .game__exit {
    width: 44px;
    height: 44px;
    flex-basis: 44px;
  }
  .market__heading h1 {
    grid-column: 1/-1;
    grid-row: 2;
    font-size: 27px;
    margin: 0;
  }
  .market__heading p {
    grid-column: 1/-1;
    grid-row: 3;
    margin: 0;
  }
  .dialog--shop {
    width: calc(100% - 16px);
    border-radius: 24px;
    padding: 0;
  }
  .dialog--shop .shop__scroll {
    height: calc(100dvh - 32px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    max-height: 820px;
  }
  .shop__header {
    display: grid;
    grid-template-columns: 80px minmax(0, 1fr);
    column-gap: 12px;
    row-gap: 6px;
    padding: 12px;
    min-width: 0;
  }
  .dialog--shop .shop__close {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    float: none;
    margin: 0;
    min-height: 44px;
    padding: 8px 12px;
  }
  .shop__header .shop__intro {
    display: contents;
  }
  .shop__header .shop__intro > .shop__portrait {
    display: block;
    grid-column: 1;
    grid-row: 1/3;
    width: 80px;
    height: 150px;
    align-self: center;
    object-fit: contain;
  }
  .shop__intro > div {
    grid-column: 2;
    grid-row: 2;
    min-width: 0;
  }
  .shop__intro .eyebrow {
    display: none;
  }
  .shop__intro h2 {
    font-size: 22px;
    line-height: 1.2;
    margin: 0 0 6px;
    overflow-wrap: anywhere;
  }
  .shop__intro p {
    font-size: 13px;
    line-height: 1.4;
  }
  .shop__header .market-wallet {
    grid-column: 1/-1;
    grid-row: 3;
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    max-width: 100%;
    margin: 6px 0 0;
    padding: 2px 0 6px;
    overscroll-behavior-x: contain;
  }
  .shop__header .wallet-chip {
    flex: 0 0 auto;
    min-height: 36px;
  }
  .shop__header .wallet-chip span {
    display: none;
  }
  .shop__catalog {
    padding: 12px 12px calc(18px + env(safe-area-inset-bottom, 0px));
    scrollbar-gutter: auto;
  }
  .shop__grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }
  .shop-card {
    padding: 16px;
    gap: 10px;
  }
  .shop-card__art {
    height: 130px;
  }
  .shop-card__art img {
    width: 160px;
    height: 124px;
  }
  .shop-card h3 {
    font-size: 20px;
  }
  .shop-card__type {
    font-size: 12px;
  }
  .shop-card .button {
    min-height: 46px;
    font-size: 16px;
    padding: 12px;
  }
  .price-chip {
    padding: 6px 9px;
    gap: 5px;
  }
  .shop__footer .button {
    min-height: 44px;
  }
}
/* Both companions sit below the exercise; the hero remains visible without a pet. */
@media (max-width: 1000px) {
  .adventure,
  .adventure[data-has-pet='true'] {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: end;
    column-gap: 8px;
    row-gap: 12px;
  }
  .adventure > .game {
    grid-column: 1/-1;
    grid-row: 1;
    min-width: 0;
  }
  .mentor {
    display: flex;
    grid-column: 1;
    grid-row: 2;
    height: auto;
    min-width: 0;
    align-self: end;
    justify-content: flex-end;
  }
  .mentor__hero {
    position: static;
    width: 100%;
    height: 260px;
    max-height: 38dvh;
    object-fit: contain;
    object-position: center bottom;
    margin: 0 0 8px;
    pointer-events: none;
  }
  .mentor > .button {
    min-height: 44px;
    max-width: 100%;
    font-size: 14px;
    margin: 0;
  }
  .adventure__pet-space {
    grid-column: 2;
    grid-row: 2;
    align-self: end;
    justify-self: stretch;
    width: 100%;
    height: calc(var(--pet-height) + 52px);
  }
  .adventure__pet {
    left: 0;
    right: auto;
    bottom: 52px;
    height: var(--pet-height);
    width: auto;
    max-width: none;
  }
}
@media (max-width: 700px) {
  .keypad__key {
    min-height: 44px;
  }
  .market__directory button {
    min-height: 48px;
  }
}
@media (hover: none) {
  .button:hover:not(:disabled) {
    filter: none;
    transform: none;
  }
  .button:active:not(:disabled) {
    transform: translateY(3px);
  }
  .header__logo:hover,
  .game__exit:hover {
    transform: none;
  }
}
/* Prevent accidental selection while playing; editable fields keep normal editing. */
body,
body * {
  -webkit-user-select: none;
  user-select: none;
}
input,
textarea,
[contenteditable='true'],
[contenteditable='true'] * {
  -webkit-user-select: text;
  user-select: text;
}
img {
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
}
button {
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

@media (max-width: 700px) and (max-height: 500px) {
  .shop__header {
    grid-template-columns: 60px minmax(0, 1fr);
    padding: 8px 12px;
    row-gap: 2px;
  }
  .shop__header .shop__intro > .shop__portrait {
    width: 60px;
    height: 86px;
  }
  .shop__intro p {
    display: none;
  }
  .shop__intro h2 {
    font-size: 20px;
    margin-bottom: 0;
  }
  .dialog--shop .shop__close {
    min-height: 40px;
  }
  .shop__header .market-wallet {
    margin-top: 3px;
  }
  .dialog--shop .shop__scroll {
    height: calc(100dvh - 16px);
  }
}

/* Voice controls stay outside the arithmetic workspace. */
.voice-repeat {
  display: block;
  margin: 0 0 12px auto;
  border: 1px solid #9ed9ea;
  border-radius: 18px;
  background: #fff;
  color: #125779;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  padding: 10px 16px;
  min-height: 44px;
  cursor: pointer;
}
.voice-repeat:focus-visible {
  outline: 3px solid #21a9d2;
  outline-offset: 3px;
}
.dialog--sound {
  max-width: 520px;
}
.sound-setting {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0 12px;
  font-weight: 700;
}
.sound-setting input {
  width: 24px;
  height: 24px;
}
.sound-setting output {
  margin-left: auto;
}
#voice-volume {
  width: 100%;
  min-height: 44px;
  margin-bottom: 20px;
  accent-color: #128cbd;
}
@media (max-width: 700px) {
  .header__tools {
    grid-template-columns: minmax(75px, 1fr) minmax(50px, 0.7fr) 44px minmax(88px, 1.1fr) 44px;
    gap: 5px;
  }
  .header__tools .header__sound {
    font-size: 12px;
    padding: 6px 3px;
  }
  .voice-repeat {
    font-size: 14px;
    margin-bottom: 10px;
    padding: 8px 12px;
  }
}
@media (max-width: 380px) {
  .header__tools {
    grid-template-columns: minmax(70px, 1fr) minmax(50px, 0.8fr) 44px 44px;
  }
  .header__tools > [data-action='parent'] {
    grid-column: 1/-1;
    grid-row: 2;
  }
  .header__tools > .header__sound {
    grid-column: 4;
    grid-row: 1;
  }
}

/* Reserve the quick-action slot so typing does not resize the split panel. */
.split__quick-action {
  width: 100%;
  min-height: 62px;
  flex-shrink: 0;
  grid-column: 1/-1;
  align-self: end;
  padding-top: 12px;
  margin-top: auto;
}
.split__quick-action .button {
  width: 100%;
  min-height: 48px;
  padding: 10px 8px;
  font-size: 15px;
  line-height: 1.2;
}

.help__controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.dialog--help .help__controls .dialog__close {
  float: none;
  margin: 0;
  min-height: 44px;
}
.help__controls .button {
  min-height: 44px;
}
.help__general section {
  margin: 20px 0;
}
.help__general h3 {
  font-size: 19px;
  margin-bottom: 6px;
}
.help__general p {
  line-height: 1.6;
}
.help__audio-note {
  font-size: 14px;
  color: #52768a;
}
.dialog--help .help__controls .dialog__close {
  width: 44px;
  height: 44px;
  padding: 0;
  font-size: 28px;
  line-height: 1;
}

.answer-panel__quick-action {
  grid-column: 1/-1;
  justify-self: stretch;
  align-self: end;
  min-height: 62px;
  padding-top: 10px;
}
.answer-panel__quick-action .button {
  width: 100%;
  min-height: 48px;
  font-size: 15px;
  padding: 10px 8px;
}
.finish__actions .button {
  min-height: 70px;
  position: relative;
  padding-left: 72px;
  padding-right: 20px;
}
.finish__actions .button img {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 48px;
  pointer-events: none;
}
@media (max-width: 700px) {
  .answer-panel__quick-action {
    grid-row: 3;
  }
  .finish__actions .button {
    font-size: 17px;
    min-height: 68px;
  }
}

/* School island and permanent achievements. */
.islands__cards {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.island-card h2 {
  overflow-wrap: anywhere;
}
.school {
  max-width: 1240px;
  margin: auto;
}
.school__panel {
  padding: 28px;
}
.school__heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}
.school__heading h1 {
  margin: 8px 0 12px;
}
.school__heading p {
  line-height: 1.5;
  color: #52768a;
}
.school__tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 24px 0 18px;
}
.school__tabs button {
  min-height: 60px;
  padding: 12px 10px;
  border: 2px solid #abd8e8;
  border-radius: 18px;
  background: #f1fbff;
  font-weight: 900;
  color: #165274;
}
.school__tabs button[aria-selected='true'] {
  background: #ffe59a;
  border-color: #e8b338;
  box-shadow: 0 4px 0 #cd9a22;
}
.school__toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.school__toolbar label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}
.school__toolbar select {
  min-height: 44px;
  border: 1px solid #9ecbdf;
  border-radius: 12px;
  padding: 8px;
  background: #fff;
  color: #164768;
}
.school__toolbar > span {
  margin-right: auto;
  font-weight: 800;
}
.school__task {
  min-height: 390px;
  background: #fffdf4;
  border: 2px solid #c1e2eb;
  border-radius: 24px;
  padding: 24px;
  text-align: center;
}
.school__instruction {
  max-width: 750px;
  margin: 10px auto 20px;
  line-height: 1.5;
}
.school__equation {
  font-size: clamp(34px, 5vw, 54px);
  font-weight: 900;
  color: #14496a;
  margin: 12px 0 24px;
}
.school__scheme {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-bottom: 20px;
}
.school__scheme input {
  width: 80px;
  height: 64px;
}
.school__answer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  font-weight: 900;
  margin: 20px auto;
  flex-wrap: wrap;
}
.school__answer input {
  height: 70px;
  width: 115px;
  font-size: 40px;
}
.school__keypad {
  margin: 18px auto;
  max-width: 260px;
}
.school__keypad button {
  min-height: 44px;
}
.school__choices {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 16px;
  margin: 20px 0;
}
.school-choice {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  justify-content: center;
  border: 3px solid #a7d6e8;
  background: #f0fbff;
  border-radius: 20px;
  min-width: 150px;
  min-height: 130px;
  padding: 18px;
  font-size: 24px;
}
.school-choice span {
  color: #558196;
  font-size: 19px;
}
.school-choice--selected,
.school-error--selected {
  background: #fff0b9 !important;
  border-color: #db9a24 !important;
  box-shadow: 0 0 0 3px #ffe28c;
}
.school__errors {
  display: grid;
  gap: 14px;
  max-width: 540px;
  margin: 20px auto;
}
.school-error {
  min-height: 64px;
  border: 3px solid #b2dbe7;
  background: #f5fcff;
  border-radius: 16px;
  font-size: 26px;
  padding: 12px;
}
.school-error strong {
  display: inline-block;
  color: #a2477d;
  padding: 0 8px;
  background: #fff2f7;
  border-radius: 8px;
}
.school__hint,
.school__proof {
  max-width: 720px;
  margin: 18px auto 0;
  padding: 16px;
  border-radius: 16px;
  background: #fff0c6;
  line-height: 1.5;
}
.school__proof {
  background: #e8f6cf;
  color: #467115;
}
.school__actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
}
.school__actions > [data-school-check],
.school__actions > [data-school-next] {
  margin-left: auto;
}
.school .feedback {
  margin-top: 18px;
}
.school input[data-result='retry'] {
  background: #fff0eb;
  border-color: #db8274;
}
.school input[data-result='correct'] {
  background: #eff9dd;
  border-color: #8bb948;
}
.school input:focus-visible {
  outline: 3px solid #28a9ce;
  outline-offset: 3px;
}
.dialog--achievements {
  width: min(1040px, calc(100% - 24px));
}
.achievements__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin: 24px 0;
}
.achievement-card {
  border: 2px dashed #bfdce6;
  border-radius: 22px;
  padding: 20px;
  text-align: center;
  background: #f2f7f9;
}
.achievement-card img {
  width: 100px;
  height: 100px;
  filter: grayscale(1);
  opacity: 0.45;
}
.achievement-card h3 {
  margin: 12px 0 8px;
}
.achievement-card p {
  font-size: 15px;
  line-height: 1.5;
}
.achievement-card strong {
  font-size: 14px;
  color: #6d8490;
}
.achievement-card--earned {
  background: #fff8dc;
  border: 2px solid #e8bd54;
}
.achievement-card--earned img {
  filter: none;
  opacity: 1;
}
.achievement-card--earned strong {
  color: #518321;
}
.achievement-notice {
  position: fixed;
  bottom: 22px;
  right: 22px;
  max-width: min(430px, calc(100vw - 32px));
  z-index: 50;
}
.achievement-notice .button {
  font-size: 16px;
  line-height: 1.4;
}
.dialog--diploma {
  width: min(850px, calc(100% - 24px));
}
.diploma__controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.diploma__controls .dialog__close {
  float: none;
  margin: 0;
}
.diploma {
  border: 5px double #dcae39;
  border-radius: 22px;
  padding: 30px;
  text-align: center;
  background: #fffdf2;
}
.diploma > img {
  display: block;
  margin: auto;
}
.diploma h2 {
  font-size: 42px;
  color: #b07713;
  margin: 14px 0;
}
.diploma h3 {
  font-size: 32px;
  margin-bottom: 18px;
  overflow-wrap: anywhere;
}
.diploma__friends {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 30px;
  margin: 20px;
}
.diploma__friends img {
  object-fit: contain;
}
.diploma time {
  color: #657a84;
}
@media (max-width: 1100px) {
  .islands__cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 700px) {
  .school__panel {
    padding: 16px;
  }
  .school__tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .school__tabs button {
    min-height: 56px;
    font-size: 14px;
  }
  .school__task {
    padding: 16px;
    min-height: 360px;
  }
  .school__toolbar {
    gap: 10px;
  }
  .school__toolbar .button {
    flex: 1;
    font-size: 14px;
  }
  .school__toolbar label {
    flex: 1;
  }
  .school__heading h1 {
    font-size: 28px;
  }
  .school__actions .button {
    flex: 1;
    min-width: 135px;
    font-size: 15px;
  }
  .school__actions > [data-school-check],
  .school__actions > [data-school-next] {
    margin-left: 0;
  }
  .school-choice {
    min-width: 100px;
    flex: 1;
    min-height: 110px;
    padding: 10px;
    font-size: 21px;
  }
  .school-error {
    font-size: 22px;
  }
  .school__keypad {
    max-width: 260px;
  }
  .achievements__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .achievement-card {
    padding: 14px 10px;
  }
  .achievement-card h3 {
    font-size: 17px;
  }
  .achievement-card p {
    font-size: 13px;
  }
  .achievement-card img {
    width: 80px;
    height: 80px;
  }
  .diploma {
    padding: 18px;
  }
  .diploma h2 {
    font-size: 32px;
  }
  .diploma h3 {
    font-size: 26px;
  }
  .market__nav > [data-action='achievements'] {
    width: 44px;
    padding: 6px;
  }
  .market__nav > [data-action='achievements'] span {
    display: none;
  }
}
@media (max-width: 600px) {
  .islands__cards {
    grid-template-columns: minmax(0, 1fr);
  }
}
@media print {
  body:has([data-dialog='diploma'][open]) {
    position: static !important;
    background: white !important;
  }
  body:has([data-dialog='diploma'][open]) > *:not([data-dialog='diploma']) {
    display: none !important;
  }
  dialog[data-dialog='diploma'][open] {
    position: static !important;
    display: block !important;
    width: 100% !important;
    max-width: none !important;
    max-height: none !important;
    overflow: visible !important;
    border: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    background: white !important;
  }
  dialog[data-dialog='diploma']::backdrop {
    display: none !important;
  }
  .diploma__controls {
    display: none !important;
  }
  .diploma {
    break-inside: avoid;
  }
  .diploma img {
    print-color-adjust: exact;
  }
  .diploma {
    print-color-adjust: exact;
  }
}

.school__character {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 16px auto;
  color: #54778a;
  font-weight: 700;
}
.school__character img {
  width: 90px;
  height: 80px;
  flex-shrink: 0;
}
.school__character span {
  max-width: 280px;
  text-align: left;
}

#effects-volume,
#music-volume {
  width: 100%;
  min-height: 44px;
  margin-bottom: 12px;
  accent-color: #128cbd;
}

/* One-tap master mute beside sound settings. */
.header__sound {
  display: flex;
  align-items: center;
  gap: 6px;
}
.header__mute {
  width: 48px;
  min-width: 48px;
  min-height: 48px;
  padding: 8px;
}
.header__mute svg {
  display: block;
  flex-shrink: 0;
}
.header__sound-cross {
  display: none;
}
.header__mute[data-muted='true'] .header__sound-cross {
  display: block;
}
.header__mute[data-muted='true'] .header__sound-waves {
  display: none;
}
.header__mute[data-muted='true'] {
  background: #fff0da;
  color: #94521b;
}
@media (max-width: 700px) {
  .header__tools {
    grid-template-columns: minmax(65px, 1fr) minmax(45px, 0.7fr) 44px minmax(80px, 1.1fr) 88px;
  }
  .header__tools .header__sound {
    padding: 0;
    gap: 3px;
  }
  .header__sound > .button {
    min-width: 0;
    min-height: 44px;
    padding: 6px 3px;
    font-size: 12px;
  }
  .header__sound > [data-action='sound'] {
    flex: 1;
  }
  .header__sound > .header__mute {
    width: 44px;
    min-width: 44px;
    padding: 8px;
  }
  .header__mute svg {
    width: 22px;
    height: 22px;
  }
}
@media (max-width: 380px) {
  .header__tools {
    grid-template-columns: minmax(65px, 1fr) minmax(45px, 0.8fr) 44px 88px;
  }
}

/* Keep school entry close to its description instead of pushing it to the card bottom. */
.island-card .button[data-action='school'] {
  margin-top: 8px;
}
