:root {
  --ink: #3b2468;
  --cream: #fff8ee;
  --sun: #ffe566;
  --sun-shadow: #e2b400;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: Fredoka, "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
  background: #2a2158;
  overscroll-behavior: none;
}

button, p, h1, h2 { font-family: inherit; }

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

.noscript {
  margin: 16px;
  color: white;
  font-size: 1.2rem;
}

.sky-page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 18% 16%, rgba(255, 255, 255, 0.16), transparent 22%),
    radial-gradient(circle at 82% 12%, rgba(255, 214, 102, 0.22), transparent 18%),
    linear-gradient(180deg, #3c2d86 0%, #6a54d6 42%, #241b4e 100%);
}

.app {
  width: min(440px, 100%);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: linear-gradient(180deg, #6d5bdc 0%, #b7a4ff 30%, #f7b6d8 66%, #ffe29a 100%);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px 8px;
  background: rgba(255, 248, 238, 0.92);
  z-index: 2;
}

h1 {
  margin: 0;
  font-size: clamp(1.05rem, 3.6vw, 1.4rem);
  line-height: 1.1;
}

.hud {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.pill {
  margin: 0;
  min-width: 68px;
  padding: 6px 10px;
  border-radius: 999px;
  background: white;
  border: 2px solid #efe4ff;
  font-size: 1.05rem;
  font-weight: 700;
  text-align: center;
}

.icon-btn,
.mover,
.play {
  font: inherit;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  border: 3px solid var(--ink);
}

.icon-btn {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: white;
  font-size: 1.35rem;
  line-height: 1;
}

.icon-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

#stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

#stage::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 22px;
  background: linear-gradient(180deg, transparent, rgba(255, 196, 92, 0.55));
  pointer-events: none;
  z-index: 1;
}

.decor, #items, #fx { position: absolute; inset: 0; pointer-events: none; }
#fx, #items { z-index: 2; }
.decor { z-index: 0; }

.moon {
  position: absolute;
  top: 16px;
  right: 18px;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: #fff6c2;
  box-shadow: inset -14px -8px 0 #f3cb62, 0 0 0 6px rgba(255, 246, 194, 0.28), 0 0 28px rgba(255, 246, 194, 0.7);
}

.moon span {
  position: absolute;
  top: 24px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink);
}

.moon span:first-child { left: 18px; }
.moon span:nth-child(2) { left: 38px; }

.moon i {
  position: absolute;
  left: 22px;
  top: 38px;
  width: 22px;
  height: 10px;
  border-bottom: 3px solid var(--ink);
  border-radius: 0 0 12px 12px;
}

.cloud {
  position: absolute;
  height: 26px;
  background: rgba(255, 255, 255, 0.82);
  border-radius: 20px;
}

.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  background: inherit;
  border-radius: 50%;
}

.c1 { width: 92px; top: 54px; left: 8%; animation: drift 18s linear infinite; }
.c1::before { width: 36px; height: 36px; left: 14px; top: -18px; }
.c1::after { width: 28px; height: 28px; left: 42px; top: -12px; }

.c2 { width: 74px; top: 108px; left: 62%; animation: drift 22s linear infinite reverse; }
.c2::before { width: 30px; height: 30px; left: 12px; top: -14px; }
.c2::after { width: 22px; height: 22px; left: 36px; top: -10px; }

.twinkles i {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 0 8px white;
  animation: twinkle 2.4s ease-in-out infinite;
}

.twinkles i:nth-child(1) { top: 18%; left: 12%; }
.twinkles i:nth-child(2) { top: 28%; left: 46%; animation-delay: 0.4s; }
.twinkles i:nth-child(3) { top: 12%; left: 70%; animation-delay: 0.8s; }
.twinkles i:nth-child(4) { top: 40%; left: 24%; width: 5px; height: 5px; animation-delay: 1.1s; }
.twinkles i:nth-child(5) { top: 48%; left: 78%; animation-delay: 0.2s; }
.twinkles i:nth-child(6) { top: 62%; left: 14%; width: 6px; height: 6px; animation-delay: 1.4s; }
.twinkles i:nth-child(7) { top: 70%; left: 58%; animation-delay: 0.6s; }
.twinkles i:nth-child(8) { top: 34%; left: 88%; width: 5px; height: 5px; animation-delay: 1.7s; }

.catcher {
  position: absolute;
  left: 0;
  bottom: 8px;
  width: 132px;
  z-index: 3;
  pointer-events: none;
  filter: drop-shadow(0 8px 0 rgba(59, 36, 104, 0.12));
}

.catcher svg { display: block; width: 100%; height: auto; }

.catcher-bob { animation: idle 1.8s ease-in-out infinite; transform-origin: 50% 80%; }

.catcher-bob.hop { animation: hop 0.28s ease; }

