@font-face {
  font-family: "Baloo 2";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("/fonts/baloo2-latin.woff2") format("woff2");
}

:root {
  --sky-top: #6cc8ff;
  --sky-bottom: #d8f2ff;
  --ink: #17324d;
  --coral: #ff5d73;
  --coral-light: #ff8a9a;
  --sun: #ffd23f;
  --sun-dark: #f2b705;
  --leaf: #2bb673;
  --leaf-dark: #1e8f59;
  --white: #ffffff;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: "Baloo 2", "Trebuchet MS", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 12%, rgba(255, 255, 255, .55) 0 38px, transparent 39px),
    radial-gradient(circle at 85% 22%, rgba(255, 255, 255, .45) 0 26px, transparent 27px),
    linear-gradient(var(--sky-top), var(--sky-bottom));
  background-color: var(--sky-bottom);
  -webkit-tap-highlight-color: transparent;
}

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: max(20px, env(safe-area-inset-top)) 16px 8px;
}

.brand {
  margin: 0;
  padding: 2px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .7);
  font-weight: 600;
  font-size: 1rem;
}

h1 {
  margin: 10px 0 0;
  font-weight: 800;
  font-size: clamp(2rem, 9vw, 3rem);
  line-height: 1;
  color: var(--white);
  text-shadow: 0 3px 0 var(--ink);
  letter-spacing: .5px;
}

h1 span { color: var(--sun); }

/* ---------- the box ---------- */

.box {
  position: relative;
  width: min(78vw, 320px);
  margin: 44px 0 4px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  border-radius: 24px;
  touch-action: manipulation;
}

.box:focus-visible {
  outline: 4px dashed var(--ink);
  outline-offset: 6px;
}

.box svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.box-face { fill: var(--coral); }
.lid-face { fill: var(--coral-light); }
.ribbon, .bow { fill: var(--sun); }
.bow-knot { fill: var(--sun-dark); }
.shadow { fill: rgba(23, 50, 77, .18); }

.mark {
  fill: var(--white);
  font-family: "Baloo 2", "Trebuchet MS", sans-serif;
  font-weight: 800;
  font-size: 92px;
  paint-order: stroke;
  stroke: var(--ink);
  stroke-width: 6px;
}

.body, .lid {
  transform-box: fill-box;
  transform-origin: 50% 100%;
}

.lid { transition: transform .45s cubic-bezier(.3, 1.6, .5, 1); }

[data-state="closed"] .box svg { animation: bob 2.2s ease-in-out infinite; }
[data-state="closed"] .box:active svg { animation: none; transform: scale(.95); }

[data-state="playing"] .lid,
[data-state="open"] .lid { transform: translate(-10%, -48%) rotate(-16deg); }

[data-state="playing"] .body { animation: wiggle .5s ease-in-out; }

[data-state="open"] .box,
[data-state="playing"] .box { cursor: default; }

/* music notes float up while the sound plays */
.notes {
  position: absolute;
  inset: 18% 0 auto;
  pointer-events: none;
}

.notes i {
  position: absolute;
  left: 50%;
  font-style: normal;
  font-weight: 800;
  font-size: 2.6rem;
  color: var(--ink);
  opacity: 0;
}

[data-state="playing"] .notes i { animation: float 1.8s ease-out infinite; }
.notes i:nth-child(1) { margin-left: -70px; }
.notes i:nth-child(2) { margin-left: -12px; animation-delay: .6s !important; }
.notes i:nth-child(3) { margin-left: 46px; animation-delay: 1.2s !important; }

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

@keyframes wiggle {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(-5deg); }
  40% { transform: rotate(5deg); }
  60% { transform: rotate(-3deg); }
  80% { transform: rotate(3deg); }
}

@keyframes float {
  0% { opacity: 0; transform: translateY(20px) scale(.6); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-90px) scale(1.1); }
}

/* ---------- text + buttons ---------- */

.prompt {
  margin: 6px 0 0;
  font-weight: 800;
  font-size: clamp(1.4rem, 6.5vw, 1.9rem);
  line-height: 1.15;
}

.counter {
  min-height: 1.5em;
  margin: 2px 0 0;
  font-weight: 600;
  font-size: 1rem;
  opacity: .75;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 10px;
  width: 100%;
  max-width: 420px;
}

.actions[hidden] { display: none; }

.btn {
  flex: 1 1 140px;
  min-height: 60px;
  padding: 8px 10px;
  border: 0;
  border-radius: 18px;
  font: inherit;
  font-weight: 800;
  font-size: clamp(1rem, 4.6vw, 1.3rem);
  white-space: nowrap;
  color: var(--white);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .08s, box-shadow .08s;
}

.btn:focus-visible { outline: 4px dashed var(--ink); outline-offset: 3px; }
.btn:active { transform: translateY(4px); }

.btn-again { background: var(--leaf); box-shadow: 0 6px 0 var(--leaf-dark); }
.btn-again:active { box-shadow: 0 2px 0 var(--leaf-dark); }

.btn-next { background: var(--coral); box-shadow: 0 6px 0 #d63d55; }
.btn-next:active { box-shadow: 0 2px 0 #d63d55; }

.hint {
  max-width: 420px;
  margin: 14px 0 0;
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--white);
  font-weight: 600;
}

.foot {
  padding: 12px 16px max(14px, env(safe-area-inset-bottom));
  text-align: center;
  font-size: .95rem;
  font-weight: 600;
}

.foot p { margin: 2px 0; }
.foot a { color: inherit; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  [data-state="playing"] .notes i { opacity: 1; }
}
