/* ===== 赛博物理终端 · Cyber-Physics Terminal Style ===== */

/* --- CRT 扫描线全局覆盖 --- */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(0, 255, 65, 0.03) 2px,
      rgba(0, 255, 65, 0.03) 4px
    ),
    linear-gradient(
      90deg,
      rgba(255, 0, 0, 0.02) 0%,
      transparent 20%,
      transparent 80%,
      rgba(0, 0, 255, 0.02) 100%
    );
  pointer-events: none;
  z-index: 100;
}

/* --- 基础重置 --- */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  overflow: hidden;
  background: #050505;
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  user-select: none;
  color: #e2e8f0;
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

/* --- 通用 --- */
.hidden { display: none !important; }

.overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

/* ===== HUD ===== */
#hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: rgba(5, 5, 5, 0.85);
  border-bottom: 1px solid #34d399;
  box-shadow: 0 1px 8px rgba(52, 211, 153, 0.15);
  z-index: 5;
  font-size: 13px;
  letter-spacing: 0.08em;
}

#hud-left { display: flex; align-items: center; gap: 10px; }
#wall-hp-label {
  font-weight: 700;
  color: #34d399;
  text-shadow: 0 0 6px rgba(52, 211, 153, 0.3);
  letter-spacing: 0.15em;
  font-size: 11px;
  text-transform: uppercase;
}

#wall-hp-bar {
  width: 200px; height: 14px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 0;
  overflow: hidden;
  border: 1px solid #34d399;
  position: relative;
}

/* L形标角 */
#wall-hp-bar::before {
  content: '';
  position: absolute;
  top: -3px; left: -3px;
  width: 8px; height: 8px;
  border-top: 2px solid #22d3ee;
  border-left: 2px solid #22d3ee;
}
#wall-hp-bar::after {
  content: '';
  position: absolute;
  bottom: -3px; right: -3px;
  width: 8px; height: 8px;
  border-bottom: 2px solid #22d3ee;
  border-right: 2px solid #22d3ee;
}

#wall-hp-fill {
  height: 100%;
  width: 100%;
  background: #34d399;
  transition: width 0.3s ease;
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.4);
}

#hud-center {
  font-size: 16px;
  font-weight: 700;
  color: #22d3ee;
  letter-spacing: 0.2em;
  text-shadow: 0 0 8px rgba(34, 211, 238, 0.3);
}

#hud-right {
  font-weight: 700;
  color: #22d3ee;
  letter-spacing: 0.12em;
  text-shadow: 0 0 4px rgba(34, 211, 238, 0.2);
}

/* ===== 标题画面 ===== */
#title-screen {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #050505;
  z-index: 20;
}

#title-main {
  text-align: center;
  animation: fadeInUp 0.8s ease-out;
}

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

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

/* Glitch 动画 */
@keyframes textGlitch {
  0%, 90%, 100% { transform: none; text-shadow: 0 0 8px rgba(52, 211, 153, 0.4); }
  92% { transform: translate(2px, -1px); text-shadow: -2px 0 #ef4444, 2px 0 #22d3ee; }
  94% { transform: translate(-2px, 1px); text-shadow: 2px 0 #ef4444, -2px 0 #22d3ee; }
  96% { transform: translate(1px, 0); text-shadow: -1px 0 #22d3ee, 1px 0 #ef4444; }
  98% { transform: none; text-shadow: 0 0 8px rgba(52, 211, 153, 0.4); }
}

/* 节点呼吸闪烁 */
@keyframes pulseOpacity {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

#game-title {
  font-size: 52px;
  font-weight: 700;
  color: #34d399;
  text-shadow: 0 0 30px rgba(52, 211, 153, 0.5), 0 0 60px rgba(52, 211, 153, 0.2);
  letter-spacing: 0.3em;
  margin-bottom: 8px;
  animation: textGlitch 4s infinite;
}

#game-subtitle {
  font-size: 14px;
  color: #e2e8f0;
  letter-spacing: 0.2em;
  margin-bottom: 24px;
  opacity: 0.6;
}

#title-formula {
  font-size: 18px;
  color: #22d3ee;
  letter-spacing: 0.15em;
  margin-bottom: 40px;
  padding: 14px 28px;
  border: 1px solid #22d3ee;
  border-radius: 0;
  background: rgba(34, 211, 238, 0.04);
  text-shadow: 0 0 8px rgba(34, 211, 238, 0.3);
  position: relative;
}

/* 标角装饰 */
#title-formula::before {
  content: '';
  position: absolute;
  top: -4px; left: -4px;
  width: 12px; height: 12px;
  border-top: 2px solid #34d399;
  border-left: 2px solid #34d399;
}
#title-formula::after {
  content: '';
  position: absolute;
  bottom: -4px; right: -4px;
  width: 12px; height: 12px;
  border-bottom: 2px solid #34d399;
  border-right: 2px solid #34d399;
}

