:root {
  /* 深空蓝黑 + 琥珀金 + 霓虹青 的现代游戏配色 */
  --bg: #060a12;
  --panel-2: rgba(26, 36, 58, 0.85);
  --line: rgba(140, 168, 255, 0.13);
  --line-strong: rgba(140, 168, 255, 0.24);
  --text: #e9efff;
  --dim: #8b98b8;
  --faint: #5d6a8a;
  --accent: #ffc531;
  --accent-hi: #ffe49a;
  --accent-deep: #b07a08;
  --accent-glow: rgba(255, 197, 49, 0.35);
  --fire-1: #ffb08a;
  --fire-2: #ff6a3d;
  --fire-3: #e02f12;
  --fire-shadow: #7c1806;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  /* 顶部冷光 + 底部暖光，营造纵深 */
  background-image:
    radial-gradient(120% 70% at 50% -12%, rgba(72, 108, 190, 0.16) 0%, transparent 58%),
    radial-gradient(90% 60% at 50% 112%, rgba(255, 170, 40, 0.05) 0%, transparent 60%);
  color: var(--text);
  /* 界面文字换 UI 无衬线栈（现代感），数值处单独用等宽 */
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
}

/* ---------------------------------------------------------------- HUD */

#hud {
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
  gap: 2px;
  padding: 7px 10px;
  background: rgba(17, 25, 42, 0.72);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

/* HUD 与操作区默认常驻，靠 hidden 属性整体收起：首页只留 canvas 菜单。
   ID 选择器自带的 display 会盖掉浏览器原生的 [hidden]，所以必须显式覆盖 */
#hud[hidden],
#controls[hidden] {
  display: none;
}

.hud-item {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  position: relative;
}

/* 数据项之间的细分隔线（首项左侧不画） */
.hud-item + .hud-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 22%;
  bottom: 22%;
  width: 1px;
  background: linear-gradient(180deg, transparent, var(--line-strong), transparent);
}

.hud-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  color: var(--faint);
}

.hud-value {
  font-family: "Cascadia Mono", ui-monospace, Consolas, monospace;
  font-size: 19px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  text-shadow: 0 0 14px rgba(140, 168, 255, 0.25);
}

.hud-score .hud-value {
  color: var(--accent);
  text-shadow: 0 0 16px var(--accent-glow);
}

/* HUD 右侧的圆形玻璃按钮（图标为内联 SVG） */
#btn-pause,
#btn-settings {
  flex: 0 0 auto;
  align-self: center;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  -webkit-appearance: none;
  appearance: none;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--dim);
  font-family: inherit;
  font-size: 14px;
  letter-spacing: 0.04em;
  cursor: pointer;
  touch-action: none;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease,
    transform 0.1s ease;
}

#btn-pause svg,
#btn-settings svg {
  display: block;
}

#btn-pause:active,
#btn-settings:active {
  transform: scale(0.92);
  background: rgba(44, 58, 92, 0.9);
  color: var(--text);
}

#btn-settings {
  font-size: 16px;
}

#btn-settings[aria-expanded="true"] {
  background: rgba(66, 52, 14, 0.55);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 18px rgba(255, 197, 49, 0.25);
}

/* ---------------------------------------------------------------- 战场 */

#stage {
  position: relative; /* 「返回首页」按钮的定位基准 */
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  place-items: center;
}

/* 联机对局结算画面的「返回首页」按钮：绝对定位，不参与 #stage 的 grid 排版，
   否则会把画布挤成两行、破坏 main.js 里精确计算的正方形尺寸 */
#btn-to-home {
  position: absolute;
  left: 50%;
  bottom: 13%;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 30px;
  -webkit-appearance: none;
  appearance: none;
  background: linear-gradient(180deg, #ffd257, #ffb020);
  border: 1px solid var(--accent-hi);
  border-radius: 999px;
  box-shadow:
    0 4px 0 var(--accent-deep),
    0 10px 26px rgba(0, 0, 0, 0.5),
    0 0 30px rgba(255, 180, 40, 0.28);
  color: #241602;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  transform: translateX(-50%);
  touch-action: manipulation;
  transition: filter 0.15s ease, box-shadow 0.15s ease;
}

#btn-to-home:active {
  filter: brightness(1.08);
  box-shadow:
    0 2px 0 var(--accent-deep),
    0 6px 16px rgba(0, 0, 0, 0.5),
    0 0 22px rgba(255, 180, 40, 0.22);
  transform: translateX(-50%) translateY(2px);
}

