/* Slingstar. The game is the canvas; everything here floats over it. */

:root {
  --accent: #72e4ff;
  --ink: #f5f3ff;
  --dim: rgba(245, 243, 255, .62);
  --top: env(safe-area-inset-top, 0px);
  --bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #02040d;
  color: var(--ink);
  font-family: "Outfit", ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}

body { position: fixed; inset: 0; }

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

p { margin: 0; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---- score ------------------------------------------------------------- */

.hud {
  position: absolute;
  top: calc(var(--top) + 3.2vh);
  left: 0; right: 0;
  display: grid;
  justify-items: center;
  gap: 2px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity .5s ease, transform .5s ease;
}
.hud.is-on { opacity: 1; transform: none; }

.score {
  font-size: clamp(64px, 19vmin, 108px);
  font-weight: 200;
  line-height: .95;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 28px color-mix(in srgb, var(--accent) 65%, transparent), 0 2px 18px rgba(0, 0, 0, .55);
  transition: text-shadow 1.2s ease;
}
.score.bump { animation: bump .32s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes bump { 0% { transform: scale(1.22); } 100% { transform: scale(1); } }

.streak {
  display: flex;
  align-items: baseline;
  gap: .5em;
  padding: 5px 14px 6px;
  border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, rgba(4, 6, 16, .45));
  color: var(--accent);
  font-size: 12px;
  letter-spacing: .2em;
  text-transform: uppercase;
  opacity: 0;
  transform: scale(.8);
  transition: opacity .25s ease, transform .25s ease, color 1.2s ease, border-color 1.2s ease;
}
.streak b { color: #fff; font-size: 17px; font-weight: 600; letter-spacing: 0; }
.streak.is-on { opacity: 1; transform: none; }
.streak.bump { animation: bump .36s cubic-bezier(.2, 1.8, .4, 1); }

/* ---- floating words ---------------------------------------------------- */

.pops { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }

.pop {
  position: absolute;
  left: 0; top: 0;
  display: grid;
  justify-items: center;
  white-space: nowrap;
  font-size: 19px;
  font-weight: 500;
  text-shadow: 0 0 14px rgba(0, 0, 0, .7), 0 0 22px color-mix(in srgb, var(--accent) 60%, transparent);
  animation: pop 1.05s cubic-bezier(.15, .8, .3, 1) forwards;
  will-change: transform, opacity;
}
.pop small {
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .32em;
  text-indent: .32em;
  text-transform: uppercase;
}
.pop.is-perfect { font-size: 26px; font-weight: 600; }
@keyframes pop {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(.6); }
  14% { opacity: 1; transform: translate(-50%, -100%) scale(1.12); }
  30% { transform: translate(-50%, -115%) scale(1); }
  72% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -210%) scale(.96); }
}

/* ---- zone banner ------------------------------------------------------- */

.zone {
  position: absolute;
  top: 31%;
  left: 0; right: 0;
  display: grid;
  justify-items: center;
  gap: 8px;
  pointer-events: none;
  opacity: 0;
}
.zone small { color: var(--dim); font-size: 11px; letter-spacing: .42em; text-indent: .42em; text-transform: uppercase; }
.zone b {
  color: #fff;
  font-size: clamp(26px, 8.4vmin, 44px);
  font-weight: 200;
  letter-spacing: .26em;
  text-indent: .26em;
  text-transform: uppercase;
  text-shadow: 0 0 30px var(--accent), 0 0 4px rgba(0, 0, 0, .6);
}
.zone.is-on { animation: zone 2.9s ease forwards; }
@keyframes zone {
  0% { opacity: 0; letter-spacing: .1em; transform: scale(1.12); }
  16% { opacity: 1; transform: scale(1); }
  74% { opacity: 1; }
  100% { opacity: 0; transform: scale(.97); }
}

/* ---- title ------------------------------------------------------------- */

.title {
  position: absolute;
  top: calc(var(--top) + 9vh);
  left: 0; right: 0;
  display: grid;
  justify-items: center;
  gap: 2vh;
  pointer-events: none;
  transition: opacity .6s ease, transform .9s cubic-bezier(.3, 0, .2, 1);
}
.title.is-off { opacity: 0; transform: translateY(-9vh) scale(.94); }

