/* Captain Pip's Treasure Voyage
   Everything is sized with clamp() so the same layout works on a phone held
   sideways, an iPad, and a laptop. Nothing scrolls: the play screen always
   fits on one screen so a small child never has to hunt for the buttons. */

:root {
  --sky-1: #cdeeff;
  --sky-2: #7fd0f2;
  --sea: #1a7fb5;
  --sea-deep: #0a4f7a;
  --parchment: #fff5dd;
  --parchment-2: #ffe9bd;
  --parchment-edge: #d8b57f;
  --wood: #8b5a2b;
  --gold: #ffc94a;
  --gold-deep: #dd9420;
  --ink: #3a2410;
  --green: #2ea86a;
  --red: #e2574c;
  --tile: clamp(84px, 17vw, 148px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  touch-action: manipulation;
}

body {
  font-family: "Chalkboard SE", "Comic Sans MS", "Trebuchet MS", system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, var(--sky-1) 0%, var(--sky-2) 38%, var(--sea) 62%, var(--sea-deep) 100%);
  user-select: none;
}

/* ------------------------------------------------------------------ ocean */
.ocean {
  position: fixed;
  inset: auto 0 0 0;
  height: 46vh;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.wave {
  position: absolute;
  left: 0;
  width: 200%;
  height: 70px;
  background-repeat: repeat-x;
  background-size: 400px 70px;
  opacity: 0.35;
}

.wave-back {
  bottom: 28%;
  animation: drift 19s linear infinite;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 70' preserveAspectRatio='none'%3E%3Cpath d='M0 34 Q50 14 100 34 T200 34 T300 34 T400 34 V70 H0Z' fill='%23ffffff'/%3E%3C/svg%3E");
}

.wave-mid {
  bottom: 14%;
  opacity: 0.28;
  animation: drift 13s linear infinite reverse;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 70' preserveAspectRatio='none'%3E%3Cpath d='M0 40 Q60 18 120 40 T240 40 T360 40 T480 40 V70 H0Z' fill='%23bff0ff'/%3E%3C/svg%3E");
}

.wave-front {
  bottom: -6%;
  opacity: 0.4;
  animation: drift 9s linear infinite;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 70' preserveAspectRatio='none'%3E%3Cpath d='M0 44 Q40 26 80 44 T160 44 T240 44 T320 44 T400 44 V70 H0Z' fill='%2398e0ff'/%3E%3C/svg%3E");
}

@keyframes drift {
  to {
    transform: translateX(-400px);
  }
}

/* ----------------------------------------------------------- screen shell */
.app {
  position: relative;
  z-index: 1;
  height: 100dvh;
  padding: clamp(8px, 2vw, 20px);
  padding-top: max(clamp(8px, 2vw, 20px), env(safe-area-inset-top));
  padding-bottom: max(clamp(8px, 2vw, 20px), env(safe-area-inset-bottom));
}

.screen {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 1.6vh, 18px);
  animation: fade-in 0.35s ease both;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

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

.sparks {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 41;
}

.spark {
  position: absolute;
  font-size: 1.5rem;
  animation: spark-fly 0.8s ease-out forwards;
}

@keyframes spark-fly {
  to {
    transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(0.3);
    opacity: 0;
  }
}

/* --------------------------------------------------------------- controls */
.btn {
  font: inherit;
  cursor: pointer;
  border-radius: 999px;
  border: 4px solid var(--parchment-edge);
  background: var(--parchment);
  color: var(--ink);
  padding: 0.5em 1.2em;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.18);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.18);
}