/* 上面写了 display，会盖掉 hidden 属性的默认 display:none，必须显式补一条 */
#btn-to-home[hidden] {
  display: none;
}

canvas {
  display: block;
  /* JS 会精确覆盖为正方形（见 main.js 的 fitCanvas），这里是无 JS 时的兜底 */
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #05080f;
  border-radius: 12px;
  box-shadow:
    0 0 0 1px rgba(140, 168, 255, 0.15),
    0 0 34px rgba(80, 120, 220, 0.10),
    0 18px 44px rgba(0, 0, 0, 0.55);
}

/* ---------------------------------------------------------------- 控制区 */

#controls {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

#dpad {
  --pad: min(48vw, 200px);
  width: var(--pad);
  height: var(--pad);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 6px;
  touch-action: none;
}

.dpad-key {
  background: rgba(17, 25, 42, 0.72);
  border: 1px solid var(--line);
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: rgba(139, 152, 184, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: background 0.08s ease, color 0.08s ease, border-color 0.08s ease,
    box-shadow 0.08s ease;
}

/* 箭头由内联 SVG 提供（HTML 里），这里只控尺寸 */
.dpad-key svg {
  display: block;
  width: 30%;
  height: 30%;
}

.dpad-key[data-dir="up"] {
  grid-area: 1 / 2;
}

.dpad-key[data-dir="left"] {
  grid-area: 2 / 1;
}

.dpad-key[data-dir="right"] {
  grid-area: 2 / 3;
}

.dpad-key[data-dir="down"] {
  grid-area: 3 / 2;
}

.dpad-center {
  grid-area: 2 / 2;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 34%, rgba(52, 66, 102, 0.6), rgba(13, 19, 33, 0.7) 74%);
  border: 1px solid var(--line);
  box-shadow: inset 0 2px 12px rgba(0, 0, 0, 0.5);
}

.dpad-key.active {
  background: linear-gradient(180deg, #ffd257, #ffb020);
  border-color: var(--accent-hi);
  color: #241602;
  box-shadow:
    0 0 20px rgba(255, 197, 49, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

/* ---------------------------------------------------------------- 摇杆 */

#joystick {
  --pad: min(48vw, 200px);
  position: relative;
  width: var(--pad);
  height: var(--pad);
  display: none;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, rgba(40, 54, 88, 0.55), rgba(10, 15, 26, 0.8) 76%);
  border: 1px solid var(--line);
  box-shadow:
    inset 0 2px 30px rgba(0, 0, 0, 0.65),
    0 10px 26px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  touch-action: none;
}

/* 操作方式由 body[data-controls] 决定，二者互斥显示 */
body[data-controls="joystick"] #dpad {
  display: none;
}

body[data-controls="joystick"] #joystick {
  display: grid;
}

.joystick-knob {
  width: 42%;
  height: 42%;
  border-radius: 50%;
  background: radial-gradient(circle at 36% 30%, #5d6c96, #232c44 78%);
  border: 2px solid rgba(140, 168, 255, 0.28);
  box-shadow:
    0 6px 16px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
  transition: transform 0.1s ease-out, background 0.1s ease, border-color 0.1s ease;
  will-change: transform;
}

/* 拖动中：跟手不加过渡，只让配色变化有过渡 */
.joystick-knob.active {
  background: radial-gradient(circle at 36% 30%, var(--accent-hi), var(--accent) 78%);
  border-color: var(--accent-hi);
  box-shadow: 0 0 24px rgba(255, 197, 49, 0.5);
  transition: background 0.1s ease, border-color 0.1s ease;
}

#actions {
  display: flex;
  align-items: center;
  padding-bottom: 4px;
}

/* 开火键：霓虹红橙渐变 + 外光环 + 实体底边，按下时光环内收 */
#btn-fire {
  --size: min(36vw, 148px);
  width: var(--size);
  height: var(--size);
  -webkit-appearance: none;
  appearance: none;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 196, 164, 0.6);
  background: radial-gradient(circle at 34% 28%, var(--fire-1) 0%, var(--fire-2) 46%, var(--fire-3) 80%);
  box-shadow:
    0 0 0 7px rgba(255, 106, 61, 0.09),
    0 0 36px rgba(255, 90, 50, 0.32),
    0 8px 0 var(--fire-shadow),
    0 16px 30px rgba(0, 0, 0, 0.55);
  color: #fff;
  font-family: inherit;
  /* 文案是「开火」两个汉字，字形比 FIRE 四个字母宽而矮，
     所以字号比例调大一点、字距收紧一点，视觉体量才和原来接近 */
  font-size: calc(var(--size) * 0.24);
  font-weight: 800;
  letter-spacing: 0.05em;
  text-shadow: 0 2px 8px rgba(120, 20, 4, 0.6);
  display: grid;
  place-items: center;
  cursor: pointer;
  touch-action: none;
  transition: transform 0.06s ease, box-shadow 0.06s ease, filter 0.06s ease;
}

