/* ============================================
   NEON STRIKE - Design System & Styles
   ============================================ */

:root {
  /* Core palette */
  --bg-deep: #050510;
  --bg-panel: rgba(10, 10, 30, 0.92);
  --bg-glass: rgba(15, 15, 40, 0.8);

  --neon-blue: #00d4ff;
  --neon-blue-g: rgba(0, 212, 255, 0.4);
  --neon-green: #39ff14;
  --neon-green-g: rgba(57, 255, 20, 0.35);
  --neon-pink: #ff2d95;
  --neon-pink-g: rgba(255, 45, 149, 0.4);
  --neon-orange: #ff8c00;
  --neon-orange-g: rgba(255, 140, 0, 0.4);
  --neon-purple: #b84dff;
  --neon-yellow: #ffe156;
  --neon-red: #ff3344;
  --neon-cyan: #00f0ff;

  --text-primary: #e4e4f0;
  --text-dim: #7777aa;
  --border-glow: rgba(0, 212, 255, 0.15);

  --font-display: 'Orbitron', monospace, sans-serif;
  --font-pixel: 'Press Start 2P', monospace;
  --font-body: 'Inter', system-ui, sans-serif;

  --radius: 10px;
  --transition: 250ms ease;
}

/* === Reset === */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-body);
  background: var(--bg-deep);
  color: var(--text-primary);
  height: 100vh;
  height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none; /* 彻底阻止移动端全局触控的弹性页面滚动与回弹 */
}

/* === Ambient BG === */
#ambient-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(0, 212, 255, 0.05) 0%, transparent 55%),
    radial-gradient(ellipse at 70% 80%, rgba(255, 45, 149, 0.04) 0%, transparent 55%);
  animation: ambientShift 25s ease-in-out infinite alternate;
}

@keyframes ambientShift {
  0% { opacity: 0.8; }
  100% { opacity: 1; transform: scale(1.05); }
}

/* === App Layout === */
#app {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 24px;
  align-items: flex-start;
  padding: 16px;
}

/* === Game Wrapper === */
#game-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

/* === HUD Top === */
#hud-top {
  display: flex;
  justify-content: space-between;
  width: 100%;
  max-width: none; /* 由 JS 动态精确设定以匹配 Canvas 宽度 */
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius);
  padding: 6px 16px;
}

.hud-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.hud-label {
  font-family: var(--font-display);
  font-size: 0.5rem;
  letter-spacing: 0.2em;
  color: var(--text-dim);
}

.hud-value {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--neon-blue);
  text-shadow: 0 0 8px var(--neon-blue-g);
  transition: transform 150ms ease;
}

.hud-value.pop { transform: scale(1.25); }

#hud-hiscore { color: var(--neon-yellow); text-shadow: 0 0 8px rgba(255, 225, 86, 0.4); }
#hud-wave { color: var(--neon-green); text-shadow: 0 0 8px var(--neon-green-g); }

/* === Canvas Frame === */
#canvas-frame {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 2px solid var(--border-glow);
  box-shadow:
    0 0 30px rgba(0, 212, 255, 0.08),
    0 0 60px rgba(0, 212, 255, 0.04),
    inset 0 0 40px rgba(0, 0, 0, 0.4);
}

#game-canvas {
  display: block;
  background: #060614;
}

/* === Overlays === */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(3, 3, 12, 0.9);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 20;
  animation: overlayIn 0.35s ease;
}

.overlay.hidden { display: none; }

@keyframes overlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.overlay-inner {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 20px;
}

/* Title screen */
.title-ship {
  font-size: 3rem;
  animation: shipFloat 2.5s ease-in-out infinite;
  filter: drop-shadow(0 0 12px var(--neon-blue-g));
}

@keyframes shipFloat {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-10px); }
}

.game-logo {
  font-family: var(--font-display);
  font-size: 2.4em;
  font-weight: 900;
  letter-spacing: 0.2em;
  line-height: 1.15;
  background: linear-gradient(135deg, var(--neon-blue), var(--neon-pink));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 20px var(--neon-blue-g));
}

