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

html, body {
  width: 100%;
  height: 100%;
  background: #0f0f1e;
  /* 全屏铺满：禁止任何滚动条 */
  overflow: hidden;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #f0f0f0;
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  justify-content: flex-start;
  gap: 0;
  padding: 0;
  overflow: hidden;
}

#game-wrap {
  position: relative;
  flex: 1 1 auto;          /* 占满除侧栏外的全部宽度 */
  min-width: 0;
  height: 100vh;
  overflow: hidden;
  background: #0f0f1e;
}

#game-canvas {
  position: absolute;
  inset: 0;                /* 铺满 #game-wrap，逻辑 960×576 由 JS 等比缩放居中 */
  display: block;
  width: 100%;
  height: 100%;
  background: #0f0f1e;
  cursor: crosshair;
}

/* ---------- 顶部 HUD：数值左上角 + 动作按钮右上角 ---------- */
/* #hud 为定位容器（透明、透传点击），数值与按钮各自成组 */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-wrap: wrap;            /* 窄屏时数值/按钮可换行，不溢出画布 */
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  pointer-events: none;
  user-select: none;
  z-index: 4;
}

#hud-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  pointer-events: none;
}

/* 单项数值：胶囊卡片，图标+数值，按类型配色微光 */
.hud-stat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px 5px 7px;
  background: linear-gradient(135deg, rgba(35,35,66,0.92), rgba(22,22,44,0.92));
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 999px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.06);
  color: #f0f0f0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.hud-ico {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: block;
}
.hud-val {
  font-variant-numeric: tabular-nums;
  min-width: 1ch;
}
.hud-sub {
  font-size: 11px;
  font-weight: 500;
  color: #ffd24a;
  margin-left: 1px;
}
/* 类型配色：边框 + 同色微光，强化视觉区分 */
.hud-stat.is-gold  { border-color: rgba(255,210,74,0.55);  box-shadow: 0 2px 10px rgba(0,0,0,0.45), 0 0 12px rgba(255,210,74,0.10), inset 0 1px 0 rgba(255,255,255,0.06); }
.hud-stat.is-lives { border-color: rgba(224,85,85,0.55);   box-shadow: 0 2px 10px rgba(0,0,0,0.45), 0 0 12px rgba(224,85,85,0.10), inset 0 1px 0 rgba(255,255,255,0.06); }
.hud-stat.is-wave  { border-color: rgba(90,138,208,0.55);  box-shadow: 0 2px 10px rgba(0,0,0,0.45), 0 0 12px rgba(90,138,208,0.12), inset 0 1px 0 rgba(255,255,255,0.06); }

#hud-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  pointer-events: none;
}

#hud-actions button {
  pointer-events: auto;
  white-space: nowrap;
  padding: 6px 16px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  color: #1a1a2e;
  background: linear-gradient(180deg, #ffe07a, #ffd24a);
  border: 1px solid #b8860b;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s, box-shadow 0.15s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
#hud-actions button:hover:not(:disabled) {
  background: linear-gradient(180deg, #ffe890, #ffd960);
}
#hud-actions button:active:not(:disabled) {
  transform: scale(0.96);
}
#hud-actions button:disabled {
  background: #3a3a55;
  color: #888;
  border-color: #2a2a44;
  cursor: not-allowed;
  box-shadow: none;
}
#hud-actions .mute-btn {
  background: linear-gradient(180deg, #4a4a78, #35355a);
  color: #f0f0f0;
  border-color: #2a2a4a;
}
#hud-actions .mute-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, #5555a0, #3d3d6e);
}
#hud-actions .mute-btn.muted {
  background: linear-gradient(180deg, #555, #333);
  color: #bbb;
  border-color: #222;
}

/* ---------- 侧边升级面板 ---------- */
#side-panel {
  flex: 0 0 220px;
  min-width: 0;
  width: 220px;
  height: 100vh;
  max-height: none;          /* 铺满整屏高度，内部滚动 */
  padding: 14px;
  background: #232342;
  border-radius: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel-section {
  background: #1c1c38;
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.panel-section h3 {
  font-size: 14px;
  color: #ffd24a;
  letter-spacing: 1px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  padding-bottom: 5px;
}

.panel-caption {
  font-size: 12px;
  color: #9ca6cb;
  line-height: 1.5;
}

.up-btn,
.wpn-btn,
#btn-unlock-magic {
  font-family: inherit;
  font-size: 13px;
  color: #f0f0f0;
  background: #2f2f5a;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, transform 0.05s;
}

