/* ============================================================================
 * FUSE CITY / 熔断之城 —— UI 样式
 * 暗底 + 霓虹描边 + 玻璃拟态面板。所有尺寸用 vmin/clamp，保证 1080p 到 4K 都不散。
 * ==========================================================================*/

:root {
  --bg: #05070d;
  --bg-2: #0a1020;
  --panel: rgba(10, 18, 34, 0.82);
  --panel-2: rgba(14, 24, 44, 0.92);
  --line: rgba(99, 216, 255, 0.22);
  --line-2: rgba(99, 216, 255, 0.45);
  --cyan: #63d8ff;
  --magenta: #ff5ea8;
  --amber: #ffd166;
  --green: #65e6a8;
  --red: #ff5a5a;
  --text: #dff1ff;
  --text-dim: #8aa4c4;
  --font: "Segoe UI", system-ui, -apple-system, "Microsoft YaHei", "PingFang SC", sans-serif;
  --mono: "Cascadia Mono", Consolas, "SF Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  user-select: none;
  -webkit-user-select: none;
  cursor: default;
}

#app { position: relative; width: 100vw; height: 100vh; overflow: hidden; }

#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.hidden { display: none !important; }

/* ------------------------------------------------------------------ 通用件 */

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.overlay { background: rgba(3, 6, 12, 0.72); backdrop-filter: blur(7px); z-index: 30; }

