:root {
  --cyan: #00f0ff;
  --magenta: #ff2bd6;
  --violet: #7a5cff;
  --green: #39ff88;
  --yellow: #ffe14d;
  --bg: #05010d;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg);
  font-family: "Chakra Petch", "Microsoft YaHei", system-ui, sans-serif;
  color: #eaf6ff;
  user-select: none;
  -webkit-user-select: none;
}

#game {
  position: fixed;
  inset: 0;
  display: block;
  background: var(--bg);
  cursor: none;
}

/* ---------- 摄像头面板 ---------- */
#cam-panel {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 200px;
  border: 1px solid rgba(0, 240, 255, 0.5);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 0 22px rgba(0, 240, 255, 0.35), inset 0 0 18px rgba(0, 240, 255, 0.12);
  background: #07031a;
  z-index: 20;
}

#cam-panel video {
  display: block;
  width: 100%;
  height: 150px;
  object-fit: cover;
  transform: scaleX(-1);
}

#cam-panel #overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 150px;
  pointer-events: none;
}

#cam-label {
  font-size: 11px;
  letter-spacing: 2px;
  text-align: center;
  padding: 5px 0;
  color: var(--cyan);
  background: rgba(0, 240, 255, 0.08);
  text-shadow: 0 0 8px var(--cyan);
}

#gesture-indicator {
  position: absolute;
  top: 8px; left: 8px;
  font-family: "Audiowide", sans-serif;
  font-size: 11px;
  letter-spacing: 1px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(5, 1, 13, 0.72);
  color: var(--green);
  border: 1px solid rgba(57, 255, 136, 0.5);
  text-shadow: 0 0 8px var(--green);
}

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 18px 24px;
  pointer-events: none;
  z-index: 15;
}

.hud-key {
  font-family: "Audiowide", sans-serif;
  font-size: 11px;
  letter-spacing: 2px;
  color: rgba(234, 246, 255, 0.55);
}

.hud-left { display: flex; flex-direction: column; gap: 6px; }
.hud-score { display: flex; align-items: baseline; gap: 10px; }
#score {
  font-family: "Audiowide", sans-serif;
  font-size: 34px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 12px var(--cyan), 0 0 30px rgba(0, 240, 255, 0.6);
}
.hud-combo { display: flex; align-items: baseline; gap: 8px; }
#combo {
  display: inline-block;
  font-family: "Audiowide", sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--yellow);
  text-shadow: 0 0 10px var(--yellow);
}

.hud-center {
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
#wave {
  font-family: "Audiowide", sans-serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--magenta);
  text-shadow: 0 0 12px var(--magenta);
}

