/* ============================================================
   AIMFORGE · in-game HUD / overlays
   ============================================================ */
.game-root { position: fixed; inset: 0; z-index: var(--z-game); background: #040707; }
.game-root[hidden] { display: none !important; }
.game-shell {
  --mode-accent: #d8ff4f;
  --mode-accent-rgb: 216, 255, 79;
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #040707;
  color: var(--text);
  cursor: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.game-shell [hidden] { display: none !important; }
.game-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.game-scanlines {
  position: absolute; inset: 0; z-index: 2; pointer-events: none; opacity: 0.18;
  background: repeating-linear-gradient(180deg, rgba(255,255,255,0.035) 0 1px, transparent 1px 3px);
  mix-blend-mode: soft-light;
}
.game-vignette {
  position: absolute; inset: 0; z-index: 3; pointer-events: none;
  background:
    radial-gradient(ellipse 74% 65% at 50% 47%, transparent 52%, rgba(0,0,0,0.42) 100%),
    linear-gradient(180deg, rgba(0,0,0,0.28), transparent 16%, transparent 82%, rgba(0,0,0,0.34));
}
.game-frame { position: absolute; inset: 17px; z-index: 4; pointer-events: none; opacity: 0.75; }
.game-frame i { position: absolute; width: 20px; height: 20px; border: 1px solid rgba(var(--mode-accent-rgb), 0.4); }
.game-frame .tl { left: 0; top: 0; border-right: 0; border-bottom: 0; }
.game-frame .tr { right: 0; top: 0; border-left: 0; border-bottom: 0; }
.game-frame .bl { left: 0; bottom: 0; border-right: 0; border-top: 0; }
.game-frame .br { right: 0; bottom: 0; border-left: 0; border-top: 0; }
.game-shell.is-fallback { cursor: crosshair; }

/* ---------- HUD ---------- */
.hud { position: absolute; inset: 0; z-index: 8; pointer-events: none; transition: opacity 0.4s var(--ease), filter 0.4s var(--ease); }
.hud.is-dim { opacity: 0.35; filter: blur(1.2px); }
.hud-top {
  position: absolute; top: 0; left: 0; right: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: start;
  gap: 22px;
  padding: 28px 34px 0;
}
.hud-left, .hud-right { display: flex; }
.hud-module { position: relative; }
.hud-mode { display: flex; align-items: stretch; gap: 0; min-width: 258px; }
.hud-pause {
  pointer-events: auto;
  display: grid; place-items: center;
  width: 46px; height: 56px;
  flex: none;
  border: 1px solid rgba(255,255,255,0.1);
  border-right: 0;
  border-radius: 8px 0 0 8px;
  color: var(--text-dim);
  background: rgba(9,13,14,0.66);
  backdrop-filter: blur(10px);
  transition: 0.2s;
}
.hud-pause:hover { color: var(--mode-accent); background: rgba(var(--mode-accent-rgb), 0.08); }
.hud-pause svg { width: 15px; height: 15px; }
.hud-mode-text {
  display: flex; flex-direction: column; justify-content: center;
  gap: 3px;
  min-width: 0;
  padding: 10px 16px;
  border: 1px solid rgba(255,255,255,0.1);
  border-left: 1px solid rgba(var(--mode-accent-rgb), 0.3);
  border-radius: 0 8px 8px 0;
  background: linear-gradient(180deg, rgba(9,13,14,0.72), rgba(9,13,14,0.45));
  backdrop-filter: blur(10px);
}
.hud-mode-text::before {
  content: '';
  position: absolute; left: 46px; top: 10px; bottom: 10px; width: 1px;
  background: linear-gradient(180deg, transparent, rgba(255,255,255,0.11), transparent);
}
.hud-kicker { display: flex; align-items: center; gap: 8px; color: var(--muted); font-family: var(--font-mono); font-size: 8px; font-weight: 400; letter-spacing: 0.11em; line-height: 1.2; }
.hud-kicker em { width: 3px; height: 3px; border-radius: 50%; background: var(--mode-accent); box-shadow: 0 0 6px var(--mode-accent); }
.hud-mode-text > b { font-family: var(--font-display); font-size: 24px; font-weight: 700; letter-spacing: 0.025em; line-height: 1; color: var(--text); }
.hud-timer-wrap { text-align: center; padding-top: 1px; }
.hud-timer-label { display: flex; align-items: center; justify-content: center; gap: 9px; color: var(--muted); font-family: var(--font-mono); font-size: 8px; letter-spacing: 0.12em; }
.hud-timer-label i { width: 16px; height: 1px; background: rgba(255,255,255,0.2); }
.hud-timer-label span:last-child { color: rgba(var(--mode-accent-rgb), 0.7); }
.hud-timer {
  margin: 3px 0 1px;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 40px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 22px rgba(0,0,0,0.7);
}
.hud-progress { width: 208px; height: 2px; margin: 6px auto 0; background: rgba(255,255,255,0.12); overflow: hidden; }
.hud-progress i { display: block; height: 100%; width: 0%; background: var(--mode-accent); box-shadow: 0 0 10px var(--mode-accent); transition: width 0.12s linear; }
.hud-score-wrap { text-align: right; padding-top: 2px; }
.hud-score-wrap::after { content: ''; display: block; width: 72px; height: 1px; margin-left: auto; margin-top: 5px; background: linear-gradient(90deg, transparent, rgba(var(--mode-accent-rgb), 0.6)); }
.hud-score {
  display: block;
  margin-top: 2px;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 54px;
  font-weight: 600;
  line-height: 0.92;
  letter-spacing: 0.015em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 3px 24px rgba(0,0,0,0.8);
}
.hud-pb { display: block; margin-top: 6px; color: var(--muted); font-family: var(--font-mono); font-size: 8px; letter-spacing: 0.12em; }
.hud-bottom {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 28px;
  padding: 0 34px 28px;
}
.hud-stats { display: flex; align-items: stretch; gap: 0; }
.hud-stat {
  position: relative;
  min-width: 112px;
  padding: 9px 20px 8px;
  border-left: 1px solid rgba(255,255,255,0.1);
  background: linear-gradient(180deg, rgba(7,11,12,0.35), rgba(7,11,12,0.72));
  backdrop-filter: blur(8px);
}
.hud-stat:first-child { border-left: 2px solid rgba(var(--mode-accent-rgb), 0.55); }
.hud-stat span { display: block; color: var(--muted); font-family: var(--font-mono); font-size: 8px; letter-spacing: 0.11em; margin-bottom: 3px; }
.hud-stat b { color: var(--text); font-family: var(--font-display); font-size: 27px; font-weight: 600; line-height: 0.9; letter-spacing: 0.02em; font-variant-numeric: tabular-nums; }
.hud-stat em { margin-left: 3px; color: var(--faint); font-family: var(--font-mono); font-size: 8px; font-style: normal; }
.hud-stat:first-child b { color: var(--mode-accent); }
.hud-hints { display: flex; align-items: center; gap: 16px; padding-bottom: 4px; }
.hud-hint { display: flex; align-items: center; gap: 6px; color: var(--faint); font-family: var(--font-mono); font-size: 8px; letter-spacing: 0.06em; }
.hud-hint span { padding: 2px 5px; border: 1px solid rgba(255,255,255,0.13); border-radius: 3px; color: var(--muted); background: rgba(255,255,255,0.035); }
.hud-hint b { color: var(--muted); font-weight: 400; }
.hud-sens { color: var(--faint); font-family: var(--font-mono); font-size: 8px; letter-spacing: 0.08em; margin-left: 6px; padding-left: 14px; border-left: 1px solid rgba(255,255,255,0.1); }
.hud-sens b { color: var(--muted); font-weight: 400; }
.hud-combo {
  position: absolute; left: 50%; bottom: 122px;
  transform: translateX(-50%);
  text-align: center;
  color: var(--mode-accent);
  text-shadow: 0 0 24px rgba(var(--mode-accent-rgb), 0.28);
  transition: opacity 0.2s;
}
.hud-combo span { display: block; color: rgba(var(--mode-accent-rgb), 0.58); font-family: var(--font-mono); font-size: 8px; letter-spacing: 0.2em; margin-bottom: -2px; }
.hud-combo b { display: block; font-family: var(--font-display); font-size: 52px; font-weight: 600; line-height: 0.9; letter-spacing: 0.01em; font-variant-numeric: tabular-nums; }
.hud-combo em { display: block; color: rgba(255,255,255,0.24); font-family: var(--font-mono); font-size: 7px; font-style: normal; letter-spacing: 0.24em; margin-top: 2px; }
.hud-combo.pulse b { animation: combo-pop 0.32s var(--ease); }
.hud-combo.hot b { color: #fff7cf; }
@keyframes combo-pop { 0% { transform: scale(1.22); filter: brightness(1.35); } 100% { transform: scale(1); filter: none; } }
.hud-toast {
  position: absolute; left: 50%; top: 23%; transform: translate(-50%, 4px);
  color: var(--mode-accent);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.16em;
  opacity: 0;
  text-shadow: 0 0 16px rgba(var(--mode-accent-rgb), 0.6);
}
.hud-toast.show { animation: toast-fade 0.8s var(--ease) forwards; }
@keyframes toast-fade { 0% { opacity: 0; transform: translate(-50%, 8px); } 15% { opacity: 1; transform: translate(-50%, 0); } 70% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -7px); } }
.hud-fps { position: absolute; right: 16px; bottom: 12px; font-family: var(--font-mono); font-size: 8px; color: var(--faint); }

/* ---------- tracking meter ---------- */
.hud-track-meter {
  position: absolute; left: 50%; bottom: 126px;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px;
  min-width: 370px;
  padding: 10px 16px;
  border: 1px solid rgba(255,255,255,0.11);
  border-top-color: rgba(var(--mode-accent-rgb), 0.35);
  border-radius: 9px;
  background: rgba(7,11,12,0.62);
  backdrop-filter: blur(10px);
}
.track-copy { display: flex; flex-direction: column; gap: 3px; min-width: 100px; }
.track-copy .hud-kicker { font-size: 7px; }
.track-copy b { font-family: var(--font-mono); font-size: 8px; font-weight: 500; letter-spacing: 0.12em; color: var(--faint); }
.hud-track-meter.is-locked .track-copy b { color: var(--mode-accent); }
.track-bar { flex: 1; height: 3px; background: rgba(255,255,255,0.1); overflow: hidden; }
.track-bar i { display: block; width: 0%; height: 100%; background: linear-gradient(90deg, #6fe8ee, var(--mode-accent)); box-shadow: 0 0 10px rgba(var(--mode-accent-rgb), 0.6); transition: width 0.12s linear; }
.track-pct { display: flex; align-items: baseline; gap: 2px; min-width: 38px; justify-content: flex-end; }
.track-pct b { font-family: var(--font-display); font-size: 25px; line-height: 0.8; font-weight: 600; color: var(--mode-accent); font-variant-numeric: tabular-nums; }
.track-pct span { font-family: var(--font-mono); font-size: 8px; color: var(--faint); }
.hud-track-meter.is-locked { border-top-color: var(--mode-accent); box-shadow: 0 0 30px rgba(var(--mode-accent-rgb), 0.06); }

/* ---------- countdown ---------- */
.game-countdown {
  position: absolute; inset: 0; z-index: 20;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 48%, rgba(4,8,7,0.25), rgba(4,8,7,0.78) 72%);
  pointer-events: none;
}
.countdown-kicker {
  color: var(--mode-accent);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.32em;
  margin-bottom: 8px;
  opacity: 0.8;
}
.countdown-number {
  min-width: 190px;
  text-align: center;
  color: var(--text);
  font-family: var(--font-display);
  font-size: clamp(130px, 18vw, 220px);
  font-weight: 700;
  line-height: 0.8;
  letter-spacing: 0.01em;
  text-shadow: 0 0 60px rgba(var(--mode-accent-rgb), 0.22), 0 8px 30px rgba(0,0,0,0.5);
}
.countdown-number.tick { animation: countdown-tick 0.52s var(--ease) both; }
@keyframes countdown-tick {
  0% { opacity: 0; transform: scale(1.5); filter: blur(7px); }
  28% { opacity: 1; transform: scale(1); filter: blur(0); }
  80% { opacity: 1; }
  100% { opacity: 0.86; transform: scale(0.97); }
}
.countdown-sub { margin-top: 20px; color: var(--muted); font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.14em; }
.countdown-lines { display: flex; gap: 7px; margin-top: 24px; }
.countdown-lines i { width: 22px; height: 2px; background: rgba(var(--mode-accent-rgb), 0.24); }
.countdown-lines i:nth-child(2) { background: rgba(var(--mode-accent-rgb), 0.55); }
.game-countdown.is-resume .countdown-sub { color: var(--muted); }
.game-countdown.is-resume .countdown-number { font-size: clamp(82px, 10vw, 120px); }

/* ---------- pause ---------- */
.game-pause, .game-ending {
  position: absolute; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: rgba(3,6,7,0.62);
  backdrop-filter: blur(13px);
  cursor: default;
}
.pause-panel {
  position: relative;
  width: min(580px, 100%);
  padding: 38px 42px 30px;
  border: 1px solid rgba(255,255,255,0.13);
  border-radius: 13px;
  background:
    linear-gradient(140deg, rgba(255,255,255,0.045), transparent 45%),
    rgba(10,15,16,0.94);
  box-shadow: 0 30px 100px rgba(0,0,0,0.7), inset 0 1px 0 rgba(255,255,255,0.06);
  animation: pause-in 0.35s var(--ease) both;
}
.pause-panel::before, .pause-panel::after {
  content: '';
  position: absolute;
  width: 36px; height: 1px;
  background: var(--mode-accent);
  opacity: 0.6;
}
.pause-panel::before { left: -1px; top: 22px; }
.pause-panel::after { right: -1px; bottom: 22px; }
@keyframes pause-in { from { opacity: 0; transform: translateY(14px) scale(0.985); } to { opacity: 1; transform: none; } }
.pause-eyebrow { color: var(--mode-accent); font-family: var(--font-mono); font-size: 8px; letter-spacing: 0.23em; margin-bottom: 10px; }
.pause-panel h2 { font-family: var(--font-display); font-size: 48px; font-weight: 700; line-height: 0.95; letter-spacing: 0.015em; }
.pause-panel > p { margin-top: 9px; color: var(--muted); font-size: 12px; }
.pause-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin: 25px 0; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.08); }
.pause-stats > div { padding: 13px 14px; background: #0a0e10; }
.pause-stats span { display: block; color: var(--faint); font-family: var(--font-mono); font-size: 8px; letter-spacing: 0.1em; margin-bottom: 5px; }
.pause-stats b { font-family: var(--font-display); font-size: 27px; font-weight: 600; line-height: 1; }
.pause-actions { display: flex; align-items: center; gap: 9px; }
.game-btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 43px;
  padding: 0 18px;
  border: 1px solid rgba(255,255,255,0.13);
  border-radius: 7px;
  color: var(--text-dim);
  background: rgba(255,255,255,0.03);
  font-size: 11px;
  font-weight: 500;
  transition: 0.2s var(--ease);
  cursor: pointer;
}
.game-btn:hover { color: var(--text); border-color: rgba(255,255,255,0.25); background: rgba(255,255,255,0.055); }
.game-btn.primary { flex: 1; color: #101507; background: var(--mode-accent); border-color: var(--mode-accent); font-weight: 600; }
.game-btn.primary:hover { filter: brightness(1.07); box-shadow: 0 0 30px rgba(var(--mode-accent-rgb), 0.18); }
.game-btn.ghost { color: var(--faint); border-color: transparent; background: transparent; }
.game-btn.ghost:hover { color: var(--muted); background: rgba(255,255,255,0.03); }
.game-btn .key { padding: 2px 5px; border: 1px solid rgba(0,0,0,0.22); border-radius: 3px; font-family: var(--font-mono); font-size: 7px; letter-spacing: 0.06em; opacity: 0.55; }
.pause-tip { margin-top: 18px; color: var(--faint); font-family: var(--font-mono); font-size: 8px; letter-spacing: 0.04em; }
.pause-tip kbd { padding: 1px 4px; border: 1px solid var(--line-strong); border-radius: 3px; font-family: var(--font-mono); font-size: 7px; color: var(--muted); }

/* ---------- ending ---------- */
.game-ending { z-index: 40; }
.ending-inner { width: min(480px, 100%); text-align: center; }
.ending-mark { color: var(--mode-accent); font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.34em; margin-bottom: 16px; opacity: 0.8; }
.ending-inner h2 { font-family: var(--font-display); font-size: 66px; font-weight: 700; line-height: 0.9; letter-spacing: 0.01em; }
.ending-loader { display: flex; justify-content: center; align-items: flex-end; gap: 5px; height: 26px; margin: 30px 0 18px; }
.ending-loader i { display: block; width: 2px; height: 8px; background: var(--mode-accent); opacity: 0.3; animation: loader-bars 1s ease-in-out infinite; }
.ending-loader i:nth-child(2) { animation-delay: 0.1s; }
.ending-loader i:nth-child(3) { animation-delay: 0.2s; }
.ending-loader i:nth-child(4) { animation-delay: 0.3s; }
.ending-loader i:nth-child(5) { animation-delay: 0.4s; }
@keyframes loader-bars { 0%, 100% { height: 7px; opacity: 0.22; } 50% { height: 25px; opacity: 1; } }
.ending-inner p { color: var(--muted); font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.16em; }
.ending-inner .dots i { font-style: normal; animation: dot-blink 1.2s infinite; }
.ending-inner .dots i:nth-child(2) { animation-delay: 0.2s; }
.ending-inner .dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot-blink { 0%, 100% { opacity: 0.15; } 45% { opacity: 1; } }
.ending-scan { width: 100%; height: 1px; margin-top: 30px; background: rgba(255,255,255,0.08); overflow: hidden; }
.ending-scan i { display: block; width: 30%; height: 100%; background: var(--mode-accent); animation: ending-scan 1.1s ease-in-out infinite; }
@keyframes ending-scan { 0% { transform: translateX(-120%); } 100% { transform: translateX(430%); } }

/* ---------- hints ---------- */
.game-lockhint {
  position: absolute; top: 122px; left: 50%; transform: translateX(-50%);
  z-index: 25;
  pointer-events: auto;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  padding: 8px 14px;
  border: 1px solid rgba(255,255,255,0.13);
  border-radius: 5px;
  color: var(--muted);
  background: rgba(6,10,11,0.8);
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.08em;
  backdrop-filter: blur(8px);
}
.game-lockhint:hover { border-color: rgba(var(--mode-accent-rgb), 0.45); color: var(--text-dim); }
.game-lockhint i { color: var(--faint); font-style: normal; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .hud-top { padding: 20px 22px 0; gap: 12px; }
  .hud-score { font-size: 42px; }
  .hud-timer { font-size: 34px; }
  .hud-progress { width: 160px; }
  .hud-bottom { padding: 0 22px 20px; }
  .hud-stat { min-width: 96px; padding: 8px 14px; }
  .hud-stat b { font-size: 23px; }
  .hud-hints { gap: 10px; }
  .hud-hint:nth-child(2) { display: none; }
  .hud-pb { display: none; }
}
@media (max-width: 800px) {
  .game-shell { cursor: crosshair; }
  .hud-top { grid-template-columns: 1fr auto; padding: 14px 14px 0; }
  .hud-mode { min-width: 0; }
  .hud-mode-text { padding: 8px 11px; }
  .hud-mode-text > b { font-size: 18px; }
  .hud-pause { width: 38px; height: 48px; }
  .hud-timer-wrap { position: absolute; top: 68px; left: 50%; transform: translateX(-50%); }
  .hud-timer { font-size: 30px; }
  .hud-progress { width: 130px; }
  .hud-score-wrap { grid-column: 2; grid-row: 1; }
  .hud-score { font-size: 34px; }
  .hud-score-wrap .hud-kicker { font-size: 7px; }
  .hud-bottom { padding: 0 12px 14px; align-items: flex-end; }
  .hud-stats { gap: 0; width: 100%; justify-content: space-between; }
  .hud-stat { min-width: 0; flex: 1; padding: 7px 8px; background: rgba(7,11,12,0.55); }
  .hud-stat span { font-size: 6.5px; letter-spacing: 0.04em; }
  .hud-stat b { font-size: 19px; }
  .hud-stat em { display: none; }
  .hud-hints, .hud-sens { display: none; }
  .hud-combo { bottom: 94px; }
  .hud-combo b { font-size: 40px; }
  .hud-track-meter { bottom: 94px; min-width: 0; width: calc(100% - 28px); padding: 8px 11px; gap: 9px; }
  .track-copy { min-width: 72px; }
  .pause-panel { padding: 28px 22px 22px; }
  .pause-panel h2 { font-size: 38px; }
  .pause-actions { flex-wrap: wrap; }
  .game-btn.primary { min-width: 100%; order: -1; }
  .game-frame { inset: 8px; opacity: 0.4; }
  .game-lockhint { top: 108px; white-space: nowrap; font-size: 7px; }
  .countdown-number { font-size: 130px; }
}
@media (max-height: 640px) {
  .hud-bottom { padding-bottom: 14px; }
  .hud-stat { padding-top: 6px; padding-bottom: 6px; }
  .hud-stat b { font-size: 20px; }
  .hud-combo { bottom: 98px; }
  .pause-panel { padding-top: 24px; padding-bottom: 20px; max-height: calc(100dvh - 32px); overflow-y: auto; }
  .pause-stats { margin: 16px 0; }
  .pause-panel h2 { font-size: 36px; }
}
@media (prefers-reduced-motion: reduce) {
  .countdown-number.tick, .hud-combo.pulse b, .pause-panel, .hud-toast.show, .ending-loader i, .ending-scan i { animation: none !important; }
}

/* touch controls */
.game-touch-hint { display: none; }
.game-shell.is-touch .game-touch-hint {
  position: absolute; top: 104px; left: 50%; transform: translateX(-50%);
  z-index: 26; display: flex; align-items: center; justify-content: center;
  padding: 7px 11px; border: 1px solid rgba(255,255,255,0.1); border-radius: 5px;
  color: var(--muted); background: rgba(6,10,11,0.68); backdrop-filter: blur(8px);
  font-family: var(--font-mono); font-size: 7px; letter-spacing: 0.06em; white-space: nowrap;
  pointer-events: none;
}
.game-shell.is-touch .hud-hints { display: none; }
.game-shell.is-touch .game-lockhint { display: none !important; }