.bg-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(99, 216, 255, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99, 216, 255, 0.055) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(circle at 50% 42%, #000 10%, transparent 72%);
  -webkit-mask-image: radial-gradient(circle at 50% 42%, #000 10%, transparent 72%);
  pointer-events: none;
}

.panel {
  position: relative;
  width: min(680px, 92vw);
  max-height: 88vh;
  overflow-y: auto;
  padding: clamp(18px, 3vh, 34px) clamp(18px, 3vw, 36px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5), 0 26px 70px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(12px);
}
.panel.wide { width: min(1080px, 94vw); }
.panel.narrow { width: min(460px, 90vw); }

.panel h2 {
  margin: 0 0 14px;
  font-size: clamp(17px, 2.2vh, 24px);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 0 18px rgba(99, 216, 255, 0.55);
}

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

.panel-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.panel-actions.col { flex-direction: column; align-items: stretch; }

.hint { color: var(--text-dim); font-size: clamp(11px, 1.5vh, 13px); line-height: 1.6; margin: 4px 0 12px; }
.hint.small { font-size: 11.5px; text-align: center; margin-top: 14px; }

/* ------------------------------------------------------------------ 按钮 */

.btn {
  appearance: none;
  padding: clamp(9px, 1.5vh, 13px) clamp(16px, 2vw, 26px);
  font-family: inherit;
  font-size: clamp(12.5px, 1.7vh, 15px);
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text);
  background: rgba(99, 216, 255, 0.07);
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .08s, color .15s;
  white-space: nowrap;
}
.btn:hover, .btn:focus-visible {
  background: rgba(99, 216, 255, 0.18);
  border-color: var(--line-2);
  color: #fff;
  outline: none;
  box-shadow: 0 0 22px rgba(99, 216, 255, 0.28);
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn.primary {
  color: #041018;
  background: linear-gradient(135deg, var(--cyan), #7ef7d0);
  border-color: transparent;
  box-shadow: 0 0 26px rgba(99, 216, 255, 0.4);
}
.btn.primary:hover { box-shadow: 0 0 36px rgba(99, 216, 255, 0.65); }
.btn.ghost { background: transparent; color: var(--text-dim); }
.btn.ghost:hover { color: var(--text); }
.btn.tiny { padding: 6px 12px; font-size: 12px; letter-spacing: 0.04em; }
.btn:disabled { opacity: 0.35; cursor: not-allowed; box-shadow: none; }

/* ------------------------------------------------------------------ 主菜单 */

.menu-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(10px, 2vh, 20px);
  z-index: 1;
}

.title-block { text-align: center; }
.title-cn {
  font-size: clamp(40px, 9vh, 92px);
  font-weight: 800;
  letter-spacing: 0.22em;
  margin-left: 0.22em;
  color: #fff;
  text-shadow: 0 0 30px rgba(99, 216, 255, 0.75), 0 0 90px rgba(255, 94, 168, 0.35);
}
.title-en {
  font-family: var(--mono);
  font-size: clamp(12px, 2.1vh, 20px);
  letter-spacing: 0.72em;
  margin-left: 0.72em;
  color: var(--cyan);
  opacity: 0.92;
}
.tagline { margin: 14px 0 0; color: var(--text-dim); font-size: clamp(11.5px, 1.7vh, 14px); max-width: 46em; line-height: 1.7; }

.credit-box {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 16px;
  font-family: var(--mono);
  font-size: clamp(12px, 1.7vh, 15px);
  background: rgba(255, 209, 102, 0.09);
  border: 1px solid rgba(255, 209, 102, 0.32);
  border-radius: 999px;
  color: var(--amber);
}
.credit-box .coin { font-size: 1.18em; text-shadow: 0 0 12px rgba(255, 209, 102, 0.8); }
.credit-box .sep { opacity: 0.4; }
.credit-box.small { padding: 5px 12px; font-size: 13px; }
.credit-box b { color: #fff; }

.menu-nav { display: flex; flex-direction: column; gap: 9px; width: min(340px, 78vw); }
.menu-nav .btn { width: 100%; }

.ver { position: absolute; bottom: -6vh; font-family: var(--mono); font-size: 11px; color: rgba(138, 164, 196, 0.5); }

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

#hud { position: absolute; inset: 0; pointer-events: none; z-index: 10; }

.hud-top {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: clamp(10px, 1.8vh, 20px) clamp(12px, 2vw, 26px);
  gap: 14px;
}

.hud-left { width: clamp(180px, 22vw, 300px); }
.hp-wrap { display: flex; flex-direction: column; gap: 5px; }
.hp-bar {
  position: relative; height: clamp(15px, 1.9vh, 21px);
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 90, 90, 0.5);
  border-radius: 5px;
  overflow: hidden;
}
.hp-bar i {
  position: absolute; inset: 0; width: 100%;
  background: linear-gradient(90deg, #ff2e4d, #ff8f5e);
  transition: width .12s linear;
  box-shadow: 0 0 16px rgba(255, 46, 77, 0.7);
}
.hp-bar span {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: clamp(9.5px, 1.35vh, 12px); color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}
.xp-bar {
  position: relative; height: 7px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(99, 216, 255, 0.32);
  border-radius: 4px; overflow: hidden;
}
.xp-bar i {
  position: absolute; inset: 0; width: 0%;
  background: linear-gradient(90deg, #2f7bff, var(--cyan));
  box-shadow: 0 0 12px rgba(99, 216, 255, 0.75);
  transition: width .1s linear;
}
.hp-meta { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 12px; color: var(--cyan); }

.hud-center { text-align: center; flex: 1; }
#hud-time {
  font-family: var(--mono);
  font-size: clamp(24px, 4.4vh, 46px);
  font-weight: 700;
  color: #fff;
  text-shadow: 0 0 24px rgba(99, 216, 255, 0.6);
  line-height: 1;
}
#hud-phase { font-family: var(--mono); font-size: clamp(9.5px, 1.4vh, 12px); letter-spacing: 0.3em; color: var(--text-dim); margin-top: 4px; }
#hud-boss-warn { font-size: 22px; color: var(--red); animation: blink .5s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.15; } }

.hud-right { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.hud-stat { display: flex; align-items: baseline; gap: 6px; font-family: var(--mono); }
.hud-stat b { font-size: clamp(15px, 2.1vh, 21px); color: #fff; }
.hud-stat span { font-size: clamp(9.5px, 1.35vh, 11.5px); color: var(--text-dim); letter-spacing: 0.1em; }
.hud-stat.small b { font-size: 12px; color: var(--text-dim); }
.hud-stat.small.off { display: none; }

#hud-boss { position: absolute; left: 50%; transform: translateX(-50%); bottom: clamp(46px, 7vh, 78px); width: min(72vw, 900px); text-align: center; }
.boss-name { font-family: var(--mono); font-size: clamp(12px, 1.8vh, 16px); letter-spacing: 0.28em; color: #fff; margin-bottom: 5px; text-shadow: 0 0 16px currentColor; }
.boss-bar { position: relative; height: 13px; background: rgba(0, 0, 0, 0.65); border: 1px solid rgba(255, 255, 255, 0.28); border-radius: 4px; overflow: hidden; }
.boss-bar i { position: absolute; inset: 0; width: 100%; background: linear-gradient(90deg, var(--red), #ff9f43); transition: width .14s linear; }
.boss-sub { font-family: var(--mono); font-size: 10.5px; color: var(--text-dim); margin-top: 4px; letter-spacing: 0.2em; }

.hud-loadout { position: absolute; left: clamp(12px, 2vw, 26px); bottom: clamp(12px, 2vh, 22px); display: flex; flex-direction: column; gap: 5px; }
.slot-row { display: flex; gap: 5px; flex-wrap: wrap; max-width: 46vw; }
.slot {
  position: relative;
  width: clamp(28px, 3.6vh, 38px); height: clamp(28px, 3.6vh, 38px);
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(14px, 2vh, 19px);
  background: rgba(6, 12, 22, 0.72);
  border: 1.5px solid var(--line);
  border-radius: 7px;
}
.slot.evolved { border-color: var(--amber); box-shadow: 0 0 16px rgba(255, 209, 102, 0.45); }
.slot .lv {
  position: absolute; right: -3px; bottom: -5px;
  font-family: var(--mono); font-size: 9.5px; font-weight: 700;
  padding: 0 3px; border-radius: 4px;
  background: #0a1020; border: 1px solid var(--line); color: var(--cyan);
}
.slot.evolved .lv { color: var(--amber); border-color: rgba(255, 209, 102, 0.6); }

.banner {
  position: absolute; left: 50%; top: 21%;
  transform: translateX(-50%);
  padding: 9px 30px;
  font-size: clamp(15px, 2.4vh, 24px);
  font-weight: 700; letter-spacing: 0.2em;
  color: #fff; white-space: nowrap;
  background: rgba(4, 8, 16, 0.7);
  border-top: 1px solid currentColor; border-bottom: 1px solid currentColor;
  text-shadow: 0 0 22px currentColor;
  animation: bannerIn .28s ease-out;
}
@keyframes bannerIn { from { opacity: 0; transform: translateX(-50%) scale(0.94); } }

.toast {
  position: absolute; left: 50%; bottom: 22%;
  transform: translateX(-50%);
  padding: 9px 22px;
  font-size: 14px; color: #fff;
  background: rgba(10, 18, 34, 0.92);
  border: 1px solid var(--amber);
  border-radius: 8px;
  box-shadow: 0 0 28px rgba(255, 209, 102, 0.35);
  white-space: nowrap;
}

.tutorial {
  position: absolute; left: 50%; bottom: clamp(70px, 12vh, 130px);
  transform: translateX(-50%);
  text-align: center; color: var(--text-dim);
  font-size: clamp(11px, 1.6vh, 13.5px); line-height: 1.9;
  transition: opacity .6s;
}

/* ------------------------------------------------------------ 升级三选一 */

#overlay-levelup { flex-direction: column; gap: clamp(10px, 2vh, 22px); }
.levelup-head { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; justify-content: center; }
.levelup-head h2 { margin: 0; }
.levelup-tools { display: flex; gap: 8px; }

.cards { display: flex; gap: clamp(10px, 1.6vw, 20px); flex-wrap: wrap; justify-content: center; padding: 0 14px; }
.card {
  position: relative;
  width: clamp(200px, 21vw, 268px);
  min-height: clamp(176px, 26vh, 250px);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  gap: 9px;
  padding: clamp(14px, 2.4vh, 24px) clamp(12px, 1.6vw, 20px);
  text-align: center;
  background: linear-gradient(180deg, rgba(14, 24, 44, 0.95), rgba(8, 14, 26, 0.95));
  border: 1.5px solid var(--line);
  border-top-width: 4px;
  border-radius: 12px;
  cursor: pointer;
  transition: transform .12s, box-shadow .18s, border-color .18s;
  animation: cardIn .22s ease-out backwards;
}
.card:nth-child(1) { animation-delay: .02s; }
.card:nth-child(2) { animation-delay: .07s; }
.card:nth-child(3) { animation-delay: .12s; }
@keyframes cardIn { from { opacity: 0; transform: translateY(14px) scale(0.97); } }
.card:hover, .card:focus-visible {
  transform: translateY(-5px);
  border-color: var(--line-2);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.6), 0 0 34px rgba(99, 216, 255, 0.3);
  outline: none;
}
.card .ico { font-size: clamp(30px, 5.4vh, 50px); line-height: 1; text-shadow: 0 0 26px currentColor; }
.card .cname { font-size: clamp(14px, 2vh, 18px); font-weight: 700; color: #fff; }
.card .cdesc { font-size: clamp(11px, 1.5vh, 13px); color: var(--text-dim); line-height: 1.65; }
.card .ctag {
  position: absolute; top: -1px; right: -1px;
  padding: 3px 10px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em;
  border-radius: 0 12px 0 9px;
  background: rgba(99, 216, 255, 0.16); color: var(--cyan);
  border-left: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.card.evolve { border-color: var(--amber); box-shadow: 0 0 34px rgba(255, 209, 102, 0.35); }
.card.evolve .ctag { background: rgba(255, 209, 102, 0.2); color: var(--amber); }
.card.heal { border-color: rgba(101, 230, 168, 0.5); }
.card .keyhint {
  position: absolute; left: 10px; top: 8px;
  font-family: var(--mono); font-size: 10px; color: var(--text-dim);
  border: 1px solid var(--line); border-radius: 4px; padding: 0 5px;
}

/* ------------------------------------------------------------ 结算 */

.result-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 22px; margin: 6px 0 4px; }
.result-row { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1px dashed rgba(99, 216, 255, 0.16); padding: 7px 0; }
.result-row span { color: var(--text-dim); font-size: 12.5px; }
.result-row b { font-family: var(--mono); font-size: 17px; color: #fff; }
.result-row.hi b { color: var(--amber); text-shadow: 0 0 16px rgba(255, 209, 102, 0.6); }
.ach-unlocked { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.ach-toast {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 8px;
  background: rgba(255, 209, 102, 0.09); border: 1px solid rgba(255, 209, 102, 0.4);
  font-size: 12.5px;
}
.ach-toast .ico { font-size: 19px; }
.ach-toast b { color: var(--amber); }

.pause-stats { display: flex; flex-wrap: wrap; gap: 8px 18px; font-family: var(--mono); font-size: 12.5px; color: var(--text-dim); margin-bottom: 6px; }
.pause-stats b { color: #fff; }

/* ------------------------------------------------------------ 角色卡 */

.char-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.char-card {
  padding: 18px;
  background: linear-gradient(180deg, rgba(14, 24, 44, 0.9), rgba(8, 14, 26, 0.9));
  border: 1.5px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  transition: transform .12s, box-shadow .18s, border-color .18s;
  display: flex; flex-direction: column; gap: 9px;
}
.char-card:hover { transform: translateY(-4px); border-color: var(--line-2); box-shadow: 0 16px 38px rgba(0, 0, 0, 0.6); }
.char-card.selected { border-color: var(--cyan); box-shadow: 0 0 30px rgba(99, 216, 255, 0.34); }
.char-card.locked { opacity: 0.62; }
.char-card .cico { font-size: 34px; text-shadow: 0 0 24px currentColor; }
.char-card .cname { font-size: 19px; font-weight: 700; color: #fff; letter-spacing: 0.06em; }
.char-card .ctagline { font-family: var(--mono); font-size: 11px; color: var(--cyan); letter-spacing: 0.06em; }
.char-card .cdesc { font-size: 12.5px; color: var(--text-dim); line-height: 1.7; }
.char-card .cstart { font-family: var(--mono); font-size: 11.5px; color: var(--amber); }
.char-card .cfoot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; }

/* --------------------------------------------------------- 永久强化 */

.upgrade-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(252px, 1fr)); gap: 10px; }
.up {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 13px;
  background: rgba(10, 18, 34, 0.66);
  border: 1px solid var(--line);
  border-radius: 10px;
  transition: border-color .15s, background .15s;
}
.up.afford { border-color: rgba(101, 230, 168, 0.45); }
.up.afford:hover { background: rgba(101, 230, 168, 0.08); }
.up.maxed { border-color: rgba(255, 209, 102, 0.5); background: rgba(255, 209, 102, 0.06); }
.up .uico { font-size: 22px; width: 28px; text-align: center; color: var(--cyan); }
.up .umain { flex: 1; min-width: 0; }
.up .uname { font-size: 13.5px; font-weight: 600; color: #fff; }
.up .udesc { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.pips { display: flex; gap: 3px; margin-top: 6px; }
.pips i { width: 11px; height: 5px; border-radius: 2px; background: rgba(99, 216, 255, 0.2); }
.pips i.on { background: var(--cyan); box-shadow: 0 0 8px rgba(99, 216, 255, 0.8); }
.up .ubuy { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.up .ucost { font-family: var(--mono); font-size: 12px; color: var(--amber); }
.up .ucost.no { color: var(--red); }
.up .ubuy .btn { padding: 5px 12px; font-size: 11.5px; }

/* ------------------------------------------------------------ 成就 */

.ach-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(268px, 1fr)); gap: 10px; }
.ach {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 13px;
  background: rgba(10, 18, 34, 0.6);
  border: 1px solid rgba(99, 216, 255, 0.14);
  border-radius: 10px;
  opacity: 0.55;
}
.ach.got { opacity: 1; border-color: rgba(255, 209, 102, 0.45); background: rgba(255, 209, 102, 0.07); }
.ach .aico { font-size: 24px; width: 30px; text-align: center; }
.ach .aname { font-size: 13px; font-weight: 600; color: #fff; }
.ach .adesc { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.ach.got .aico { text-shadow: 0 0 18px rgba(255, 209, 102, 0.9); }

/* ------------------------------------------------------------ 设置 */

.settings { display: flex; flex-direction: column; gap: 12px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.set-row > label { font-size: 13.5px; color: var(--text); min-width: 120px; }
.set-row input[type="range"] { flex: 1; accent-color: var(--cyan); max-width: 320px; }
.set-row .val { font-family: var(--mono); font-size: 12.5px; color: var(--cyan); width: 46px; text-align: right; }
.toggle {
  padding: 6px 16px; font-family: var(--mono); font-size: 12px;
  border: 1px solid var(--line); border-radius: 999px;
  background: rgba(99, 216, 255, 0.06); color: var(--text-dim); cursor: pointer;
  min-width: 74px;
}
.toggle.on { background: rgba(101, 230, 168, 0.16); border-color: rgba(101, 230, 168, 0.55); color: var(--green); }

/* ------------------------------------------------------------ 致命错误 */

.fatal {
  position: absolute; inset: 0; z-index: 99;
  display: flex; align-items: center; justify-content: center;
  padding: 40px; background: rgba(20, 4, 8, 0.94);
  font-family: var(--mono); font-size: 13px; color: #ffb4b4; white-space: pre-wrap;
  overflow: auto; line-height: 1.7;
}

/* 小屏（Steam Deck 掌机模式）适配 */
@media (max-width: 900px), (max-height: 620px) {
  .hud-loadout { bottom: 8px; }
  .slot { width: 26px; height: 26px; font-size: 13px; }
  #hud-boss { bottom: 40px; }
  .title-cn { letter-spacing: 0.14em; margin-left: 0.14em; }
}
