/* Moon facts
   The look is a child's exercise book laid over real space: ink-blue outlines, a periwinkle
   heading blob, a cream note panel, star yellow, rocket red and a lilac-edged fact sheet, all
   floating over a real 3D Moon. */

@font-face {
  font-family: 'Shantell Sans';
  src: url('../fonts/shantell-sans-latin.woff2') format('woff2');
  font-weight: 300 800;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Shantell Sans';
  src: url('../fonts/shantell-sans-latin-ext.woff2') format('woff2');
  font-weight: 300 800;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --ink: #1b2152;
  --night: #0c1036;
  --paper: #fff7e0;
  --peri: #cfd9ff;
  --lilac: #b7a6ec;
  --star: #ffd43b;
  --rocket: #f2573f;
  --dust: #d5d8e3;
  --white: #fffdf6;

  /* One unit that grows with the screen, so a phone and a telly both get comfortable sizes. */
  --u: clamp(0.82rem, 0.6rem + 0.9vmin, 1.3rem);
  --line: 3px;
  --hand: 'BNCE' 0, 'INFM' 0, 'SPAC' 0;
  --hand-loud: 'BNCE' 34, 'INFM' 36, 'SPAC' 0;

  /* The free rectangle between the heading and the fact panel; main.js keeps these current. */
  --sx: 0px; --sy: 0px; --sw: 100vw; --sh: 100vh;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--night);
  color: var(--ink);
  font-family: 'Shantell Sans', 'Comic Sans MS', 'Chalkboard SE', 'Comic Neue', system-ui, sans-serif;
  font-variation-settings: var(--hand);
  font-size: var(--u);
  line-height: 1.3;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg { display: block; }

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  outline: none;
}

button {
  font: inherit;
  font-variation-settings: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-appearance: none;
  appearance: none;
}
button:focus-visible, input:focus-visible { outline: 4px solid #fff; outline-offset: 3px; }

/* ---- Frame ---------------------------------------------------------------------------------- */

#ui {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: calc(var(--u) * 0.5);
  padding:
    max(calc(var(--u) * 0.7), env(safe-area-inset-top))
    max(calc(var(--u) * 0.8), env(safe-area-inset-right))
    max(calc(var(--u) * 0.8), env(safe-area-inset-bottom))
    max(calc(var(--u) * 0.8), env(safe-area-inset-left));
  pointer-events: none;
}
#ui button, #ui input, .sheet { pointer-events: auto; }

#ui[data-screen='title'] :is(.top, .bottom, .widgets, .finale),
#ui[data-screen='story'] :is(.title-screen, .finale),
#ui[data-screen='finale'] :is(.title-screen, .bottom, .widgets, .question) { display: none; }

/* The paper blob behind headings. */
.blob {
  margin: 0;
  background: var(--peri);
  color: var(--ink);
  border: var(--line) solid var(--ink);
  border-radius: 47% 53% 51% 49% / 62% 48% 52% 38%;
  box-shadow: 0 calc(var(--u) * 0.32) 0 var(--ink);
  font-weight: 800;
  font-variation-settings: var(--hand-loud);
  text-align: center;
  text-wrap: balance;
  line-height: 1.08;
}

/* ---- Title ---------------------------------------------------------------------------------- */

