:root {
  --sky: #4db8ff;
  --sun: #ffe066;
  --leaf: #7fd67f;
  --coral: #ff8fa3;
  --plum: #8a6cff;
  --teal: #3cc9b0;
  --orange: #ffb84d;
  --stone: #c9bfae;
  --snow: #ffffff;
  --cream: #fff8e7;
  --ink: #2f2a24;
  --ink-soft: #6b5e4e;
  --shadow: 0 6px 0 rgba(47, 42, 36, 0.18);
  --radius: 18px;
  --tone: var(--sky);
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: 'Nunito', 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #cfebff 0%, #eaf7ff 55%, var(--cream) 100%);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 200%;
  height: 35vh;
  background: radial-gradient(circle at 10% 20%, rgba(255,255,255,0.75) 120px, transparent 121px),
              radial-gradient(circle at 18% 28%, rgba(255,255,255,0.85) 80px, transparent 81px),
              radial-gradient(circle at 45% 15%, rgba(255,255,255,0.7) 140px, transparent 141px),
              radial-gradient(circle at 55% 25%, rgba(255,255,255,0.9) 90px, transparent 91px),
              radial-gradient(circle at 82% 20%, rgba(255,255,255,0.75) 110px, transparent 111px);
  background-size: 50% 100%;
  opacity: 0.45;
  pointer-events: none;
  z-index: -1;
  animation: cloud-drift 120s linear infinite;
}

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

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  z-index: 50;
  background: var(--snow);
  padding: 0.6rem 1rem;
  border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus {
  left: 0;
}

/* Every interactive control gets a visible focus ring: this game is meant to
   be fully playable from a keyboard, not merely reachable by one. */
:focus-visible {
  outline: 4px solid var(--plum);
  outline-offset: 3px;
}

/* ---- app shell ---------------------------------------------------------- */

/* The shared `.ppgh` header sits above this and flexes #app into the remaining
   space (see /shared/game-header.css), so #app must not claim a viewport of its
   own — that would push a header's height of overflow onto every screen. */
#app {
  display: flex;
  flex-direction: column;
  min-height: 0;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 0 env(safe-area-inset-bottom);
}

#particles {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 40;
}

.hud {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.8rem;
  flex-wrap: wrap;
}

.hud-score {
  display: flex;
  gap: 0.4rem;
  flex: 1;
  justify-content: center;
  flex-wrap: wrap;
}

.hud-chip {
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 0.25rem 0.8rem;
  font-weight: 800;
  font-size: 0.95rem;
  box-shadow: 0 4px 0 var(--ink);
  white-space: nowrap;
  transition: transform 150ms ease;
}
.hud-chip:hover {
  transform: translateY(-2px);
}

.hud-actions {
  display: flex;
  gap: 0.4rem;
}

.hud-button {
  font: inherit;
  font-weight: 800;
  border: 3px solid var(--ink);
  background: var(--snow);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  min-height: 46px;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--ink);
  transition: transform 100ms ease, box-shadow 100ms ease, background-color 200ms ease;
  position: relative;
  top: 0;
}
.hud-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 var(--ink);
  background-color: var(--cream);
}
.hud-button:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--ink);
}

.progress-bar {
  height: 12px;
  margin: 0 0.8rem 0.5rem;
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(4px);
  border: 2px solid var(--ink);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}
.progress-fill {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--leaf) 0%, #5cb85c 100%);
  transition: width 320ms ease;
}

.screen {
  flex: 1;
  padding: 0 0.8rem 2rem;
}

.screen-heading {
  font-size: clamp(1.4rem, 5vw, 2rem);
  margin: 0.2rem 0;
  text-align: center;
  font-weight: 900;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.8);
}
.screen-blurb {
  margin: 0 0 1rem;
  text-align: center;
  color: var(--ink-soft);
  font-weight: 700;
}

