/* The 3D stage, tray, arrows and garden. Gugu tokens. */

.stage { position: relative; width: 100%; height: 420px; border-radius: 28px; border: 5px solid var(--ink); overflow: hidden; background: var(--mist); }
.stage.tall { height: 480px; }
.stage canvas { display: block; width: 100%; height: 100%; }

.stagebar-row { margin-top: 14px; }
.tray { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.tray-gear {
  display: inline-flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 96px; min-height: 84px; padding: 8px 14px;
  border: 4px solid var(--ink); border-radius: 20px; background: #fff;
  box-shadow: 0 4px 0 var(--ink); cursor: pointer; font-family: var(--display);
}
.tray-gear[aria-pressed="true"] { background: var(--sun); }
.tray-gear:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.tray-gear__body { width: 40px; height: 40px; }
.tray-gear__label { font-weight: 800; font-size: 18px; }

.motor {
  min-width: 120px; min-height: 84px; margin-left: 10px; padding: 8px 18px;
  border: 4px solid var(--ink); border-radius: 20px; background: var(--coral); color: var(--ink);
  font: 800 22px var(--display); box-shadow: 0 4px 0 var(--ink); cursor: pointer;
}
.motor[aria-pressed="true"] { background: var(--mint); }

.stagebar { display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap; margin-top: 14px; }

/* predict arrows / fast-slow */
.choices { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }
.choice {
  display: inline-flex; align-items: center; gap: 10px;
  min-width: 150px; min-height: 96px; padding: 10px 22px;
  border: 4px solid var(--ink); border-radius: 28px; background: var(--sun); color: var(--ink);
  font: 800 26px var(--display); box-shadow: 0 6px 0 var(--ink); cursor: pointer;
}
.choice[aria-pressed="true"] { background: var(--mint); }
.choice:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
.gorow { text-align: center; margin-top: 14px; }
.go { min-width: 200px; background: var(--sky); }
.go:disabled { opacity: .45; box-shadow: none; transform: none; cursor: default; }

.feedback { min-height: 44px; margin: 18px 0 8px; font-family: var(--display); font-weight: 800; font-size: 30px; text-align: center; }

.garden-labels { min-height: 32px; margin: 10px 0 14px; font-weight: 700; color: var(--slate-2, #4A5068); text-align: center; }
/* "Challenge done!" floats over the top of the Garden: it takes no room on
   a phone (the Garden fits the screen exactly) and never blocks a tap */
[data-screen="garden"] { position: relative; }
.garden-cheer { position: absolute; top: 6px; left: 50%; transform: translateX(-50%); z-index: 2; margin: 0; padding: 4px 16px; border: 3px solid var(--ink, #1B1464); border-radius: 999px; background: var(--sun, #FFC93C); color: var(--ink, #1B1464); font-weight: 800; white-space: nowrap; pointer-events: none; }
.garden-cheer:empty { display: none; }
/* a gear's speed in the Garden: its colour (the 3D gear's), its way, a word */
.speed-chip { display: inline-flex; align-items: center; gap: 4px; margin: 2px 4px; padding: 1px 10px 1px 4px; border: 2px solid var(--ink, #1B1464); border-radius: 999px; background: #fff; color: var(--ink, #1B1464); white-space: nowrap; }
.speed-chip::before { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ink, #1B1464); background: var(--gear, #8d9298); }
.speed-chip[data-teeth="8"] { --gear: #4cc3ff; }
.speed-chip[data-teeth="16"] { --gear: #2ed3a0; }
.speed-chip[data-teeth="24"] { --gear: #ff9f43; }
.speed-chip[data-teeth="40"] { --gear: #ff6b5b; }

/* Phones: a phone browser leaves ~360x560 once its bars show, and mobile vh
   is the bars-hidden height — size by svh so the controls stay on screen. */
@media (max-width: 560px) {
  .wrap { padding: 0 12px; }
  .top { padding: 6px 0 10px; }
  .brand { font-size: 22px; }
  .pill { padding: 5px 12px; min-height: 38px; font-size: 13px; }
  main.wrap { padding-top: 8px; padding-bottom: 2px; }
  .progress { font-size: 14px; margin-bottom: 2px; }
  .question { font-size: 20px; margin-bottom: 8px; }
  .stage { height: clamp(170px, 44svh, 330px); border-width: 4px; }
  .stagebar-row { margin-top: 6px; }
  .tray-gear { min-width: 64px; min-height: 56px; padding: 4px 8px; }
  .tray-gear__body { width: 30px; height: 30px; }
  .tray-gear__label { font-size: 14px; }
  .motor { min-width: 78px; min-height: 56px; font-size: 16px; margin-left: 0; }
  /* the two answers side by side, then Go: all on screen */
  .choices { flex-wrap: nowrap; gap: 10px; margin-top: 6px; }
  .choice { flex: 1 1 0; min-width: 0; min-height: 56px; padding: 6px 10px; gap: 6px; font-size: 18px; border-radius: 20px; }
  .choice svg { width: 36px; flex: none; }
  .gorow { margin-top: 6px; }
  .go { min-height: 56px; font-size: 20px; }
  /* a predict board is only watched, never tapped: it can be a bit shorter */
  [data-screen="play"]:has(#predict .choice) .stage { height: clamp(150px, 32svh, 280px); }
  .feedback { min-height: 22px; margin: 2px 0 0; font-size: 19px; line-height: 1.15; }
}

/* Phones turned sideways: stage on the left, words on the right. */
@media (orientation: landscape) and (max-height: 500px) {
  .wrap { max-width: 960px; padding: 0 14px; }
  .top { padding: 4px 0; }
  .brand { font-size: 22px; }
  main.wrap { padding-top: 6px; padding-bottom: 8px; }
  .question { font-size: 20px; margin-bottom: 6px; }
  .stage { height: clamp(150px, calc(100svh - 158px), 300px); }
  /* levels 3 and 5 hold 24-tooth cranks: their stage takes the room under it too */
  [data-screen="play"][data-level="3"] > .stage,
  [data-screen="play"][data-level="5"] > .stage { height: clamp(150px, calc(100svh - 112px), 300px); }
  [data-screen="play"]:not([hidden]) {
    display: grid; grid-template-columns: clamp(280px, 44vw, 430px) 1fr; column-gap: 18px; align-content: start;
  }
  [data-screen="play"] > .stage { grid-column: 1; grid-row: 1 / span 6; align-self: start; }
  /* the tray and the answer buttons never show together: same right-hand slot.
     An empty answer box must leave the slot, or it sits on top of the tray
     and eats every tap on the gears and the motor. */
  [data-screen="play"] > .stagebar-row { grid-column: 2; grid-row: 3; margin-top: 6px; }
  [data-screen="play"] > #predict:empty { display: none; }
  [data-screen="play"] > .stagebar-row .stagebar { justify-content: flex-start; margin-top: 0; }
  [data-screen="play"] > .progressrow { grid-column: 2; grid-row: 1; margin-bottom: 2px; }
  [data-screen="play"] > .qrow { grid-column: 2; grid-row: 2; margin: 0; }
  [data-screen="play"] > #predict { grid-column: 2; grid-row: 3; margin-top: 6px; }
  [data-screen="play"] > .gorow { grid-column: 2; grid-row: 4; margin-top: 6px; }
  [data-screen="play"] > .coachrow { grid-column: 2; grid-row: 5; margin: 4px 0 0; }
  [data-screen="play"] .coachrow .feedback { min-height: 26px; font-size: 20px; line-height: 1.2; }
  .choices { flex-wrap: nowrap; gap: 10px; justify-content: flex-start; }
  .choice { flex: 1 1 0; min-width: 0; min-height: 56px; padding: 6px 10px; gap: 6px; font-size: 18px; border-radius: 20px; }
  .choice svg { width: 34px; flex: none; }
  .gorow { text-align: left; }
  .go { min-height: 54px; font-size: 20px; }
}

/* The Gear Garden fills the viewport instead of running off the bottom:
   nothing to scroll, so taps always land where the child aims. */
[data-screen="garden"]:not([hidden]) {
  display: flex; flex-direction: column; gap: 10px;
  max-height: calc(100vh - 150px);
}
@supports (height: 1svh) {
  [data-screen="garden"]:not([hidden]) { max-height: calc(100svh - 150px); }
}
[data-screen="garden"] .stage.tall { flex: 1 1 auto; height: auto; min-height: 200px; }
[data-screen="garden"] .done-title { font-size: 32px; margin-bottom: 0; }

/* Phones: the Garden (stage, tray + motor, Home) fits without scrolling. */
@media (max-width: 560px) {
  [data-screen="garden"]:not([hidden]) { gap: 6px; max-height: calc(100vh - 104px); }
  @supports (height: 1svh) {
    [data-screen="garden"]:not([hidden]) { max-height: calc(100svh - 104px); }
  }
  [data-screen="garden"] .done-title { font-size: 24px; }
  [data-screen="garden"] .stage.tall { min-height: 140px; }
  [data-screen="garden"] .stagebar { gap: 8px; margin-top: 0; }
  [data-screen="garden"] .stagebar-row { margin-top: 0; }
  [data-screen="garden"] .garden-labels { margin: 0; min-height: 22px; font-size: 14px; white-space: nowrap; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
  [data-screen="garden"] .speed-chip { margin: 0 3px; padding: 0 8px 0 3px; }
  /* Decorate, Challenge and Home share one row, equal widths */
  [data-screen="garden"] .row { flex-wrap: nowrap; gap: 6px; }
  [data-screen="garden"] .row .big { flex: 1 1 0; min-width: 0; min-height: 52px; font-size: 17px; padding: 6px 8px; }
}
@media (orientation: landscape) and (max-height: 500px) {
  [data-screen="garden"]:not([hidden]) {
    display: grid; grid-template-columns: clamp(280px, 50vw, 520px) 1fr; column-gap: 16px; row-gap: 6px;
    align-content: start; max-height: none;
  }
  [data-screen="garden"] .stage.tall { grid-column: 1; grid-row: 1 / span 4; height: calc(100svh - 112px); min-height: 150px; }
  [data-screen="garden"] .done-title { grid-column: 2; grid-row: 1; font-size: 22px; }
  [data-screen="garden"] .stagebar-row { grid-column: 2; grid-row: 2; margin-top: 0; }
  [data-screen="garden"] .stagebar { justify-content: flex-start; gap: 8px; margin-top: 0; }
  /* the speed chips stay on one line: many gears scroll sideways, the
     buttons below never move off the screen */
  [data-screen="garden"] .garden-labels { grid-column: 2; grid-row: 3; margin: 0; min-height: 20px; font-size: 14px; text-align: left; white-space: nowrap; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
  [data-screen="garden"] .speed-chip { margin: 0 3px 0 0; padding: 0 8px 0 3px; }
  [data-screen="garden"] .row { grid-column: 2; grid-row: 4; }
  [data-screen="garden"] .row { flex-wrap: nowrap; gap: 6px; }
  [data-screen="garden"] .row .big { flex: 1 1 0; min-width: 0; min-height: 50px; font-size: 16px; padding: 6px; }
  .tray-gear { min-width: 58px; min-height: 52px; padding: 4px 6px; border-width: 3px; }
  .tray-gear__body { width: 26px; height: 26px; }
  .tray-gear__label { font-size: 14px; }
  .motor { min-width: 70px; min-height: 52px; font-size: 16px; margin-left: 0; }
  .tray { gap: 8px; }
}

/* The tray shows each gear at its real relative size, in its 3D colour:
   choosing "two small or one big" is the game, so the sizes must read. */
.tray-gear[data-teeth="8"] .tray-gear__body { width: 24px; height: 24px; }
.tray-gear[data-teeth="16"] .tray-gear__body { width: 31px; height: 31px; }
.tray-gear[data-teeth="24"] .tray-gear__body { width: 38px; height: 38px; }
.tray-gear[data-teeth="40"] .tray-gear__body { width: 46px; height: 46px; }
.tray-gear { justify-content: flex-end; }
@media (max-width: 560px), (orientation: landscape) and (max-height: 500px) {
  .tray-gear[data-teeth="8"] .tray-gear__body { width: 17px; height: 17px; }
  .tray-gear[data-teeth="16"] .tray-gear__body { width: 22px; height: 22px; }
  .tray-gear[data-teeth="24"] .tray-gear__body { width: 27px; height: 27px; }
  .tray-gear[data-teeth="40"] .tray-gear__body { width: 33px; height: 33px; }
}

/* Level 1's coach: the next step, in the feedback spot, a little smaller than
   "Great!"; the button it talks about pulses. */
.feedback.coach { font-size: 22px; color: var(--ink); }
.coach-pulse { animation: coach-pulse 1.1s ease-in-out infinite; }
/* outline only: the button stays put, so a tap always lands on it */
@keyframes coach-pulse {
  0%, 100% { outline: 2px solid transparent; outline-offset: 2px; }
  50% { outline: 5px solid var(--coral); outline-offset: 5px; }
}
@media (max-width: 560px) {
  .feedback.coach { font-size: 15px; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .feedback.coach { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .coach-pulse { animation: none; outline: 4px solid var(--coral); outline-offset: 3px; }
}

/* Dragging: a finger on a gear (in the tray or on the board) moves the gear,
   never the page. The dragged gear follows the finger at its real size. */
.tray-gear, .stage canvas { touch-action: none; }
.drag-ghost {
  position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none;
  border: 4px solid var(--ink); border-radius: 999px; opacity: 0.85;
  box-shadow: 0 6px 14px rgba(27, 20, 100, 0.35);
  background-image: radial-gradient(circle, var(--ink) 0 9%, transparent 10%);
}
.drag-ghost[data-teeth="8"] { background-color: #4cc3ff; }
.drag-ghost[data-teeth="16"] { background-color: #2ed3a0; }
.drag-ghost[data-teeth="24"] { background-color: #ff9f43; }
.drag-ghost[data-teeth="40"] { background-color: #ff6b5b; }

/* ---------- The Space Garage look (the Claude Design canvas) ----------
   A night-sky board, progress dots, a mission card, Gugu's coach bubble with
   the step pills, a toolbox tray of gear-shaped buttons and a round motor. */
.stage { background: var(--night); }
.tray-gear__body { display: block; }
.tray-gear__body svg { display: block; width: 100%; height: 100%; }

.progressrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.progressrow .progress { margin: 0; }
.pdots { display: flex; gap: 8px; }
.pdot { width: 14px; height: 14px; border: 3px solid var(--ink); border-radius: 999px; background: var(--cream); }
.pdot[data-state="now"] { background: var(--sun); }
.pdot[data-state="done"] { background: var(--mint); }

.qrow { padding: 6px 8px 6px 16px; background: #fff; border: 3px solid var(--ink); border-radius: 20px; box-shadow: 0 4px 0 var(--ink); }
.qrow .question { flex: 1; min-width: 0; }

.coachrow { display: flex; align-items: flex-start; gap: 10px; min-height: 56px; margin: 14px 0 6px; }
.chick { width: 48px; height: 48px; flex: none; }
.bubble { flex: 1; min-width: 0; padding: 4px 14px; background: #fff; border: 3px solid var(--ink); border-radius: 18px; }
.coachrow:has(.feedback:empty) .bubble { visibility: hidden; }
.coachrow .feedback { min-height: 0; margin: 0; text-align: left; }
.step-pills { display: flex; gap: 6px; margin: 2px 0 4px; }
.step-pills:empty { display: none; }
.step-pill { flex: 1; padding: 0 4px; border: 2px solid var(--ink); border-radius: 999px; background: var(--cream); font: 800 14px/1.4 var(--display); text-align: center; white-space: nowrap; }
.step-pill[data-state="now"] { background: var(--sun); }
.step-pill[data-state="done"] { background: var(--mint); }

.stagebar .tray { padding: 8px; background: #E9DFC8; border: 3px solid var(--ink); border-radius: 22px; }
.motor { width: 88px; height: 88px; min-width: 0; min-height: 0; padding: 0; border-radius: 999px; font-size: 34px; line-height: 1; box-shadow: 0 5px 0 var(--ink); }

@media (max-width: 560px) {
  .progressrow { margin-bottom: 0; }
  .pdot { width: 12px; height: 12px; border-width: 2px; }
  .qrow { padding: 2px 4px 2px 12px; margin: 0 0 4px; border-width: 3px; border-radius: 16px; box-shadow: 0 3px 0 var(--ink); }
  .qrow .question { margin: 0; }
  .coachrow { min-height: 34px; gap: 6px; margin: 2px 0 0; }
  .chick { width: 32px; height: 32px; }
  .bubble { padding: 0 10px; border-radius: 14px; }
  .step-pill { font-size: 11px; line-height: 1.25; }
  .step-pills { margin: 1px 0 3px; }
  .stagebar .tray { padding: 3px; border-radius: 16px; }
  .stagebar .tray-gear { min-height: 50px; padding: 2px 8px; border-width: 3px; gap: 0; }
  .stagebar .tray-gear__label { line-height: 1.1; }
  .motor { width: 56px; height: 56px; font-size: 24px; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .qrow { padding: 2px 4px 2px 12px; border-radius: 16px; }
  .coachrow { min-height: 34px; gap: 6px; }
  .chick { width: 32px; height: 32px; }
  .bubble { padding: 1px 10px; border-radius: 14px; }
  .step-pill { font-size: 12px; }
  .stagebar .tray { padding: 3px; border-radius: 16px; }
  .motor { width: 52px; height: 52px; font-size: 22px; }
}
/* Inside the mission card the speaker button needs no shadow of its own, and
   a smaller (still 44 px) button keeps the phone play screen from scrolling. */
.qrow .replay { width: 48px; height: 48px; border-width: 3px; box-shadow: none; }
@media (max-width: 560px) {
  .qrow .replay { width: 44px; height: 44px; }
  .stage { height: clamp(170px, 42svh, 330px); }
}
@media (orientation: landscape) and (max-height: 500px) {
  .qrow .replay { width: 44px; height: 44px; }
}
/* Build puzzles have no answer buttons and no Go: their empty rows take no
   room (the board gets it). sound.css loads later, so the card's phone margin
   is set with a stronger selector. */
[data-screen="play"] > #predict:empty { display: none; }
[data-screen="play"] > .gorow:has(> #go[hidden]) { display: none; }
@media (max-width: 560px) {
  [data-screen="play"] > .qrow { margin: 0 0 4px; }
  .stage { height: clamp(170px, 44svh, 330px); }
}
/* the stuck ring has no gears to add: no empty toolbox */
.stagebar .tray:empty { display: none; }

/* Gear Pals: the ghost hand taps where Gugu's wish is made. Its fingertip
   (the top of the index finger in the svg, 24/64 across, 6/64 down) sits on
   the point set in left/top. */
.ghost-hand { position: fixed; z-index: 5; width: 56px; height: 56px; pointer-events: none;
  transform: translate(-37.5%, -9%); animation: ghost-tap 1.2s ease-in-out infinite; }
.ghost-hand[hidden] { display: none; }
@keyframes ghost-tap {
  0%, 100% { transform: translate(-37.5%, -9%) scale(1); opacity: 0.95; }
  50% { transform: translate(-37.5%, -2%) scale(0.88); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) { .ghost-hand { animation: none; } }