.btn-gold {
  background: linear-gradient(180deg, #ffe08a, var(--gold));
  border-color: var(--gold-deep);
}

.btn-big {
  font-size: clamp(1.1rem, 3.4vw, 1.7rem);
  padding: 0.6em 1.4em;
  animation: nudge 2.6s ease-in-out infinite;
}

.btn-small {
  font-size: clamp(0.85rem, 2.4vw, 1rem);
}

@keyframes nudge {
  0%, 88%, 100% { transform: translateY(0) scale(1); }
  92% { transform: translateY(-6px) scale(1.04); }
  96% { transform: translateY(0) scale(1); }
}

.gear {
  position: fixed;
  top: 6px;
  right: 8px;
  z-index: 50;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  font-size: 1rem;
  cursor: pointer;
  opacity: 0.5;
}

.settings {
  position: fixed;
  z-index: 60;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--parchment);
  border: 5px solid var(--wood);
  border-radius: 20px;
  padding: 1.2rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  font-size: 1rem;
}

.settings[hidden] {
  display: none;
}

.settings h2 {
  margin: 0;
  font-size: 1.1rem;
}

.settings label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ------------------------------------------------------------------ title */
.title-art {
  font-size: clamp(4rem, 16vw, 9rem);
  animation: bob 3.4s ease-in-out infinite;
  filter: drop-shadow(0 10px 12px rgba(0, 0, 0, 0.25));
}

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-10px) rotate(3deg); }
}

.title {
  margin: 0;
  text-align: center;
  font-size: clamp(1.8rem, 7vw, 3.4rem);
  line-height: 1.1;
  color: #fff;
  text-shadow: 0 3px 0 var(--sea-deep), 0 8px 18px rgba(0, 0, 0, 0.3);
}

.title .gold {
  color: var(--gold);
}

.subtitle {
  margin: 0;
  color: #fff;
  font-size: clamp(0.9rem, 2.6vw, 1.2rem);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.title-buttons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
  margin-top: 0.5rem;
}

.hint-line {
  margin: 0;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.9rem;
}

/* ------------------------------------------------------------------- topbar */
.topbar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  flex: 0 0 auto;
}

.stop-chip {
  margin: 0;
  font-size: clamp(0.95rem, 2.8vw, 1.35rem);
  background: rgba(255, 255, 255, 0.85);
  border-radius: 999px;
  padding: 0.25em 0.9em;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.12);
}

.tally {
  font-size: clamp(0.9rem, 2.6vw, 1.3rem);
  letter-spacing: 2px;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.pips {
  display: flex;
  gap: 8px;
}

.pip {
  width: clamp(12px, 3vw, 18px);
  height: clamp(12px, 3vw, 18px);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.12);
}

.pip.filled {
  background: var(--gold);
}

.pip.now {
  background: #fff;
  animation: pip-pulse 1.4s ease-in-out infinite;
}

@keyframes pip-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.35); }
}

.repeat {
  border: none;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  width: clamp(38px, 9vw, 48px);
  height: clamp(38px, 9vw, 48px);
  font-size: clamp(1.1rem, 3.4vw, 1.5rem);
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.15);
}

.repeat:active {
  transform: translateY(2px);
}

/* --------------------------------------------------------------- map board */
.map-screen {
  justify-content: space-between;
}

.board {
  position: relative;
  /* Islands and labels are sized from the board itself (cqw), so the map reads
     the same whether it is 300px wide on a phone or 1100px on a laptop. */
  container-type: size;
  width: min(100%, calc((100dvh - clamp(120px, 22vh, 190px)) * 1.6));
  aspect-ratio: 16 / 10;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.05));
  border: 4px solid rgba(255, 255, 255, 0.5);
  border-radius: 22px;
  overflow: hidden;
}