.primary-button,
.ghost-button {
  font: inherit;
  font-weight: 800;
  font-size: 1.05rem;
  border-radius: var(--radius);
  border: 3px solid var(--ink);
  padding: 0.7rem 1.4rem;
  min-height: 52px;
  cursor: pointer;
  box-shadow: 0 6px 0 var(--ink);
  transition: transform 120ms cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 120ms cubic-bezier(0.34, 1.56, 0.64, 1), background-color 200ms ease;
  position: relative;
}
.primary-button {
  background: linear-gradient(135deg, var(--sun) 0%, #ffcc00 100%);
  color: var(--ink);
}
.primary-button:hover {
  transform: translateY(-3px);
  box-shadow: 0 9px 0 var(--ink);
  background: linear-gradient(135deg, #ffe680 0%, #ffd633 100%);
}
.primary-button:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 var(--ink);
}
.ghost-button {
  background: var(--snow);
}
.ghost-button:hover {
  transform: translateY(-3px);
  box-shadow: 0 9px 0 var(--ink);
  background: var(--cream);
}
.ghost-button.danger {
  background: #ffe1e6;
}
.ghost-button.danger:hover {
  background: #ffd1d8;
}
.ghost-button:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 var(--ink);
}
button[disabled] {
  opacity: 0.55;
  cursor: default;
  transform: none !important;
  box-shadow: 0 6px 0 var(--ink) !important;
}

/* ---- world map ---------------------------------------------------------- */

.map-hero {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  justify-content: center;
  text-align: left;
}
.map-hero h2 {
  font-size: clamp(1.3rem, 5vw, 2rem);
  margin: 0;
}
.map-hero p {
  margin: 0;
  color: var(--ink-soft);
}

.mountain {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 62vh;
  margin: 0.8rem 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 4px solid var(--ink);
  box-shadow: var(--shadow);
}
.mountain-picture {
  display: block;
}

/* `cover` rather than the old stretched SVG: the art is composed per aspect,
   so cropping a little is right and distorting it is not. */
.mountain-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.area-node {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  min-width: 84px;
  max-width: 132px;
  padding: 0.4rem 0.5rem;
  font: inherit;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: var(--snow);
  cursor: pointer;
  box-shadow: 0 5px 0 var(--ink);
  transition: transform 120ms cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 120ms cubic-bezier(0.34, 1.56, 0.64, 1), background-color 200ms ease;
}
.area-node.is-locked {
  background: #e9e4da;
  transform: translate(-50%, -50%) !important;
  box-shadow: 0 3px 0 var(--ink) !important;
  cursor: default;
}
.area-emoji {
  font-size: 1.5rem;
  line-height: 1;
  transition: transform 200ms ease;
}
.area-node:hover:not(.is-locked) .area-emoji {
  transform: scale(1.2);
}
.area-label {
  font-weight: 800;
  font-size: 0.8rem;
  text-align: center;
  line-height: 1.1;
}
.area-status {
  font-size: 0.65rem;
  color: var(--ink-soft);
  text-align: center;
  line-height: 1.1;
}

.tone-sky { --tone: var(--sky); }
.tone-sun { --tone: var(--sun); }
.tone-leaf { --tone: var(--leaf); }
.tone-coral { --tone: var(--coral); }
.tone-plum { --tone: var(--plum); }
.tone-teal { --tone: var(--teal); }
.tone-orange { --tone: var(--orange); }
.tone-stone { --tone: var(--stone); }

.area-node:not(.is-locked) {
  background: color-mix(in srgb, var(--tone) 25%, rgba(255, 255, 255, 0.8));
  backdrop-filter: blur(4px);
}
.area-node:hover:not(.is-locked) {
  transform: translate(-50%, -55%);
  box-shadow: 0 8px 0 var(--ink);
  background: color-mix(in srgb, var(--tone) 35%, rgba(255, 255, 255, 0.95));
}
.area-node:active:not(.is-locked) {
  transform: translate(-50%, -46%);
  box-shadow: 0 2px 0 var(--ink);
}

.daily-button {
  display: block;
  margin: 0.5rem auto 0;
}

/* ---- area / level list -------------------------------------------------- */

.world-section {
  background: var(--snow);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  padding: 0.8rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
  border-top: 10px solid var(--tone);
}
.world-heading {
  margin: 0 0 0.2rem;
  font-size: 1.15rem;
}
.world-blurb {
  margin: 0 0 0.7rem;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.6rem;
}
.level-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  font: inherit;
  padding: 0.6rem 0.4rem;
  min-height: 96px;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: color-mix(in srgb, var(--tone) 18%, rgba(255, 255, 255, 0.65));
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  cursor: pointer;
  box-shadow: 0 5px 0 var(--ink);
  transition: transform 120ms cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 120ms cubic-bezier(0.34, 1.56, 0.64, 1), background-color 200ms ease;
}
.level-card.is-locked {
  background: #ece7dd;
  box-shadow: 0 3px 0 var(--ink) !important;
  transform: none !important;
  cursor: default;
}
.level-card:hover:not(.is-locked) {
  transform: translateY(-4px);
  box-shadow: 0 9px 0 var(--ink);
  background: color-mix(in srgb, var(--tone) 25%, rgba(255, 255, 255, 0.85));
}
.level-card:active:not(.is-locked) {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--ink);
}
.level-number {
  font-weight: 900;
  font-size: 1.3rem;
}
.level-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.15;
}
.level-stars {
  color: var(--orange);
  letter-spacing: 2px;
}

