:root {
  --ng-top: calc(env(safe-area-inset-top) + 56px);
  --ng-bottom: calc(env(safe-area-inset-bottom) + 12px);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  background: #000;
  font-family: "Trebuchet MS", Verdana, sans-serif;
}

canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: block;
}

#vig {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 45%, rgba(0, 0, 0, 0) 50%, rgba(4, 6, 20, .5) 100%);
}

#hud {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  color: #eaf6ff;
}

#left {
  position: absolute;
  top: calc(var(--ng-top) + 22px);
  left: 14px;
}

#count {
  font-size: clamp(32px, 10vw, 50px);
  font-weight: 900;
  color: #9cecff;
  text-shadow: 0 0 18px rgba(60, 190, 255, .85), 0 3px 0 #10365a;
  line-height: 1;
  transition: transform .09s;
}

#count small {
  font-size: .36em;
  letter-spacing: 2px;
  color: #d6f2ff;
  opacity: .85;
  font-weight: 700;
}

#dist {
  font-size: clamp(11px, 3.2vw, 14px);
  letter-spacing: 2px;
  color: #e2eeff;
  opacity: .95;
  font-weight: 700;
  margin-top: 3px;
}

#best {
  font-size: clamp(10px, 3vw, 12px);
  letter-spacing: 1.2px;
  color: #ffd98a;
  opacity: .9;
  margin-top: 2px;
}

#combo {
  position: absolute;
  top: calc(var(--ng-top) + 26px);
  right: 14px;
  text-align: right;
  font-size: clamp(15px, 4.6vw, 22px);
  font-weight: 900;
  color: #ffe27a;
  opacity: 0;
  transform: scale(.6);
  transition: opacity .18s, transform .18s;
  text-shadow: 0 0 14px rgba(255, 180, 60, .8);
}

#banner {
  position: absolute;
  left: 0;
  right: 0;
  top: 34%;
  text-align: center;
  font-size: clamp(24px, 8vw, 40px);
  font-weight: 900;
  letter-spacing: 2px;
  opacity: 0;
  transform: scale(.7);
  transition: opacity .22s, transform .22s;
  text-shadow: 0 4px 26px rgba(0, 0, 0, .8);
}

#sub {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(34% + 50px);
  text-align: center;
  font-size: clamp(12px, 3.6vw, 16px);
  letter-spacing: 1px;
  opacity: 0;
  transition: opacity .22s;
  color: #e6f4ff;
}

#coins {
  font-size: clamp(13px, 3.6vw, 17px);
  font-weight: 900;
  letter-spacing: 1.5px;
  color: #ffd24a;
  text-shadow: 0 0 14px rgba(255, 168, 30, .7);
  margin-top: 6px;
}

#coins small {
  font-size: .62em;
  letter-spacing: 2px;
  opacity: .8;
  font-weight: 700;
}

#shieldtag {
  font-size: clamp(10px, 3vw, 12px);
  letter-spacing: 2px;
  font-weight: 700;
  color: #8fe6ff;
  text-shadow: 0 0 12px rgba(80, 210, 255, .8);
  opacity: 0;
  margin-top: 3px;
  transition: opacity .25s;
}

/* Sits under the shield tag in #left, so the two run-critical readouts share one
   column and a glance costs one saccade. Pulses on its own timer rather than on
   a class toggle — the tag over the wave is already pulsing in the world and the
   two must not visibly beat against each other. */
#warn {
  font-size: clamp(11px, 3.4vw, 14px);
  letter-spacing: 3px;
  font-weight: 900;
  color: #ff6a78;
  text-shadow: 0 0 14px rgba(255, 60, 80, .9);
  opacity: 0;
  margin-top: 4px;
  transition: opacity .12s;
  /* Paused rather than absent while hidden: a running animation on an invisible
     element still costs a composite every frame, and this element is invisible
     for most of a run. Hud.warn drives the play state. */
  animation: warnpulse .5s linear infinite paused;
}

@keyframes warnpulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.09); }
}

