/* ============================================================
 * 保卫1002！ v2.0 — 全局样式
 * 手机横屏优先（640×360 / 664×375 / 844×390 / 915×412），竖屏亦可玩
 * ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #0b1018;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  color: #f2e9d8;
  user-select: none; -webkit-user-select: none;
  touch-action: none; -webkit-touch-callout: none;
  overscroll-behavior: none;
}

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

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

.hidden { display: none !important; }

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

#minimap {
  position: absolute; left: 8px; top: 8px;
  width: 120px; height: 120px;
  background: rgba(10, 14, 24, 0.55);
  border: 2px solid rgba(255, 214, 110, 0.55);
  border-radius: 8px;
}

#hud-left {
  position: absolute; left: 8px; top: 134px;
  display: flex; flex-direction: column; gap: 4px;
  width: 190px;
}
.bar-row { width: 100%; }
.bar {
  position: relative; width: 100%; height: 14px;
  background: rgba(8, 10, 18, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 7px; overflow: hidden;
}
.bar-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; border-radius: 6px; transition: width 0.12s; }
.bar-fill.hp { background: linear-gradient(180deg, #ff6b5e, #d32f2f); }
.bar-fill.mp { background: linear-gradient(180deg, #54b8ff, #1e63d0); width: 0%; }
.bar-fill.mp.full { box-shadow: 0 0 8px #54b8ff; }
.bar-text {
  position: absolute; inset: 0; text-align: center;
  font-size: 10px; line-height: 12px; color: #fff;
  text-shadow: 0 1px 2px #000; font-weight: 700;
}
.boss-bar { height: 12px; border-color: rgba(255, 120, 120, 0.5); }
.boss-bar > #boss-hp-fill, #boss-hp-fill { background: linear-gradient(180deg, #ff8a5e, #b71c1c); height: 100%; width: 100%; }

#lv-text {
  font-size: 13px; font-weight: 800; color: #ffd66d;
  text-shadow: 0 1px 3px #000; letter-spacing: 0.5px;
}

#exp-wrap {
  position: absolute; left: 50%; transform: translateX(-50%); top: 6px;
  width: min(46vw, 420px); height: 10px;
  background: rgba(8, 10, 18, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 5px; overflow: hidden;
}
#exp-fill {
  height: 100%; width: 0%;
  background: linear-gradient(180deg, #b9ff6e, #4caf50);
  border-radius: 4px; transition: width 0.15s;
}

#hud-topright {
  position: absolute; right: 8px; top: 8px;
  display: flex; flex-direction: column; align-items: flex-end; gap: 3px;
}
.tr-btns { display: flex; gap: 6px; pointer-events: auto; }
#btn-pause, #btn-mute {
  width: 48px; height: 48px;
  background: rgba(16, 22, 36, 0.78);
  color: #ffd66d; border: 2px solid rgba(255, 214, 110, 0.5);
  border-radius: 10px; font-size: 17px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
#btn-pause:active, #btn-mute:active { transform: scale(0.94); }
#stat-time, #stat-kill, #stat-stage {
  font-size: 12px; font-weight: 700; color: #ffe9b8;
  text-shadow: 0 1px 3px #000;
  background: rgba(10, 14, 24, 0.45); padding: 1px 8px; border-radius: 6px;
}
#stat-stage { color: #9fd8ff; }

/* 专属技能按钮：右下角，≥48px */
#skill-btn {
  position: absolute; right: 14px; bottom: 14px;
  width: 76px; height: 76px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #3a4a6b, #141a2c 75%);
  border: 2px solid rgba(255, 255, 255, 0.28);
  color: #cfd8ea; pointer-events: auto; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px; padding: 0;
}
#skill-btn .skill-ring {
  position: absolute; inset: -3px; border-radius: 50%;
  background: conic-gradient(#54b8ff calc(var(--mp, 0) * 1%), rgba(255,255,255,0.08) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 4px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 4px));
}
#skill-btn .skill-label { font-size: 13px; font-weight: 800; }
#skill-btn .skill-sub { font-size: 9px; opacity: 0.75; }
#skill-btn.ready {
  border-color: #ffd66d; color: #fff;
  box-shadow: 0 0 16px 4px rgba(255, 214, 110, 0.65), inset 0 0 12px rgba(255, 214, 109, 0.35);
  animation: skillPulse 1s ease-in-out infinite;
}
#skill-btn.ready .skill-sub { color: #ffd66d; }
@keyframes skillPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
#skill-btn:active { transform: scale(0.93); }