button {
  padding: 14px 48px;
  font-size: 18px;
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-weight: 700;
  color: #050505;
  background: #34d399;
  border: none;
  border-radius: 0;
  cursor: pointer;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  transition: all 0.2s ease;
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.3);
  position: relative;
}

button:hover {
  background: #22d3ee;
  box-shadow: 0 0 24px rgba(34, 211, 238, 0.4), 0 4px 16px rgba(34, 211, 238, 0.2);
  color: #050505;
  transform: translateY(-2px);
}

button:active {
  transform: translateY(0);
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.3);
}

/* ===== 武器选择面板 ===== */
#weapon-select {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(5, 5, 5, 0.92);
  z-index: 18;
  animation: fadeIn 0.3s ease;
}

#weapon-select-title {
  font-size: 28px;
  font-weight: 700;
  color: #34d399;
  margin-bottom: 40px;
  letter-spacing: 0.25em;
  text-shadow: 0 0 20px rgba(52, 211, 153, 0.3);
  text-transform: uppercase;
}

#weapon-select-title::after {
  content: '';
  display: block;
  width: 80%;
  height: 1px;
  background: linear-gradient(90deg, transparent, #34d399, transparent);
  margin-top: 12px;
  box-shadow: 0 0 6px rgba(52, 211, 153, 0.4);
}

#weapon-select-cards {
  display: flex;
  gap: 36px;
  flex-wrap: wrap;
  justify-content: center;
}

.weapon-select-card {
  width: 280px;
  padding: 32px 24px;
  background: rgba(5, 5, 5, 0.95);
  border: 1px solid rgba(52, 211, 153, 0.2);
  cursor: pointer;
  transition: all 0.25s ease;
  text-align: center;
  position: relative;
  box-shadow: inset 0 0 20px rgba(5, 5, 5, 0.8);
}

.weapon-select-card::before {
  content: '';
  position: absolute;
  top: -4px; left: -4px;
  width: 14px; height: 14px;
  border-top: 2px solid #34d399;
  border-left: 2px solid #34d399;
  transition: all 0.25s ease;
}
.weapon-select-card::after {
  content: '';
  position: absolute;
  bottom: -4px; right: -4px;
  width: 14px; height: 14px;
  border-bottom: 2px solid #34d399;
  border-right: 2px solid #34d399;
  transition: all 0.25s ease;
}

.weapon-select-card:hover {
  border-color: #34d399;
  box-shadow: 0 0 24px rgba(52, 211, 153, 0.2), inset 0 0 30px rgba(52, 211, 153, 0.05);
  transform: translateY(-6px);
  background: rgba(10, 10, 10, 0.95);
}

.weapon-select-card:hover::before,
.weapon-select-card:hover::after {
  width: 20px; height: 20px;
}

.ws-category {
  font-size: 12px;
  letter-spacing: 0.2em;
  margin-bottom: 12px;
  text-transform: uppercase;
}