#btn-fire.active {
  transform: translateY(5px);
  filter: brightness(1.14);
  box-shadow:
    0 0 0 4px rgba(255, 106, 61, 0.12),
    0 0 22px rgba(255, 90, 50, 0.28),
    0 3px 0 var(--fire-shadow),
    0 8px 18px rgba(0, 0, 0, 0.5);
}

/* ------------------------------------------------- 横屏：控制区浮到两侧 */

@media (orientation: landscape) and (max-height: 620px) {
  #app {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "hud  stage fire"
      "dpad stage fire";
    gap: 6px 10px;
    padding: max(4px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(4px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  }

  #hud {
    grid-area: hud;
    align-self: start;
    padding: 4px 6px;
  }

  .hud-label {
    font-size: 9px;
  }

  .hud-value {
    font-size: 15px;
  }

  #btn-pause,
  #btn-settings {
    width: 36px;
    height: 36px;
  }

  #stage {
    grid-area: stage;
    min-height: 0;
  }

  /* 让操作区与开火键直接参与上层 grid 排版 */
  #controls {
    display: contents;
  }

  #dpad {
    grid-area: dpad;
    align-self: end;
    justify-self: center;
    --pad: min(38vh, 184px);
  }

  #joystick {
    grid-area: dpad;
    align-self: end;
    justify-self: center;
    --pad: min(38vh, 184px);
  }

  #actions {
    grid-area: fire;
    align-self: center;
    justify-self: center;
    padding-bottom: 0;
  }

  #btn-fire {
    --size: min(30vh, 140px);
  }
}

/* 矮屏竖屏（小尺寸安卓机）压缩控制区，把高度让给战场 */
@media (orientation: portrait) and (max-height: 640px) {
  #dpad {
    --pad: min(40vw, 156px);
  }

  #joystick {
    --pad: min(40vw, 156px);
  }

  #btn-fire {
    --size: min(31vw, 122px);
  }

  .hud-label {
    font-size: 9px;
  }

  .hud-value {
    font-size: 16px;
  }
}

/* 极矮屏（横屏小手机）进一步压缩 */
@media (orientation: landscape) and (max-height: 400px) {
  #dpad {
    --pad: 35vh;
  }

  #joystick {
    --pad: 35vh;
  }

  #btn-fire {
    --size: 28vh;
  }

  #hud {
    padding: 2px 5px;
  }

  .hud-label {
    font-size: 8px;
  }

  .hud-value {
    font-size: 13px;
  }
}

/* ---------------------------------------------------------------- 设置面板 */

.settings-panel {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  background: rgba(3, 6, 12, 0.66);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.settings-panel.show {
  display: flex;
}

.settings-card {
  width: min(340px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 20px;
  background: linear-gradient(180deg, rgba(22, 32, 54, 0.94), rgba(13, 19, 33, 0.96));
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  box-shadow:
    0 24px 64px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.settings-head h2 {
  position: relative;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--text);
  padding-left: 12px;
}

/* 标题左侧的琥珀装饰条 */
.settings-head h2::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 14px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--accent-hi), var(--accent));
  box-shadow: 0 0 10px var(--accent-glow);
}

#btn-settings-close {
  width: 32px;
  height: 32px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--dim);
  font-family: inherit;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

#btn-settings-close:active {
  background: rgba(44, 58, 92, 0.9);
  color: var(--text);
}

.settings-group-label {
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--dim);
}

.settings-options {
  display: grid;
  gap: 10px;
}

.setting-option {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  padding: 12px 14px;
  text-align: left;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(24, 34, 56, 0.65);
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}

.setting-option:active {
  background: rgba(34, 46, 76, 0.8);
}

.setting-option.selected {
  background: rgba(66, 52, 14, 0.4);
  border-color: var(--accent);
  box-shadow:
    0 0 0 1px rgba(255, 197, 49, 0.3),
    0 0 22px rgba(255, 197, 49, 0.14);
}