.route {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.route-line {
  fill: none;
  stroke: rgba(255, 255, 255, 0.75);
  stroke-width: 1;
  stroke-dasharray: 3 3;
  stroke-linecap: round;
}

.route-done {
  fill: none;
  stroke: var(--gold);
  stroke-width: 1.6;
  stroke-linecap: round;
}

.stop {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  border: none;
  background: none;
  cursor: pointer;
  padding: 4px;
  font: inherit;
  color: #fff;
}

.stop-emoji {
  font-size: clamp(20px, 8cqw, 52px);
  filter: drop-shadow(0 4px 5px rgba(0, 0, 0, 0.3));
  line-height: 1;
}

.stop-name {
  font-size: clamp(8px, 2.5cqw, 14px);
  background: rgba(10, 79, 122, 0.7);
  border-radius: 999px;
  padding: 1px 8px;
  white-space: nowrap;
}

.stop-star {
  position: absolute;
  top: -4px;
  right: -2px;
  font-size: clamp(9px, 3.4cqw, 20px);
}

.stop.locked {
  opacity: 0.5;
  filter: grayscale(0.6);
}

.stop.current .stop-emoji {
  animation: stop-pulse 1.6s ease-in-out infinite;
}

.stop.current .stop-name {
  background: var(--gold-deep);
}

@keyframes stop-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}

.vehicle {
  position: absolute;
  /* Floats just above the stop, clear of the name badge underneath it. */
  transform: translate(-50%, -150%);
  font-size: clamp(18px, 7cqw, 46px);
  line-height: 1;
  filter: drop-shadow(0 5px 6px rgba(0, 0, 0, 0.35));
  pointer-events: none;
}

.vehicle .hull {
  display: inline-block;
  animation: bob 2.6s ease-in-out infinite;
}

.vehicle.moving {
  transition: left 2s ease-in-out, top 2s ease-in-out;
}

.map-actions {
  flex: 0 0 auto;
}

/* Held upright, the map wants to be square rather than a letterbox. */
@media (orientation: portrait) {
  .board {
    width: min(100%, calc(100dvh - 230px));
    aspect-ratio: 1 / 1;
  }
}

/* ------------------------------------------------------------------ story */
.story-screen {
  justify-content: space-around;
}

.story-art {
  font-size: clamp(5rem, 22vw, 11rem);
  animation: bob 3.2s ease-in-out infinite;
  filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.3));
}

.panel {
  background: linear-gradient(180deg, var(--parchment), var(--parchment-2));
  border: 5px solid var(--parchment-edge);
  border-radius: 24px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.2);
  padding: clamp(0.7rem, 2.4vw, 1.3rem);
}

.story-panel {
  width: min(640px, 100%);
  text-align: center;
  font-size: clamp(1rem, 3.2vw, 1.4rem);
}

.story-panel p {
  margin: 0;
}

/* ------------------------------------------------------------------- play */
/* Rows: title bar, the puzzle, the answers, the parrot. The puzzle row takes
   the slack, but the parchment inside it only ever grows to fit its contents —
   on a tall tablet an empty sign stretched to the ceiling looks broken. */
.play-screen {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  justify-items: center;
  gap: clamp(6px, 1.4vh, 16px);
}

.stage {
  width: min(760px, 100%);
  align-self: center;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(4px, 1.2vh, 12px);
  min-height: min(30vh, 260px);
}

.play-screen .choices {
  align-self: end;
}

.play-screen .mate {
  align-self: end;
  justify-self: start;
}

.kind-badge {
  margin: 0;
  font-size: clamp(0.7rem, 2vw, 0.9rem);
  background: rgba(0, 0, 0, 0.07);
  border-radius: 999px;
  padding: 2px 12px;
}

.prompt {
  margin: 0;
  text-align: center;
  font-size: clamp(1rem, 3.2vw, 1.5rem);
}

.stimulus {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.wordcard {
  font-size: clamp(2.4rem, 11vw, 5rem);
  letter-spacing: 0.06em;
  color: var(--ink);
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.09);
  line-height: 1.05;
}

.wordcard.letter,
.wordcard.number {
  font-size: clamp(3.2rem, 15vw, 6.5rem);
  color: var(--gold-deep);
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.12);
}

.rowset {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(2px, 0.8vw, 8px);
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: clamp(2px, 1vw, 10px);
  max-width: 100%;
}