.upgrade-panel {
  background: linear-gradient(180deg, rgba(33,33,60,0.98), rgba(24,24,46,0.98));
  border: 1px solid rgba(255,210,74,0.14);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 0 8px 20px rgba(0,0,0,0.22);
}

.upgrade-panel .up-btn {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(67,67,116,0.94), rgba(43,43,82,0.94));
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 3px 10px rgba(0,0,0,0.20), inset 0 1px 0 rgba(255,255,255,0.04);
  transition: transform 0.12s ease, background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.upgrade-panel .up-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  background: linear-gradient(135deg, rgba(78,78,132,0.96), rgba(50,50,94,0.96));
  border-color: rgba(255,210,74,0.30);
  box-shadow: 0 6px 16px rgba(0,0,0,0.24), 0 0 0 1px rgba(255,210,74,0.08);
}

.upgrade-panel .up-btn:active:not(:disabled) {
  transform: translateY(0) scale(0.985);
}

.upgrade-panel .up-btn:disabled {
  opacity: 1;
}

.upgrade-panel .up-btn.is-affordable {
  border-color: rgba(255,210,74,0.22);
}

.upgrade-panel .up-btn.is-maxed {
  border-color: rgba(106,208,106,0.26);
  background: linear-gradient(135deg, rgba(46,76,58,0.92), rgba(30,54,42,0.92));
}

.upgrade-panel .up-btn:not(.is-affordable):not(.is-maxed) {
  background: linear-gradient(135deg, rgba(56,56,92,0.92), rgba(37,37,72,0.92));
}

.up-top,
.up-level-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.up-name {
  font-size: 15px;
  font-weight: 700;
  color: #f7f8ff;
}

.up-pill {
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid rgba(255,210,74,0.26);
  background: rgba(255,210,74,0.15);
  color: #ffe07a;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.upgrade-panel .up-btn.is-maxed .up-pill {
  border-color: rgba(124,226,147,0.30);
  background: rgba(124,226,147,0.14);
  color: #a9efb8;
}

.upgrade-panel .up-btn:not(.is-affordable):not(.is-maxed) .up-pill {
  border-color: rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.08);
  color: #c4c9dc;
}

.up-level {
  font-size: 13px;
  font-weight: 600;
  color: #dbe1ff;
}

.up-delta {
  font-size: 12px;
  color: #9fe1b0;
}

.up-track {
  display: flex;
  gap: 6px;
}

.up-dot {
  flex: 1 1 0;
  height: 6px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
}

.up-dot.is-on {
  background: linear-gradient(90deg, #ffe07a, #ffbf57);
  box-shadow: 0 0 10px rgba(255,210,74,0.22);
}

.up-dot.is-next {
  background: rgba(255,210,74,0.22);
}

.up-btn:hover:not(:disabled),
#btn-unlock-magic:hover:not(:disabled) {
  background: #3d3d78;
}

.up-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.up-btn:disabled,
#btn-unlock-magic:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.weapon-grid {
  display: grid;
  gap: 8px;
}

.wpn-btn {
  display: grid;
  gap: 6px;
  padding: 10px 11px 11px;
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(60,60,104,0.96), rgba(37,37,74,0.96));
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 3px 10px rgba(0,0,0,0.20), inset 0 1px 0 rgba(255,255,255,0.04);
  transition: transform 0.12s ease, background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
}

.wpn-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  background: linear-gradient(145deg, rgba(72,72,120,0.98), rgba(45,45,86,0.98));
  border-color: rgba(255,210,74,0.22);
  box-shadow: 0 6px 16px rgba(0,0,0,0.24), 0 0 0 1px rgba(255,210,74,0.08);
}

.wpn-btn:active:not(:disabled) {
  transform: translateY(0) scale(0.985);
}