.setting-option-title {
  font-size: 14px;
  font-weight: 700;
}

.setting-option.selected .setting-option-title::after {
  content: " ✓";
  color: var(--accent);
}

.setting-option-desc {
  font-size: 11px;
  color: var(--dim);
}

.setting-option.selected .setting-option-desc {
  color: #cbb679;
}

.settings-note {
  margin-top: 14px;
  font-size: 10px;
  line-height: 1.7;
  color: var(--faint);
}

.settings-legal {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.settings-legal a {
  color: var(--dim);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.settings-legal a:active {
  color: var(--accent);
}

/* ---------------------------------------------------------------- 联机面板 */

#btn-online-close {
  width: 32px;
  height: 32px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--dim);
  font-family: inherit;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

#btn-online-close:active {
  background: rgba(44, 58, 92, 0.9);
  color: var(--text);
}

.online-btn {
  width: 100%;
  padding: 12px 14px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(24, 34, 56, 0.65);
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease,
    filter 0.12s ease;
}

.online-btn:active {
  background: rgba(34, 46, 76, 0.8);
}

/* 主按钮：琥珀渐变 + 实体底边，轻量「3D」按压感 */
.online-btn-primary {
  background: linear-gradient(180deg, #ffd257, #ffb020);
  border-color: var(--accent-hi);
  color: #241602;
  box-shadow:
    0 3px 0 var(--accent-deep),
    0 8px 20px rgba(255, 180, 40, 0.22);
}

.online-btn-primary:active {
  filter: brightness(1.06);
  box-shadow:
    0 1px 0 var(--accent-deep),
    0 4px 12px rgba(255, 180, 40, 0.18);
}

.online-btn-small {
  width: auto;
  padding: 8px 12px;
  font-size: 12px;
}

.online-btn-ghost {
  margin-top: 16px;
  background: transparent;
  border-color: var(--line);
  color: var(--dim);
  font-weight: 400;
}

.online-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.online-or {
  margin: 12px 0;
  font-size: 11px;
  text-align: center;
  color: #5a5a70;
}

.online-join-row {
  display: flex;
  gap: 8px;
}

.online-join-row .online-btn {
  width: auto;
  flex: 0 0 auto;
  padding: 12px 18px;
}

.online-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 12px 14px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(10, 15, 26, 0.7);
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  font-family: "Cascadia Mono", ui-monospace, Consolas, monospace;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-align: center;
}

.online-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(255, 197, 49, 0.3), 0 0 18px rgba(255, 197, 49, 0.12);
}

.online-status-text {
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
}

.online-code-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 14px;
}

/* 作者样式里的 display 会盖掉 hidden 属性的默认 display:none，必须显式补一条 */
.online-code-row[hidden] {
  display: none;
}

.online-code-value {
  font-family: "Cascadia Mono", ui-monospace, Consolas, monospace;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: var(--accent);
  text-shadow: 0 0 18px var(--accent-glow);
}

.online-error {
  margin-top: 14px;
  padding: 9px 11px;
  background: rgba(255, 60, 40, 0.10);
  border: 1px solid rgba(255, 92, 92, 0.4);
  border-radius: 12px;
  font-size: 11px;
  line-height: 1.6;
  color: #ff9c86;
}

/* 大厅：两个主按钮并排 */
.online-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.online-list-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 18px 0 8px;
}

.online-list-title {
  flex: 1 1 auto;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--dim);
}

.online-count {
  flex: 0 0 auto;
  font-size: 10px;
  color: var(--faint);
}

.online-room-list {
  display: grid;
  gap: 6px;
  min-height: 46px;
  max-height: 208px;
  overflow-y: auto;
  padding: 6px;
  background: rgba(10, 15, 26, 0.55);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.online-empty {
  padding: 12px 8px;
  font-size: 11px;
  line-height: 1.7;
  text-align: center;
  color: var(--faint);
}

.room-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 11px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(24, 34, 56, 0.65);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.room-item:active {
  background: rgba(66, 52, 14, 0.4);
  border-color: var(--accent);
}

.room-code {
  font-family: "Cascadia Mono", ui-monospace, Consolas, monospace;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--accent);
}

.room-meta {
  flex: 1 1 auto;
  font-size: 11px;
  text-align: left;
  color: var(--dim);
}

.room-action {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 700;
  color: #7fd4ff;
}