/* Boss 血条 */
#boss-hp-wrap {
  position: absolute; left: 50%; transform: translateX(-50%); top: 24px;
  width: min(60vw, 460px); text-align: center;
}
#boss-name { font-size: 13px; font-weight: 800; color: #ff9d8a; text-shadow: 0 1px 3px #000; margin-bottom: 2px; }

/* 回合提示 */
#round-tip {
  position: absolute; left: 50%; top: 34%; transform: translateX(-50%);
  font-size: 22px; font-weight: 900; color: #ffd66d;
  text-shadow: 0 2px 8px #000, 0 0 18px rgba(255, 214, 109, 0.5);
  animation: tipPop 0.35s ease;
}
@keyframes tipPop { from { transform: translateX(-50%) scale(0.6); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }

/* 低血量红晕 */
#lowhp-vignette {
  position: absolute; inset: 0; pointer-events: none; opacity: 0;
  box-shadow: inset 0 0 90px 30px rgba(210, 30, 30, 0.55);
  transition: opacity 0.3s;
}
#lowhp-vignette.on { opacity: 1; animation: vigPulse 1.2s ease-in-out infinite; }
@keyframes vigPulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }

/* 临时增益图标 */
#buff-bar {
  position: absolute; left: 8px; bottom: 10px;
  display: flex; gap: 6px;
}
.buff-chip {
  background: rgba(16, 22, 36, 0.8); border: 1px solid rgba(155, 205, 255, 0.5);
  color: #bfe0ff; font-size: 11px; font-weight: 700;
  padding: 3px 8px; border-radius: 8px;
}

/* ============================================================
 * 全屏界面（标题 / 选角 / 结算）
 * ============================================================ */