.wpn-head,
.wpn-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.wpn-hotkey,
.wpn-tag,
.wpn-cost,
.wpn-state {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.wpn-hotkey,
.wpn-tag {
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  color: #dbe1ff;
}

.wpn-cost {
  color: #ffe07a;
  font-variant-numeric: tabular-nums;
}

.wpn-name {
  font-size: 15px;
  font-weight: 700;
  color: #f7f8ff;
}

.wpn-state {
  color: #9fe1b0;
  flex-shrink: 0;
}

.wpn-desc {
  font-size: 12px;
  color: #d7dcf4;
  line-height: 1.4;
}

.wpn-meta {
  font-size: 11px;
  color: #97a1c9;
  font-variant-numeric: tabular-nums;
}

.wpn-btn.active {
  border-color: rgba(255,210,74,0.46);
  background: linear-gradient(145deg, rgba(81,81,138,0.98), rgba(52,52,98,0.98));
  box-shadow: 0 8px 20px rgba(0,0,0,0.26), 0 0 0 1px rgba(255,210,74,0.10);
}

.wpn-btn.active .wpn-hotkey,
.wpn-btn.active .wpn-tag {
  background: rgba(255,210,74,0.16);
  color: #ffe07a;
}

.wpn-btn.is-affordable:not(.active):not(.locked) {
  border-color: rgba(255,210,74,0.20);
}

.wpn-btn.is-unaffordable:not(.locked) .wpn-cost,
.wpn-btn.is-unaffordable:not(.locked) .wpn-state {
  color: #c3c8db;
}

.wpn-btn.locked {
  background: linear-gradient(145deg, rgba(67,55,93,0.96), rgba(47,39,69,0.96));
  border-color: rgba(183,146,255,0.26);
  box-shadow: 0 3px 10px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.04);
  cursor: not-allowed;
}

.wpn-btn.locked .wpn-hotkey,
.wpn-btn.locked .wpn-tag {
  background: rgba(214,176,255,0.14);
  color: #e4d0ff;
}

.wpn-btn.locked .wpn-state {
  color: #e4d0ff;
}

.wpn-btn:disabled {
  opacity: 1;
}

#btn-unlock-magic {
  display: grid;
  gap: 4px;
  text-align: left;
  padding: 10px 12px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(88,61,138,0.96), rgba(60,40,104,0.96));
  border-color: rgba(183,146,255,0.32);
  box-shadow: 0 3px 10px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.04);
}

#btn-unlock-magic:hover:not(:disabled) {
  background: linear-gradient(135deg, rgba(101,72,154,0.98), rgba(69,47,118,0.98));
}

#btn-unlock-magic.is-affordable {
  border-color: rgba(214,176,255,0.42);
}

#btn-unlock-magic:disabled {
  opacity: 1;
  background: linear-gradient(135deg, rgba(70,56,92,0.94), rgba(53,42,74,0.94));
  color: #c9c5d6;
}

.unlock-title {
  font-size: 14px;
  font-weight: 700;
  color: #f6f1ff;
}

.unlock-meta {
  font-size: 12px;
  color: #d6c8ff;
}

#btn-unlock-magic.hidden {
  display: none;
}

.hint {
  font-size: 12px;
  color: #cfd5f5;
  line-height: 1.5;
  padding: 9px 10px;
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
}

.panel-section.tip p {
  font-size: 12px;
  color: #aab;
  line-height: 1.6;
}

/* ---------- 胜负覆盖层 ---------- */
#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.65);
  border-radius: 6px;
  z-index: 5;
}

#overlay.hidden {
  display: none;
}

.overlay-card {
  text-align: center;
  padding: 28px 40px;
  background: #232342;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  max-width: calc(100% - 24px);
}

.overlay-card h2 {
  font-size: 40px;
  margin-bottom: 10px;
}

.overlay-card h2.win { color: #6ad06a; }
.overlay-card h2.lose { color: #e05555; }

.overlay-card p {
  font-size: 16px;
  color: #cfcfcf;
  margin-bottom: 18px;
}

#btn-restart {
  font-family: inherit;
  font-size: 16px;
  padding: 10px 28px;
  color: #1a1a2e;
  background: #ffd24a;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

#btn-restart:hover {
  background: #ffe07a;
}

/* ---------- 升级答题遮罩 ---------- */
/* 覆盖整个 #app（含侧边栏），答题期间游戏暂停、其余按钮不可点 */
#quiz-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.72);
  z-index: 6;               /* 高于 #overlay(5) 与 HUD(4) */
  padding: 16px;
}

#quiz-overlay.hidden {
  display: none;
}