/* ---- play screen -------------------------------------------------------- */

.play-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.play-title {
  font-size: clamp(1.1rem, 4.4vw, 1.6rem);
  margin: 0.2rem 0;
}
.tier-badge {
  background: var(--snow);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 800;
}
.play-timer {
  font-weight: 900;
  background: var(--snow);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
}
.play-timer.is-low {
  background: #ffe1e6;
}

.play-prompt {
  text-align: center;
  font-size: clamp(1.05rem, 4vw, 1.35rem);
  font-weight: 800;
  margin: 0.5rem 0;
}
.play-subprompt {
  text-align: center;
  color: var(--ink-soft);
  font-weight: 700;
  margin: 0.4rem 0;
}

.play-board {
  position: relative;
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  padding: 0.8rem;
  min-height: 180px;
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.4), 0 8px 30px rgba(47, 42, 36, 0.06);
}

.play-tray {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.8rem 0;
}

.answer-host {
  padding-top: 0.6rem;
}

/* ---- size sort ---------------------------------------------------------- */

.sort-board {
  display: flex;
  gap: 0.8rem;
  justify-content: center;
  flex-wrap: wrap;
}
.basket {
  flex: 1 1 140px;
  max-width: 260px;
  min-height: 150px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  border: 4px dashed var(--ink);
  border-radius: var(--radius);
  background: var(--cream);
}
.basket.drop-near {
  background: color-mix(in srgb, var(--leaf) 40%, var(--cream));
  border-style: solid;
}
.basket-label {
  font-weight: 900;
  font-size: 1.25rem;
}
.basket-count {
  font-weight: 800;
  color: var(--ink-soft);
}
.sort-piece {
  touch-action: none;
  cursor: grab;
  background: var(--snow);
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 0.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sort-piece.selected {
  outline: 4px solid var(--plum);
}
.sort-piece.dragging {
  cursor: grabbing;
}

/* ---- measuring stage ---------------------------------------------------- */

.measure-stage {
  overflow-x: auto;
}
.measure-track {
  position: relative;
  padding: 0.5rem 0 4.6rem;
  min-height: 170px;
}
.measure-object {
  display: block;
  line-height: 0;
}
.measure-object svg {
  display: block;
}
.measure-start-mark {
  position: absolute;
  left: -2px;
  top: 0;
  bottom: 3.4rem;
  width: 4px;
  border-radius: 2px;
  background: var(--coral);
}

.instrument-wrap {
  position: absolute;
  left: 0;
  bottom: 0.4rem;
  touch-action: none;
  cursor: grab;
  line-height: 0;
  filter: drop-shadow(0 3px 0 rgba(47, 42, 36, 0.25));
}
.instrument-wrap.dragging {
  cursor: grabbing;
}
.instrument-wrap.is-aligned {
  filter: drop-shadow(0 0 0 rgba(0, 0, 0, 0)) drop-shadow(0 0 8px var(--leaf));
}
.instrument-readout {
  position: absolute;
  right: -6px;
  top: -1.7rem;
  background: var(--snow);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
  font-size: 0.9rem;
  font-weight: 900;
  line-height: 1.5;
}
.instrument-readout:empty {
  display: none;
}
.instrument svg,
.instrument {
  display: block;
}

/* ---- choices ------------------------------------------------------------ */

.choice-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
}
.choice-card {
  font: inherit;
  font-weight: 800;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  min-width: 96px;
  min-height: 60px;
  padding: 0.6rem 1rem;
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
  box-shadow: 0 5px 0 var(--ink);
  transition: transform 120ms cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 120ms cubic-bezier(0.34, 1.56, 0.64, 1), background-color 200ms ease;
}
.number-choices .choice-card {
  font-size: 1.25rem;
}
.choice-card:hover:not(.is-dimmed) {
  transform: translateY(-3px);
  box-shadow: 0 8px 0 var(--ink);
  background: rgba(255, 255, 255, 0.9);
}
.choice-card:active:not(.is-dimmed) {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--ink);
}
.choice-card.is-correct {
  background: color-mix(in srgb, var(--leaf) 75%, rgba(255,255,255,0.7)) !important;
}
.choice-card.is-wrong {
  background: #ffe1e6 !important;
}
.choice-card.is-guess {
  background: color-mix(in srgb, var(--sun) 75%, rgba(255,255,255,0.7)) !important;
}
.choice-card.is-dimmed {
  opacity: 0.4;
  cursor: default;
  transform: none !important;
  box-shadow: 0 5px 0 var(--ink) !important;
}
.choice-art {
  line-height: 0;
}