.screen {
  position: absolute; inset: 0; z-index: 20;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 35%, #1b2a45 0%, #0b1018 70%);
  padding: 12px; overflow: hidden;
}
.screen-title { font-size: clamp(18px, 4.5vmin, 26px); color: #ffd66d; margin-bottom: 10px; letter-spacing: 2px; }

.title-box { text-align: center; max-width: 640px; }
.title-sub { font-size: clamp(11px, 2.6vmin, 14px); color: #8fb0d9; letter-spacing: 4px; margin-bottom: 6px; }
.title-main {
  font-size: clamp(40px, 11vmin, 84px); font-weight: 900; letter-spacing: 4px;
  background: linear-gradient(180deg, #ffe9a8 15%, #ffb03a 55%, #ff7a3a 90%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 0 rgba(120, 40, 0, 0.45)) drop-shadow(0 0 26px rgba(255, 170, 60, 0.35));
  margin-bottom: 4px;
}
.mode-row { display: flex; gap: 12px; justify-content: center; margin: 14px 0 16px; }
.mode-btn {
  min-width: 132px; min-height: 48px; padding: 8px 14px;
  background: rgba(22, 32, 54, 0.9); color: #cfe0f5;
  border: 2px solid rgba(255, 255, 255, 0.18); border-radius: 12px;
  font-size: 15px; font-weight: 800; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.mode-desc { font-size: 10px; font-weight: 500; opacity: 0.7; }
.mode-btn.selected { border-color: #ffd66d; color: #ffe9b8; box-shadow: 0 0 14px rgba(255, 214, 109, 0.35); background: rgba(60, 48, 24, 0.85); }
.big-btn {
  min-width: 180px; min-height: 48px; padding: 10px 26px;
  background: linear-gradient(180deg, #ffcf5e, #f49b2e);
  color: #3a2404; border: none; border-radius: 12px;
  font-size: 17px; font-weight: 900; letter-spacing: 2px; cursor: pointer;
  box-shadow: 0 4px 0 #a35f10, 0 6px 14px rgba(0, 0, 0, 0.45);
}
.big-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #a35f10; }
.text-btn {
  min-height: 48px; padding: 8px 18px; margin-top: 8px;
  background: transparent; color: #9fd0ff; border: none;
  font-size: 14px; font-weight: 700; cursor: pointer; text-decoration: underline;
}
.save-hint { margin-top: 14px; font-size: 11px; color: #7f95b5; }
.author { margin-top: 4px; font-size: 12px; color: #b8c6dd; letter-spacing: 1px; }

/* ============================================================
 * 选角界面
 * ============================================================ */
#char-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  width: min(96vw, 860px); max-height: 62vh; overflow-y: auto; padding: 4px;
}
.char-card {
  background: rgba(20, 28, 48, 0.92);
  border: 2px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px; padding: 8px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-height: 48px;
}
.char-card.selected { border-color: #ffd66d; box-shadow: 0 0 14px rgba(255, 214, 109, 0.4); background: rgba(52, 44, 22, 0.92); }
.char-card img { width: clamp(52px, 9vmin, 84px); height: auto; image-rendering: pixelated; }
.char-name { font-size: 14px; font-weight: 900; color: #ffe9b8; }
.char-role { font-size: 11px; color: #9fd8ff; }
.char-weapon { font-size: 10px; color: #c9b8f5; }
.char-skill { font-size: 10px; color: #ffb27a; text-align: center; line-height: 1.35; }
.select-bar { margin-top: 10px; display: flex; flex-direction: column; align-items: center; }

/* ============================================================
 * 弹窗（升级 / 宝箱 / 暂停 / 日志）
 * ============================================================ */
.modal-mask {
  position: absolute; inset: 0; z-index: 30;
  background: rgba(5, 8, 14, 0.72);
  display: flex; align-items: center; justify-content: center;
  padding: 10px;
}
.modal {
  background: linear-gradient(180deg, #1a2440, #121a2e);
  border: 2px solid rgba(255, 214, 110, 0.4);
  border-radius: 16px; padding: clamp(10px, 2.5vmin, 22px);
  width: min(96vw, 760px); max-height: 92vh; overflow-y: auto;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}
.modal-title { font-size: clamp(16px, 3.6vmin, 22px); font-weight: 900; color: #ffd66d; margin-bottom: 12px; letter-spacing: 2px; }

.card-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.pick-card {
  width: min(30vw, 200px); min-width: 150px; min-height: 48px;
  background: rgba(12, 18, 34, 0.95);
  border: 2px solid var(--rc, #8a8f9e); border-radius: 12px;
  padding: 12px 10px; cursor: pointer; color: #e8eefb;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  transition: transform 0.12s;
}
.pick-card:active { transform: scale(0.96); }
.pick-card .pc-rarity { font-size: 10px; font-weight: 800; color: var(--rc, #aaa); letter-spacing: 1px; }
.pick-card .pc-name { font-size: 15px; font-weight: 900; }
.pick-card .pc-desc { font-size: 12px; color: #b9c6dd; line-height: 1.5; }
.pick-card .pc-mul { font-size: 11px; color: #ffb27a; font-weight: 700; }
.pick-card.heal { --rc: #6fd96f; }
.pick-card.heal .pc-rarity { color: #6fd96f; }

.pause-modal { width: min(92vw, 380px); }
.pause-info { font-size: 12px; color: #b9c6dd; line-height: 1.8; margin-bottom: 10px; }
.pause-btns { display: flex; flex-direction: column; align-items: center; }

.log-modal { width: min(96vw, 640px); text-align: left; }
.log-entry { border-left: 3px solid #ffd66d; padding: 4px 0 4px 12px; margin-bottom: 14px; }
.log-ver { font-size: 16px; font-weight: 900; color: #ffe9b8; }
.log-date { font-size: 11px; color: #7f95b5; margin-bottom: 4px; }
.log-entry ul { list-style: none; }
.log-entry li { font-size: 12.5px; color: #c6d2e6; line-height: 1.7; padding-left: 14px; position: relative; }
.log-entry li::before { content: "•"; position: absolute; left: 0; color: #ffd66d; }

/* ============================================================
 * 结算
 * ============================================================ */
.settle-box {
  background: linear-gradient(180deg, #1a2440, #101828);
  border: 2px solid rgba(255, 214, 110, 0.45);
  border-radius: 16px; padding: clamp(12px, 3vmin, 26px);
  width: min(96vw, 560px); max-height: 92vh; overflow-y: auto;
  text-align: center;
}
#settle-list { text-align: left; margin: 8px auto 12px; max-width: 440px; }
.settle-item {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: 13px; padding: 5px 8px; border-radius: 8px;
}
.settle-item:nth-child(odd) { background: rgba(255, 255, 255, 0.045); }
.settle-item .k { color: #9fb0cc; }
.settle-item .v { color: #ffe9b8; font-weight: 800; text-align: right; }
.settle-item.buffs .v { font-weight: 500; font-size: 12px; }
#settle-rank {
  font-size: clamp(20px, 5vmin, 30px); font-weight: 900; color: #ffd66d;
  text-shadow: 0 0 18px rgba(255, 214, 109, 0.5); margin: 6px 0 10px;
}
.settle-btns { display: flex; flex-direction: column; align-items: center; }

/* ============================================================
 * 开场播片 / 关卡导语 / Boss 登场 / Toast
 * ============================================================ */
#cutscene {
  position: absolute; inset: 0; z-index: 40;
  background: rgba(4, 6, 12, 0.94);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px; text-align: center; cursor: pointer;
}
#cutscene-text {
  max-width: 620px; font-size: clamp(15px, 3.4vmin, 20px); line-height: 2;
  color: #e8e2d0; white-space: pre-wrap;
}
#btn-cutscene-skip {
  position: absolute; right: 16px; bottom: 16px;
  min-width: 88px; min-height: 48px; padding: 10px 18px;
  background: rgba(30, 40, 64, 0.9); color: #ffd66d;
  border: 1px solid rgba(255, 214, 109, 0.5); border-radius: 10px;
  font-size: 14px; font-weight: 700; cursor: pointer;
}

#level-intro {
  position: absolute; inset: 0; z-index: 35;
  background: rgba(5, 8, 14, 0.66);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
#level-intro-card {
  background: linear-gradient(180deg, #22304f, #141d33);
  border: 2px solid rgba(255, 214, 110, 0.55); border-radius: 14px;
  padding: clamp(14px, 3.4vmin, 28px) clamp(16px, 4vmin, 36px);
  max-width: min(88vw, 520px); text-align: center;
  animation: cardIn 0.3s ease;
}
@keyframes cardIn { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
#level-intro-name { font-size: clamp(17px, 4vmin, 24px); font-weight: 900; color: #ffd66d; margin-bottom: 8px; }
#level-intro-text { font-size: clamp(13px, 2.9vmin, 16px); line-height: 1.9; color: #dfe6f2; }
#level-intro-tip { margin-top: 10px; font-size: 11px; color: #7f95b5; }

#boss-intro {
  position: absolute; left: 0; right: 0; top: 16%; z-index: 36;
  display: flex; flex-direction: column; align-items: center; pointer-events: none;
}
#boss-intro-bubble {
  background: rgba(20, 26, 44, 0.92); border: 2px solid rgba(255, 120, 120, 0.6);
  color: #ffd2c2; font-size: clamp(13px, 3vmin, 17px); font-weight: 800;
  padding: 10px 18px; border-radius: 14px; max-width: min(80vw, 460px); text-align: center;
  animation: cardIn 0.25s ease;
}
#boss-intro-sub {
  margin-top: 10px; font-size: clamp(12px, 2.6vmin, 15px); color: #ffe9b8;
  text-shadow: 0 1px 4px #000; max-width: 86vw; text-align: center;
}

#toast {
  position: absolute; left: 50%; transform: translateX(-50%); top: 18%; z-index: 45;
  background: rgba(16, 22, 36, 0.9); border: 1px solid rgba(255, 214, 109, 0.45);
  color: #ffe9b8; font-size: 13px; font-weight: 700;
  padding: 8px 18px; border-radius: 10px; pointer-events: none;
}

/* 竖屏微调：技能按钮与血条上移避开底部手势区 */
@media (max-aspect-ratio: 3/4) {
  #skill-btn { bottom: 20px; }
  #hud-left { top: 136px; width: min(52vw, 220px); }
}