.logo { width: min(74vw, 40vh, 430px); margin: 0; }
.logo-svg { display: block; width: 100%; height: auto; overflow: visible; filter: drop-shadow(0 0 9px color-mix(in srgb, var(--accent) 75%, transparent)); }
.ls-stroke { fill: none; stroke: #fff; stroke-width: .3; stroke-linecap: round; stroke-linejoin: round; }
.ls-stroke.ls-b { stroke: color-mix(in srgb, var(--accent) 55%, #fff); }
.ls-star { fill: #fff; }
.ls-arc { fill: none; stroke: url(#ls-tail); stroke-width: .34; stroke-linecap: round; }
.ls-head { fill: #fff; }
.ls-head-glow { fill: var(--accent); opacity: .45; }

.is-live .ls-stroke { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1s cubic-bezier(.5, 0, .2, 1) forwards; animation-delay: calc(var(--i) * 70ms + 150ms); }
.is-live .ls-star { opacity: 0; animation: star-in .5s ease forwards, twinkle 3.4s ease-in-out infinite; animation-delay: calc(var(--i) * 70ms + 100ms), calc(var(--j) * .41s + 1.6s); }
.is-live .ls-arc { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.1s cubic-bezier(.6, 0, .2, 1) .9s forwards; }
.is-live .ls-head, .is-live .ls-head-glow { opacity: 0; animation: star-in .4s ease 1.8s forwards; }
.is-live .ls-head-glow { animation: glow-in .4s ease 1.8s forwards, pulse 2.2s ease-in-out 2.2s infinite; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes star-in { to { opacity: 1; } }
@keyframes glow-in { to { opacity: .45; } }
@keyframes twinkle { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes pulse { 0%, 100% { opacity: .45; } 50% { opacity: .8; } }

.tagline { color: var(--dim); font-size: clamp(13px, 3.7vmin, 17px); font-weight: 300; letter-spacing: .14em; }
.title-best {
  margin-top: .4vh;
  padding: 5px 14px;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 999px;
  color: var(--dim);
  font-size: 11px;
  letter-spacing: .28em;
  text-indent: .28em;
  text-transform: uppercase;
}
.title-best b { color: #fff; font-weight: 500; letter-spacing: .06em; }

/* ---- tap prompt and hints ---------------------------------------------- */

.prompt {
  position: absolute;
  left: 0; right: 0;
  bottom: calc(var(--bottom) + 6.5vh);
  display: grid;
  justify-items: center;
  color: #fff;
  font-size: 13px;
  font-weight: 400;
  letter-spacing: .4em;
  text-indent: .4em;
  text-transform: uppercase;
  text-shadow: 0 0 16px var(--accent), 0 1px 8px rgba(0, 0, 0, .7);
  pointer-events: none;
  transition: opacity .35s ease;
}
.prompt span { animation: breathe 1.6s ease-in-out infinite; }
.prompt.is-off { opacity: 0; }
@keyframes breathe { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }

.hint {
  position: absolute;
  left: 8vw; right: 8vw;
  bottom: calc(var(--bottom) + 12vh);
  color: var(--dim);
  font-size: 14px;
  font-weight: 300;
  line-height: 1.45;
  letter-spacing: .04em;
  text-align: center;
  text-shadow: 0 1px 10px rgba(0, 0, 0, .8);
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .45s ease, transform .45s ease;
}
.hint.is-on { opacity: 1; transform: none; }
.hint b { color: #fff; font-weight: 500; }

/* ---- game over --------------------------------------------------------- */

.over {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: calc(var(--top) + 20px) 22px calc(var(--bottom) + 20px);
  animation: fade-in .45s ease both;
}
.over[hidden] { display: none; }
@keyframes fade-in { from { opacity: 0; } }

.card {
  width: min(100%, 370px);
  padding: 30px 26px 24px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 30px;
  background: linear-gradient(180deg, rgba(16, 20, 40, .86), rgba(5, 7, 18, .93));
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  backdrop-filter: blur(18px) saturate(1.3);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .12), 0 0 60px color-mix(in srgb, var(--accent) 16%, transparent);
  text-align: center;
  animation: card-in .55s cubic-bezier(.2, 1.2, .3, 1) both;
}
@keyframes card-in { from { opacity: 0; transform: translateY(26px) scale(.94); } }

.over-cause { color: var(--dim); font-size: 12px; letter-spacing: .34em; text-indent: .34em; text-transform: uppercase; }
.over-new {
  display: inline-block;
  margin-top: 16px;
  padding: 4px 14px 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #05060f;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .26em;
  text-indent: .26em;
  text-transform: uppercase;
  box-shadow: 0 0 26px var(--accent);
  animation: bump .5s cubic-bezier(.2, 1.8, .4, 1) .35s both;
}
.over-new[hidden] { display: none; }
.over-score {
  margin-top: 6px;
  font-size: clamp(84px, 27vmin, 124px);
  font-weight: 200;
  line-height: 1;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 36px color-mix(in srgb, var(--accent) 70%, transparent);
}
.over-best { color: var(--dim); font-size: 12px; letter-spacing: .26em; text-indent: .26em; text-transform: uppercase; }
.over-best b { color: #fff; font-weight: 500; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 22px 0 0;
  padding: 16px 0;
  border-top: 1px solid rgba(255, 255, 255, .1);
  border-bottom: 1px solid rgba(255, 255, 255, .1);
}
.stats div + div { border-left: 1px solid rgba(255, 255, 255, .1); }
.stats dt { color: var(--dim); font-size: 10px; letter-spacing: .2em; text-indent: .2em; text-transform: uppercase; }
.stats dd { margin: 5px 0 0; font-size: 25px; font-weight: 300; font-variant-numeric: tabular-nums; }

.over-zone { margin-top: 14px; color: var(--dim); font-size: 13px; font-weight: 300; letter-spacing: .05em; }
.over-zone b { color: var(--accent); font-weight: 400; }

.btn {
  display: grid;
  place-items: center;
  min-height: 50px;
  padding: 0 20px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 999px;
  background: rgba(255, 255, 255, .05);
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: .24em;
  text-indent: .24em;
  text-decoration: none;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .12s ease, background .2s ease, border-color .2s ease;
}
.btn:active { transform: scale(.96); }
.btn:focus-visible, .chip:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.btn-main {
  width: 100%;
  min-height: 58px;
  margin-top: 20px;
  border-color: transparent;
  background: linear-gradient(135deg, #fff, color-mix(in srgb, var(--accent) 70%, #fff));
  color: #05060f;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 0 34px color-mix(in srgb, var(--accent) 55%, transparent), 0 10px 26px rgba(0, 0, 0, .4);
}
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }

/* ---- corner controls --------------------------------------------------- */

.corner {
  position: absolute;
  top: calc(var(--top) + 12px);
  left: 14px; right: 14px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  transition: opacity .4s ease;
}
.corner.is-off { opacity: 0; }
.corner.is-off .chip { pointer-events: none; }

.chip {
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 50%;
  background: rgba(6, 8, 20, .4);
  color: var(--ink);
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
}
.chip svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.chip .mute { display: none; }
.chip[aria-pressed="false"] { color: var(--dim); }
.chip[aria-pressed="false"] .wave { display: none; }
.chip[aria-pressed="false"] .mute { display: inline; }

/* ---- paused / failure -------------------------------------------------- */

.paused {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  background: rgba(2, 4, 13, .6);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.paused[hidden] { display: none; }
.paused b { font-size: 34px; font-weight: 200; letter-spacing: .3em; text-indent: .3em; text-transform: uppercase; }
.paused span { color: var(--dim); font-size: 12px; letter-spacing: .34em; text-indent: .34em; text-transform: uppercase; }

.fail {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 12vw;
  color: var(--dim);
  font-size: 17px;
  font-weight: 300;
  line-height: 1.5;
  text-align: center;
}
.fail[hidden] { display: none; }

@media (max-height: 560px) {
  .title { top: calc(var(--top) + 4vh); gap: 1vh; }
  .logo { width: min(60vw, 40vh); }
  .prompt { bottom: calc(var(--bottom) + 4vh); }
  .card { padding: 18px 22px 16px; }
  .over-score { font-size: 64px; }
  .stats { margin-top: 12px; padding: 10px 0; }
  .btn-main { margin-top: 12px; min-height: 48px; }
}

@media (prefers-reduced-motion: reduce) {
  .is-live .ls-stroke, .is-live .ls-arc { animation: none; stroke-dashoffset: 0; }
  .is-live .ls-star, .is-live .ls-head { animation: none; opacity: 1; }
  .is-live .ls-head-glow { animation: none; opacity: .45; }
  .prompt span, .score.bump, .streak.bump { animation: none; }
  .title, .hud { transition: opacity .3s ease; }
  .title.is-off { transform: none; }
}