#hint {
  position: absolute;
  bottom: var(--ng-bottom);
  left: 16px;
  font-size: 11px;
  letter-spacing: 2px;
  color: #c9deef;
  opacity: .85;
  transition: opacity .4s;
}

/* Menu layer. 0/2/10 are canvas / vignette / hud, so the screens take 20. */
.screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  color: #eaf6ff;
  background: radial-gradient(ellipse at 50% 45%, rgba(4, 7, 22, .62), rgba(3, 5, 16, .93));
  pointer-events: none;
}

.screen.on { display: flex; }

.screen h1 {
  margin: 0 0 6px;
  font-size: clamp(28px, 8vw, 56px);
  letter-spacing: 4px;
  color: #9cecff;
  text-shadow: 0 0 26px rgba(60, 190, 255, .85);
}

.screen h2 {
  margin: 0 0 16px;
  font-size: clamp(18px, 5vw, 28px);
  letter-spacing: 3px;
  color: #ff6a78;
  text-shadow: 0 0 18px rgba(255, 70, 90, .7);
}

.screen p {
  margin: 4px 0;
  font-size: clamp(11px, 2.6vw, 14px);
  letter-spacing: 2px;
  opacity: .72;
  max-width: 36ch;
  line-height: 1.7;
}

.screen .big {
  margin: 8px 0 2px;
  font-size: clamp(26px, 7vw, 46px);
  font-weight: 900;
  letter-spacing: 2px;
  color: #9cecff;
  text-shadow: 0 0 20px rgba(60, 190, 255, .8);
  opacity: 1;
}

.screen .credits {
  margin-top: 12px;
  letter-spacing: 3px;
  opacity: .88;
}

.screen .credits span {
  color: #ffd24a;
  font-weight: 900;
  text-shadow: 0 0 14px rgba(255, 170, 40, .8);
}

.screen .note {
  margin-top: 12px;
  font-size: 10px;
  letter-spacing: 2px;
  opacity: .45;
}

.screen .hint {
  margin-top: 18px;
  font-size: 10px;
  opacity: .55;
}

.screen .shop-head {
  width: min(440px, 90vw);
  max-width: none;
  margin: 16px 0 2px;
  text-align: left;
  font-size: 9px;
  letter-spacing: 4px;
  opacity: .45;
}

.btn {
  pointer-events: auto;
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 2px;
  font-weight: 700;
  color: #eaf6ff;
  background: rgba(120, 200, 255, .08);
  border: 1px solid rgba(120, 200, 255, .5);
  border-radius: 7px;
  padding: 9px 14px;
  cursor: pointer;
  transition: background .12s linear, opacity .12s linear;
}

.btn:hover:not(:disabled) { background: rgba(120, 200, 255, .22); }
.btn:disabled { opacity: .3; cursor: default; border-color: rgba(255, 255, 255, .18); }

.btn.wide {
  margin-top: 12px;
  min-width: 170px;
  padding: 12px 18px;
}

.btn.buy { min-width: 96px; text-align: center; }

/* The shop is the one screen that can outgrow a short viewport. Both halves of
   the mobile scroll fix live here and in input.js's touchmove guard — the
   document-wide preventDefault and body{touch-action:none} are independent, so
   either alone does nothing. */
#screen-shop {
  justify-content: flex-start;
  padding: 6vh 20px 26px;
  overflow-y: auto;
  touch-action: pan-y;
  pointer-events: auto;
}

#screen-shop h1 { font-size: clamp(22px, 5vw, 36px); }

#shop-list, #shop-charges, #shop-skins, #shop-envs { width: min(440px, 90vw); }

.shop-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: min(440px, 90vw);
  margin: 7px 0;
  padding: 11px 14px;
  text-align: left;
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: 9px;
  background: rgba(255, 255, 255, .04);
}

.shop-info {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
  line-height: 1.2;
}

.shop-name {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 2px;
  color: #9cecff;
}

.shop-desc {
  font-size: 10px;
  letter-spacing: 1px;
  opacity: .72;
}

.shop-lv {
  font-size: 9px;
  letter-spacing: 2px;
  opacity: .45;
}