.hud-right { width: 240px; display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: flex; align-items: center; gap: 8px; }
.bar-label {
  font-family: "Audiowide", sans-serif;
  font-size: 10px;
  letter-spacing: 1px;
  width: 52px;
  color: rgba(234, 246, 255, 0.7);
}
.bar {
  flex: 1;
  height: 12px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  width: 100%;
  border-radius: 7px;
  transition: width 0.15s linear;
}
.bar-fill.hp { background: linear-gradient(90deg, #ff2bd6, #ff5c8a); box-shadow: 0 0 12px var(--magenta); }
.bar-fill.shield { background: linear-gradient(90deg, #00f0ff, #39ff88); box-shadow: 0 0 12px var(--cyan); }
.bar-fill.nova { background: linear-gradient(90deg, #7a5cff, #00f0ff); box-shadow: 0 0 12px var(--violet); }
.nova-ready {
  font-family: "Audiowide", sans-serif;
  font-size: 11px;
  color: var(--green);
  text-shadow: 0 0 8px var(--green);
  animation: blink 0.7s infinite;
}
@keyframes blink { 50% { opacity: 0.25; } }

.skill-row { display: flex; gap: 6px; margin-top: 2px; }
.skill {
  flex: 1;
  font-family: "Audiowide", sans-serif;
  font-size: 9px;
  letter-spacing: 0.5px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  padding: 4px 2px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: rgba(234, 246, 255, 0.38);
  background: rgba(255, 255, 255, 0.04);
  transition: color 0.15s, border-color 0.15s, box-shadow 0.15s, text-shadow 0.15s;
}
.skill.ready {
  color: var(--green);
  border-color: rgba(57, 255, 136, 0.55);
  box-shadow: 0 0 10px rgba(57, 255, 136, 0.3);
  text-shadow: 0 0 8px var(--green);
}

/* ---------- 覆盖层 / 按钮 ---------- */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(10, 3, 30, 0.82), rgba(5, 1, 13, 0.96));
  z-index: 30;
  backdrop-filter: blur(4px);
}
.hidden { display: none !important; }

.start-inner {
  text-align: center;
  max-width: 620px;
  padding: 40px;
}

.title {
  font-family: "Audiowide", sans-serif;
  font-size: 64px;
  font-weight: 900;
  letter-spacing: 4px;
  color: #fff;
  text-shadow: 0 0 10px var(--cyan), 0 0 32px var(--cyan), 0 0 64px var(--cyan);
  animation: title-jitter 6s infinite;
}
.title span { color: var(--magenta); text-shadow: 0 0 10px var(--magenta), 0 0 32px var(--magenta), 0 0 64px var(--magenta); }
.title.small-title { font-size: 42px; color: var(--cyan); text-shadow: 0 0 10px var(--cyan), 0 0 32px var(--cyan); }
.title.danger { font-size: 56px; color: var(--magenta); text-shadow: 0 0 10px var(--magenta), 0 0 40px var(--magenta); }

.subtitle {
  font-family: "Audiowide", sans-serif;
  letter-spacing: 6px;
  margin-top: 6px;
  color: var(--violet);
  text-shadow: 0 0 10px var(--violet);
}

.gesture-legend {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 34px 0 30px;
}
.g-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid rgba(0, 240, 255, 0.25);
  border-radius: 10px;
  background: rgba(0, 240, 255, 0.04);
  text-align: left;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.g-item:hover {
  border-color: rgba(0, 240, 255, 0.6);
  background: rgba(0, 240, 255, 0.09);
  box-shadow: 0 0 14px rgba(0, 240, 255, 0.25);
}
.g-icon { font-size: 26px; }
.g-item b {
  display: block;
  font-size: 15px;
  color: #fff;
}
.g-item span {
  display: block;
  font-size: 12px;
  color: rgba(234, 246, 255, 0.6);
}

.start-buttons { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
.btn {
  font-family: "Audiowide", sans-serif;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 15px 28px;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, background 0.12s;
  border: 1px solid transparent;
}
.btn:active { transform: scale(0.96); }
.btn.primary {
  position: relative;
  overflow: hidden;
  color: #04010a;
  background: linear-gradient(90deg, var(--cyan), var(--violet));
  box-shadow: 0 0 18px rgba(0, 240, 255, 0.5);
  border-color: rgba(0, 240, 255, 0.6);
  animation: btn-pulse 2.2s ease-in-out infinite;
}
.btn.primary:hover { box-shadow: 0 0 30px rgba(0, 240, 255, 0.8); }
.btn.primary::after {
  content: "";
  position: absolute;
  top: 0; left: -80%;
  width: 50%; height: 100%;
  background: linear-gradient(105deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  animation: btn-shine 3.2s ease-in-out infinite;
}
.btn.ghost {
  color: var(--cyan);
  background: transparent;
  border-color: rgba(0, 240, 255, 0.5);
  text-shadow: 0 0 8px var(--cyan);
}
.btn.ghost:hover { background: rgba(0, 240, 255, 0.1); }

.tip { margin-top: 22px; font-size: 13px; color: rgba(234, 246, 255, 0.65); }
.tip.small { margin-top: 8px; font-size: 12px; color: rgba(234, 246, 255, 0.45); }

.final-stats {
  margin: 30px auto;
  width: 320px;
  border: 1px solid rgba(0, 240, 255, 0.25);
  border-radius: 10px;
  background: rgba(0, 240, 255, 0.04);
}
.fs-row {
  display: flex;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(0, 240, 255, 0.12);
  font-size: 16px;
}
.fs-row:last-child { border-bottom: none; }
.fs-row b { font-family: "Audiowide", sans-serif; color: var(--yellow); text-shadow: 0 0 8px var(--yellow); }

/* ---------- 加载 ---------- */
.loading-spinner {
  width: 54px; height: 54px;
  border: 3px solid rgba(0, 240, 255, 0.2);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 18px;
  box-shadow: 0 0 18px rgba(0, 240, 255, 0.4);
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading p { font-family: "Audiowide", sans-serif; letter-spacing: 2px; color: var(--cyan); }

/* ============ 屏幕边框（机舱 HUD 角标） ============ */
.screen-frame {
  position: fixed;
  inset: 14px;
  z-index: 12;
  pointer-events: none;
}
.corner {
  position: absolute;
  width: 34px; height: 34px;
  border: 2px solid rgba(0, 240, 255, 0.55);
  filter: drop-shadow(0 0 6px rgba(0, 240, 255, 0.8));
  animation: corner-pulse 2.6s ease-in-out infinite;
}
.corner.tl { top: 0; left: 0; border-right: 0; border-bottom: 0; }
.corner.tr { top: 0; right: 0; border-left: 0; border-bottom: 0; animation-delay: 0.65s; }
.corner.bl { bottom: 0; left: 0; border-right: 0; border-top: 0; animation-delay: 1.3s; }
.corner.br { bottom: 0; right: 0; border-left: 0; border-top: 0; animation-delay: 1.95s; }
@keyframes corner-pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 0.9; }
}

/* ============ CRT 复古街机覆盖层 ============ */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 45;
  pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.025) 0 1px, rgba(0, 0, 0, 0.16) 1px 3px),
    radial-gradient(ellipse at center, transparent 50%, rgba(0, 0, 0, 0.58) 100%);
  animation: crt-flicker 4s infinite;
}
body::after {
  content: "";
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 16vh;
  z-index: 46;
  pointer-events: none;
  background: linear-gradient(to bottom, transparent, rgba(130, 220, 255, 0.05), transparent);
  animation: crt-roll 8s linear infinite;
}
@keyframes crt-flicker {
  0%, 100% { opacity: 1; }
  95% { opacity: 1; }
  96% { opacity: 0.84; }
  97% { opacity: 1; }
  98% { opacity: 0.92; }
}
@keyframes crt-roll {
  0% { transform: translateY(-20vh); }
  100% { transform: translateY(120vh); }
}

/* ============ 标题 / 按钮 / 连击动效 ============ */
#start-screen .title {
  animation: neon-flicker 4s infinite, title-jitter 6s infinite;
}
.title.danger {
  animation: danger-flicker 2.5s infinite, title-jitter 5s infinite;
}
@keyframes neon-flicker {
  0%, 100% { text-shadow: 0 0 10px var(--cyan), 0 0 32px var(--cyan), 0 0 64px var(--cyan); }
  91% { text-shadow: 0 0 10px var(--cyan), 0 0 32px var(--cyan), 0 0 64px var(--cyan); }
  92% { text-shadow: 0 0 3px var(--cyan), 0 0 12px var(--cyan), 0 0 22px var(--cyan); }
  93% { text-shadow: 0 0 10px var(--cyan), 0 0 32px var(--cyan), 0 0 64px var(--cyan); }
}
@keyframes danger-flicker {
  0%, 100% { text-shadow: 0 0 10px var(--magenta), 0 0 40px var(--magenta); }
  50% { text-shadow: 0 0 6px var(--magenta), 0 0 22px var(--magenta), 0 0 60px var(--magenta); }
}
@keyframes title-jitter {
  0%, 100% { transform: none; }
  90% { transform: translate(-2px, 1px) skewX(-3deg); }
  92% { transform: translate(2px, -1px) skewX(2deg); }
  94% { transform: translate(-1px, 0) skewX(-1deg); }
  96% { transform: none; }
}
@keyframes btn-pulse {
  0%, 100% { box-shadow: 0 0 18px rgba(0, 240, 255, 0.5); }
  50% { box-shadow: 0 0 32px rgba(0, 240, 255, 0.9); }
}
@keyframes btn-shine {
  0% { left: -80%; }
  55%, 100% { left: 160%; }
}
@keyframes combo-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.45); }
  100% { transform: scale(1); }
}
#combo.pop { animation: combo-pop 0.25s ease; }