.tool-stage {
  display: flex;
  justify-content: center;
}
.tool-subject {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}
.tool-subject-label {
  font-weight: 800;
  font-size: 1.1rem;
}

/* ---- compare ------------------------------------------------------------ */

.compare-stage {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}
.compare-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font: inherit;
  text-align: left;
  padding: 0.6rem;
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  background: var(--snow);
  cursor: pointer;
  box-shadow: var(--shadow);
  overflow-x: auto;
}
.compare-label {
  font-weight: 800;
  min-width: 5.5rem;
  flex-shrink: 0;
}
.compare-art {
  line-height: 0;
}
.compare-row.is-correct {
  background: color-mix(in srgb, var(--leaf) 45%, var(--snow));
}
.compare-row.is-wrong {
  background: #ffe1e6;
}

/* ---- weight ------------------------------------------------------------- */

.weight-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}
.scale-host {
  line-height: 0;
}
.pan-drop {
  width: min(100%, 380px);
  min-height: 96px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 4px dashed var(--ink);
  border-radius: var(--radius);
  background: var(--cream);
  padding: 0.4rem;
}
.pan-drop.drop-near {
  background: color-mix(in srgb, var(--teal) 35%, var(--cream));
  border-style: solid;
}
.weight-piece {
  touch-action: none;
  cursor: grab;
  line-height: 0;
}
.weight-piece.selected {
  outline: 4px solid var(--plum);
  border-radius: 10px;
}
.check-button {
  display: block;
  margin: 0.6rem auto 0;
}

/* ---- celebrate ---------------------------------------------------------- */

.celebrate-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  text-align: center;
}
.celebrate-stars {
  display: flex;
  gap: 0.4rem;
}
.celebrate-tally {
  font-weight: 800;
  font-size: 1.05rem;
}
.reward-card {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--snow);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  padding: 0.5rem 0.9rem;
  font-weight: 800;
  box-shadow: var(--shadow);
}
.celebrate-streak {
  font-weight: 800;
  color: var(--ink-soft);
}
.celebrate-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 0.4rem;
}

/* ---- parents & settings ------------------------------------------------- */

.parents-screen,
.settings-screen {
  max-width: 720px;
  margin: 0 auto;
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.6rem;
  margin-bottom: 1rem;
}
.stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--snow);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  padding: 0.6rem;
}
.stat-card strong {
  font-size: 1.5rem;
}
.stat-card span {
  font-size: 0.8rem;
  color: var(--ink-soft);
  text-align: center;
}

.parents-section {
  background: var(--snow);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  padding: 0.8rem;
  margin-bottom: 1rem;
}
.parents-section h2 {
  margin: 0 0 0.6rem;
  font-size: 1.1rem;
}
.topic-row {
  display: grid;
  grid-template-columns: 8rem 1fr auto;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
  font-size: 0.85rem;
}
.topic-label {
  font-weight: 700;
}
.topic-meter {
  height: 12px;
  background: #ece7dd;
  border-radius: 999px;
  overflow: hidden;
}
.topic-fill {
  display: block;
  height: 100%;
  background: var(--orange);
}
.topic-fill.is-strong {
  background: var(--leaf);
}
.topic-value {
  color: var(--ink-soft);
  white-space: nowrap;
}
.parents-suggestion {
  margin: 0.8rem 0 0;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.sticker-shelf,
.badge-shelf {
  display: grid;
  gap: 0.5rem;
}
.sticker-shelf {
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  margin-bottom: 0.8rem;
}
.badge-shelf {
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}
.sticker-cell,
.badge-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.4rem;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: var(--cream);
}
.badge-cell small {
  font-weight: 500;
  color: var(--ink-soft);
}
.sticker-cell.is-locked,
.badge-cell.is-locked {
  opacity: 0.4;
  filter: grayscale(1);
}

