/* ============================================================
 * 《保卫1002！》全局样式
 * 竖屏优先 / 禁止滚动 / 禁止长按菜单 / 按钮 ≥48px
 * ============================================================ */

:root {
  --bg-deep: #0b1020;
  --bg-panel: #151d33;
  --bg-card: #1c2742;
  --line: #2c3a5c;
  --text: #e8ecf6;
  --text-dim: #9aa7c7;
  --accent: #7dff6b;        /* 荧光绿：经验/主色 */
  --accent-dark: #3fae35;
  --danger: #ff4d5e;        /* 荧光红：血/危险 */
  --gold: #ffc94d;
  --purple: #b96bff;
  --blue: #5aa7ff;
  --gray: #9aa7c7;
}

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

html, body {
  width: 100%; height: 100%;
  background: var(--bg-deep);
  color: var(--text);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  overflow: hidden;                 /* 禁止页面滚动 */
  user-select: none;                /* 禁止长按选择 */
  -webkit-user-select: none;
  touch-action: none;               /* 禁止浏览器手势 */
  -webkit-touch-callout: none;      /* 禁止长按菜单 */
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #05070f;
}

#game-canvas {
  display: block;
  position: absolute;
  background: #0d1526;
}

/* ---------- UI 覆盖层 ---------- */
#ui-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
#ui-layer > * { pointer-events: auto; }

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: radial-gradient(ellipse at 50% 30%, #16203a 0%, #0b1020 70%);
  overflow-y: auto;
  z-index: 20;
}

.hidden { display: none !important; }

/* 可滚动内容区：放行纵向触摸滚动（手机端选角/背包/结算可滑动） */
.screen, .char-grid, .modal, .bag-list, .card-row { touch-action: pan-y; }

/* ---------- 标题界面 ---------- */
.title-box { text-align: center; max-width: 420px; width: 100%; }

.game-title {
  font-size: clamp(44px, 13vw, 64px);
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--text);
  text-shadow: 0 0 18px rgba(125, 255, 107, 0.55), 0 4px 0 #1a2b12;
}
.game-title .title-num {
  color: var(--accent);
  text-shadow: 0 0 22px rgba(125, 255, 107, 0.9);
}
.game-sub {
  margin-top: 6px;
  font-size: 16px;
  color: var(--accent);
  letter-spacing: 6px;
}
.game-story {
  margin-top: 14px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-dim);
}
.title-record {
  margin: 16px auto 4px;
  font-size: 13px;
  color: var(--gold);
  min-height: 20px;
}
.author-line {
  margin-top: 18px;
  font-size: 13px;
  color: var(--text-dim);
  letter-spacing: 2px;
}

/* ---------- 按钮（全部 ≥48px） ---------- */
.btn {
  min-height: 48px;
  min-width: 120px;
  padding: 12px 22px;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.08s, filter 0.08s;
  touch-action: manipulation;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { filter: grayscale(1) brightness(0.6); cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(180deg, #8dff7c, #46b53a);
  color: #0a1a08;
  box-shadow: 0 4px 0 #2c7a24, 0 6px 14px rgba(70, 181, 58, 0.35);
}
.btn-ghost {
  background: transparent;
  border: 2px solid var(--line);
  color: var(--text-dim);
}
.btn-big { width: 100%; max-width: 300px; margin-top: 10px; font-size: 18px; }
#screen-title .btn-ghost { margin-top: 12px; width: 100%; max-width: 300px; }

/* ---------- 选角界面 ---------- */
.screen-title {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 14px;
  text-align: center;
}
.char-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 460px;
  max-height: 62vh;
  overflow-y: auto;
  padding: 2px;
}
.char-card {
  background: var(--bg-card);
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  cursor: pointer;
  position: relative;
  transition: border-color 0.12s, transform 0.12s;
}
.char-card:active { transform: scale(0.97); }
.char-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 14px rgba(125, 255, 107, 0.45);
}
.char-card .cc-portrait {
  width: 100%;
  height: 74px;
  border-radius: 10px;
  background: #101827;
  margin-bottom: 8px;
}
.char-card h3 { font-size: 15px; font-weight: 800; }
.char-card .cc-tag {
  display: inline-block;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(125, 255, 107, 0.15);
  color: var(--accent);
  margin: 4px 0 6px;
}
.char-card .cc-row { font-size: 11px; color: var(--text-dim); line-height: 1.6; text-align: left; }
.char-card .cc-row b { color: var(--text); font-weight: 600; }
.cc-badge {
  position: absolute;
  top: -8px;
  right: 6px;
  font-size: 10px;
  font-weight: 800;
  color: #3a2a00;
  background: linear-gradient(180deg, #ffe08a, var(--gold));
  padding: 3px 8px;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(255, 201, 77, 0.5);
}
.select-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  width: 100%;
  max-width: 460px;
}
.select-actions .btn { flex: 1; }

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}
#hud > * { pointer-events: auto; }