.title-screen {
  position: relative;
  grid-row: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(var(--u) * 1.5);
  padding-top: clamp(1rem, 7vh, 5rem);
}
.title-blob {
  max-width: min(92vw, 13em);
  padding: 0.42em 0.9em 0.5em;
  font-size: clamp(2rem, 1rem + 6.2vmin, 5.4rem);
  transform: rotate(-2deg);
  border-width: 4px;
}
.go {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  padding: 0.3em 1em 0.36em 0.7em;
  background: var(--star);
  border: 4px solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 calc(var(--u) * 0.5) 0 var(--ink);
  font-size: calc(var(--u) * 2.3);
  font-weight: 800;
  font-variation-settings: var(--hand-loud);
  transition: transform 0.08s, box-shadow 0.08s;
}
.go svg { width: 1.5em; height: 1.5em; }
.go:active:not(:disabled) { transform: translateY(calc(var(--u) * 0.36)); box-shadow: 0 calc(var(--u) * 0.14) 0 var(--ink); }
.go:disabled { background: var(--dust); cursor: progress; }
.go:disabled svg { opacity: 0.45; }
.title-tip {
  display: flex;
  align-items: center;
  gap: 0.5em;
  margin: 0;
  color: var(--peri);
  font-size: calc(var(--u) * 1.05);
  font-weight: 500;
}
.title-tip svg { width: 1.4em; height: 1.4em; flex: none; }
/* Top right of the title screen: the language menu and full screen. For the grown-up, so they are small. */
.title-tools {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: calc(var(--u) * 0.45);
}
.langs {
  position: relative;
  font-size: calc(var(--u) * 0.95);
  font-weight: 600;
  pointer-events: auto;
}
.langs summary, .langs a {
  display: flex;
  align-items: center;
  gap: 0.5em;
  color: var(--peri);
  cursor: pointer;
  white-space: nowrap;
}
.langs summary {
  padding: 0.3em 0.8em 0.34em 0.6em;
  border: 2px solid var(--peri);
  border-radius: 999px;
  background: rgb(12 16 54 / 0.8);
  list-style: none;
}
.langs summary::-webkit-details-marker { display: none; }
.langs summary::after {
  content: '';
  width: 0.4em;
  height: 0.4em;
  margin: -0.2em 0 0 0.1em;
  border: solid currentColor;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.langs[open] summary::after { margin-top: 0.2em; transform: rotate(-135deg); }
.langs .flag { width: 1.5em; height: 1em; flex: none; border-radius: 2px; }
.langs-menu {
  position: absolute;
  top: calc(100% + 0.35em);
  right: 0;
  min-width: 100%;
  padding: 0.3em;
  border: 2px solid var(--peri);
  border-radius: 0.9em;
  background: rgb(12 16 54 / 0.95);
}
.langs a { padding: 0.35em 0.6em; border-radius: 0.6em; text-decoration: none; }
.langs a[aria-current] { color: var(--star); }
.langs summary:hover, .langs summary:focus-visible, .langs a:hover, .langs a:focus-visible { background: var(--peri); color: var(--ink); }

/* ---- Top bar: where you are, the question, tools ---------------------------------------------- */

.top {
  grid-row: 1;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: calc(var(--u) * 0.6);
}
.stops { display: flex; gap: calc(var(--u) * 0.45); justify-self: start; }
.tools { display: flex; gap: calc(var(--u) * 0.45); grid-column: -2; justify-self: end; }

.stop, .tool {
  position: relative;
  display: grid;
  place-items: center;
  width: calc(var(--u) * 3.2);
  height: calc(var(--u) * 3.2);
  padding: 0;
  background: var(--paper);
  border: var(--line) solid var(--ink);
  border-radius: 50%;
  box-shadow: 0 calc(var(--u) * 0.2) 0 var(--ink);
  transition: transform 0.12s;
}
.stop > svg, .tool > svg { width: 70%; height: 70%; }
.stop[aria-current='step'] { background: var(--star); transform: scale(1.14); }
.stop .badge {
  position: absolute;
  top: -22%;
  right: -22%;
  width: 56%;
  height: 56%;
  transform: scale(0);
  transition: transform 0.35s cubic-bezier(0.3, 1.6, 0.5, 1);
}
.stop.done .badge { transform: scale(1) rotate(12deg); }
.tool { background: var(--peri); }
.tool[aria-pressed='false'] { background: var(--dust); }

.question {
  max-width: min(100%, 17em);
  padding: 0.3em 1.2em 0.38em;
  font-size: calc(var(--u) * 1.9);
}

/* ---- Bottom bar: the fact, and the two buttons that move the story ---------------------------- */

.bottom {
  grid-row: 3;
  display: grid;
  grid-template-columns: auto minmax(0, 46rem) auto;
  justify-content: center;
  align-items: end;
  gap: calc(var(--u) * 0.8);
}
.nav {
  display: grid;
  place-items: center;
  padding: 0;
  border: 4px solid var(--ink);
  border-radius: 50%;
  box-shadow: 0 calc(var(--u) * 0.42) 0 var(--ink);
  transition: transform 0.08s, box-shadow 0.08s;
}
.nav > svg { width: 56%; height: 56%; }
.nav:active { transform: translateY(calc(var(--u) * 0.3)); box-shadow: 0 calc(var(--u) * 0.12) 0 var(--ink); }
.back { width: calc(var(--u) * 3.6); height: calc(var(--u) * 3.6); background: var(--paper); }
/* The arrow stays plain while the Moon is talking, while an animation is playing, or while a star
   task is waiting. It turns yellow when it is time to press it. It can still be pressed early. */
.next {
  width: calc(var(--u) * 5.2);
  height: calc(var(--u) * 5.2);
  background: var(--paper);
  transform: scale(0.86);
  transition: transform 0.25s, background-color 0.25s, box-shadow 0.08s;
}
.back[disabled] { visibility: hidden; }
.next[data-state='ready'] { background: var(--star); transform: none; animation: ready 1.3s ease-in-out 0.3s infinite; }
@keyframes ready { 50% { transform: scale(1.09); } }

.fact {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: calc(var(--u) * 0.8);
  min-height: calc(var(--u) * 5.2);
  padding: calc(var(--u) * 0.7) calc(var(--u) * 1.2) calc(var(--u) * 0.8) calc(var(--u) * 0.8);
  background: var(--paper);
  border: var(--line) solid var(--ink);
  border-radius: calc(var(--u) * 1.7) calc(var(--u) * 1.4) calc(var(--u) * 1.8) calc(var(--u) * 1.3);
  box-shadow: 0 calc(var(--u) * 0.32) 0 var(--ink);
}
.fact.swap { animation: swap 0.22s ease-out; }
@keyframes swap { from { transform: scale(0.97); } }

.say {
  display: grid;
  place-items: center;
  width: calc(var(--u) * 3.2);
  height: calc(var(--u) * 3.2);
  padding: 0;
  background: var(--peri);
  border: var(--line) solid var(--ink);
  border-radius: 50%;
  box-shadow: 0 calc(var(--u) * 0.2) 0 var(--ink);
}
.say > svg { width: 60%; height: 60%; }
.say:active { transform: translateY(2px); }

.fact-text {
  margin: 0;
  font-size: calc(var(--u) * 1.72);
  font-weight: 600;
  line-height: 1.25;
  text-wrap: balance;
}
.fact-text .s { transition: color 0.2s, background-size 0.25s; background: linear-gradient(var(--star), var(--star)) no-repeat 0 92% / 0 0.34em; }
.fact-text.reading .s { color: #6b7095; }
.fact-text.reading .s.now { color: var(--ink); background-size: 100% 0.34em; }

.hint {
  position: absolute;
  right: calc(var(--u) * 1);
  bottom: calc(100% - var(--u) * 0.3);        /* it stands on the panel's edge, clear of the words inside */
  display: flex;
  align-items: center;
  gap: 0.4em;
  margin: 0;
  padding: 0.16em 0.9em 0.22em 0.6em;
  background: var(--star);
  border: var(--line) solid var(--ink);
  max-width: calc(100% - var(--u) * 1.6);     /* a long invitation wraps on a narrow screen */
  border-radius: calc(var(--u) * 1.5);
  box-shadow: 0 calc(var(--u) * 0.2) 0 var(--ink);
  font-size: calc(var(--u) * 1.18);
  font-weight: 700;
  line-height: 1.15;
  text-wrap: balance;
  transform: rotate(-1.5deg);
  animation: nudge 1.7s ease-in-out infinite;
}
.hint svg { width: 1.25em; height: 1.25em; flex: none; }
.hint.cheer { background: #b9f0c2; animation: none; }
/* while the Moon is saying it out loud */
.hint.calling { animation: call 0.7s ease-in-out infinite; box-shadow: 0 calc(var(--u) * 0.2) 0 var(--ink), 0 0 0 calc(var(--u) * 0.45) rgb(255 212 59 / 0.5); }
@keyframes call { 50% { transform: rotate(-1.5deg) scale(1.13); } }
@keyframes nudge { 50% { transform: rotate(-1.5deg) scale(1.06); } }

/* ---- Things scenes put on screen -------------------------------------------------------------- */

.widgets { position: absolute; inset: 0; pointer-events: none; }

.tag {
  position: absolute;
  left: 0;
  top: 0;
  padding: 0.08em 0.7em 0.14em;
  background: var(--paper);
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 3px 0 var(--ink);
  font-size: calc(var(--u) * 1.08);
  font-weight: 700;
  white-space: nowrap;
  will-change: transform;
}
.tag.num {
  display: grid;
  place-items: center;
  width: 2.1em;
  height: 2.1em;
  padding: 0;
  background: var(--star);
  font-size: calc(var(--u) * 1.5);
  font-weight: 800;
}
.tag.shout {
  padding: 0.05em 0.6em 0.12em;
  background: #fff;
  border-width: 3px;
  border-radius: 1.1em 1.1em 1.1em 0.25em;
  font-size: calc(var(--u) * 2);
  font-weight: 800;
  font-variation-settings: var(--hand-loud);
}
.tag.pop { animation: pop 0.34s cubic-bezier(0.3, 1.7, 0.5, 1); }
@keyframes pop { from { scale: 0.2; } }

.tally, .chip {
  position: absolute;
  left: calc(var(--sx) + var(--sw) / 2);
  top: calc(var(--sy) + var(--u) * 0.4);
  transform: translateX(-50%);
  display: flex;
  align-items: baseline;
  gap: 0.35em;
  padding: 0.05em 0.9em 0.12em;
  background: var(--paper);
  border: var(--line) solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 calc(var(--u) * 0.24) 0 var(--ink);
  font-size: calc(var(--u) * 1.5);
  font-weight: 700;
  white-space: nowrap;
}
.tally b { min-width: 1.3em; font-size: 1.7em; font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; }
/* On a tall screen the Earths are stacked up the middle with the Moon's name at the top, so the tally stands beside them. */
.tally.beside {
  left: calc(var(--sx) + var(--sw) * 0.76);
  top: calc(var(--sy) + var(--sh) * 0.36);
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 0.3em 0.8em 0.4em;
  border-radius: calc(var(--u) * 1.6);
  line-height: 1.05;
}
.tally.beside b { min-width: 0; }
.chip { background: var(--star); font-weight: 800; }
.chip.pop { animation: chip 0.3s cubic-bezier(0.3, 1.7, 0.5, 1); }
@keyframes chip { from { scale: 0.7; } }

.countdown {
  position: absolute;
  left: calc(var(--sx) + var(--sw) / 2);
  top: calc(var(--sy) + var(--sh) / 2);
  transform: translate(-50%, -50%);
  color: var(--star);
  font-size: min(calc(var(--u) * 12), calc(var(--sh) * 0.7));
  font-weight: 800;
  line-height: 1;
  -webkit-text-stroke: 0.09em var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 0.06em 0 var(--ink);
}
.countdown.pop { animation: count 0.4s cubic-bezier(0.2, 1.4, 0.4, 1); }
@keyframes count { from { scale: 1.7; opacity: 0.2; } }

.launch {
  position: absolute;
  left: calc(var(--sx) + var(--sw) / 2);
  top: calc(var(--sy) + var(--sh) - var(--u) * 0.6);
  transform: translate(-50%, -100%);
  display: grid;
  place-items: center;
  width: calc(var(--u) * 6);
  height: calc(var(--u) * 6);
  padding: 0;
  background: var(--rocket);
  border: 4px solid var(--ink);
  border-radius: 50%;
  box-shadow: 0 calc(var(--u) * 0.5) 0 var(--ink), 0 0 0 calc(var(--u) * 0.55) rgb(242 87 63 / 0.28);
  transition: translate 0.08s, box-shadow 0.08s;
}
.launch svg { width: 66%; height: 66%; }
.launch:active { translate: 0 calc(var(--u) * 0.36); box-shadow: 0 calc(var(--u) * 0.14) 0 var(--ink), 0 0 0 calc(var(--u) * 0.55) rgb(242 87 63 / 0.28); }

.thermo {
  position: absolute;
  left: calc(var(--sx) + var(--u) * 0.4);
  top: calc(var(--sy) + var(--sh) / 2);
  transform: translateY(-50%);
  display: grid;
  justify-items: center;
  gap: 0.35em;
  padding: 0.6em 0.5em 0.4em;
  background: var(--paper);
  border: var(--line) solid var(--ink);
  border-radius: calc(var(--u) * 1.3);
  box-shadow: 0 calc(var(--u) * 0.28) 0 var(--ink);
  font-size: calc(var(--u) * 1.3);
}
.thermo-tube {
  position: relative;
  width: calc(var(--u) * 1.5);
  height: min(calc(var(--u) * 10), calc(var(--sh) * 0.46));
  overflow: hidden;
  background: #fff;
  border: var(--line) solid var(--ink);
  border-radius: 999px;
}
.thermo-fill { position: absolute; inset: auto 0 0; height: 90%; background: var(--rocket); transition: height 0.4s, background-color 0.6s; }
.thermo[data-cold='true'] .thermo-fill { background: #4aa3f5; }
.thermo b { min-width: 4.1em; font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; }

.porthole {
  position: absolute;
  overflow: hidden;
  container-type: inline-size;
  border: var(--line) solid var(--ink);
  border-radius: calc(var(--u) * 1.6);
  box-shadow: 0 calc(var(--u) * 0.32) 0 var(--ink);
}
.porthole-window { aspect-ratio: 1; padding: calc(var(--u) * 0.6); overflow: hidden; }
.porthole-glass {
  width: 100%;
  height: 100%;
  border: var(--line) solid var(--ink);
  border-radius: 50%;
  /* The round window is a hole: this huge shadow is the card around it. */
  box-shadow: 0 0 0 100vmax var(--paper);
}
.porthole-text {
  position: relative;
  display: grid;
  margin: 0;
  padding: 0 0.5em 0.5em;
  background: var(--paper);
  text-align: center;
  font-size: calc(var(--u) * 0.98);
  font-size: clamp(0.45rem, 7.6cqw, calc(var(--u) * 0.98));     /* "Partial eclipse" has to fit the smallest card */
  font-weight: 500;
  line-height: 1.15;
  white-space: nowrap;
}
.porthole-text b { font-size: 1.42em; font-weight: 800; }

.phase-bar {
  position: absolute;
  left: calc(var(--sx) + var(--sw) / 2);
  top: calc(var(--sy) + var(--sh));
  width: min(calc(var(--sw) * 0.94), 40rem);
  transform: translate(-50%, -100%);
  --thumb: calc(var(--u) * 3.3);
  --tick: calc(var(--u) * 1.5);
}
.phase-ticks { display: flex; justify-content: space-between; padding: 0 calc((var(--thumb) - var(--tick)) / 2); }
.phase-ticks svg { width: var(--tick); height: var(--tick); }
.phase-bar input {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: calc(var(--thumb) + 8px);
  margin: 0;
  background: transparent;
  cursor: grab;
  touch-action: none;
}
.phase-bar input::-webkit-slider-runnable-track {
  height: calc(var(--u) * 1.1);
  background: var(--paper);
  border: var(--line) solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 3px 0 var(--ink);
}
.phase-bar input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: var(--thumb);
  height: var(--thumb);
  margin-top: calc((var(--u) * 1.1 - var(--line) * 2 - var(--thumb)) / 2);
  background: var(--star);
  border: 4px solid var(--ink);
  border-radius: 50%;
  box-shadow: 0 4px 0 var(--ink);
}
.phase-bar input::-moz-range-track {
  height: calc(var(--u) * 1.1);
  background: var(--paper);
  border: var(--line) solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 3px 0 var(--ink);
}
.phase-bar input::-moz-range-thumb {
  width: var(--thumb);
  height: var(--thumb);
  background: var(--star);
  border: 4px solid var(--ink);
  border-radius: 50%;
  box-shadow: 0 4px 0 var(--ink);
}

/* ---- The ending: a sheet of all the facts, and a badge --------------------------------------------- */

.finale {
  grid-row: 2 / -1;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  place-items: center;
  min-height: 0;
}
.sheet {
  width: min(100%, 70rem);
  max-height: 100%;
  overflow: auto;
  padding: calc(var(--u) * 1.2) calc(var(--u) * 1.6) calc(var(--u) * 1.3);
  background: var(--white);
  border: calc(var(--u) * 0.42) solid var(--lilac);
  border-radius: calc(var(--u) * 2);
  box-shadow: 0 calc(var(--u) * 0.5) 0 rgb(8 10 36 / 0.6);
  -webkit-user-select: text;
  user-select: text;
}
.sheet-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4em 1.2em; }
.sheet-head h2 { margin-right: auto; }
.sheet h2 { margin: 0; font-size: calc(var(--u) * 2.2); font-weight: 800; font-variation-settings: var(--hand-loud); }
.sheet-stars { display: flex; gap: 0.2em; }
.sheet-stars svg { width: calc(var(--u) * 2); height: calc(var(--u) * 2); }
.sheet-stars svg.empty { filter: grayscale(1); opacity: 0.3; }
.sheet-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(9rem, 20%);
  align-items: start;
  gap: calc(var(--u) * 1.6);
  margin-top: calc(var(--u) * 0.4);
}
.facts { min-width: 0; margin: 0; padding: 0; list-style: none; columns: 2 19rem; column-gap: calc(var(--u) * 1.6); }
.facts li {
  break-inside: avoid;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.6em;
  padding: 0.34em 0 0.28em;
  border-bottom: 2px solid #d6cff3;
  border-radius: 0.5em;
  font-size: calc(var(--u) * 1.16);
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;                 /* the whole row reads the fact aloud, not just its little button */
}
.facts li:active { background: var(--peri); }
.facts li.now { background: #fff1b8; }             /* the fact she is reading out */
.sheet-said { min-height: 1.3em; margin: 0.25em 0 0; font-size: calc(var(--u) * 1.3); font-weight: 700; }
.facts li > svg { width: 1.7em; height: 1.7em; }
.facts .say { width: 1.9em; height: 1.9em; box-shadow: 0 2px 0 var(--ink); }
.badge { display: grid; justify-items: center; gap: 0.3em; margin: 0; text-align: center; }
.badge > svg { width: min(100%, 13rem); }
.badge-ribbon { fill: var(--lilac); stroke: var(--ink); stroke-width: 5; stroke-linejoin: round; }
.badge figcaption { display: grid; justify-items: center; gap: 0.25em; font-size: calc(var(--u) * 1.15); font-weight: 600; }
.badge .sheet-stars { flex-wrap: wrap; justify-content: center; }
.badge .sheet-stars svg { width: calc(var(--u) * 1.5); height: calc(var(--u) * 1.5); }
.badge figcaption b { font-size: 1.22em; white-space: nowrap; font-weight: 800; font-variation-settings: var(--hand-loud); }
.finale.play .badge > svg { animation: badge 0.7s cubic-bezier(0.3, 1.5, 0.5, 1) 0.5s backwards; }
@keyframes badge { from { transform: scale(0.3) rotate(-25deg); opacity: 0; } }

.sheet-small { margin: 0.5em 0 0; color: #585d86; font-size: max(0.82rem, calc(var(--u) * 0.86)); font-weight: 400; line-height: 1.4; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: calc(var(--u) * 0.6); }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  padding: 0.28em 1em 0.34em 0.8em;
  background: var(--star);
  border: var(--line) solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 calc(var(--u) * 0.26) 0 var(--ink);
  font-size: calc(var(--u) * 1.1);
  font-weight: 700;
}
.pill svg { width: 1.2em; height: 1.2em; }
.pill:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.pill.quiet { background: var(--white); padding-left: 1em; }

/* ---- Overlays --------------------------------------------------------------------------------- */

.iris {
  position: absolute;
  inset: 0;
  z-index: 50;
  pointer-events: auto;
  background: radial-gradient(circle at var(--ix, 50%) var(--iy, 50%), transparent calc(var(--ir, 0px) - 1.5px), #0a0d2c var(--ir, 0px));
}
.fly-star { position: absolute; left: 0; top: 0; z-index: 40; width: calc(var(--u) * 4.4); height: calc(var(--u) * 4.4); pointer-events: none; will-change: transform; }
.confetti { position: absolute; inset: 0; z-index: 30; overflow: hidden; pointer-events: none; }
.confetti svg {
  position: absolute;
  left: 50%;
  top: 42%;
  width: calc(var(--u) * 2.2);
  height: calc(var(--u) * 2.2);
  animation: burst 1.5s cubic-bezier(0.15, 0.7, 0.3, 1) forwards;
}
@keyframes burst {
  from { transform: translate(-50%, -50%) scale(0.2); opacity: 1; }
  70% { opacity: 1; }
  to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(var(--rot)) scale(1); opacity: 0; }
}

.fallback { position: fixed; inset: 0; z-index: 60; overflow: auto; padding: 2rem; background: var(--night); color: var(--paper); font-size: 1.2rem; }
.fallback h1 { margin: 0 0 0.5em; }
.fallback li { margin: 0.5em 0; }

/* ---- Narrow and short screens ------------------------------------------------------------------ */

/* Tall, narrow screens (a phone held upright): the heading and the fact panel each get a row of their own.
   A phone held sideways keeps the single-row layout, because there height is the scarce thing. */
@media (max-width: 880px) and (orientation: portrait) {
  .top { grid-template-columns: 1fr auto; }
  .question { grid-column: 1 / -1; grid-row: 2; justify-self: center; }
  .bottom { grid-template-columns: auto 1fr auto; align-items: center; }
  .fact { grid-column: 1 / -1; grid-row: 1; }
  .back { grid-column: 1; grid-row: 2; }
  .next { grid-column: 3; grid-row: 2; width: calc(var(--u) * 4.6); height: calc(var(--u) * 4.6); }
  .sheet-body { grid-template-columns: 1fr; }
  .badge { order: -1; }
  .badge > svg { width: 8.5rem; }
}
@media (max-width: 520px) {
  .stops, .tools { gap: calc(var(--u) * 0.3); }
  .stop, .tool { width: calc(var(--u) * 2.75); height: calc(var(--u) * 2.75); border-width: 2.5px; }
  #full, #full-title { display: none; }
}
@media (max-height: 520px) {
  :root { --u: clamp(0.72rem, 0.5rem + 0.9vmin, 1rem); }
  .launch { left: calc(var(--sx) + var(--sw) - var(--u) * 4); width: calc(var(--u) * 5); height: calc(var(--u) * 5); }
  .title-screen { padding-top: 0.6rem; gap: 0.8rem; }
  .title-blob { font-size: clamp(1.5rem, 1rem + 4vmin, 2.6rem); }
}

@media (prefers-reduced-motion: reduce) {
  .hint, .hint.calling, .next[data-state='ready'], .fact.swap, .tag.pop, .chip.pop, .countdown.pop { animation: none; }
  .next[data-state='ready'] { outline: 4px solid #fff; outline-offset: 3px; }
  .finale.play .badge > svg { animation: none; }
  .confetti { display: none; }
}

/* ---- Print: just the fact sheet, in ink -------------------------------------------------------- */

@media print {
  body { overflow: visible; background: #fff; }
  #stage, .top, .bottom, .widgets, .title-screen, .iris, .fly-star, .confetti, .sheet-actions, .facts .say { display: none !important; }
  #ui { position: static; display: block; padding: 0; }
  #ui[data-screen] .finale { display: block; }
  .sheet { width: 100%; max-height: none; overflow: visible; box-shadow: none; }
  .badge > svg { animation: none !important; }
  .facts li { cursor: auto; }
  .facts li.now { background: none; }
  .sheet-said { display: none; }
}
