:root {
  --sky: #1b2550;
  --ink: #1b2550;
  --foam: #fff4e0;
  --paper: #fffaf2;
  --tangerine: #ff7a45;
  --sun: #ffe566;
  --gold: #f2b035;
  --lagoon: #1aa6a6;
  --lagoon-deep: #0e7a7a;
  --berry: #ff5c7a;
  --skin: #f6c7a4;
  --skin-deep: #e7b08a;
  --line: #c47b58;
  --key-h: 48px;
  --key-gap: 6px;
  --tray: #152246;
  color-scheme: dark;
}

*,
*::before,
*::after { box-sizing: border-box; }

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

body {
  font-family: "Nunito", "Avenir Next", "Trebuchet MS", sans-serif;
  color: var(--foam);
  background: var(--sky);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button, select { font: inherit; }

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

.sky {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 12% 18%, #ffffff 0 1.5px, transparent 2px),
    radial-gradient(circle at 22% 32%, #fff4e0 0 1.2px, transparent 2px),
    radial-gradient(circle at 70% 16%, #fff 0 1.4px, transparent 2px),
    radial-gradient(circle at 84% 28%, #fff4e0 0 1.2px, transparent 2px),
    radial-gradient(circle at 40% 12%, #fff 0 1px, transparent 2px),
    radial-gradient(circle at 58% 24%, #fff4e0 0 1.3px, transparent 2px),
    radial-gradient(ellipse 90% 60% at 50% -10%, #31498a 0%, transparent 60%),
    var(--sky);
  padding:
    env(safe-area-inset-top)
    env(safe-area-inset-right)
    env(safe-area-inset-bottom)
    env(safe-area-inset-left);
}

.moon {
  position: fixed;
  top: 108px;
  left: max(12px, 3vw);
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: #ffe9a8;
  box-shadow: 0 0 0 10px #ffe9a822;
  z-index: 0;
}

.moon::before,
.moon::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: #f0d48a;
}

.moon::before { width: 16px; height: 16px; top: 16px; left: 18px; }
.moon::after { width: 10px; height: 10px; top: 40px; left: 38px; }

.hill {
  position: fixed;
  left: -8%;
  right: -8%;
  bottom: -48px;
  height: 200px;
  background: var(--gold);
  border-radius: 50% 50% 0 0;
  z-index: 0;
}

.top, main { position: relative; z-index: 1; }

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 22px 0;
  flex-wrap: wrap;
}

h1 {
  margin: 0;
  font-family: "Baloo 2", "Arial Rounded MT Bold", "Trebuchet MS", sans-serif;
  font-weight: 800;
  font-size: clamp(28px, 3vw, 42px);
  letter-spacing: -0.03em;
  line-height: 0.95;
  color: var(--foam);
}

.meters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.pill {
  margin: 0;
  background: var(--foam);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 14px 6px;
  font-family: "Baloo 2", "Arial Rounded MT Bold", sans-serif;
  font-size: 22px;
  line-height: 1;
  box-shadow: 0 4px 0 #c9842a;
}

.star { color: #e09a00; }

.canister {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--foam);
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 10px 6px 12px;
  box-shadow: 0 4px 0 #c9842a;
}

.canister-label {
  font-family: "Baloo 2", sans-serif;
  font-size: 16px;
}

.canister-glass {
  width: 112px;
  height: 18px;
  border-radius: 999px;
  background: #1b2550;
  overflow: hidden;
  border: 2px solid #1b2550;
}

.canister-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(#bfffe8, var(--lagoon));
  transform-origin: left center;
  transform: scaleX(1);
}

.canister.is-low .canister-fill {
  background: linear-gradient(#ffd0da, var(--berry));
}

.icon-btn {
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  background: var(--foam);
  color: var(--ink);
  box-shadow: 0 4px 0 #c9842a;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.icon-btn .slash { display: none; }
.icon-btn.is-muted .slash { display: block; }
.icon-btn.is-muted .waves { display: none; }
.icon-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #c9842a; }

main {
  width: min(1100px, calc(100% - 24px));
  margin: 0 auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  padding: 12px 0 28px;
}

.stage { text-align: center; }

.rocket {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  animation: floaty 2.8s ease-in-out infinite;
  filter: drop-shadow(0 14px 0 #10183a66);
}

.flame {
  width: 78px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-right: -14px;
  flex: none;
}

.flame span {
  display: block;
  height: 62%;
  width: 24px;
  margin-right: -12px;
  border-radius: 40% 0 0 40%;
  background: var(--tangerine);
  transform-origin: right center;
  animation: flicker 0.22s ease-in-out infinite alternate;
}

.flame span:nth-child(2) {
  background: var(--sun);
  height: 42%;
  animation-delay: -0.08s;
}

.flame span:nth-child(3) {
  background: #fffaf2;
  height: 22%;
  width: 16px;
  animation-delay: -0.14s;
}

.flame.is-puff span { transform: scaleX(1.35); }
.flame.is-boost span { transform: scaleX(1.8); }

.hull {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  background: linear-gradient(#ff9468, var(--tangerine) 42%, #f25a28);
  border-radius: 42px 16px 16px 42px;
  padding: 16px 18px 16px 14px;
  box-shadow: inset 0 -8px 0 #d94820;
}

.hull::before,
.hull::after {
  content: "";
  position: absolute;
  left: 34px;
  width: 46px;
  height: 18px;
  background: var(--gold);
}

.hull::before {
  top: -12px;
  clip-path: polygon(0 100%, 100% 100%, 28% 0);
}

.hull::after {
  bottom: -12px;
  clip-path: polygon(0 0, 100% 0, 28% 100%);
}

.comet {
  width: 74px;
  height: 74px;
  flex: none;
  border-radius: 50%;
  position: relative;
  background: radial-gradient(circle at 35% 32%, #fff6c2, var(--sun) 42%, #ffb703);
  box-shadow: 0 5px 0 #e09a00;
}

.comet::after {
  content: "";
  position: absolute;
  width: 24%;
  height: 14%;
  border-radius: 10px;
  background: #fff;
  opacity: 0.75;
  top: 14%;
  left: 18%;
  transform: rotate(-18deg);
}

.eye {
  position: absolute;
  top: 34%;
  width: 13%;
  height: 18%;
  background: var(--ink);
  border-radius: 8px;
  z-index: 1;
  animation: blink 4.6s infinite;
}

.eye.left { left: 24%; }
.eye.right { right: 24%; }

.mouth {
  position: absolute;
  left: 50%;
  bottom: 18%;
  width: 32%;
  height: 16%;
  border: 3px solid var(--ink);
  border-top: 0;
  border-radius: 0 0 16px 16px;
  transform: translateX(-50%);
  z-index: 1;
}

.comet.mood-yes .mouth { width: 36%; height: 18%; }
.comet.mood-oops .mouth {
  width: 22%;
  height: 22%;
  bottom: 16%;
  border-radius: 50%;
  border: 3px solid var(--ink);
}
.comet.mood-cheer .eye,
.comet.mood-sleep .eye,
.comet.mood-oops .eye { animation: none; }
.comet.mood-cheer .eye {
  height: 12%;
  top: 38%;
  background: transparent;
  border-bottom: 3px solid var(--ink);
  border-radius: 0 0 10px 10px;
}
.comet.mood-sleep .eye {
  height: 8%;
  top: 42%;
  background: transparent;
  border-top: 3px solid var(--ink);
  border-radius: 0;
}

.words {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  flex: 1 1 240px;
  margin: 0;
  max-width: min(720px, 100%);
  background: var(--foam);
  border-radius: 22px;
  padding: 12px;
  box-shadow: inset 0 -5px 0 #ead7b4;
}

.word {
  display: inline-flex;
  gap: 8px;
  flex: none;
}

.slot {
  min-width: 1.05em;
  height: 1.35em;
  padding: 0 0.08em;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--paper);
  color: var(--ink);
  font-family: "Nunito", "Avenir Next", sans-serif;
  font-weight: 900;
  font-size: clamp(30px, 4.4vw, 44px);
  line-height: 1;
  box-shadow: 0 4px 0 #e4d0ae;
}

.slot.is-space { min-width: 2.5em; }
.slot .space-word {
  font-family: "Baloo 2", sans-serif;
  font-size: 0.38em;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.slot.is-done {
  background: var(--lagoon);
  color: #f4fffc;
  box-shadow: 0 4px 0 var(--lagoon-deep);
  animation: pop 0.22s ease;
}

.slot.is-now {
  background: var(--sun);
  box-shadow: 0 6px 0 #d9a400;
  transform: translateY(-4px);
  animation: bob 0.7s ease-in-out infinite;
}

.slot.is-shake { animation: shake 0.28s linear; }

.porthole {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff, #9ebcff 46%, #24386e 70%);
  box-shadow: 0 0 0 5px var(--foam);
}

.nose {
  width: 58px;
  align-self: stretch;
  min-height: 86px;
  margin-left: -10px;
  flex: none;
  background: linear-gradient(#ffe566, #ffb703);
  clip-path: polygon(0 7%, 100% 50%, 0 93%);
}

.cheer {
  min-height: 1.3em;
  margin: 10px 0 0;
  font-family: "Baloo 2", sans-serif;
  font-size: clamp(26px, 4vw, 36px);
  color: var(--sun);
}

.tap-hint { display: none; margin: 0; font-weight: 800; }

.deck { display: none; }

.deck-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.deck-note {
  margin: 0;
  font-family: "Baloo 2", sans-serif;
  font-size: 20px;
  color: var(--ink);
  background: var(--sun);
  border-radius: 999px;
  padding: 4px 12px 2px;
}

.layout-pick {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  color: var(--ink);
  background: var(--foam);
  border-radius: 999px;
  padding: 4px 8px 4px 12px;
  box-shadow: 0 4px 0 #c9842a;
}

.layout-pick select {
  background: var(--foam);
  color: var(--ink);
  border: 0;
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 800;
}

.board {
  position: relative;
  background: var(--tray);
  border: 6px solid var(--gold);
  border-radius: 28px;
  padding: 14px 14px 108px;
  box-shadow: 0 12px 0 #c9842a;
}

.keystack { position: relative; }

.keygrid {
  display: grid;
  grid-template-columns: repeat(60, 1fr);
  grid-auto-rows: var(--key-h);
  gap: var(--key-gap);
}

.labels {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.key {
  position: relative;
  border-radius: 10px;
  background: linear-gradient(var(--paper), #f3e0c4);
  box-shadow: 0 4px 0 #c9a46c;
  min-width: 0;
}

.key.is-home { background: linear-gradient(#fff6d8, #ffe3a3); }
.key.is-target {
  background: var(--sun);
  box-shadow: 0 0 0 3px #fff4e0, 0 4px 0 #d9a400;
}
.key.is-down { transform: translateY(3px); box-shadow: 0 1px 0 #c9a46c; }
.key.is-bad { background: #ff8fa3; box-shadow: 0 4px 0 #d45370; }
.key.is-dead::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--tangerine);
}

.label {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  min-height: 0;
}

.tiny {
  font-family: "Nunito", sans-serif;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  color: var(--tangerine);
  margin-top: 2px;
}

.glyph {
  margin-top: 2px;
  padding: 0 4px;
  border-radius: 6px;
  background: var(--paper);
  box-shadow: 0 0 0 3px var(--paper);
  color: var(--ink);
  font-family: "Nunito", sans-serif;
  font-weight: 800;
  font-size: 13px;
  line-height: 1.15;
}

.label.is-letter .glyph {
  font-size: 18px;
  font-weight: 900;
}

.label.is-target .glyph {
  background: var(--sun);
  box-shadow: 0 0 0 3px var(--sun);
}

.label[data-code="Space"] .glyph {
  margin-top: 4px;
  background: transparent;
  box-shadow: none;
  font-family: "Baloo 2", sans-serif;
  font-size: 18px;
  letter-spacing: 0.08em;
}

.label.is-target[data-code="Space"] .glyph {
  background: var(--sun);
  box-shadow: 0 0 0 3px var(--sun);
}

.bump {
  width: 8px;
  height: 8px;
  margin-top: auto;
  margin-bottom: 4px;
  border-radius: 50%;
  background: var(--ink);
}

.hands {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  overflow: visible;
  pointer-events: none;
}

.hands .outline { stroke: var(--line); stroke-linecap: butt; }
.hands .skin { stroke: var(--skin); stroke-linecap: butt; }
.hands .tip { fill: var(--skin-deep); stroke: var(--line); stroke-width: 3; }
.hands .nail { fill: #fff0e4; }
.hands .palm { fill: #f0bc96; stroke: var(--line); stroke-width: 3; }
.hands .wrist { fill: #f0bc96; stroke: var(--line); stroke-width: 3; }
.hands .finger.is-reach .skin { stroke: var(--sun); }
.hands .finger.is-reach .tip { fill: var(--sun); }
.hands .finger.is-press .skin { stroke: #ffd000; }
.hands .finger.is-press .tip { fill: #ffb703; }
.hands .finger.is-bad .skin { stroke: #ff8fa3; }
.hands .finger.is-bad .tip { fill: var(--berry); }
.hands.is-live line,
.hands.is-live circle,
.hands.is-live ellipse,
.hands.is-live rect {
  transition: x1 0.1s linear, y1 0.1s linear, x2 0.1s linear, y2 0.1s linear, cx 0.1s linear, cy 0.1s linear, r 0.1s linear, x 0.1s linear, y 0.1s linear;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  background: #1b2550cc;
  padding: 20px;
}

.overlay[hidden] { display: none; }

.card {
  width: min(520px, 100%);
  text-align: center;
  background: var(--foam);
  color: var(--ink);
  border-radius: 36px;
  padding: 28px 28px 24px;
  box-shadow: 0 12px 0 #e09a00, 0 0 0 8px var(--tangerine);
  transform: rotate(-1.5deg);
}

.card.is-count {
  background: transparent;
  box-shadow: none;
  transform: none;
}

.kicker {
  margin: 0 0 6px;
  font-family: "Baloo 2", sans-serif;
  font-size: 18px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #c45a32;
}

.card h2 {
  margin: 0;
  font-family: "Baloo 2", "Arial Rounded MT Bold", sans-serif;
  font-size: clamp(40px, 6vw, 64px);
  line-height: 0.92;
  letter-spacing: -0.03em;
}

.card.is-count h2 {
  font-size: clamp(88px, 16vw, 140px);
  color: var(--sun);
  text-shadow: 0 8px 0 #c9842a;
}

.blurb, .best {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.35;
}

.blurb { margin: 12px 0 0; }
.best { margin: 8px 0 0; color: #c45a32; }

.go {
  margin-top: 18px;
  border: 0;
  cursor: pointer;
  background: var(--tangerine);
  color: #fffaf2;
  font-family: "Baloo 2", sans-serif;
  font-size: 32px;
  line-height: 1;
  border-radius: 999px;
  padding: 12px 36px 14px;
  box-shadow: 0 6px 0 #c44820;
}

.go:active { transform: translateY(4px); box-shadow: 0 2px 0 #c44820; }
.go:disabled { cursor: default; }

.catcher {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 48px;
  opacity: 0;
  border: 0;
  padding: 0;
  font-size: 16px;
  color: transparent;
  background: transparent;
  caret-color: transparent;
  z-index: 2;
}

.confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 4;
}

.confetti i {
  position: absolute;
  top: 38%;
  width: 12px;
  height: 18px;
  border-radius: 3px;
  animation: burst 0.95s ease-out forwards;
}

body.is-desktop .deck { display: block; }
body.is-desktop .catcher {
  width: 1px;
  height: 1px;
  overflow: hidden;
  pointer-events: none;
}
body.is-touch .tap-hint { display: block; }

:focus-visible {
  outline: 3px solid var(--sun);
  outline-offset: 3px;
}

@keyframes floaty {
  50% { transform: translateY(-7px); }
}

@keyframes flicker {
  from { transform: scaleX(0.8); }
  to { transform: scaleX(1.15); }
}

@keyframes bob {
  50% { transform: translateY(-9px); }
}

@keyframes pop {
  0% { transform: scale(0.7); }
  70% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

@keyframes shake {
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}

@keyframes blink {
  0%, 92%, 100% { transform: scaleY(1); }
  96% { transform: scaleY(0.12); }
}

@keyframes burst {
  to { transform: translate(var(--dx), 62vh) rotate(200deg); opacity: 0; }
}

@keyframes liftoff {
  0% { transform: translateX(0) rotate(0); }
  35% { transform: translateX(8%) rotate(-2deg); }
  100% { transform: translateX(115%) rotate(-8deg); }
}

.rocket.is-go { animation: liftoff 0.78s cubic-bezier(.2, .7, .2, 1) forwards; }
.rocket.is-in { animation: rollin 0.45s cubic-bezier(.2, .8, .2, 1); }

@keyframes rollin {
  from { transform: translateX(-36%); }
  to { transform: none; }
}

@media (max-width: 720px) {
  .top { padding: 12px 12px 0; }
  h1 { font-size: 26px; }
  .pill { font-size: 18px; padding: 7px 10px 5px; }
  .canister-glass { width: 72px; }
  .moon { width: 48px; height: 48px; top: 10px; }
  .words { max-width: 100%; }
  .flame { width: 42px; }
  .nose { width: 34px; }
  .comet { width: 58px; height: 58px; }
  .porthole { width: 22px; height: 22px; }
  .hull { padding: 12px; border-radius: 28px 12px 12px 28px; }
  .hull::before, .hull::after { display: none; }
}

@media (max-height: 820px) {
  :root { --key-h: 42px; }
  .board { padding-bottom: 92px; }
  main { gap: 8px; padding-top: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  .rocket,
  .flame span,
  .eye,
  .slot.is-now,
  .slot.is-done,
  .confetti i,
  .rocket.is-go,
  .rocket.is-in {
    animation: none;
  }
  .hands.is-live line,
  .hands.is-live circle,
  .hands.is-live ellipse,
  .hands.is-live rect { transition: none; }
}