.quiz-card {
  width: 100%;
  max-width: 460px;
  text-align: center;
  padding: 24px 26px 22px;
  background: linear-gradient(180deg, #2a2a4e, #1f1f3a);
  border-radius: 14px;
  border: 1px solid rgba(255, 210, 74, 0.22);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.quiz-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.quiz-title {
  font-size: 16px;
  font-weight: 700;
  color: #ffe07a;
  letter-spacing: 1px;
}

.quiz-timer {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #ffd24a;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 210, 74, 0.12);
  border: 1px solid rgba(255, 210, 74, 0.28);
}

.quiz-timer.is-low {
  color: #ff6a6a;
  border-color: rgba(255, 106, 106, 0.4);
  background: rgba(255, 106, 106, 0.12);
}

.quiz-question {
  font-size: 17px;
  line-height: 1.55;
  color: #f3f4ff;
  margin-bottom: 16px;
  min-height: 3.1em;
}

.quiz-upgrade-label {
  font-size: 12px;
  color: #9ca6cb;
  margin-bottom: 8px;
}

.quiz-feedback {
  margin-top: 14px;
  font-size: 15px;
  font-weight: 700;
  min-height: 1.2em;
}

.quiz-feedback.is-correct {
  color: #7ee89a;
}

.quiz-feedback.is-wrong {
  color: #ff7a7a;
}

.quiz-feedback.hidden {
  display: none;
}

.quiz-options {
  display: grid;
  gap: 9px;
  text-align: left;
}

.quiz-opt {
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  color: #e8eaff;
  background: linear-gradient(135deg, rgba(67, 67, 116, 0.94), rgba(43, 43, 82, 0.94));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 11px 14px;
  cursor: pointer;
  text-align: left;
  transition: transform 0.1s ease, background 0.15s ease, border-color 0.15s ease;
}

.quiz-opt:hover:not(:disabled) {
  transform: translateY(-1px);
  background: linear-gradient(135deg, rgba(78, 78, 132, 0.96), rgba(50, 50, 94, 0.96));
  border-color: rgba(255, 210, 74, 0.3);
}

.quiz-opt:active:not(:disabled) {
  transform: scale(0.985);
}

/* 答对/答错后的选项高亮与禁用 */
.quiz-opt.is-correct {
  background: linear-gradient(135deg, rgba(64, 148, 88, 0.96), rgba(40, 110, 66, 0.96));
  border-color: rgba(124, 226, 147, 0.5);
}

.quiz-opt.is-wrong {
  background: linear-gradient(135deg, rgba(148, 60, 60, 0.96), rgba(110, 40, 44, 0.96));
  border-color: rgba(255, 106, 106, 0.5);
}

.quiz-opt:disabled {
  opacity: 0.6;
  cursor: default;
}

/* 窄屏收紧答题卡内边距 */
@media (max-width: 480px) {
  .quiz-card {
    padding: 18px 16px;
  }
  .quiz-question {
    font-size: 15px;
  }
  .quiz-opt {
    font-size: 13px;
    padding: 10px 12px;
  }
}

/* ---------- 响应式：窄屏 / 移动端纵向堆叠 ---------- */
/* 900px 以下：画布在上、面板在下，整体仍铺满视口、无页面滚动；面板内部滚动 */
@media (max-width: 900px) {
  #app {
    flex-direction: column;
    align-items: stretch;
  }
  #game-wrap {
    width: 100%;
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
  }
  #side-panel {
    width: 100%;
    max-width: none;
    flex: 0 0 auto;
    height: auto;
    max-height: 42vh;
  }
}

/* 小屏手机：收紧 HUD 与面板内边距，保证可读与可点 */
@media (max-width: 480px) {
  #hud {
    padding: 8px;
    gap: 6px;
  }
  .hud-stat {
    font-size: 13px;
    padding: 4px 10px 4px 6px;
  }
  .hud-ico {
    width: 16px;
    height: 16px;
  }
  .hud-sub {
    font-size: 10px;
  }
  #hud-actions button {
    padding: 5px 12px;
    font-size: 13px;
  }
  .upgrade-panel .up-btn {
    padding: 9px 10px;
    gap: 7px;
  }
  .up-name {
    font-size: 14px;
  }
  .up-level,
  .up-delta,
  .unlock-meta {
    font-size: 11px;
  }
  .up-pill {
    font-size: 11px;
    padding: 2px 8px;
  }
  .wpn-btn {
    padding: 9px 10px;
    gap: 5px;
  }
  .wpn-name {
    font-size: 14px;
  }
  .wpn-hotkey,
  .wpn-tag,
  .wpn-cost,
  .wpn-state,
  .wpn-desc,
  .wpn-meta {
    font-size: 11px;
  }
  #btn-unlock-magic {
    padding: 9px 10px;
  }
  .overlay-card {
    padding: 20px 18px;
  }
  .overlay-card h2 {
    font-size: 30px;
  }
}