/* ---------- 启动加载界面 ---------- */
.boot-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #05010d;
  cursor: pointer;
  transition: opacity 0.5s ease;
}
.boot-overlay.fade-out { opacity: 0; pointer-events: none; }
.boot-inner { text-align: center; width: min(420px, 86vw); }
.boot-title {
  font-family: "Audiowide", sans-serif;
  font-size: 40px;
  font-weight: 900;
  letter-spacing: 4px;
  color: #fff;
  text-shadow: 0 0 10px var(--cyan), 0 0 32px var(--cyan), 0 0 64px var(--cyan);
  animation: neon-flicker 3s infinite;
}
.boot-title span {
  color: var(--magenta);
  text-shadow: 0 0 10px var(--magenta), 0 0 32px var(--magenta), 0 0 64px var(--magenta);
}
.boot-bar {
  width: 100%;
  height: 14px;
  margin: 34px 0 18px;
  border: 1px solid rgba(0, 240, 255, 0.45);
  border-radius: 8px;
  background: rgba(0, 240, 255, 0.05);
  overflow: hidden;
  box-shadow: 0 0 18px rgba(0, 240, 255, 0.25), inset 0 0 12px rgba(0, 240, 255, 0.15);
}
.boot-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--cyan), var(--violet));
  box-shadow: 0 0 14px var(--cyan);
  border-radius: 8px;
  transition: width 0.08s linear;
}
.boot-status {
  font-family: "Audiowide", sans-serif;
  font-size: 13px;
  letter-spacing: 3px;
  color: var(--cyan);
  text-shadow: 0 0 8px var(--cyan);
}
.boot-status.ready { color: var(--green); text-shadow: 0 0 10px var(--green); }
.boot-hint {
  margin-top: 26px;
  font-size: 11px;
  letter-spacing: 2px;
  color: rgba(234, 246, 255, 0.35);
  animation: blink 1.2s infinite;
}

@media (max-width: 600px) {
  .title { font-size: 42px; }
  .title.danger { font-size: 38px; }
  .gesture-legend { grid-template-columns: 1fr; }
  .hud-right { width: 170px; }
  #score { font-size: 24px; }
  #cam-panel { width: 140px; }
  #cam-panel video, #cam-panel #overlay { height: 105px; }
}
