* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink: #2B2D42;
  --paper: #FFF8F1;
}

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #1E1F30;
}

body {
  display: flex;
  justify-content: center;
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

#stage {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  touch-action: none;
  cursor: pointer;
  background: #FFE8D6;
}

@media (min-width: 520px) {
  body { background: radial-gradient(circle at 50% 30%, #2E3050, #16172A 70%); }
  #stage { box-shadow: 0 0 0 1px rgba(255,255,255,.06), 0 30px 90px rgba(0,0,0,.55); }
}

canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* score */
.score {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 34px);
  left: 0; right: 0;
  text-align: center;
  font-size: 68px;
  font-weight: 900;
  line-height: 1;
  color: #fff;
  font-variant-numeric: tabular-nums;
  text-shadow:
    0 3px 0 var(--ink), 0 -3px 0 var(--ink), 3px 0 0 var(--ink), -3px 0 0 var(--ink),
    2px 2px 0 var(--ink), -2px 2px 0 var(--ink), 2px -2px 0 var(--ink), -2px -2px 0 var(--ink),
    0 8px 0 rgba(43,45,66,.25);
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity .2s, transform .3s;
  pointer-events: none;
}
.score.show { opacity: 1; transform: none; }
.score.pop { animation: pop .28s cubic-bezier(.2,1.6,.4,1); }
@keyframes pop {
  0% { transform: scale(1.35) rotate(-4deg); }
  100% { transform: scale(1); }
}

/* mute */
.mute {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  right: 14px;
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 2.5px solid var(--ink);
  background: rgba(255, 248, 241, .85);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--ink);
  transition: transform .1s, box-shadow .1s;
  z-index: 5;
}
.mute:active { transform: translateY(3px); box-shadow: 0 0 0 var(--ink); }

/* cards */
.card {
  position: absolute;
  left: 50%;
  width: min(300px, 84%);
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 28px;
  padding: 26px 22px 22px;
  text-align: center;
  box-shadow: 0 7px 0 var(--ink), 0 26px 50px rgba(43,45,66,.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s, transform .45s cubic-bezier(.2,1.5,.4,1);
}

.ready {
  bottom: 16%;
  transform: translate(-50%, 24px) scale(.94);
}
.ready.show { opacity: 1; transform: translate(-50%, 0) scale(1); }

.over {
  top: 43%;
  transform: translate(-50%, -50%) scale(.8) rotate(-3deg);
}
.over.show { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(-1.5deg); }

.logo {
  font-size: 50px;
  font-weight: 900;
  letter-spacing: -1px;
  line-height: 1;
}
.logo span {
  display: inline-block;
  color: var(--c);
  text-shadow: 0 3px 0 var(--ink);
  -webkit-text-stroke: 1.5px var(--ink);
  animation: wobble 2.4s ease-in-out infinite;
}
.logo span:nth-child(2) { animation-delay: .12s; }
.logo span:nth-child(3) { animation-delay: .24s; }
.logo span:nth-child(4) { animation-delay: .36s; }
.logo span:nth-child(5) { animation-delay: .48s; }
.logo span:nth-child(6) { animation-delay: .60s; }
.logo span:nth-child(7) { animation-delay: .72s; }
@keyframes wobble {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  30% { transform: translateY(-5px) scale(.94, 1.08); }
  60% { transform: translateY(1px) scale(1.08, .92); }
}

.tag {
  margin-top: 10px;
  font-size: 16px;
  font-weight: 600;
  opacity: .7;
}

.hint {
  margin-top: 18px;
  font-size: 14px;
  font-weight: 700;
  color: rgba(43,45,66,.75);
}
.pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 13px;
  letter-spacing: .3px;
}

.best {
  margin-top: 14px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  opacity: .55;
}
.best b { font-size: 15px; }

.over h2 {
  font-size: 54px;
  font-weight: 900;
  letter-spacing: -1px;
  line-height: 1;
  color: #FF3B6B;
  -webkit-text-stroke: 2px var(--ink);
  text-shadow: 0 4px 0 var(--ink);
}

.stats {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}
.stats div {
  flex: 1;
  background: #FFE8D6;
  border: 2.5px solid var(--ink);
  border-radius: 18px;
  padding: 10px 6px 8px;
}
.stats span {
  display: block;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  opacity: .6;
}
.stats b {
  display: block;
  font-size: 38px;
  font-weight: 900;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.newbest {
  display: none;
  margin: 14px auto 0;
  width: max-content;
  padding: 5px 14px;
  border-radius: 999px;
  background: #FFB400;
  border: 2.5px solid var(--ink);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  transform: rotate(-3deg);
}
.newbest.on { display: block; animation: pop .5s cubic-bezier(.2,1.6,.4,1); }

.splats {
  margin-top: 14px;
  font-size: 13px;
  font-weight: 600;
  opacity: .6;
}

.again {
  margin-top: 14px;
  font-size: 15px;
  font-weight: 900;
  opacity: 0;
  transition: opacity .3s .65s;
}
.over.show .again { opacity: 1; animation: breathe 1.4s ease-in-out .95s infinite; }
@keyframes breathe {
  0%, 100% { opacity: 1; }
  50% { opacity: .45; }
}
