:root {
  --ink: #1b1b1b;
  --navy: #12315c;
  --navy-edge: #07182e;
  --gold: #ffe56a;
  --lime: #b6f34a;
  --cream: #fff6e0;
  --pink: #ff5da2;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: #06243f;
  color: var(--cream);
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#frame {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#stage {
  position: relative;
  width: 960px;
  height: 540px;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 0 0 4px var(--ink), 8px 8px 0 rgba(0, 0, 0, .28);
  background: #3ec0ff;
  font-size: 16px;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#hud, #title, #over {
  position: absolute;
  inset: 0;
}

#hud { pointer-events: none; z-index: 2; }
#title { z-index: 3; }
#over { z-index: 4; }
#title[hidden], #over[hidden], #hud[hidden], #banner[hidden], #hint[hidden] { display: none !important; }

.title-block {
  position: absolute;
  top: 0.7em;
  left: 0.8em;
  transform: rotate(-4deg);
  max-width: 16em;
}
.title-block h1 {
  margin: 0;
  font-family: "Lilita One", "Bricolage Grotesque", sans-serif;
  font-size: 1.7em;
  font-weight: 400;
  line-height: .88;
  color: #fff;
  letter-spacing: 0.01em;
  -webkit-text-stroke: 0.08em #1a4fa0;
  paint-order: stroke fill;
  text-shadow: 0.05em 0.06em 0 #123880;
}
.title-block h1 span {
  display: block;
  color: var(--gold);
  font-size: 1.18em;
}
.tagline {
  margin: 0.28em 0 0;
  display: inline-block;
  background: #1a4fa0;
  color: #fff;
  border-radius: 999px;
  padding: 0.18em 0.7em 0.22em;
  font-size: 0.68em;
  font-weight: 800;
}

.score-pill, .next-pill {
  position: absolute;
  top: 0.75em;
  display: flex;
  align-items: center;
  gap: 0.45em;
  background: var(--navy);
  border: 3px solid var(--navy-edge);
  border-radius: 16px;
  padding: 0.28em 0.7em 0.28em 0.35em;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .25);
}
.score-pill { left: 50%; transform: translateX(-50%); }
.next-pill { right: 0.7em; padding-right: 0.4em; }
.score-pill small, .next-pill small {
  display: block;
  font-size: 0.62em;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #d6e4ff;
  line-height: 1;
}
.score-pill b, .next-pill b {
  display: block;
  font-family: "Lilita One", "Bricolage Grotesque", sans-serif;
  font-size: 1.35em;
  font-weight: 400;
  color: var(--gold);
  line-height: 1;
  white-space: nowrap;
}
.coin {
  width: 2.3em;
  height: 2.3em;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 35% 35%, #fff1a8, #ffc83d 55%, #e09400);
  border: 3px solid #a86a00;
  color: #fff;
  font-size: 1.15em;
  text-shadow: 0 1px 0 #c47d00;
}
.pin {
  width: 1.5em;
  height: 1.5em;
  background: #3ecf6e;
  border: 3px solid #0e6b32;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: inset 0 0 0 0.28em #eafff2;
}

.banner {
  position: absolute;
  top: 22%;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  background: var(--lime);
  color: #143018;
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 0.4em 0.9em;
  font-weight: 800;
  font-size: 1.05em;
  box-shadow: 4px 4px 0 var(--ink);
  white-space: nowrap;
}
.banner.crash { background: #ffd23f; }

#hint {
  position: absolute;
  left: 50%;
  bottom: 0.8em;
  transform: translateX(-50%);
  margin: 0;
  background: rgba(7, 24, 46, .8);
  color: #fff;
  border-radius: 999px;
  padding: 0.35em 0.8em;
  font-weight: 800;
  font-size: 0.85em;
}

#mute {
  pointer-events: auto;
  position: absolute;
  right: 0.7em;
  bottom: 0.7em;
  border: 3px solid var(--ink);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  font: inherit;
  font-weight: 800;
  font-size: 0.8em;
  padding: 0.35em 0.75em;
  cursor: pointer;
}
#mute[aria-pressed="true"] { background: var(--lime); }

#title {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background: #08345f url("title.jpg") center 18% / cover no-repeat;
}
#title::before {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 46%;
  background: linear-gradient(transparent, rgba(4, 18, 40, .82));
}
.title-actions, #title .back { position: relative; z-index: 1; }
.title-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45em;
  padding: 0 1em 1.1em;
  text-align: center;
}
#title-best { margin: 0; font-weight: 800; min-height: 1.2em; }
.how { margin: 0; font-size: 0.82em; font-weight: 600; line-height: 1.35; }

.back {
  color: #fff;
  font-weight: 800;
  text-decoration: none;
  font-size: 0.85em;
}
#title .back {
  position: absolute;
  top: 0.7em;
  left: 0.8em;
  background: rgba(7, 24, 46, .78);
  border-radius: 999px;
  padding: 0.35em 0.75em;
}
.back.dark { color: var(--ink); display: inline-block; margin-top: 0.7em; }
.back:hover { text-decoration: underline; }

.btn {
  display: inline-block;
  padding: 0.7em 1.2em;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: var(--lime);
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  font-size: 1.05em;
  text-decoration: none;
  box-shadow: 4px 4px 0 var(--ink);
  cursor: pointer;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--ink); }
.btn.alt { background: #fff; }

#over {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 16, 36, .55);
  padding: 1em;
}
.sheet {
  width: min(34em, 100%);
  background: var(--cream);
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 28px;
  box-shadow: 8px 8px 0 var(--ink);
  padding: 1.1em 1.3em 1.2em;
  text-align: center;
}
.eyebrow {
  margin: 0;
  font-weight: 800;
  font-size: 0.78em;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.sheet h2 {
  margin: 0.15em 0 0.2em;
  font-family: "Lilita One", "Bricolage Grotesque", sans-serif;
  font-size: 2em;
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--pink);
  -webkit-text-stroke: 0.03em var(--ink);
  paint-order: stroke fill;
}
.bigscore {
  margin: 0;
  font-family: "Lilita One", sans-serif;
  font-size: 2.6em;
  line-height: 1;
  color: var(--navy);
}
.bestline { margin: 0.2em 0 0.6em; font-weight: 800; }
.fact { margin: 0 auto; max-width: 34em; font-size: 0.98em; font-weight: 600; }
.src { margin: 0.35em 0 0.8em; font-size: 0.75em; font-weight: 600; opacity: .7; }
.row { display: flex; gap: 0.6em; justify-content: center; flex-wrap: wrap; }

#rotate {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 6;
  background: #06243f;
  color: var(--cream);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
  padding: 2em;
  font-size: 1.4em;
  font-weight: 800;
}
#rotate .how { font-weight: 600; font-size: 0.7em; opacity: .85; }

@media (orientation: portrait) and (max-width: 820px) {
  #rotate { display: flex; }
}

@media (max-height: 430px) {
  .title-block h1 { font-size: 1.25em; }
  .tagline { display: none; }
  .score-pill b, .next-pill b { font-size: 1.05em; }
  .sheet h2 { font-size: 1.4em; }
  .bigscore { font-size: 1.8em; }
  .fact { font-size: 0.85em; }
  .sheet { padding: 0.7em 0.9em; }
}

@media (prefers-reduced-motion: reduce) {
  .btn:hover { transform: none; }
}