.subtitle {
  font-family: var(--font-display);
  font-size: 0.65em;
  letter-spacing: 0.4em;
  color: var(--text-dim);
}

.controls-info {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.78em;
  color: var(--text-dim);
}

.controls-info kbd {
  display: inline-block;
  background: rgba(0, 212, 255, 0.1);
  border: 1px solid rgba(0, 212, 255, 0.25);
  border-radius: 4px;
  padding: 1px 7px;
  font-family: var(--font-display);
  font-size: 0.65em;
  color: var(--neon-blue);
}

.mobile-tip {
  font-size: 0.68em;
  color: var(--text-dim);
  opacity: 0.6;
}

/* Arcade button */
.arcade-btn {
  font-family: var(--font-display);
  font-size: 0.85em;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--bg-deep);
  background: linear-gradient(135deg, var(--neon-blue), var(--neon-pink));
  border: none;
  border-radius: 0.5em;
  padding: 0.8em 2.2em;
  cursor: pointer;
  text-transform: uppercase;
  transition: all var(--transition);
  box-shadow:
    0 0 1.25em var(--neon-blue-g),
    0 0 2.5em rgba(0, 212, 255, 0.12);
}

.arcade-btn:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow:
    0 0 30px var(--neon-blue-g),
    0 0 60px rgba(255, 45, 149, 0.15);
}

.arcade-btn:active { transform: scale(0.97); }

/* Pause */
.pause-title {
  font-family: var(--font-display);
  font-size: 2em;
  font-weight: 900;
  letter-spacing: 0.15em;
  color: var(--neon-blue);
  text-shadow: 0 0 20px var(--neon-blue-g);
}

/* Game Over */
.go-title {
  font-family: var(--font-display);
  font-size: 2em;
  font-weight: 900;
  letter-spacing: 0.12em;
  background: linear-gradient(135deg, var(--neon-red), var(--neon-orange));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 15px rgba(255, 51, 68, 0.5));
}

.go-score-label {
  font-family: var(--font-display);
  font-size: 0.6em;
  letter-spacing: 0.25em;
  color: var(--text-dim);
}

.go-score {
  font-family: var(--font-display);
  font-size: 3em;
  font-weight: 900;
  color: var(--neon-blue);
  text-shadow: 0 0 25px var(--neon-blue-g);
  animation: scoreIn 0.5s ease-out;
}

@keyframes scoreIn {
  from { transform: scale(0.4); opacity: 0; }
  60% { transform: scale(1.15); }
  to { transform: scale(1); opacity: 1; }
}

.go-record {
  font-family: var(--font-display);
  font-size: 0.9em;
  color: var(--neon-yellow);
  text-shadow: 0 0 12px rgba(255, 225, 86, 0.5);
  animation: pulse 1s ease-in-out infinite;
}

.go-record.hidden { display: none; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.go-stats {
  display: flex;
  gap: 24px;
  font-size: 0.78em;
  color: var(--text-dim);
}

.go-stats strong {
  color: var(--neon-blue);
}

/* Wave Announce */
.wave-announce {
  position: absolute;
  top: 35%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 15;
  text-align: center;
  pointer-events: none;
}

.wave-announce.hidden { display: none; }

.wa-sub {
  display: block;
  font-family: var(--font-display);
  font-size: 0.6em;
  letter-spacing: 0.5em;
  color: var(--neon-red);
  text-shadow: 0 0 10px rgba(255, 51, 68, 0.5);
  animation: waBlink 0.5s ease-in-out 3;
}

.wa-main {
  display: block;
  font-family: var(--font-display);
  font-size: 1.8em;
  font-weight: 900;
  letter-spacing: 0.15em;
  color: var(--neon-blue);
  text-shadow: 0 0 25px var(--neon-blue-g);
  animation: waSlide 0.6s ease-out;
}

@keyframes waBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

@keyframes waSlide {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* === HUD Bottom === */
#hud-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: none; /* 由 JS 动态精确设定以匹配 Canvas 宽度 */
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius);
  padding: 6px 16px;
}