.item {
  font-size: calc(clamp(1.5rem, 5.4vw, 2.6rem) * var(--item-scale, 1));
  line-height: 1.15;
}

/* A "taken away" item is veiled in parchment and struck through, rather than
   faded outright — the red cross has to stay bright to read as "gone". */
.item.gone {
  position: relative;
}

.item.gone::before {
  content: "";
  position: absolute;
  inset: -2px;
  background: rgba(255, 245, 221, 0.7);
  border-radius: 10px;
}

.item.gone::after {
  content: "✕";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--red);
  font-size: 1.4em;
  font-weight: bold;
  opacity: 0.9;
}

.item.qmark {
  color: var(--gold-deep);
  font-weight: bold;
  animation: pip-pulse 1.3s ease-in-out infinite;
}

.pattern {
  gap: clamp(4px, 1.6vw, 14px);
}

.sum {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 2vw, 16px);
  flex-wrap: wrap;
}

.grp {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px;
  max-width: 38vw;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 16px;
  padding: 6px 8px;
}

.op {
  font-size: clamp(1.6rem, 6vw, 2.6rem);
  color: var(--gold-deep);
}

.blankword {
  display: flex;
  align-items: center;
  gap: clamp(8px, 3vw, 22px);
}

.blank-pic {
  font-size: clamp(2.4rem, 10vw, 4rem);
}

.blank-letters {
  display: flex;
  gap: 0.12em;
  font-size: clamp(2.4rem, 10vw, 4.5rem);
  letter-spacing: 0.04em;
}

.gap {
  color: var(--gold-deep);
  animation: pip-pulse 1.3s ease-in-out infinite;
}

/* A puzzle with nothing to look at ("which has more?") turns its question
   into the signpost instead, so the parchment never sits empty. */
.stage.no-stimulus .prompt {
  font-size: clamp(1.6rem, 6vw, 2.8rem);
}

/* ------------------------------------------------------------------ tiles */
.choices {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  justify-content: center;
  gap: clamp(8px, 2.2vw, 18px);
  width: 100%;
}

.tile {
  font: inherit;
  cursor: pointer;
  width: var(--tile);
  height: var(--tile);
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #fffdf6, var(--parchment));
  border: 5px solid var(--parchment-edge);
  border-radius: 22px;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.18);
  transition: transform 0.09s ease, box-shadow 0.09s ease, opacity 0.25s ease;
  padding: 6px;
}

.tile:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.18);
}

.tile:disabled {
  cursor: default;
}

.tile .face {
  font-size: clamp(2.4rem, 9vw, 4rem);
  line-height: 1;
}

.tile.num {
  font-size: clamp(2.2rem, 8vw, 3.6rem);
  color: var(--ink);
}

.tile.letter {
  font-size: clamp(2.2rem, 8vw, 3.6rem);
  color: var(--gold-deep);
}

.tile.word {
  width: auto;
  min-width: clamp(110px, 26vw, 190px);
  height: auto;
  min-height: clamp(62px, 14vw, 90px);
  font-size: clamp(1.5rem, 6vw, 2.6rem);
  letter-spacing: 0.04em;
}

.tile.group {
  width: clamp(120px, 34vw, 220px);
  height: clamp(110px, 26vw, 180px);
}

.tile.group .items {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.tile.group .item {
  font-size: clamp(1.3rem, 4.6vw, 2.2rem);
}

.tile.correct {
  border-color: var(--green);
  background: linear-gradient(180deg, #eaffef, #c7f5d8);
  animation: pop 0.45s ease;
}

@keyframes pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.18) rotate(-3deg); }
  100% { transform: scale(1); }
}

.tile.wrong {
  animation: shake 0.4s ease;
  opacity: 0.35;
  filter: grayscale(0.85);
  border-color: #c9b79a;
  box-shadow: none;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-9px) rotate(-3deg); }
  45% { transform: translateX(8px) rotate(3deg); }
  70% { transform: translateX(-5px); }
}