.ws-name {
  font-size: 22px;
  font-weight: 700;
  color: #e2e8f0;
  margin-bottom: 10px;
  letter-spacing: 0.08em;
}

.ws-formula {
  font-size: 16px;
  color: #34d399;
  margin-bottom: 14px;
  text-shadow: 0 0 6px rgba(52, 211, 153, 0.3);
  letter-spacing: 0.1em;
}

.ws-desc {
  font-size: 13px;
  color: #94a3b8;
  line-height: 1.7;
  letter-spacing: 0.05em;
}

/* ===== 升级面板 ===== */
#upgrade-panel {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(5, 5, 5, 0.92);
  z-index: 15;
  animation: fadeIn 0.3s ease;
}

#upgrade-title {
  font-size: 28px;
  font-weight: 700;
  color: #34d399;
  margin-bottom: 32px;
  letter-spacing: 0.25em;
  text-shadow: 0 0 20px rgba(52, 211, 153, 0.3);
  text-transform: uppercase;
}

/* 标题发光底线 */
#upgrade-title::after {
  content: '';
  display: block;
  width: 80%;
  height: 1px;
  background: linear-gradient(90deg, transparent, #34d399, transparent);
  margin-top: 12px;
  box-shadow: 0 0 6px rgba(52, 211, 153, 0.4);
}

#upgrade-cards {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  justify-content: center;
}

/* 赛博终端卡片 */
.upgrade-card {
  width: 220px;
  padding: 24px 20px;
  background: rgba(5, 5, 5, 0.95);
  border: 1px solid rgba(52, 211, 153, 0.2);
  border-radius: 0;
  cursor: pointer;
  transition: all 0.25s ease;
  text-align: center;
  position: relative;
  box-shadow: inset 0 0 20px rgba(5, 5, 5, 0.8);
}

/* L形标角 */
.upgrade-card::before {
  content: '';
  position: absolute;
  top: -4px; left: -4px;
  width: 14px; height: 14px;
  border-top: 2px solid #34d399;
  border-left: 2px solid #34d399;
  transition: all 0.25s ease;
}
.upgrade-card::after {
  content: '';
  position: absolute;
  bottom: -4px; right: -4px;
  width: 14px; height: 14px;
  border-bottom: 2px solid #34d399;
  border-right: 2px solid #34d399;
  transition: all 0.25s ease;
}

.upgrade-card:hover {
  border-color: #34d399;
  box-shadow: 0 0 20px rgba(52, 211, 153, 0.15), inset 0 0 30px rgba(52, 211, 153, 0.05);
  transform: translateY(-6px);
  background: rgba(10, 10, 10, 0.95);
}

.upgrade-card:hover::before,
.upgrade-card:hover::after {
  width: 20px; height: 20px;
}

.upgrade-card .card-category {
  font-size: 11px;
  color: #22d3ee;
  letter-spacing: 0.2em;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.upgrade-card .card-name {
  font-size: 18px;
  font-weight: 700;
  color: #e2e8f0;
  margin-bottom: 8px;
  letter-spacing: 0.08em;
}

.upgrade-card .card-formula {
  font-size: 14px;
  color: #34d399;
  margin-bottom: 10px;
  text-shadow: 0 0 6px rgba(52, 211, 153, 0.3);
  letter-spacing: 0.1em;
}

.upgrade-card .card-desc {
  font-size: 12px;
  color: #94a3b8;
  line-height: 1.6;
  letter-spacing: 0.05em;
}

/* ===== 物理答题 ===== */
#quiz-btn {
  margin-top: 24px;
  padding: 10px 36px;
  font-size: 14px;
  background: #22d3ee;
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.3);
  letter-spacing: 0.15em;
}

#quiz-btn:hover {
  background: #34d399;
  box-shadow: 0 0 20px rgba(52, 211, 153, 0.4);
}

#quiz-panel {
  width: 600px;
  max-width: 90vw;
  padding: 24px;
  text-align: center;
}

#quiz-concept {
  font-size: 12px;
  color: #22d3ee;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

