/* ============ 抢地盘·色彩反击战 ============ */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #23272f;
  --bg-soft: #2c313b;
  --panel: rgba(24, 28, 35, 0.92);
  --text: #f2f4f8;
  --text-dim: #9aa2ad;
  --blue: #3f8cff;
  --radius: 16px;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  overscroll-behavior: none;
}

#app { position: fixed; inset: 0; }

/* ---------------- 屏幕系统 ---------------- */
.screen {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
}
.screen.active { display: flex; }

/* ---------------- 主菜单 ---------------- */
#screen-menu { align-items: center; overflow-y: auto; -webkit-overflow-scrolling: touch; }
#menu-bg { position: absolute; inset: 0; width: 100%; height: 100%; }

.menu-box { position: relative; text-align: center; padding: 32px 24px; z-index: 1; margin: auto; flex: 0 0 auto; }
.game-title {
  font-size: clamp(44px, 11vw, 72px);
  font-weight: 900;
  letter-spacing: 4px;
  background: linear-gradient(120deg, #3f8cff 15%, #ff9d2b 40%, #a05cf0 65%, #2fbf71 90%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 8px 30px rgba(63, 140, 255, 0.25);
}
.menu-story-hint {
  margin: 18px auto 0;
  max-width: 300px;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.7;
}
.menu-help {
  margin: 16px auto 0;
  max-width: 320px;
  text-align: left;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 12px;
  line-height: 1.9;
  color: var(--text-dim);
}
.menu-help .mh-title { color: var(--text); font-weight: 800; font-size: 12.5px; }
.menu-btns { margin-top: 30px; display: flex; flex-direction: column; gap: 14px; align-items: center; }

.btn {
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  color: #fff;
  background: var(--blue);
  border-radius: 999px;
  padding: 14px 46px;
  font-size: 18px;
  box-shadow: 0 6px 18px rgba(63, 140, 255, 0.35);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.btn:active { transform: scale(0.96); }
.btn.secondary {
  background: var(--bg-soft);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  font-size: 15px;
  padding: 11px 34px;
}
.btn.danger { background: #e3486133; color: #ff8d9d; box-shadow: none; }
/* 无尽远征：彩色渐变入口 */
.btn.endless {
  background: linear-gradient(100deg, #ff6b6b, #f5c542 30%, #2fbf71 55%, #2bc4c9 75%, #a05cf0);
  box-shadow: 0 6px 18px rgba(160, 92, 240, 0.4);
}
.btn-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.free-badge {
  margin-top: 26px;
  display: inline-block;
  font-size: 12px;
  color: #ffd27a;
  border: 1px solid #ffd27a55;
  border-radius: 999px;
  padding: 5px 14px;
  letter-spacing: 2px;
}

/* ---------------- 选关 ---------------- */
#screen-levels { padding: 22px 18px 30px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.levels-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.levels-head h2 { font-size: 22px; }
.back-btn {
  background: var(--bg-soft); color: var(--text);
  border: none; border-radius: 999px;
  padding: 9px 20px; font-size: 14px; font-weight: 700; cursor: pointer;
}
.chapter-head { margin: 20px 4px 10px; }
.ch-title { font-size: 17px; font-weight: 800; }
.ch-sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.level-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 480px) { .level-grid { grid-template-columns: repeat(2, 1fr); } }
.level-card {
  background: var(--bg-soft);
  border-radius: var(--radius);
  padding: 14px 8px 12px;
  text-align: center;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.1s ease;
}
.level-card:active { transform: scale(0.96); }
.level-card.boss { border-color: #ff9d2b66; }
.level-card.locked { opacity: 0.45; cursor: default; }
.lc-id { font-size: 13px; color: var(--text-dim); font-weight: 700; }
.lc-name { font-size: 14px; font-weight: 800; margin-top: 4px; min-height: 20px; }
.lc-stars { margin-top: 4px; font-size: 13px; color: #ffc94d; letter-spacing: 2px; min-height: 17px; }

/* ---------------- 战斗屏 ---------------- */
#screen-game { background: #1d2129; }
#game-area { position: relative; flex: 1; overflow: hidden; }
#game-canvas { position: absolute; inset: 0; touch-action: none; }

#hud-top {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 6px;
}
#hud-level { font-size: 13px; font-weight: 800; white-space: nowrap; }
#progress-bar {
  flex: 1;
  height: 14px;
  display: flex;
  border-radius: 999px;
  overflow: hidden;
  background: #3a404b;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.12);
}
#progress-bar .seg { transition: flex 0.5s ease; min-width: 0; }
.hud-btn {
  width: 38px; height: 38px;
  border-radius: 12px;
  border: none;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 15px; font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
}

/* 技能栏 */
#skill-bar {
  position: relative;
  z-index: 5;
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: stretch;
  padding: 10px 14px calc(12px + env(safe-area-inset-bottom, 0px));
}
.skill-btn {
  position: relative;
  width: 68px; height: 68px;
  border-radius: 18px;
  border: 2px solid rgba(255, 255, 255, 0.14);
  background: var(--bg-soft);
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  overflow: hidden;
  font-family: inherit;
}
.skill-btn:active { transform: scale(0.94); }
.skill-btn .sk-icon { font-size: 26px; line-height: 1; }
.skill-btn .sk-name { font-size: 11px; font-weight: 700; color: var(--text); }
.skill-btn .sk-cd {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 900; color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}
.skill-btn.targeting { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(63, 140, 255, 0.4); }
.skill-locked {
  width: 68px; height: 68px;
  border-radius: 18px;
  border: 2px dashed rgba(255, 255, 255, 0.12);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  opacity: 0.5;
}
.skill-locked .sk-name { font-size: 10px; color: var(--text-dim); }
#skill-cancel {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  background: var(--panel);
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 13px;
  display: none;
  z-index: 6;
  white-space: nowrap;
}
#skill-cancel.show { display: block; }

/* ---------------- 通用浮层 ---------------- */
.overlay {
  position: absolute; inset: 0;
  background: rgba(12, 15, 20, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  align-items: center; justify-content: center;
  z-index: 20;
  padding: 24px;
}
.overlay.show { display: flex; }
.panel {
  background: var(--panel);
  border-radius: 24px;
  padding: 30px 28px;
  width: min(420px, 92vw);
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.panel h2 { font-size: 22px; margin-bottom: 20px; }
.panel .btn { display: block; width: 100%; margin-top: 12px; padding: 13px 0; font-size: 16px; }

#result-stars { font-size: 52px; letter-spacing: 8px; margin: 6px 0 4px; height: 64px; }
.rstar { color: #4a5160; display: inline-block; opacity: 0.5; }
.rstar.on { color: #ffc94d; animation: starPop 0.5s cubic-bezier(0.2, 2.2, 0.4, 1) both; text-shadow: 0 0 24px #ffc94d88; }
@keyframes starPop { from { transform: scale(2.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
#result-time { color: var(--text-dim); font-size: 14px; margin-bottom: 14px; }

/* ---------------- 剧情 ---------------- */
#story-overlay {
  position: fixed; inset: 0; z-index: 40;
  background: linear-gradient(180deg, #171b22 0%, #232a36 100%);
  display: none;
  flex-direction: column;
  justify-content: center;
  padding: 34px 30px calc(40px + env(safe-area-inset-bottom, 0px));
}
#story-overlay.show { display: flex; }
#story-title {
  font-size: 24px; font-weight: 900; letter-spacing: 2px;
  background: linear-gradient(90deg, #3f8cff, #a05cf0);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  margin-bottom: 22px;
}
#story-text {
  font-size: 16px; line-height: 2;
  color: #d6dbe4;
  min-height: 150px;
  white-space: pre-wrap;
}
.story-btns { margin-top: 26px; display: flex; gap: 12px; justify-content: space-between; align-items: center; }
#story-skip { background: none; border: none; color: var(--text-dim); font-size: 13px; cursor: pointer; font-family: inherit; }

/* 剧情回顾 */
#gallery-overlay { z-index: 50; }
#gallery-overlay .panel { text-align: left; max-height: 82vh; overflow-y: auto; }
#gallery-overlay .panel h2 { text-align: center; }
.gallery-item { margin-bottom: 18px; }
.gi-title { font-weight: 800; color: #8fb7ff; margin-bottom: 6px; font-size: 15px; }
.gallery-item p { font-size: 13px; color: #c3c9d4; line-height: 1.9; margin-bottom: 4px; }

/* ---------------- 盘外升级 ---------------- */
#upg-pts { color: #ffc94d; font-weight: 800; margin-bottom: 14px; font-size: 15px; }
#upg-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.upg-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-soft);
  border-radius: 14px;
  padding: 10px 12px;
  text-align: left;
}
.upg-icon { font-size: 24px; flex-shrink: 0; }
.upg-info { flex: 1; min-width: 0; }
.upg-name { font-size: 14px; font-weight: 800; }
.upg-pips { color: #ffc94d; font-size: 11px; letter-spacing: 1px; margin-left: 4px; }
.upg-desc { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.upg-buy {
  flex-shrink: 0;
  border: none; cursor: pointer;
  background: var(--blue); color: #fff;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px; font-weight: 800;
  font-family: inherit;
}
.upg-buy:disabled { background: #4a5160; color: #9aa2ad; }
#upg-follow { font-size: 13px; padding: 11px 0; }
#result-gain { color: #ffc94d; font-weight: 800; margin-bottom: 10px; font-size: 15px; }

/* ---------------- 终局通关排行榜 ---------------- */
#rank-sub { font-size: 12px; color: var(--text-dim); margin-bottom: 10px; }
#rank-mine { color: #8fb7ff; font-weight: 800; font-size: 13px; margin-bottom: 12px; min-height: 16px; }
#rank-list {
  display: flex; flex-direction: column; gap: 8px;
  max-height: 46vh; overflow-y: auto;
  margin-bottom: 4px; text-align: left;
}
.rank-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-soft);
  border-radius: 12px; padding: 8px 12px;
}
.rank-row.top1 { background: linear-gradient(90deg, rgba(255, 201, 77, 0.22), rgba(255, 201, 77, 0.05)); }
.rank-row.top2 { background: linear-gradient(90deg, rgba(200, 210, 225, 0.18), rgba(200, 210, 225, 0.04)); }
.rank-row.top3 { background: linear-gradient(90deg, rgba(224, 152, 100, 0.18), rgba(224, 152, 100, 0.04)); }
.rank-no { width: 34px; text-align: center; font-weight: 900; font-size: 14px; color: var(--text-dim); flex-shrink: 0; }
.rank-row.top1 .rank-no, .rank-row.top2 .rank-no, .rank-row.top3 .rank-no { font-size: 19px; }
.rank-av { width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0; object-fit: cover; background: #31363f; }
.rank-av-ph { display: flex; align-items: center; justify-content: center; font-size: 15px; }
.rank-name {
  flex: 1; min-width: 0; font-size: 13px; font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rank-time { font-size: 13px; font-weight: 900; color: #ffc94d; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.rank-empty { text-align: center; color: var(--text-dim); font-size: 13px; line-height: 1.9; padding: 22px 0; }

/* ---------------- 全局弹窗（升级面板） ---------------- */
.overlay.overlay-global { position: fixed; z-index: 45; }

/* ---------------- 地盘属性浮层（长按） ---------------- */
#inspect-card {
  position: absolute;
  bottom: 20px; left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  padding: 10px 16px;
  font-size: 13px;
  line-height: 1.9;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 12;
  white-space: nowrap;
}
#inspect-card.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.ic-head { font-weight: 800; font-size: 14px; }
.ic-icon { margin-right: 4px; }
.ic-row b { color: #ffc94d; }
.ic-row { color: #c3c9d4; }

/* ---------------- Toast（全局固定，任何界面可见；放屏幕下方，避免遮挡上方地盘） ---------------- */
#toast {
  position: fixed;
  bottom: calc(112px + env(safe-area-inset-bottom, 0px)); left: 50%;
  transform: translate(-50%, 16px);
  background: var(--panel);
  border-radius: 14px;
  padding: 9px 18px;
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 50;
  max-width: 92vw;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- 远征遗物（无尽远征层间三选一） ---------------- */
#relic-sub { font-size: 12px; color: var(--text-dim); margin: -12px 0 4px; }
#relic-cards { display: flex; flex-direction: column; gap: 10px; margin: 12px 0 4px; }
.relic-card {
  display: flex; align-items: center; gap: 13px; text-align: left;
  background: rgba(63, 140, 255, 0.12);
  border: 2px solid rgba(63, 140, 255, 0.55);
  border-radius: 14px; padding: 13px 15px;
  color: #eef2f8; cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease;
}
.relic-card:active { transform: scale(0.97); background: rgba(63, 140, 255, 0.28); }
.relic-icon { font-size: 30px; line-height: 1; flex-shrink: 0; }
.relic-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.relic-name { font-weight: 800; font-size: 15px; }
.relic-own { font-style: normal; font-size: 12px; color: #9fd4e8; font-weight: 700; }
.relic-desc { font-size: 13px; color: #c3c9d4; line-height: 1.5; }
#relic-have { margin-top: 12px; font-size: 13px; color: #ffd76b; min-height: 18px; line-height: 1.6; }
.relic-have-label { color: var(--text-dim); }

/* 战斗 HUD 左上角遗物图标条：默认收起成 🎁×N 胶囊，点击展开 */
#hud-relics {
  position: absolute;
  top: 8px; left: 8px;
  display: flex; flex-wrap: wrap; gap: 4px;
  max-width: 62%;
  z-index: 6;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.relic-chip {
  background: rgba(20, 24, 30, 0.74);
  color: #ffd76b;
  border: 1px solid rgba(255, 215, 107, 0.35);
  border-radius: 9px;
  padding: 2px 7px;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.5;
}
.relic-chip i { font-style: normal; color: #fff; font-size: 11px; margin-left: 2px; }
.relic-toggle { border-color: rgba(159, 212, 232, 0.55); color: #9fd4e8; }

/* ---------------- 通用二次确认弹窗 ---------------- */
#confirm-msg { margin: -8px 0 16px; color: #c3c9d4; line-height: 1.7; font-size: 14px; }