/* 房间号加入：默认折起来，房间列表才是主入口 */
.online-code-toggle {
  margin-top: 14px;
}

.online-code-toggle summary {
  font-size: 11px;
  color: #5a5a70;
  cursor: pointer;
}

.online-code-toggle[open] summary {
  margin-bottom: 10px;
  color: var(--dim);
}

/* ------------------------------------------------------------ 关卡选择 - 军事战场S形路径 */

.stage-panel-military {
  background: rgba(8, 14, 10, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.stage-map-card {
  width: min(360px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 0;
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7);
  overflow: hidden;
  position: relative;
}

/* 背景图 */
.stage-map-bg {
  position: absolute;
  inset: 0;
  background: url('./assets/stage-map/bg.png') center / cover no-repeat;
  z-index: 0;
}

.stage-map-head {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 16px;
  position: relative;
  z-index: 1;
}

.stage-back-btn {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(40, 50, 30, 0.7);
  border: 1px solid rgba(140, 150, 100, 0.4);
  border-radius: 8px;
  color: #d4c88a;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, transform 0.1s ease;
}

.stage-back-btn:active {
  background: rgba(60, 70, 40, 0.8);
  transform: translateY(-50%) scale(0.95);
}

.stage-map-title-text {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.3em;
  color: #d4c88a;
  text-shadow: 0 0 16px rgba(212, 200, 138, 0.5), 0 2px 4px rgba(0, 0, 0, 0.8);
}

#btn-stage-close {
  width: 32px;
  height: 32px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(140, 50, 40, 0.8);
  border: 1px solid rgba(200, 100, 80, 0.5);
  border-radius: 8px;
  color: #f0d8c8;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

#btn-stage-close:active {
  background: rgba(100, 40, 32, 0.9);
  transform: scale(0.95);
}

.stage-map-desc {
  padding: 8px 18px 4px;
  font-size: 11px;
  line-height: 1.6;
  color: rgba(220, 220, 190, 0.8);
  position: relative;
  z-index: 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.stage-path {
  position: relative;
  height: 520px;
  margin: -10px 20px 0;
  z-index: 1;
}

.stage-path-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* 关卡节点 - 用素材图作为背景 */
.stage-cell {
  position: absolute;
  width: 58px;
  height: 58px;
  -webkit-appearance: none;
  appearance: none;
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
  z-index: 2;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
}

/* 已解锁/可挑战状态的节点图标 */
.stage-cell.cleared,
.stage-cell.available {
  background-image: url('./assets/stage-map/level-unlocked.png');
}

/* 未解锁状态的节点图标 */
.stage-cell.locked {
  background-image: url('./assets/stage-map/level-locked.png');
  cursor: default;
}

/* 10个节点的S形位置，贴合背景图土路 */
.stage-cell:nth-of-type(1) { left: 48%; top: 5%; transform: translateX(-50%); }
.stage-cell:nth-of-type(2) { left: 62%; top: 15%; }
.stage-cell:nth-of-type(3) { left: 9%; top: 24%; }
.stage-cell:nth-of-type(4) { left: 65%; top: 35%; }
.stage-cell:nth-of-type(5) { left: 32%; top: 42%; }
.stage-cell:nth-of-type(6) { left: 71%; top: 51%; }
.stage-cell:nth-of-type(7) { left: 15%; top: 60%; }
.stage-cell:nth-of-type(8) { left: 50%; top: 66%; }
.stage-cell:nth-of-type(9) { left: 25%; top: 78%; }
.stage-cell:nth-of-type(10) { left: 48%; top: 95%; transform: translateX(-50%); }

.stage-cell:active {
  transform: scale(0.93);
}

.stage-cell:nth-of-type(1):active,
.stage-cell:nth-of-type(10):active {
  transform: translateX(-50%) scale(0.93);
}

.stage-cell-num {
  font-family: "Cascadia Mono", ui-monospace, Consolas, monospace;
  font-size: 16px;
  font-weight: 800;
  line-height: 1;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
  margin-top: 2px;
}

.stage-cell-tag {
  font-size: 8px;
  letter-spacing: 0.06em;
  opacity: 0.85;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}

/* 可挑战状态的呼吸光效 */
.stage-cell.available {
  animation: stagePulse 2s ease-in-out infinite;
}

/* 小坦克进度标记 */
.stage-cell.available::before {
  content: "";
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: 44px;
  height: 44px;
  background: url('./assets/stage-map/tank-marker.png') center / contain no-repeat;
  z-index: 3;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.7));
  animation: tankBounce 1.5s ease-in-out infinite;
}