#hud-topleft {
  position: absolute;
  top: 8px; left: 8px;
  background: rgba(11, 16, 32, 0.72);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 7px 10px;
  min-width: 150px;
}
#hud-player-name { font-size: 12px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
#hud-level { font-size: 11px; color: var(--gold); margin-top: 3px; font-weight: 700; }

.bar {
  position: relative;
  width: 140px;
  height: 14px;
  background: #232f4d;
  border-radius: 7px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  width: 100%;
  border-radius: 7px;
  transition: width 0.15s;
}
.hp-bar .bar-fill { background: linear-gradient(90deg, #ff6b7a, var(--danger)); }
.bar span {
  position: absolute;
  inset: 0;
  font-size: 10px;
  line-height: 14px;
  text-align: center;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

#hud-top {
  position: absolute;
  top: 8px; left: 50%;
  transform: translateX(-50%);
  width: min(46vw, 220px);
}
.xp-bar { width: 100%; height: 10px; }
.xp-bar .bar-fill { background: linear-gradient(90deg, #a8ff8f, var(--accent)); width: 0%; }

#hud-topright {
  position: absolute;
  top: 64px; right: 8px;
  text-align: right;
  background: rgba(11, 16, 32, 0.72);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 700;
}
/* 音量开关：右上角独立定位（48px），避开顶部经验条 */
#btn-mute {
  position: absolute;
  top: 8px; right: 8px;
  z-index: 3;
}
#hud-time { color: var(--accent); font-variant-numeric: tabular-nums; }
#hud-kill { color: var(--gold); font-size: 12px; margin-top: 2px; }

#hud-btns {
  position: absolute;
  right: 8px; bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.icon-btn {
  min-width: 48px;
  min-height: 48px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(21, 29, 51, 0.88);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  padding: 0 10px;
  touch-action: manipulation;
}
.icon-btn:active { transform: scale(0.94); }
#btn-element { color: var(--blue); }

#hud-skills {
  position: absolute;
  left: 8px; bottom: 12px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  max-width: 55vw;
}
.skill-chip {
  min-width: 48px;
  height: 48px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(21, 29, 51, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  position: relative;
  overflow: hidden;
}
.skill-chip .cd-mask {
  position: absolute;
  left: 0; bottom: 0;
  width: 100%;
  background: rgba(0, 0, 0, 0.62);
}

/* Boss 红字警告横幅 */
#boss-banner {
  position: absolute;
  top: 34%;
  left: 0; right: 0;
  text-align: center;
  font-size: clamp(20px, 6vw, 30px);
  font-weight: 900;
  color: var(--danger);
  text-shadow: 0 0 16px rgba(255, 77, 94, 0.9), 0 2px 4px #000;
  letter-spacing: 3px;
  pointer-events: none;
  animation: bannerPulse 0.5s infinite alternate;
}
@keyframes bannerPulse {
  from { transform: scale(1); opacity: 0.9; }
  to { transform: scale(1.07); opacity: 1; }
}

/* Boss 底部大血条 */
#boss-bar-wrap {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 78px;
  width: min(72vw, 320px);
  text-align: center;
  pointer-events: none;
}
#boss-name {
  font-size: 13px;
  font-weight: 800;
  color: #ff8c8c;
  text-shadow: 0 1px 3px #000;
  margin-bottom: 3px;
}
.boss-bar { width: 100%; height: 16px; border: 1px solid #5a2430; }
.boss-bar .bar-fill { background: linear-gradient(90deg, #ff8c42, #ff2d3d); width: 100%; }
#boss-phase {
  font-size: 11px;
  font-weight: 700;
  color: var(--gold);
  margin-top: 3px;
  text-shadow: 0 1px 2px #000;
}

/* ---------- 弹窗通用 ---------- */
.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(5, 7, 15, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
  padding: 14px;
}
.modal {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px 16px;
  width: 100%;
  max-width: 420px;
  max-height: 92vh;
  overflow-y: auto;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}
.modal h2 { font-size: 21px; font-weight: 900; margin-bottom: 4px; }
.modal h3 { font-size: 18px; font-weight: 800; margin-bottom: 8px; }
.modal-sub { font-size: 12px; color: var(--text-dim); margin-bottom: 14px; }
.modal-small { max-width: 320px; }
.modal-small .btn { width: 100%; margin-top: 10px; }
.row-2 { display: flex; gap: 10px; margin-top: 12px; }
.row-2 .btn { flex: 1; margin-top: 0; }

.help-body { text-align: left; font-size: 13px; line-height: 1.8; color: var(--text-dim); }
.help-body b { color: var(--text); }
.help-body p { margin-bottom: 8px; }

/* ---------- 升级三选一卡片 ---------- */
.card-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.lv-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  cursor: pointer;
  text-align: left;
  min-height: 64px;
  transition: transform 0.08s, border-color 0.1s;
}
.lv-card:active { transform: scale(0.97); }
.lv-card .lv-icon {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  background: #101827;
}
.lv-card .lv-info { flex: 1; min-width: 0; }
.lv-card .lv-name { font-size: 15px; font-weight: 800; }
.lv-card .lv-name .lv-star { font-size: 11px; margin-left: 5px; }
.lv-card .lv-desc { font-size: 11.5px; color: var(--text-dim); line-height: 1.5; margin-top: 2px; }
.lv-card .lv-rarity { font-size: 10px; font-weight: 800; margin-top: 3px; }
.lv-card.rarity-common { border-color: #5a6478; }
.lv-card.rarity-common .lv-rarity { color: var(--gray); }
.lv-card.rarity-rare { border-color: var(--blue); box-shadow: 0 0 10px rgba(90, 167, 255, 0.25); }
.lv-card.rarity-rare .lv-rarity { color: var(--blue); }
.lv-card.rarity-epic { border-color: var(--purple); box-shadow: 0 0 10px rgba(185, 107, 255, 0.3); }
.lv-card.rarity-epic .lv-rarity { color: var(--purple); }
.lv-card.rarity-legend { border-color: var(--gold); box-shadow: 0 0 16px rgba(255, 201, 77, 0.5); }
.lv-card.rarity-legend .lv-rarity { color: var(--gold); }
.lv-card.evolve { animation: evolveGlow 0.8s infinite alternate; }
@keyframes evolveGlow {
  from { box-shadow: 0 0 8px rgba(255, 201, 77, 0.4); }
  to { box-shadow: 0 0 22px rgba(255, 201, 77, 0.85); }
}

/* ---------- 背包 ---------- */
.modal-bag { max-width: 400px; }
.equip-slots { display: flex; gap: 8px; margin-bottom: 10px; }
.equip-slot {
  flex: 1;
  background: #101827;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 6px;
  font-size: 11px;
  min-height: 76px;
}
.equip-slot .es-name { font-weight: 800; font-size: 12px; margin: 2px 0; }
.equip-slot .es-attr { color: var(--text-dim); line-height: 1.5; font-size: 10px; }
.bag-shard-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #101827;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  margin-bottom: 10px;
}
#bag-shard { font-size: 13px; color: var(--gold); font-weight: 700; }
.btn-synth { min-width: 110px; min-height: 44px; padding: 8px 14px; font-size: 14px; }
.bag-list-head { font-size: 11px; color: var(--text-dim); text-align: left; margin-bottom: 6px; }
.bag-list {
  max-height: 34vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}
.bag-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #101827;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  text-align: left;
}
.bag-item .bi-name { font-weight: 700; }
.bag-item .bi-attr { color: var(--text-dim); font-size: 10.5px; }
.bag-item .bi-count { color: var(--gold); font-weight: 800; }
.bag-empty { font-size: 12px; color: var(--text-dim); padding: 14px 0; }
.rarity-white { color: #dfe6f5; }
.rarity-blue { color: var(--blue); }
.rarity-purple { color: var(--purple); }
.rarity-gold { color: var(--gold); }

/* ---------- 结算 ---------- */
.result { max-width: 380px; }
.result-list { text-align: left; margin: 10px 0 12px; }
.result-row {
  display: flex;
  justify-content: space-between;
  font-size: 13.5px;
  padding: 7px 2px;
  border-bottom: 1px dashed var(--line);
}
.result-row .rr-label { color: var(--text-dim); }
.result-row .rr-value { font-weight: 800; text-align: right; max-width: 62%; }
.result-skills { font-size: 11.5px; color: var(--text-dim); line-height: 1.7; }
.result-comment {
  font-size: 17px;
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 0 12px rgba(255, 201, 77, 0.5);
  margin-bottom: 14px;
}

/* ---------- 虚拟摇杆 ---------- */
#stick-ui {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 15;
  display: none;
}
#stick-base {
  position: absolute;
  width: 110px; height: 110px;
  border-radius: 50%;
  border: 2px solid rgba(125, 255, 107, 0.5);
  background: rgba(11, 16, 32, 0.35);
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
}
#stick-knob {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: rgba(125, 255, 107, 0.55);
  box-shadow: 0 0 14px rgba(125, 255, 107, 0.6);
}

/* ---------- Toast ---------- */
#toast-wrap {
  position: absolute;
  top: 72px; left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  pointer-events: none;
}
.toast {
  background: rgba(11, 16, 32, 0.92);
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 700;
  padding: 9px 16px;
  border-radius: 20px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  animation: toastIn 0.25s ease-out;
  white-space: nowrap;
}
.toast.fade { opacity: 0; transition: opacity 0.4s; }
@keyframes toastIn {
  from { transform: translateY(-12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ---------- 竖屏提示（横屏时） ---------- */
#rotate-tip {
  position: absolute;
  inset: 0;
  z-index: 50;
  background: rgba(5, 7, 15, 0.95);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
  font-size: 16px;
  color: var(--text);
  text-align: center;
}
#rotate-tip .rt-icon { font-size: 42px; }

@media (orientation: landscape) and (max-height: 480px) {
  #rotate-tip { display: flex; }
}