.mystery-section {
  display: flex;
  justify-content: center;
}
.mystery-box-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  font: inherit;
  font-weight: 800;
  padding: 0.7rem 1.2rem;
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  background: var(--sun);
  cursor: pointer;
  box-shadow: var(--shadow);
  margin: 1rem auto 0;
}

.parents-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.pin-gate {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  align-items: center;
}
.pin-gate input {
  font: inherit;
  font-size: 1.4rem;
  text-align: center;
  letter-spacing: 0.4rem;
  width: 8rem;
  padding: 0.4rem;
  border: 3px solid var(--ink);
  border-radius: 12px;
  margin-left: 0.6rem;
}
.pin-error {
  color: #b4304b;
  font-weight: 700;
  min-height: 1.2em;
  margin: 0;
}

.settings-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--snow);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
  font-weight: 700;
  min-height: 56px;
  cursor: pointer;
}
.settings-row input[type='checkbox'] {
  width: 30px;
  height: 30px;
  accent-color: var(--leaf);
}
.settings-row select {
  font: inherit;
  font-weight: 700;
  padding: 0.35rem 0.5rem;
  border: 2px solid var(--ink);
  border-radius: 10px;
  background: var(--cream);
}

/* ---- accessibility modes ------------------------------------------------ */

body.high-contrast {
  background: #ffffff;
}
body.high-contrast .play-board,
body.high-contrast .hud-chip,
body.high-contrast .choice-card,
body.high-contrast .level-card,
body.high-contrast .area-node {
  background: #ffffff;
  border-color: #000000;
  color: #000000;
}
body.high-contrast .basket {
  background: #ffffff;
  border-color: #000000;
}
body.high-contrast .screen-blurb,
body.high-contrast .play-subprompt,
body.high-contrast .topic-value {
  color: #000000;
}

/* Left-handed children drag right-to-left; flipping the tray keeps the
   instrument tray under the hand that is not covering the board. */
body.left-handed .play-tray,
body.left-handed .choice-grid,
body.left-handed .sort-board {
  flex-direction: row-reverse;
}

/* Phones: the seven area buttons are positioned by percentage, so in a short
   4:3 box they collide (6 overlapping pairs at 375px wide). Giving the map a
   squarer box spreads them vertically, and compacting the buttons does the
   rest — while keeping every target at or above 44px. */
/* Portrait phones only: a square map spreads the seven buttons vertically.
   A landscape phone must NOT get this — a square map there would be taller
   than the viewport. */
@media (max-width: 719px) {
  .mountain {
    aspect-ratio: 1 / 1;
    max-height: 56vh;
  }
}

/* Very small phones (320px class): a square map is still too cramped for seven
   buttons at a 44px minimum, so give it more height. Costs a wider crop of the
   art, which is the right trade — the buttons have to stay tappable. */
@media (max-width: 359px) {
  .mountain {
    aspect-ratio: 6 / 7;
    max-height: 62vh;
  }
}

/* Compact buttons whenever the map box is small in EITHER dimension. A
   landscape phone is 812px wide but only ~233px of map height, so keying on
   width alone left four pairs of buttons overlapping there. */
@media (max-width: 719px), (max-height: 520px) {
  .area-node {
    min-width: 56px;
    max-width: 84px;
    padding: 0.4rem 0.3rem;
    border-width: 2px;
  }

  .area-emoji {
    font-size: 1.1rem;
  }

  /* One line per label. Wrapping is what pushed neighbouring buttons into each
     other — a two-line "Weight Valley" grows tall enough to hit Water World. */
  .area-label {
    font-size: 0.56rem;
    white-space: nowrap;
  }

  .area-status {
    font-size: 0.55rem;
  }

  /* "Coming soon" on five locked areas is noise at this size; the state is
     still announced through each button's aria-label. */
  .area-node.is-locked .area-status {
    display: none;
  }
}

@media (min-width: 720px) {
  .hud {
    padding: 0.8rem 1.2rem;
  }
  .screen {
    padding: 0 1.2rem 2.5rem;
  }
}
