* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

html, body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #000;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

/* The playfield is a framed rectangle that deliberately stops ABOVE the
   iOS bottom gesture zone (home indicator / Reachability). The strip
   below it is inert black — the player never has a reason to touch it,
   so bottom-edge system gestures can't be triggered mid-wipe. */
#game {
  position: fixed;
  /* Playfield starts below the HUD bar (safe area + 48px bar + 4px gap)
     so all action stays under the RD / pause / %-clean labels. */
  top: calc(env(safe-area-inset-top, 0px) + 52px);
  left: 0;
  width: 100%;
  /* Explicit height (not top+bottom stretching): canvas is a replaced
     element, so an auto height would follow its buffer's aspect ratio
     instead of the insets. */
  height: calc(100% - env(safe-area-inset-top, 0px) - 52px - env(safe-area-inset-bottom, 0px) - 18px);
  touch-action: none;
  display: block;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.hidden {
  display: none !important;
}

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  top: env(safe-area-inset-top, 0px);
  left: 0;
  right: 0;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  pointer-events: none;
  z-index: 10;
}

#hud .hud-left,
#hud #percentLabel {
  color: rgba(255, 255, 255, 0.55);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.8);
  transition: color 0.25s ease;
}

#hud .hud-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

#hud #percentLabel.danger {
  color: rgba(255, 90, 90, 0.95);
}

#hud #scoreLabel {
  color: rgba(255, 255, 255, 0.32);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.8);
  transition: color 0.25s ease;
}

/* Combo active — the score glows mint while a clean streak is stacking. */
#hud #scoreLabel.combo {
  color: #3bffb0;
  text-shadow: 0 0 10px rgba(59, 255, 176, 0.45);
}

.hud-center {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none; /* only the buttons inside are tappable */
}

.hud-btn {
  pointer-events: all;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: rgba(255, 255, 255, 0.6);
  /* 44px meets Apple's minimum tap target — this is a control the player
     stabs at mid-panic, so it must not be a 34px pinpoint. */
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Round banner ---------- */
#roundBanner {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 42px;
  font-weight: 800;
  letter-spacing: 4px;
  z-index: 15;
  pointer-events: none;
  text-shadow: 0 0 24px rgba(255, 255, 255, 0.5);
  opacity: 0;
  transition: opacity 0.4s ease;
}

#roundBanner.show {
  opacity: 1;
}

/* ---------- First-run hint ---------- */
.wipe-hint {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 90px);
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.7);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 3px;
  z-index: 14;
  pointer-events: none;
  white-space: nowrap;
  text-shadow: 0 0 12px rgba(0, 0, 0, 0.9);
  animation: hintPulse 1.6s ease-in-out infinite;
  transition: opacity 0.5s ease;
}

@keyframes hintPulse {
  0%, 100% { opacity: 0.4; }
  50%      { opacity: 0.9; }
}

/* ---------- Screens ---------- */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #000;
  z-index: 20;
  gap: 18px;
}

.menu-smear {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  animation: pulse 2.2s ease-in-out infinite;
  background: radial-gradient(circle at 35% 30%, #ff3b6e, #7b1fa2 70%);
}

.menu-smear span {
  color: #fff;
  font-weight: 800;
  letter-spacing: 2px;
  font-size: 18px;
  text-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

@keyframes pulse {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.08); filter: brightness(1.15); }
}

/* Honor the OS reduced-motion setting: the menu orb's idle pulse is pure
   decoration, so still it. Gameplay motion is essential and left intact. */
@media (prefers-reduced-motion: reduce) {
  .menu-smear { animation: none; }
  .over-best.new-best { animation: none; }
  .wipe-hint { animation: none; opacity: 0.75; }
}

.menu-sub {
  color: rgba(255, 255, 255, 0.35);
  letter-spacing: 6px;
  font-size: 13px;
  font-weight: 700;
  margin-top: 8px;
}

.menu-best {
  color: rgba(255, 255, 255, 0.25);
  letter-spacing: 2px;
  font-size: 11px;
  font-weight: 600;
  min-height: 14px;
}

/* Permanent, low-key reminder on the menu; taps to reopen the full notice. */
.menu-tip {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 22px);
  left: 50%;
  transform: translateX(-50%);
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.32);
  font-size: 12px;
  letter-spacing: 0.5px;
  font-weight: 500;
  white-space: nowrap;
  padding: 8px 12px;
}

/* First-launch (and reopenable) Reachability notice. */
.tip-card {
  max-width: 300px;
  margin: 0 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}

.tip-heading {
  color: rgba(255, 255, 255, 0.9);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 3px;
}

.tip-body {
  color: rgba(255, 255, 255, 0.6);
  font-size: 14px;
  line-height: 1.5;
}

.tip-body strong {
  color: rgba(255, 255, 255, 0.9);
}

.tip-path {
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.7;
  letter-spacing: 0.5px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 14px 18px;
  margin: 4px 0;
}

.tip-path strong {
  color: #3bffb0;
}

.pause-title {
  color: rgba(255, 255, 255, 0.85);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 4px;
  margin-bottom: 8px;
}

.text-btn {
  background: none;
  border: 1.5px solid rgba(255, 255, 255, 0.3);
  color: rgba(255, 255, 255, 0.85);
  padding: 12px 32px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
  border-radius: 30px;
  min-width: 200px;
}

.over-title {
  color: #fff;
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 3px;
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.4);
}

.over-sub {
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
  letter-spacing: 1px;
}

.over-score {
  color: #fff;
  font-size: 40px;
  font-weight: 800;
  letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 18px rgba(255, 255, 255, 0.3);
  margin-top: 4px;
}

.over-best {
  color: rgba(255, 255, 255, 0.35);
  font-size: 12px;
  letter-spacing: 1px;
  margin-bottom: 10px;
}

/* Record-breaking run — swap the muted label for a bright, popping badge. */
.over-best.new-best {
  color: #3bffb0;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 2px;
  text-shadow: 0 0 14px rgba(59, 255, 176, 0.5);
  animation: bestPop 0.5s ease;
}

@keyframes bestPop {
  0%   { transform: scale(0.6); opacity: 0; }
  60%  { transform: scale(1.12); }
  100% { transform: scale(1); opacity: 1; }
}