#quiz-question {
  font-size: 16px;
  color: #e2e8f0;
  line-height: 1.8;
  margin-bottom: 20px;
  letter-spacing: 0.05em;
}

#quiz-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.quiz-option {
  padding: 12px 20px;
  font-size: 14px;
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  color: #e2e8f0;
  background: rgba(5, 5, 5, 0.95);
  border: 1px solid rgba(52, 211, 153, 0.2);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  line-height: 1.6;
  letter-spacing: 0.05em;
  position: relative;
}

.quiz-option:hover {
  border-color: #34d399;
  background: rgba(10, 10, 10, 0.95);
  transform: translateX(4px);
}

.quiz-option.correct {
  border-color: #34d399;
  color: #34d399;
  background: rgba(52, 211, 153, 0.1);
  box-shadow: 0 0 10px rgba(52, 211, 153, 0.2);
}

.quiz-option.wrong {
  border-color: #ef4444;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.2);
}

.quiz-option.disabled {
  pointer-events: none;
  opacity: 0.6;
}

#quiz-result {
  margin-bottom: 16px;
}

#quiz-result-text {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: 0.15em;
}

#quiz-result-text.correct-text {
  color: #34d399;
  text-shadow: 0 0 8px rgba(52, 211, 153, 0.4);
}

#quiz-result-text.wrong-text {
  color: #ef4444;
  text-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
}

#quiz-analysis {
  font-size: 13px;
  color: #94a3b8;
  line-height: 1.7;
  letter-spacing: 0.05em;
  padding: 12px 16px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(5, 5, 5, 0.8);
}

#quiz-skip {
  padding: 8px 24px;
  font-size: 12px;
  background: transparent;
  border: 1px solid rgba(148, 163, 184, 0.3);
  color: #94a3b8;
  cursor: pointer;
  letter-spacing: 0.1em;
  transition: all 0.2s ease;
}

#quiz-skip:hover {
  border-color: #94a3b8;
  color: #e2e8f0;
}

/* ===== 额外升级 ===== */
#extra-upgrade-area {
  margin-top: 24px;
  text-align: center;
}

#extra-upgrade-title {
  font-size: 20px;
  font-weight: 700;
  color: #22d3ee;
  letter-spacing: 0.2em;
  margin-bottom: 16px;
  text-shadow: 0 0 12px rgba(34, 211, 238, 0.4);
}

/* ===== 游戏结束 ===== */
#gameover-screen {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 2, 2, 0.94);
  z-index: 20;
  animation: fadeIn 0.5s ease;
}

#gameover-box {
  text-align: center;
  animation: fadeInUp 0.6s ease-out;
  position: relative;
}

#gameover-box::before {
  content: '';
  position: absolute;
  top: -20px; left: -20px;
  width: 20px; height: 20px;
  border-top: 2px solid #ef4444;
  border-left: 2px solid #ef4444;
}
#gameover-box::after {
  content: '';
  position: absolute;
  bottom: -20px; right: -20px;
  width: 20px; height: 20px;
  border-bottom: 2px solid #ef4444;
  border-right: 2px solid #ef4444;
}

#gameover-box h2 {
  font-size: 44px;
  color: #ef4444;
  margin-bottom: 24px;
  text-shadow: 0 0 30px rgba(239, 68, 68, 0.5), 0 0 60px rgba(239, 68, 68, 0.2);
  letter-spacing: 0.3em;
}

#gameover-stats {
  font-size: 16px;
  color: #94a3b8;
  margin-bottom: 32px;
  line-height: 2;
  letter-spacing: 0.08em;
}

#gameover-stats span {
  color: #34d399;
  font-weight: 700;
  text-shadow: 0 0 6px rgba(52, 211, 153, 0.4);
}

#restart-btn {
  margin-top: 8px;
  background: #ef4444;
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.3);
}

#restart-btn:hover {
  background: #34d399;
  box-shadow: 0 0 24px rgba(52, 211, 153, 0.4);
}