.tile.glow {
  animation: glow 1.1s ease-in-out infinite;
  border-color: var(--gold-deep);
}

@keyframes glow {
  0%, 100% { box-shadow: 0 5px 0 rgba(0, 0, 0, 0.18), 0 0 0 0 rgba(255, 201, 74, 0.9); }
  50% { box-shadow: 0 5px 0 rgba(0, 0, 0, 0.18), 0 0 0 14px rgba(255, 201, 74, 0); }
}

/* -------------------------------------------------------------- the parrot */
.mate {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  align-self: flex-start;
  max-width: 100%;
}

.parrot {
  font-size: clamp(1.8rem, 6vw, 2.6rem);
  animation: bob 2.2s ease-in-out infinite;
}

.bubble {
  background: rgba(255, 255, 255, 0.92);
  border-radius: 18px;
  padding: 0.4em 0.9em;
  font-size: clamp(0.85rem, 2.6vw, 1.15rem);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.12);
}

/* --------------------------------------------------------- stop / finale */
.done-screen,
.finale-screen {
  justify-content: center;
  gap: clamp(10px, 2.4vh, 22px);
}

.done-star {
  font-size: clamp(4rem, 18vw, 8rem);
  animation: star-in 0.7s cubic-bezier(0.2, 1.6, 0.4, 1) both;
}

@keyframes star-in {
  from { transform: scale(0) rotate(-90deg); }
}

.treasure {
  font-size: clamp(5rem, 22vw, 10rem);
  animation: bob 2.4s ease-in-out infinite;
  filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.3));
}

.done-title {
  margin: 0;
  color: #fff;
  text-align: center;
  font-size: clamp(1.6rem, 6vw, 2.8rem);
  text-shadow: 0 3px 0 var(--sea-deep), 0 8px 16px rgba(0, 0, 0, 0.3);
}

.done-panel,
.finale-panel {
  width: min(620px, 100%);
  text-align: center;
}

.loot {
  margin: 0 0 0.3rem;
  font-size: clamp(1.6rem, 6vw, 2.4rem);
  letter-spacing: 4px;
}

.loot-line {
  margin: 0;
  font-size: clamp(0.95rem, 3vw, 1.25rem);
}

.pieces-line {
  margin: 0.4rem 0 0;
  font-size: clamp(0.85rem, 2.6vw, 1.05rem);
  opacity: 0.75;
}

.map-pieces {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 0.8rem;
}

.piece {
  background: rgba(255, 255, 255, 0.55);
  border: 2px dashed var(--parchment-edge);
  border-radius: 12px;
  padding: 6px 0;
  font-size: clamp(1.4rem, 5vw, 2.2rem);
}

/* Phones: four tiles in one row would be too skinny to hit, so they go two by
   two instead — fewer, fatter targets. */
@media (max-width: 520px) {
  :root {
    --tile: clamp(96px, 27vw, 148px);
  }
  .choices.count-4 {
    display: grid;
    grid-template-columns: repeat(2, auto);
    justify-content: center;
  }
  .tile.word {
    min-width: clamp(100px, 34vw, 190px);
  }
  .tile.group {
    width: clamp(110px, 38vw, 220px);
  }
}

/* A phone held sideways has almost no height to spare, so everything is sized
   from the height instead of the width and the decoration gets out of the way. */