.hud-lives {
  display: flex;
  gap: 4px;
}

.life-icon {
  font-size: 1rem;
  color: var(--neon-red);
  text-shadow: 0 0 6px rgba(255, 51, 68, 0.5);
  transition: all 200ms ease;
}

.life-icon.lost {
  opacity: 0.15;
  filter: grayscale(1);
}

.hud-powerups {
  display: flex;
  gap: 4px;
  min-height: 22px;
}

.hud-pw {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 0.55rem;
  font-weight: 700;
  border: 1px solid;
  animation: pwIn 0.3s ease;
}

@keyframes pwIn {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

.hud-bombs {
  display: flex;
  gap: 4px;
}

.bomb-icon {
  font-size: 0.9rem;
  transition: all 200ms ease;
}

.bomb-icon.used {
  opacity: 0.15;
  filter: grayscale(1);
}

/* === Side Info (Desktop) === */
#side-info {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius);
  padding: 16px 20px;
  width: 180px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-dim);
}

#side-info h3 {
  font-family: var(--font-display);
  font-size: 0.6rem;
  letter-spacing: 0.15em;
  color: var(--neon-blue);
  text-shadow: 0 0 6px var(--neon-blue-g);
}

#side-info hr {
  border: none;
  border-top: 1px solid rgba(0, 212, 255, 0.1);
}

.key-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.key-row kbd {
  background: rgba(0, 212, 255, 0.08);
  border: 1px solid rgba(0, 212, 255, 0.2);
  border-radius: 3px;
  padding: 1px 5px;
  font-family: var(--font-display);
  font-size: 0.55rem;
  color: var(--neon-blue);
}

.pw-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pw-icon {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 0.55rem;
  font-weight: 700;
  flex-shrink: 0;
}

.pw-s { background: rgba(0, 212, 255, 0.15); border: 1px solid var(--neon-blue); color: var(--neon-blue); }
.pw-m { background: rgba(57, 255, 20, 0.15); border: 1px solid var(--neon-green); color: var(--neon-green); }
.pw-d { background: rgba(255, 140, 0, 0.15); border: 1px solid var(--neon-orange); color: var(--neon-orange); }
.pw-l { background: rgba(255, 45, 149, 0.15); border: 1px solid var(--neon-pink); color: var(--neon-pink); }
.pw-o { background: rgba(184, 77, 255, 0.15); border: 1px solid var(--neon-purple); color: var(--neon-purple); }
.pw-sh { background: rgba(255, 225, 86, 0.15); border: 1px solid var(--neon-yellow); font-size: 0.7rem; }
.pw-w { background: rgba(0, 255, 204, 0.15); border: 1px solid #00ffcc; color: #00ffcc; }
.pw-p { background: rgba(255, 140, 0, 0.15); border: 1px solid #ff8c00; color: #ff8c00; }

/* === Responsive === */
@media (max-width: 700px) {
  #side-info { display: none; }
  #app { padding: 8px; }
  .game-logo { font-size: 1.8rem; }
  .mobile-tip { display: block; }
}

@media (min-width: 701px) {
  .mobile-tip { display: none; }
}

/* === Screen Shake === */
@keyframes shake {
  0%, 100% { transform: translate(0); }
  15% { transform: translate(-3px, -2px); }
  30% { transform: translate(3px, 2px); }
  45% { transform: translate(-2px, 2px); }
  60% { transform: translate(2px, -2px); }
  75% { transform: translate(-1px, 1px); }
}

.shake { animation: shake 0.35s ease-in-out; }

/* === Hall of Fame Leaderboard === */
#leaderboard-input-zone {
  margin-top: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed rgba(0, 212, 255, 0.3);
  padding: 10px 15px;
  border-radius: 8px;
  width: 100%;
  max-width: 320px;
  box-sizing: border-box;
  animation: borderFlash 2s infinite alternate;
}

@keyframes borderFlash {
  0% { border-color: rgba(0, 212, 255, 0.2); }
  100% { border-color: rgba(255, 45, 149, 0.5); }
}

.lb-prompt {
  font-size: 0.65em;
  color: var(--text-primary);
  margin-bottom: 8px;
  letter-spacing: 0.05em;
}

.lb-input-wrap {
  display: flex;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

#lb-name-input {
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(0, 212, 255, 0.4);
  border-radius: 4px;
  color: var(--neon-blue);
  font-family: var(--font-display);
  font-size: 0.85em;
  text-align: center;
  padding: 4px;
  width: 130px;
  outline: none;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  box-shadow: inset 0 0 5px rgba(0, 212, 255, 0.2);
}

#lb-name-input:focus {
  border-color: var(--neon-pink);
  box-shadow: inset 0 0 8px rgba(255, 45, 149, 0.3), 0 0 10px rgba(255, 45, 149, 0.2);
}