@keyframes tankBounce {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-4px); }
}

@keyframes stagePulse {
  0%, 100% {
    filter: drop-shadow(0 0 8px rgba(140, 200, 80, 0.4));
  }
  50% {
    filter: drop-shadow(0 0 18px rgba(140, 200, 80, 0.7));
  }
}

/* 未解锁状态稍微压暗 */
.stage-cell.locked {
  filter: brightness(0.7);
}

.stage-map-progress {
  padding: 12px 18px 16px;
  font-size: 11px;
  text-align: right;
  position: relative;
  z-index: 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

/* ------------------------------------------------------------ 道具说明 */

.powerup-list {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 18px;
}

.powerup-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px 14px;
  background: rgba(24, 34, 56, 0.55);
  border: 1px solid var(--line);
  border-radius: 14px;
  text-align: center;
}

.powerup-icon {
  width: 56px;
  height: 56px;
  object-fit: contain;
  image-rendering: auto;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.4));
}

.powerup-text {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.powerup-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--accent);
}

.powerup-desc {
  font-size: 12px;
  line-height: 1.6;
  color: var(--dim);
}

/* 道具面板单独加宽，其他 settings-panel 保持 340px */
#powerup-panel .settings-card {
  width: min(520px, 100%);
  padding: 28px 26px;
}

/* ---------------------------------------------------------- 闯关失败弹窗 */

.fail-score-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0 0;
  padding: 12px 14px;
  background: rgba(24, 34, 56, 0.65);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.fail-score-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--dim);
}

.fail-score-value {
  font-family: "Cascadia Mono", ui-monospace, Consolas, monospace;
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  text-shadow: 0 0 14px var(--accent-glow);
}

/* ---------------------------------------------------------------- 金手指 */

/* 藏在设置卡片最底部的小按钮：不打扰正常玩家，但想调试的人找得到 */
.cheat-btn {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 6px 8px;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  border: 1px dashed transparent;
  border-radius: 10px;
  color: #363f58;
  font-family: inherit;
  font-size: 10px;
  letter-spacing: 0.22em;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.cheat-btn:hover,
.cheat-btn:active {
  opacity: 1;
  color: var(--dim);
  border-color: var(--line-strong);
}

.cheat-unlock {
  margin-top: 16px;
}

/* ---------------------------------------------------------------- 轻提示 */

.toast {
  position: fixed;
  left: 50%;
  bottom: max(96px, calc(env(safe-area-inset-bottom) + 96px));
  z-index: 40;
  max-width: min(320px, calc(100vw - 32px));
  transform: translate(-50%, 8px);
  padding: 10px 18px;
  background: rgba(17, 25, 42, 0.88);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.5),
    backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--text);
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (prefers-reduced-motion: reduce) {
  .toast {
    transition: none;
  }
}

/* ============ DOM 首页（切图图层） ============ */
#home-screen {
  position: absolute;
  inset: 0;
  z-index: 20;
  overflow: hidden;
  background: #060a13;
}
#home-screen.hidden { display: none; }

.home-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.home-title {
  position: absolute;
  top: 6%;
  left: 50%;
  transform: translateX(-50%);
  width: 62%;
  height: auto;
  filter: drop-shadow(0 4px 12px rgba(255, 180, 50, 0.3));
}
.home-tank {
  position: absolute;
  width: 50%;
  height: auto;
  top: 13%;
}
.home-tank-yellow {
  right: 50%;
  margin-right: 1%;
}
.home-tank-blue {
  left: 50%;
  margin-left: 1%;
}

.home-glow {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  mix-blend-mode: screen;
}
.home-glow-halo {
  top: 32%;
  width: 30%;
  height: auto;
  opacity: 0.2;
}
.home-glow-ray {
  top: 38%;
  width: 55%;
  height: auto;
  opacity: 0.2;
}

.home-buttons {
  position: absolute;
  top: 44%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 58%;
}
.home-btn {
  display: block;
  width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
}
.home-btn img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
}
.home-btn:hover { transform: scale(1.03); }
.home-btn:active { transform: scale(0.97); filter: brightness(1.2); }

.home-footer {
  position: absolute;
  bottom: 3%;
  left: 50%;
  transform: translateX(-50%);
  width: 56%;
  height: auto;
  opacity: 0.7;
}