@media (max-height: 520px) {
  :root {
    --tile: min(26vh, 130px);
  }
  .story-art { font-size: clamp(3rem, 12vh, 5rem); }
  .title-art { font-size: clamp(3rem, 14vh, 5rem); }
  .done-star { font-size: clamp(3rem, 14vh, 5rem); }
  .treasure { font-size: clamp(3.5rem, 16vh, 6rem); }
  .mate,
  .kind-badge { display: none; }

  .stage {
    min-height: 0;
    overflow: hidden;
  }
  .prompt { font-size: clamp(0.9rem, 4.6vh, 1.3rem); }
  .wordcard { font-size: clamp(1.8rem, 13vh, 3.4rem); }
  .wordcard.letter,
  .wordcard.number { font-size: clamp(2rem, 16vh, 4rem); }
  .item { font-size: calc(clamp(1.1rem, 6.4vh, 2rem) * var(--item-scale, 1)); }
  .blank-pic,
  .blank-letters { font-size: clamp(1.6rem, 12vh, 3rem); }
  .tile .face { font-size: clamp(1.6rem, 13vh, 3rem); }
  .tile.num,
  .tile.letter { font-size: clamp(1.6rem, 12vh, 2.8rem); }
  .tile.letter.pair { font-size: clamp(1.2rem, 9vh, 2.1rem); }
  .tile.word {
    font-size: clamp(1.2rem, 8vh, 2rem);
    min-height: 0;
    height: var(--tile);
  }
  .tile.group {
    height: var(--tile);
    width: clamp(110px, 24vw, 200px);
  }
  .tile.group .item { font-size: clamp(0.9rem, 4.4vh, 1.5rem); }
  .stage.no-stimulus .prompt { font-size: clamp(1.2rem, 7vh, 2rem); }
}

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

/* Roomy screens (laptops, iPads): everything gets bigger, because bigger is
   easier for a four-year-old to see and to hit. */
@media (min-width: 900px) and (min-height: 620px) {
  :root {
    --tile: 168px;
  }
  .wordcard { font-size: 6rem; }
  .wordcard.letter,
  .wordcard.number { font-size: 7.5rem; }
  .item { font-size: calc(3rem * var(--item-scale, 1)); }
  .tile .face { font-size: 4.6rem; }
  .tile.num,
  .tile.letter { font-size: 4rem; }
  .tile.letter.pair { font-size: 3rem; }
  .tile.word { font-size: 3rem; }
  .tile.group { width: 240px; height: 200px; }
  .tile.group .item { font-size: 2.4rem; }
  .blank-letters,
  .blank-pic { font-size: 5rem; }
  .prompt { font-size: 1.7rem; }
}

/* Voice and speed pickers in the grown-ups panel. */
.settings .pick {
  justify-content: space-between;
  gap: 0.8rem;
}