.item {
  position: absolute;
  top: 0;
  left: 0;
  display: grid;
  place-items: center;
  font-size: 42px;
  line-height: 1;
  filter: drop-shadow(0 4px 0 rgba(59, 36, 104, 0.12));
}

.item.pop { animation: pop 0.28s ease forwards; }

.floater {
  position: absolute;
  font-size: 1.45rem;
  font-weight: 700;
  color: white;
  text-shadow: 0 2px 0 var(--ink);
  animation: floatup 0.7s ease forwards;
}

.spark {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  animation: spark 0.5s ease-out forwards;
}

.countdown {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  margin: 0;
  font-size: clamp(4.2rem, 22vw, 6rem);
  font-weight: 700;
  color: white;
  text-shadow: 0 6px 0 rgba(59, 36, 104, 0.35);
  pointer-events: none;
}

.countdown[hidden] { display: none; }

.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(59, 36, 104, 0.28);
}

.overlay[hidden] { display: none; }

#overlay-menu {
  align-items: start;
  padding-top: 12px;
}

.card {
  width: min(360px, 100%);
  padding: 18px 16px 16px;
  border-radius: 28px;
  background: rgba(255, 248, 238, 0.96);
  border: 3px solid white;
  box-shadow: 0 16px 40px rgba(59, 36, 104, 0.25);
  text-align: center;
}

.hello {
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #8b5cf6;
}

.card h2 {
  margin: 4px 0 12px;
  font-size: clamp(1.45rem, 5vw, 1.85rem);
  line-height: 1.15;
}

.steps {
  display: flex;
  gap: 8px;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}

.steps li {
  flex: 1;
  margin: 0;
  padding: 8px 4px;
  border-radius: 16px;
  background: white;
  font-weight: 700;
}

.steps span {
  display: block;
  font-size: 1.5rem;
  line-height: 1.2;
}

.note, .scoreline, .bestline {
  margin: 0 0 12px;
  font-size: 1.05rem;
  line-height: 1.35;
}

.scoreline { font-size: 1.25rem; font-weight: 700; margin-bottom: 4px; }
.bestline { min-height: 1.3em; color: #6d28d9; font-weight: 700; }

.stars {
  margin: 0;
  font-size: 2rem;
  letter-spacing: 0.08em;
}

.play {
  width: 100%;
  min-height: 64px;
  border-radius: 999px;
  background: var(--sun);
  font-size: 1.7rem;
  box-shadow: 0 6px 0 var(--sun-shadow);
}

.play:active { transform: translateY(3px); box-shadow: 0 3px 0 var(--sun-shadow); }

footer {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255, 248, 238, 0.94);
  z-index: 2;
}

.hint {
  margin: 0;
  text-align: center;
  font-size: 0.95rem;
  line-height: 1.25;
}

.mover {
  width: 76px;
  height: 76px;
  border-radius: 24px;
  background: white;
  font-size: 1.8rem;
  box-shadow: 0 5px 0 #d9c7f5;
}

.mover:active { transform: translateY(3px); box-shadow: 0 2px 0 #d9c7f5; }

button:focus-visible {
  outline: 4px solid #7c3aed;
  outline-offset: 2px;
}

.pill.bump { animation: bump 0.22s ease; }

@media (min-width: 760px) {
  .app {
    height: min(900px, calc(100dvh - 32px));
    border-radius: 32px;
    border: 4px solid rgba(255, 255, 255, 0.75);
    box-shadow: 0 24px 60px rgba(20, 10, 50, 0.45);
  }
}

@media (max-height: 620px) {
  .catcher { width: 104px; bottom: 2px; }
  .mover { width: 60px; height: 60px; border-radius: 18px; }
  .play { min-height: 54px; font-size: 1.4rem; }
  .card h2 { font-size: 1.3rem; margin-bottom: 8px; }
  .hint { font-size: 0.8rem; }
  header { padding: 6px 10px; }
  .icon-btn { width: 44px; height: 44px; }
  .moon { width: 48px; height: 48px; }
}

@media (max-width: 360px) {
  .hint { display: none; }
  footer { grid-template-columns: 1fr 1fr; }
  #btn-right { justify-self: end; }
}

@media (prefers-reduced-motion: reduce) {
  .catcher-bob,
  .cloud,
  .twinkles i,
  .item.pop,
  .floater,
  .spark,
  .pill.bump {
    animation: none !important;
  }
}

@keyframes idle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

@keyframes hop {
  40% { transform: translateY(-16px) scale(1.04); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes pop {
  to { scale: 1.45; opacity: 0; }
}

@keyframes floatup {
  to { transform: translateY(-36px); opacity: 0; }
}

@keyframes spark {
  to { transform: translate(var(--dx), var(--dy)); opacity: 0; }
}

@keyframes bump {
  40% { transform: scale(1.12); }
}

@keyframes drift {
  from { transform: translateX(0); }
  to { transform: translateX(28px); }
}

@keyframes twinkle {
  0%, 100% { opacity: 0.35; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.15); }
}
