:root {
  --font: Calibri, "Segoe UI", Inter, Arial, Helvetica, sans-serif;
  --ink: #23324d;
  --pink: #ff5f9e;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: #0f1b2e; font-family: var(--font); color: var(--ink); }
body.locked { overflow: hidden; }

/* phone-sized column, centred on larger screens */
#stage {
  position: fixed; top: 0; left: 50%; transform: translateX(-50%);
  width: min(100vw, 480px); height: 100vh; height: 100dvh;
  overflow: hidden;
  background: linear-gradient(180deg, #7fcbff 0%, #bfe6ff 45%, #ffe9cc 100%);
  touch-action: pan-y;
}
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#spacer { width: 1px; }

/* HUD */
#hud { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .6s; }
#hud.show { opacity: 1; }
#age {
  position: absolute; left: 16px; top: calc(env(safe-area-inset-top) + 14px);
  display: flex; flex-direction: column; line-height: 1;
}
#age .lbl { font-size: 12px; font-weight: 700; letter-spacing: .24em; opacity: .65; }
#ageNum {
  font-size: 64px; font-weight: 800; color: #fff; margin-top: 2px;
  text-shadow: 0 3px 0 rgba(35, 50, 77, .35);
  transform-origin: left bottom;
}
#ageNum.tick { animation: tick .35s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes tick { 0% { transform: scale(.8); } 100% { transform: scale(1); } }

#ruler {
  position: absolute; right: 8px; margin: 0; padding: 6px 4px 6px 8px;
  top: calc(env(safe-area-inset-top) + 14px); bottom: calc(env(safe-area-inset-bottom) + 14px);
  display: flex; flex-direction: column; justify-content: space-between; align-items: flex-end;
  list-style: none; pointer-events: auto;
  background: rgba(255, 255, 255, .28); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  border-radius: 18px; --k: 0;
}
#ruler::before, #ruler::after {
  content: ""; position: absolute; left: 6px; top: 12px; bottom: 12px; width: 3px; border-radius: 2px;
  background: rgba(35, 50, 77, .18);
}
#ruler::after { bottom: auto; height: calc((100% - 24px) * var(--k)); background: var(--pink); transition: height .25s; }
#ruler li {
  position: relative; min-width: 24px; text-align: center; font-size: 11px; font-weight: 700; line-height: 1;
  padding: 2px 5px; border-radius: 10px; color: rgba(35, 50, 77, .55); cursor: pointer;
  transition: transform .25s cubic-bezier(.2, 1.5, .4, 1), background .2s, color .2s;
}
#ruler li.past { color: var(--ink); }
#ruler li.cur {
  background: var(--pink); color: #fff; transform: scale(1.35); transform-origin: right center;
  box-shadow: 0 2px 8px rgba(255, 95, 158, .55);
}

#hint {
  position: absolute; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 18px); transform: translateX(-50%);
  font-weight: 700; font-size: 14px; letter-spacing: .08em; color: #fff; background: rgba(35, 50, 77, .55);
  padding: 8px 16px 8px 18px; border-radius: 999px; opacity: 0; transition: opacity .4s; white-space: nowrap;
}
#hint::after { content: "\2193"; display: inline-block; margin-left: 8px; animation: nudge 1.2s ease-in-out infinite; }
#hint.show { opacity: 1; }
@keyframes nudge { 50% { transform: translateY(4px); } }

/* hold-to-play button */
#auto {
  position: absolute; left: 14px; bottom: calc(env(safe-area-inset-bottom) + 16px);
  width: 62px; height: 62px; border-radius: 50%; border: 3px solid #fff; cursor: pointer;
  background: var(--pink); color: #fff; pointer-events: auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  box-shadow: 0 5px 0 #d63d7d, 0 10px 18px rgba(35, 50, 77, .3);
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: transform .12s, box-shadow .12s, opacity .3s;
}
#auto .ico { font-size: 20px; line-height: 1; padding-left: 2px; }
#auto .cap { font: 800 10px var(--font); letter-spacing: .12em; }
#auto:disabled { opacity: .35; cursor: default; }
#auto.on { transform: translateY(4px) scale(.96); box-shadow: 0 1px 0 #d63d7d, 0 4px 10px rgba(35, 50, 77, .3); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { background: #ff80b3; } }

/* menu */
#menu {
  position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 24px; transition: opacity .5s, transform .6s cubic-bezier(.6, 0, .8, .4);
  background:
    radial-gradient(circle at 50% 108%, #8bd673 0 38%, transparent 38.3%),
    radial-gradient(circle at 78% 22%, rgba(255, 244, 190, .95) 0 34px, transparent 35px);
}
#menu.hide { opacity: 0; transform: translateY(-30px); pointer-events: none; }
#menu .eyebrow { margin: 0 0 10px; font-weight: 700; letter-spacing: .22em; text-transform: uppercase; font-size: 12px; opacity: .7; }
#menu h1 {
  margin: 0 0 40px; font-size: clamp(48px, 15vw, 68px); line-height: .98; font-weight: 800; color: #fff;
  text-shadow: 0 4px 0 var(--pink), 0 8px 0 rgba(35, 50, 77, .25);
  animation: float 3.2s ease-in-out infinite;
}
@keyframes float { 50% { transform: translateY(-8px); } }
#start {
  font: 800 22px var(--font); letter-spacing: .06em; color: #fff; background: var(--pink);
  border: 0; border-radius: 999px; padding: 16px 54px; cursor: pointer;
  box-shadow: 0 6px 0 #d63d7d, 0 14px 24px rgba(214, 61, 125, .35);
  transition: transform .12s, box-shadow .12s;
}
#start:active { transform: translateY(5px) scale(.98); box-shadow: 0 1px 0 #d63d7d, 0 4px 10px rgba(214, 61, 125, .35); }
#start:disabled { opacity: .5; }

#error { position: absolute; left: 16px; right: 16px; bottom: 40px; z-index: 9; padding: 12px 16px; border-radius: 12px; background: #fff; font-weight: 700; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  #menu h1, #hint::after { animation: none; }
}