.settings select {
  font: inherit;
  font-size: 0.95rem;
  width: 11rem;
  max-width: 60%;
  padding: 0.2em 0.4em;
  border: 2px solid var(--parchment-edge);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.settings select:disabled {
  opacity: 0.5;
}


/* ===================================================================== sky
   The second game flies rather than sails. Only the colours and the drifting
   layer change: every component below reads its palette from these tokens. */
body.theme-sky {
  --sky-1: #dff2ff;
  --sky-2: #a9dcf8;
  --sea: #6bbdf0;
  --sea-deep: #2e7fbe;
  --parchment: #f8fcff;
  --parchment-2: #e6f3ff;
  --parchment-edge: #a6cfec;
  --wood: #4a7fa5;
  --ink: #17384f;
  background: linear-gradient(180deg, #3f9ede 0%, #79c6f2 40%, var(--sky-2) 72%, var(--sky-1) 100%);
}

/* Clouds drift across the whole sky rather than sitting at the waterline. */
body.theme-sky .ocean {
  inset: 0;
  height: 100%;
}

body.theme-sky .wave {
  height: 120px;
  background-size: 520px 120px;
  opacity: 0.85;
}

body.theme-sky .wave-back {
  bottom: auto;
  top: 6%;
  opacity: 0.55;
  animation-duration: 46s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 520 120'%3E%3Cg fill='%23ffffff'%3E%3Cellipse cx='70' cy='60' rx='52' ry='26'/%3E%3Cellipse cx='115' cy='52' rx='38' ry='28'/%3E%3Cellipse cx='160' cy='62' rx='45' ry='22'/%3E%3Cellipse cx='350' cy='45' rx='55' ry='24'/%3E%3Cellipse cx='395' cy='52' rx='40' ry='20'/%3E%3C/g%3E%3C/svg%3E");
}

body.theme-sky .wave-mid {
  bottom: auto;
  top: 40%;
  opacity: 0.4;
  animation-duration: 34s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 520 120'%3E%3Cg fill='%23ffffff'%3E%3Cellipse cx='200' cy='70' rx='60' ry='28'/%3E%3Cellipse cx='250' cy='62' rx='44' ry='30'/%3E%3Cellipse cx='300' cy='72' rx='50' ry='24'/%3E%3C/g%3E%3C/svg%3E");
}

body.theme-sky .wave-front {
  bottom: 4%;
  top: auto;
  opacity: 0.6;
  animation-duration: 26s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 520 120'%3E%3Cg fill='%23ffffff'%3E%3Cellipse cx='90' cy='80' rx='70' ry='30'/%3E%3Cellipse cx='150' cy='72' rx='50' ry='32'/%3E%3Cellipse cx='390' cy='84' rx='64' ry='26'/%3E%3Cellipse cx='440' cy='76' rx='46' ry='28'/%3E%3C/g%3E%3C/svg%3E");
}

/* The plane leans into its travel; the ship just bobs. */
body.theme-sky .vehicle .hull {
  animation: bank 3.2s ease-in-out infinite;
}

@keyframes bank {
  0%, 100% { transform: translateY(0) rotate(-6deg); }
  50% { transform: translateY(-8px) rotate(4deg); }
}

/* ============================================================ mode picker */
.mode-screen {
  gap: clamp(14px, 3vh, 28px);
}

.mode-cards {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(12px, 3vw, 28px);
  width: 100%;
}

.mode-card {
  font: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  width: clamp(150px, 38vw, 260px);
  padding: clamp(0.8rem, 2.6vw, 1.5rem) clamp(0.5rem, 2vw, 1rem);
  border: 5px solid var(--parchment-edge);
  border-radius: 26px;
  background: linear-gradient(180deg, #fffdf6, var(--parchment));
  color: var(--ink);
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.18);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.mode-card:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.18);
}

/* Each card wears the colours of the game it starts. */
.mode-card.theme-sea {
  border-color: #2a6f9e;
  background: linear-gradient(180deg, #eaf7ff, #bfe4f8);
}

.mode-card.theme-sky {
  border-color: #d8a12a;
  background: linear-gradient(180deg, #fff7e2, #ffe6ad);
}

.mode-art {
  font-size: clamp(3rem, 11vw, 5rem);
  line-height: 1.1;
  animation: bob 3s ease-in-out infinite;
}

.mode-name {
  font-size: clamp(0.95rem, 2.6vw, 1.25rem);
  line-height: 1.15;
}

.mode-ages {
  font-size: clamp(0.8rem, 2.2vw, 1rem);
  background: rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  padding: 1px 12px;
}

.mode-progress {
  font-size: clamp(0.7rem, 2vw, 0.9rem);
  letter-spacing: 1px;
  min-height: 1.2em;
}

.btn-quiet {
  background: rgba(255, 255, 255, 0.6);
  border-color: rgba(255, 255, 255, 0.75);
  box-shadow: none;
  font-size: clamp(0.75rem, 2.2vw, 0.9rem);
  opacity: 0.85;
}

/* Two-letter blends need a little less room per letter than a single one. */
.tile.letter.pair {
  font-size: clamp(1.6rem, 6vw, 2.6rem);
  letter-spacing: 0.02em;
}

/* A word shown beside its picture (rhyming puzzles). */
.blankword .wordcard {
  font-size: clamp(1.8rem, 8vw, 3.6rem);
}