.arcade-btn-small {
  font-family: var(--font-display);
  font-size: 0.65em;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--bg-deep);
  background: linear-gradient(135deg, var(--neon-blue), var(--neon-pink));
  border: none;
  border-radius: 4px;
  padding: 6px 12px;
  cursor: pointer;
  transition: all var(--transition);
}

.arcade-btn-small:hover {
  transform: scale(1.05);
  box-shadow: 0 0 10px var(--neon-blue-g);
}

#leaderboard-display-zone {
  margin: 15px 0;
  width: 100%;
  max-width: 320px;
}

.lb-title {
  font-family: var(--font-display);
  font-size: 0.75em;
  letter-spacing: 0.2em;
  color: var(--neon-yellow);
  text-shadow: 0 0 8px rgba(255, 225, 86, 0.4);
  margin-bottom: 8px;
}

.lb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.62em;
  color: var(--text-dim);
  text-align: center;
  background: rgba(10, 10, 20, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.lb-table th {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
  font-family: var(--font-display);
  font-weight: 700;
  padding: 6px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.lb-table td {
  padding: 6px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  font-family: var(--font-display);
}

.lb-table tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.01);
}

.lb-table tr.current-score-row {
  background: rgba(0, 212, 255, 0.1) !important;
  color: var(--neon-blue);
  font-weight: 700;
}

.lb-table tr:nth-child(1) td:nth-child(1) { color: #ffd700; font-weight: 900; } /* 金牌 */
.lb-table tr:nth-child(2) td:nth-child(1) { color: #c0c0c0; font-weight: 900; } /* 银牌 */
.lb-table tr:nth-child(3) td:nth-child(1) { color: #cd7f32; font-weight: 900; } /* 铜牌 */

/* === Floating Back to Portal Button === */
.back-home-btn {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 9999;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: rgba(10, 10, 26, 0.75);
  border: 1px solid var(--neon-cyan, #00d4ff);
  border-radius: 20px;
  color: var(--neon-cyan, #00d4ff);
  font-family: var(--font-display, 'Orbitron'), monospace;
  font-size: 0.75rem;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: 0.1em;
  box-shadow: 0 0 12px rgba(0, 212, 255, 0.2), inset 0 0 4px rgba(0, 212, 255, 0.1);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all 0.25s ease;
  cursor: pointer;
}

.back-home-btn:hover {
  background: var(--neon-cyan, #00d4ff);
  color: #050510;
  box-shadow: 0 0 20px rgba(0, 212, 255, 0.45);
  transform: translateY(-1.5px);
}

.back-home-btn:active {
  transform: translateY(0);
}

@media (max-width: 600px) {
  .back-home-btn {
    top: 12px;
    left: 12px;
    padding: 6px 12px;
    font-size: 0.65rem;
  }
}
