/* =========================================================
   塔防18 · 三国塔防 H5
   ========================================================= */
:root {
  --orange: #FF8A3D;
  --orange-deep: #E8671B;
  --orange-dark: #B94D13;
  --orange-soft: #FFE2C6;
  --ink: #241A20;
  --ink-2: #5C4A4E;
  --muted: #9A8579;
  --paper: #FFF8EC;
  --paper-2: #F6E6C9;
  --line: rgba(84, 50, 40, .12);
  --green: #3F9460;
  --green-dark: #256B42;
  --red: #E4493B;
  --gold: #F2B23E;
  --shadow-sm: 0 2px 8px rgba(58, 28, 20, .08);
  --shadow: 0 10px 30px rgba(58, 28, 20, .16);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #160D1C;
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
button {
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
}
button:active { transform: scale(.97); }
.mp-icon { flex: none; }

#app {
  position: fixed;
  inset: 0;
  max-width: 560px;
  margin: 0 auto;
  overflow: hidden;
  background: #160D1C;
  box-shadow: 0 0 90px rgba(0, 0, 0, .55);
}

.screen {
  position: absolute;
  inset: 0;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease;
}
.screen.active {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

/* =========================================================
   首页
   ========================================================= */
.home {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  background: #160D1C;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}
.home::-webkit-scrollbar { display: none; }

.home-hero {
  position: relative;
  flex: none;
  height: clamp(300px, 44vh, 390px);
  overflow: hidden;
  background: #C95244;
}
.hero-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 62% 52%;
}
.hero-shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(20, 10, 24, .55) 0%, rgba(20, 10, 24, 0) 26%),
    linear-gradient(0deg, rgba(22, 13, 28, .82) 0%, rgba(22, 13, 28, 0) 42%);
  pointer-events: none;
}
.hero-safe {
  position: absolute;
  inset: 0;
  padding: calc(var(--safe-top) + 12px) 16px 0;
  display: flex;
  flex-direction: column;
}

.player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.player-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 12px 5px 5px;
  border-radius: 999px;
  background: rgba(30, 16, 28, .44);
  border: 1px solid rgba(255, 236, 210, .24);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: #FFF8EA;
  text-align: left;
  max-width: 66%;
}
.player-chip:active { transform: scale(.98); }
.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 17px;
  font-weight: 900;
  color: #FFF9ED;
  background: linear-gradient(145deg, #FFB25E, #E8671B);
  border: 2px solid rgba(255, 248, 234, .8);
  box-shadow: 0 4px 10px rgba(0, 0, 0, .25);
  overflow: hidden;
  flex: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.player-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.player-meta b {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-meta small { font-size: 9.5px; color: rgba(255, 240, 220, .64); margin-top: 3px; }
.chip-edit { width: 14px !important; height: 14px !important; color: rgba(255, 244, 226, .6); }

.home-actions { display: flex; gap: 8px; }
.round-btn {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(30, 16, 28, .44);
  border: 1px solid rgba(255, 236, 210, .24);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: #FFF3DF;
}
.round-btn .mp-icon { width: 20px; height: 20px; }
.round-btn .dot {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 0 2px rgba(30, 16, 28, .7);
}

.brand {
  margin-top: auto;
  padding-bottom: 42px;
  color: #FFF8EA;
}
.brand-kicker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 3px;
  color: #FFD2A6;
  text-shadow: 0 2px 8px rgba(24, 10, 20, .7);
  margin-bottom: 4px;
}
.brand-kicker::before {
  content: "";
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: var(--orange);
}
.brand-title {
  margin: 0;
  font-size: clamp(44px, 14vw, 58px);
  line-height: 1;
  font-weight: 900;
  letter-spacing: -2px;
  color: #FFF9EC;
  text-shadow:
    0 2px 0 rgba(122, 50, 22, .5),
    0 10px 26px rgba(18, 8, 18, .6),
    0 0 40px rgba(255, 138, 61, .3);
}
.brand-sub {
  margin: 9px 0 0;
  font-size: 11.5px;
  letter-spacing: 1px;
  color: rgba(255, 240, 220, .76);
  text-shadow: 0 2px 8px rgba(18, 8, 18, .7);
}
.hero-badge {
  position: absolute;
  right: 14px;
  bottom: 14px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(24, 12, 24, .46);
  border: 1px solid rgba(255, 226, 190, .18);
  backdrop-filter: blur(10px);
  color: rgba(255, 240, 220, .78);
  font-size: 9.5px;
  letter-spacing: .3px;
}
.hero-badge .mp-icon { width: 13px; height: 13px; color: #FFC58F; }

/* 地图羊皮纸 */
.map-wrap {
  position: relative;
  z-index: 2;
  margin-top: -22px;
  border-radius: 26px 26px 0 0;
  padding: 20px 16px 0;
  background:
    radial-gradient(circle at 14% 6%, rgba(255, 255, 255, .7), transparent 38%),
    radial-gradient(circle at 86% 62%, rgba(214, 168, 104, .16), transparent 44%),
    linear-gradient(180deg, #FFF9EE 0%, #F9EDD6 42%, #F4E2C2 100%);
  box-shadow: 0 -14px 30px rgba(18, 8, 18, .3), inset 0 1px 0 rgba(255, 255, 255, .9);
}
.map-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 2px 12px;
}
.map-head h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -.4px;
  color: var(--ink);
}
.map-head p { margin: 4px 0 0; font-size: 10.5px; color: var(--muted); letter-spacing: .5px; }
.star-total {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 7px 11px;
  border-radius: 999px;
  background: #FFFDF7;
  border: 1px solid rgba(178, 126, 66, .22);
  box-shadow: var(--shadow-sm);
  font-size: 12px;
  font-weight: 800;
  color: #A66B24;
}
.star-total .mp-icon { width: 17px; height: 17px; color: var(--gold); }
.star-total b { font-size: 15px; }
.star-total span { font-size: 10px; color: #B99A70; font-weight: 600; }

.trail {
  position: relative;
  height: 684px;
  margin: 0 -4px;
}
.trail-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.trail-svg path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.trail-edge { stroke: rgba(145, 94, 45, .22); stroke-width: 11; vector-effect: non-scaling-stroke; }
.trail-line {
  stroke: #E69A4B;
  stroke-width: 3.5;
  stroke-dasharray: 7 9;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 2px 0 rgba(255, 255, 255, .65));
}
.trail-nodes { position: absolute; inset: 0; }

.level-node {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 88px;
  padding: 0;
  background: none;
  color: var(--ink);
}
.node-circle {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 19px;
  font-weight: 900;
  color: #FFF9ED;
  background: linear-gradient(160deg, #FFB15F 0%, #F47B2B 72%, #DA5E14 100%);
  border: 3px solid #FFF9ED;
  box-shadow: 0 6px 0 #BF5A17, 0 12px 18px rgba(160, 76, 22, .26);
  transition: transform .16s ease;
}
.level-node:active .node-circle { transform: translateY(3px) scale(.97); box-shadow: 0 3px 0 #BF5A17, 0 6px 10px rgba(160, 76, 22, .24); }
.level-node .node-name {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .2px;
  color: #5D4632;
  max-width: 88px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 0 rgba(255, 252, 245, .9);
}
.node-stars { display: flex; gap: 1px; height: 11px; }
.node-stars .mp-icon { width: 11px; height: 11px; color: #D6C3A4; }
.node-stars .mp-icon.on { color: var(--gold); filter: drop-shadow(0 1px 0 rgba(160, 100, 10, .25)); }
.node-lock {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(74, 54, 46, .52);
  color: #FFF3DF;
  backdrop-filter: blur(1px);
}
.node-lock .mp-icon { width: 20px; height: 20px; }
.level-node.locked .node-circle {
  background: linear-gradient(160deg, #E5D6BF, #D2BDA0);
  box-shadow: 0 5px 0 #B8A180, 0 8px 14px rgba(120, 90, 55, .15);
  color: #947B60;
}
.level-node.locked .node-name { color: #A18B71; }
.level-node.locked .node-stars { visibility: hidden; }
.level-node.current .node-circle::before {
  content: "";
  position: absolute;
  inset: -9px;
  border-radius: 50%;
  border: 2px solid rgba(255, 138, 61, .5);
  animation: ringPulse 1.9s ease-out infinite;
}
.level-node.current .node-circle::after {
  content: "挑战";
  position: absolute;
  top: -12px;
  right: -20px;
  padding: 2px 6px;
  border-radius: 999px;
  background: #2C1B24;
  color: #FFD8AE;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: .5px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .25);
}
.level-node.cleared .node-circle { filter: saturate(.94); }
.level-node .node-clear {
  position: absolute;
  right: -2px;
  bottom: -1px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--green);
  border: 2px solid #FFF9ED;
  color: #fff;
}
.level-node .node-clear .mp-icon { width: 11px; height: 11px; }

.faction-tip {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 2px 2px 8px;
  padding: 12px 13px;
  border-radius: 16px;
  background: #FFFCF5;
  border: 1px solid rgba(178, 126, 66, .2);
  box-shadow: var(--shadow-sm);
}
.tip-icon {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: linear-gradient(150deg, #FFE2C4, #FFD0A2);
  color: #C4691C;
}
.tip-icon .mp-icon { width: 19px; height: 19px; }
.faction-tip p { margin: 0; font-size: 10.5px; line-height: 1.65; color: #7A6252; }
.faction-tip b { color: #4F382A; }
.faction-tip em { font-style: normal; font-weight: 800; color: var(--orange-deep); }
.map-foot-space { height: 120px; }

.home-dock {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  z-index: 5;
  width: 100%;
  max-width: 560px;
  padding: 14px 16px calc(12px + var(--safe-bottom));
  background: linear-gradient(180deg, rgba(22, 13, 28, 0) 0%, rgba(22, 13, 28, .9) 34%, #160D1C 100%);
}
.home-dock::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 120%;
  z-index: -1;
  background: linear-gradient(180deg, rgba(22, 13, 28, 0) 0%, #160D1C 42%);
  pointer-events: none;
}

/* 通用主按钮 */
.cta {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 60px;
  padding: 12px 18px;
  border-radius: 19px;
  overflow: hidden;
  color: #FFF9ED;
  background: linear-gradient(180deg, #FFA65A 0%, #F57A2C 60%, #EA691A 100%);
  box-shadow: 0 7px 0 #B34B11, 0 16px 30px rgba(234, 105, 26, .3), inset 0 1px 0 rgba(255, 255, 255, .35);
  transition: transform .12s ease, box-shadow .12s ease;
}
.cta:active {
  transform: translateY(4px) scale(.995);
  box-shadow: 0 3px 0 #B34B11, 0 8px 16px rgba(234, 105, 26, .26), inset 0 1px 0 rgba(255, 255, 255, .3);
}
.cta-glow {
  position: absolute;
  top: -40%;
  left: -10%;
  width: 60%;
  height: 110%;
  background: radial-gradient(ellipse at center, rgba(255, 255, 255, .38), transparent 68%);
  pointer-events: none;
}
.cta-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; z-index: 1; }
.cta-text small { font-size: 9.5px; letter-spacing: 2px; color: rgba(255, 246, 228, .78); font-weight: 600; }
.cta-text b { font-size: 18px; font-weight: 900; letter-spacing: 1px; }
.cta > .mp-icon { width: 24px; height: 24px; z-index: 1; }
.main-cta { justify-content: flex-start; padding-left: 22px; }
.main-cta .cta-text { flex: 1; }
.main-cta > .mp-icon { width: 22px; height: 22px; margin-right: 4px; }
.cta.small { min-height: 50px; border-radius: 16px; font-size: 15px; font-weight: 800; }

/* =========================================================
   战斗页
   ========================================================= */
.game { background: #0F1611; }
#gameCanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.game-ui { position: absolute; inset: 0; pointer-events: none; }
.game-ui button { pointer-events: auto; }

.game-top {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(var(--safe-top) + 10px) 12px 0;
}
.hud-icon {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  color: #FFF5E4;
  background: rgba(20, 15, 22, .5);
  border: 1px solid rgba(255, 238, 214, .16);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, .18);
}
.hud-icon .mp-icon { width: 20px; height: 20px; }
.hud-icon.speed {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: -.2px;
  color: #FFD3A6;
}
.hud-icon.speed.fast { color: #FFE4A6; background: rgba(255, 138, 61, .24); border-color: rgba(255, 168, 96, .45); }
.hud-level {
  flex: 1;
  min-width: 0;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border-radius: 13px;
  background: rgba(20, 15, 22, .42);
  border: 1px solid rgba(255, 238, 214, .13);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #FFF2DE;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-stats {
  display: flex;
  justify-content: center;
  gap: 7px;
  padding: 9px 12px 0;
}
.stat-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 5px 8px;
  border-radius: 12px;
  background: rgba(18, 14, 20, .48);
  border: 1px solid rgba(255, 238, 214, .12);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #FFF7E8;
}
.stat-pill .mp-icon { width: 15px; height: 15px; color: #FFC68F; }
.stat-pill.danger .mp-icon { color: #FF8A7A; }
.stat-pill.gold .mp-icon { color: var(--gold); }
.stat-copy { display: flex; flex-direction: column; line-height: 1.05; }
.stat-copy small { font-size: 8px; color: rgba(255, 240, 220, .58); letter-spacing: .6px; }
.stat-copy b { font-size: 12.5px; font-weight: 800; letter-spacing: -.2px; }
.stat-copy b em { font-style: normal; font-size: 9px; font-weight: 600; color: rgba(255, 240, 220, .48); margin-left: 1px; }
.stat-pill.danger b { color: #FFD8D0; }
.stat-pill.danger.alarm { border-color: rgba(228, 73, 59, .55); background: rgba(90, 20, 20, .55); animation: alarmPulse 1s ease-in-out infinite; }
.stat-pill.danger.alarm b { color: #FFB2A6; }

.wave-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px 0;
}
.wave-strip-bar {
  flex: 1;
  height: 5px;
  border-radius: 99px;
  background: rgba(255, 246, 230, .16);
  overflow: hidden;
}
.wave-strip-bar span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, #FFB05F, #FF7A2C);
  box-shadow: 0 0 8px rgba(255, 138, 61, .6);
  transition: width .28s ease;
}
.wave-strip > span {
  flex: none;
  max-width: 160px;
  font-size: 9.5px;
  color: rgba(255, 243, 226, .72);
  letter-spacing: .3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.next-wave-wrap {
  display: flex;
  justify-content: flex-end;
  padding: 8px 14px 0;
}
.next-wave {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px 11px;
  border-radius: 999px;
  background: rgba(255, 138, 61, .18);
  border: 1px solid rgba(255, 168, 100, .42);
  color: #FFD9B3;
  font-size: 10px;
  font-weight: 700;
  backdrop-filter: blur(8px);
}
.next-wave .mp-icon { width: 13px; height: 13px; }
.next-wave:disabled { opacity: .4; }

/* 底部武将栏 */
.hero-dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 20px 12px calc(10px + var(--safe-bottom));
  background: linear-gradient(180deg, rgba(10, 16, 11, 0) 0%, rgba(10, 16, 11, .8) 20%, #0E1510 52%, #0C120D 100%);
  pointer-events: auto;
}
.dock-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 0 4px 2px;
  color: #FFF3DF;
}
.dock-head span:first-child { font-size: 12px; font-weight: 800; letter-spacing: .3px; }
.dock-head span:last-child { font-size: 9.5px; color: rgba(255, 236, 212, .54); }
.hero-scroll {
  display: flex;
  gap: 8px;
  padding: 8px 2px 6px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.hero-scroll::-webkit-scrollbar { display: none; }
.hero-card {
  position: relative;
  flex: none;
  width: 72px;
  padding: 7px 4px 7px;
  border-radius: 15px;
  background: rgba(255, 247, 233, .075);
  border: 1.5px solid rgba(255, 244, 226, .12);
  color: #FFF6E7;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: transform .14s ease, border-color .14s ease, background .14s ease;
}
.hero-card:active { transform: scale(.95); }
.hero-card.selected {
  background: rgba(255, 138, 61, .17);
  border-color: rgba(255, 166, 92, .85);
  box-shadow: 0 0 0 2px rgba(255, 138, 61, .18), 0 8px 18px rgba(0, 0, 0, .24);
  transform: translateY(-4px);
}
.hero-card.unaffordable { opacity: .52; }
.hero-card.locked { opacity: .36; }
.hero-portrait {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 900;
  color: #FFFCF2;
  border: 2px solid rgba(255, 250, 240, .55);
  box-shadow: inset 0 -6px 10px rgba(0, 0, 0, .2), 0 3px 8px rgba(0, 0, 0, .25);
  background: var(--faction, #888);
}
.hero-card .hero-name { font-size: 11px; font-weight: 800; letter-spacing: .2px; }
.hero-card .hero-cost {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 9.5px;
  font-weight: 700;
  color: #FFD28F;
}
.hero-card .hero-cost .mp-icon { width: 11px; height: 11px; }
.hero-card .hero-lock {
  position: absolute;
  inset: 0;
  border-radius: 15px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: rgba(10, 14, 10, .6);
  color: #FFE9CA;
  font-size: 8px;
}
.hero-card .hero-lock .mp-icon { width: 16px; height: 16px; }
.faction-name {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 7px;
  font-weight: 900;
  color: #fff;
  background: rgba(18, 16, 20, .55);
  border: 1px solid rgba(255, 255, 255, .2);
}

/* 已选武将面板 */
.tower-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 15px 14px calc(12px + var(--safe-bottom));
  border-radius: 24px 24px 0 0;
  background: linear-gradient(180deg, rgba(24, 31, 25, .98), #111812);
  border-top: 1px solid rgba(255, 235, 206, .12);
  box-shadow: 0 -14px 34px rgba(0, 0, 0, .36);
  color: #FFF6E7;
  pointer-events: auto;
  animation: sheetUp .2s ease;
}
.tp-head { display: flex; align-items: center; gap: 10px; }
.tp-portrait {
  width: 46px;
  height: 46px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  font-size: 21px;
  font-weight: 900;
  color: #fff;
  border: 2px solid rgba(255, 250, 240, .5);
  box-shadow: 0 4px 10px rgba(0, 0, 0, .28);
}
.tp-title { flex: 1; min-width: 0; }
.tp-title b { display: block; font-size: 15px; font-weight: 900; letter-spacing: .4px; }
.tp-title small { display: block; margin-top: 3px; font-size: 9.5px; color: rgba(255, 240, 218, .58); }
.tp-title small em { font-style: normal; color: #FFC183; }
.tp-close {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, .07);
  color: rgba(255, 243, 226, .7);
}
.tp-close .mp-icon { width: 17px; height: 17px; }
.tp-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 11px 0 10px;
}
.tp-stat {
  padding: 6px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .055);
  border: 1px solid rgba(255, 244, 226, .07);
}
.tp-stat small { display: block; font-size: 8px; color: rgba(255, 240, 220, .45); letter-spacing: .5px; }
.tp-stat b { display: block; margin-top: 2px; font-size: 12px; font-weight: 800; color: #FFEBD2; }
.tp-stat b em { font-style: normal; font-size: 9px; color: #8FD8A4; margin-left: 2px; }
.tp-actions { display: flex; gap: 7px; }
.tp-btn {
  flex: 1;
  min-height: 46px;
  border-radius: 13px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  font-weight: 800;
  color: #FFF8EB;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 244, 226, .1);
}
.tp-btn small { font-size: 8.5px; font-weight: 600; color: rgba(255, 244, 226, .55); }
.tp-btn .mp-icon { width: 17px; height: 17px; }
.tp-btn.upgrade {
  background: linear-gradient(180deg, #FFA85C, #EE731F);
  border-color: transparent;
  box-shadow: 0 5px 0 #AF4B10;
  color: #FFF9EE;
}
.tp-btn.upgrade small { color: rgba(255, 248, 234, .75); }
.tp-btn.skill { background: linear-gradient(180deg, #4E9E74, #2F7650); border-color: transparent; box-shadow: 0 5px 0 #1D5637; }
.tp-btn.skill small { color: rgba(235, 255, 240, .7); }
.tp-btn.sell { flex: .78; background: rgba(255, 255, 255, .06); }
.tp-btn:disabled { opacity: .38; box-shadow: none; }
.tp-skill-cd { color: #FFD9B0; }

/* 暂停 */
.pause-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(8, 10, 8, .62);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  pointer-events: auto;
}
.pause-card {
  width: 100%;
  max-width: 320px;
  padding: 24px 22px 22px;
  border-radius: 24px;
  background: linear-gradient(180deg, #FFF9EF, #F7E8CE);
  border: 1px solid rgba(255, 255, 255, .7);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
  text-align: center;
  animation: popIn .22s ease;
}
.pause-seal {
  width: 52px;
  height: 52px;
  margin: 0 auto 10px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 23px;
  font-weight: 900;
  color: #FFF8EA;
  background: linear-gradient(160deg, #FFA65A, #E8671B);
  box-shadow: 0 6px 0 #B34B11;
}
.pause-card h3 { margin: 12px 0 4px; font-size: 20px; font-weight: 900; }
.pause-card p { margin: 0 0 16px; font-size: 11px; color: var(--muted); }
.pause-card .cta { margin-bottom: 10px; }
.ghost-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-height: 44px;
  margin-top: 8px;
  border-radius: 13px;
  border: 1px solid rgba(110, 76, 48, .2);
  background: rgba(255, 253, 247, .7);
  color: #6C5140;
  font-size: 12.5px;
  font-weight: 700;
}
.ghost-btn .mp-icon { width: 17px; height: 17px; }

/* =========================================================
   出征准备
   ========================================================= */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(10, 6, 12, .58);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}
.sheet-panel {
  width: 100%;
  max-width: 520px;
  max-height: 93vh;
  overflow-y: auto;
  padding: 8px 16px 0;
  border-radius: 26px 26px 0 0;
  background:
    radial-gradient(circle at 20% 0%, rgba(255, 255, 255, .8), transparent 40%),
    linear-gradient(180deg, #FFF9EF, #F7E9D1);
  box-shadow: 0 -20px 60px rgba(0, 0, 0, .4);
  animation: sheetUp .26s cubic-bezier(.2, .8, .3, 1);
}
.sheet-panel::-webkit-scrollbar { display: none; }
.sheet-grip {
  width: 38px;
  height: 4px;
  border-radius: 99px;
  background: #D9C5A8;
  margin: 4px auto 12px;
}
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.sheet-head small { font-size: 10px; font-weight: 800; color: var(--orange-deep); letter-spacing: 2px; }
.sheet-head h3 { margin: 3px 0 0; font-size: 23px; font-weight: 900; letter-spacing: -.5px; }
.sheet-head .hud-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(110, 76, 48, .08);
  border-color: rgba(110, 76, 48, .12);
  color: #6C5140;
}
.battle-preview {
  position: relative;
  margin: 14px 0 4px;
  border-radius: 18px;
  overflow: hidden;
  background: #16251B;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08), 0 8px 18px rgba(60, 34, 18, .16);
}
#previewCanvas { display: block; width: 100%; height: auto; aspect-ratio: 32 / 15; }
.preview-info {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 26px 13px 10px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  background: linear-gradient(0deg, rgba(8, 14, 9, .88), rgba(8, 14, 9, 0));
  color: #FFF6E6;
}
.preview-map { font-size: 14px; font-weight: 900; letter-spacing: .6px; }
.preview-tags { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
.preview-tags span {
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .14);
  font-size: 8.5px;
  color: rgba(255, 246, 230, .86);
}
.sheet-section { margin-top: 14px; }
.section-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12.5px;
  font-weight: 800;
  color: #4F382A;
}
.section-label span { font-size: 9px; font-weight: 500; color: #A18B71; letter-spacing: .2px; }
.map-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.map-card {
  padding: 5px 5px 7px;
  border-radius: 14px;
  border: 2px solid rgba(145, 100, 55, .13);
  background: #FFFCF5;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: border-color .14s ease, transform .14s ease;
}
.map-card svg { display: block; width: 100%; height: 56px; border-radius: 9px; background: #1C2A20; }
.map-card b { display: block; margin-top: 5px; font-size: 11px; font-weight: 800; color: #513A2A; }
.map-card small { display: block; margin-top: 1px; font-size: 8px; color: #A18B71; }
.map-card.selected { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(255, 138, 61, .16), var(--shadow-sm); transform: translateY(-1px); }
.map-card:active { transform: scale(.97); }
.diff-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.diff-btn {
  padding: 9px 4px;
  border-radius: 13px;
  border: 1.5px solid rgba(145, 100, 55, .15);
  background: #FFFCF5;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.diff-btn b { display: block; font-size: 12.5px; font-weight: 800; color: #513A2A; }
.diff-btn small { display: block; margin-top: 2px; font-size: 8px; color: #A18B71; }
.diff-btn.selected {
  border-color: transparent;
  background: linear-gradient(180deg, #FFA65A, #F0782B);
  box-shadow: 0 4px 0 #B34B11;
  transform: translateY(-1px);
}
.diff-btn.selected b, .diff-btn.selected small { color: #FFF9ED; }
.diff-btn.selected small { color: rgba(255, 249, 237, .75); }
.battle-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 14px 0 12px;
}
.meta-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(255, 252, 245, .8);
  border: 1px solid rgba(145, 100, 55, .16);
  font-size: 9.5px;
  color: #7A6252;
}
.meta-chip .mp-icon { width: 13px; height: 13px; color: #C4691C; }
.meta-chip b { color: #4F382A; font-weight: 800; }
.start-cta { margin-bottom: 6px; }
.sheet-safe { height: calc(10px + var(--safe-bottom)); }

/* =========================================================
   弹窗
   ========================================================= */
.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(9, 6, 11, .62);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.modal-card {
  width: 100%;
  max-width: 440px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 20px;
  border-radius: 24px;
  background:
    radial-gradient(circle at 18% 0%, rgba(255, 255, 255, .85), transparent 42%),
    linear-gradient(180deg, #FFF9EF, #F7E9D1);
  border: 1px solid rgba(255, 255, 255, .7);
  box-shadow: 0 26px 70px rgba(0, 0, 0, .48);
  animation: popIn .24s cubic-bezier(.2, .8, .3, 1);
}
.modal-card::-webkit-scrollbar { display: none; }
.modal-card.wide { max-width: 480px; }
.modal-card.narrow { max-width: 380px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.modal-head small { font-size: 9.5px; letter-spacing: 2px; color: var(--orange-deep); font-weight: 800; }
.modal-head h3 { margin: 3px 0 0; font-size: 22px; font-weight: 900; letter-spacing: -.4px; }
.modal-close {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(110, 76, 48, .08);
  border-color: rgba(110, 76, 48, .12);
  color: #6C5140;
}

.result-card { text-align: center; padding-top: 26px; }
.result-emblem {
  width: 68px;
  height: 68px;
  margin: 0 auto;
  border-radius: 22px;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #FFB05F, #E8671B);
  box-shadow: 0 7px 0 #B34B11, 0 14px 30px rgba(232, 103, 27, .32);
  color: #FFF9ED;
}
.result-emblem .mp-icon { width: 35px; height: 35px; }
.result-emblem.lose { background: linear-gradient(160deg, #8A8177, #5A4D44); box-shadow: 0 7px 0 #3B3029, 0 14px 30px rgba(0, 0, 0, .28); }
.result-card h2 { margin: 18px 0 2px; font-size: 27px; font-weight: 900; letter-spacing: 2px; }
.result-card > p { margin: 0; font-size: 11px; color: var(--muted); }
.result-stars { display: flex; align-items: center; justify-content: center; gap: 9px; margin: 15px 0 16px; height: 42px; }
.result-stars .mp-icon { width: 38px; height: 38px; color: #D8C6A7; }
.result-stars .mp-icon.on {
  color: var(--gold);
  filter: drop-shadow(0 4px 0 rgba(176, 114, 20, .35));
  animation: starPop .4s cubic-bezier(.2, .9, .3, 1.4) both;
}
.result-stars .mp-icon.on:nth-child(2) { animation-delay: .1s; }
.result-stars .mp-icon.on:nth-child(3) { animation-delay: .2s; }
.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin-bottom: 12px;
}
.result-stat {
  padding: 9px 5px;
  border-radius: 13px;
  background: rgba(255, 252, 245, .86);
  border: 1px solid rgba(145, 100, 55, .14);
}
.result-stat small { display: block; font-size: 8.5px; color: #A18B71; }
.result-stat b { display: block; margin-top: 3px; font-size: 15px; font-weight: 900; color: #4F382A; }
.record-line {
  min-height: 18px;
  margin-bottom: 10px;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--orange-deep);
}
.result-actions { display: flex; gap: 8px; }
.result-actions .ghost-btn { margin-top: 0; min-height: 50px; border-radius: 16px; }
.result-actions .cta { flex: 1.4; }
.text-btn { margin-top: 12px; padding: 6px 12px; font-size: 11px; color: #8A7564; text-decoration: underline; text-underline-offset: 3px; }

/* 成就 */
.ach-summary {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px;
  border-radius: 16px;
  background: #FFFCF5;
  border: 1px solid rgba(145, 100, 55, .14);
  margin-bottom: 12px;
}
.ach-ring {
  flex: none;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: flex;
  align-items: baseline;
  justify-content: center;
  padding-top: 14px;
  background: conic-gradient(var(--orange) var(--p, 0%), #EFE2CB 0);
  position: relative;
  color: #4F382A;
}
.ach-ring::before { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: #FFFCF5; }
.ach-ring b { position: relative; font-size: 17px; font-weight: 900; }
.ach-ring span { position: relative; font-size: 8.5px; color: #A18B71; }
.ach-summary p { margin: 0; font-size: 10.5px; line-height: 1.6; color: #7A6252; }
.ach-list { display: flex; flex-direction: column; gap: 7px; }
.ach-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 14px;
  background: rgba(255, 252, 245, .8);
  border: 1px solid rgba(145, 100, 55, .12);
}
.ach-icon {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: #EEE0C9;
  color: #B29B7B;
}
.ach-icon .mp-icon { width: 19px; height: 19px; }
.ach-item.on .ach-icon { background: linear-gradient(150deg, #FFD9AE, #FFB066); color: #B34B11; }
.ach-copy { flex: 1; min-width: 0; }
.ach-copy b { display: block; font-size: 12px; font-weight: 800; color: #4F382A; }
.ach-copy small { display: block; margin-top: 2px; font-size: 9.5px; line-height: 1.45; color: #9A8579; }
.ach-state { flex: none; font-size: 9px; font-weight: 800; color: #B7A48D; }
.ach-item.on .ach-state { color: var(--orange-deep); }
.ach-progress { margin-top: 4px; height: 3px; border-radius: 99px; background: #EFE2CB; overflow: hidden; }
.ach-progress span { display: block; height: 100%; background: var(--orange); border-radius: 99px; }

/* 排行榜 */
.rank-levels {
  display: flex;
  gap: 5px;
  overflow-x: auto;
  padding: 2px 1px 9px;
  scrollbar-width: none;
}
.rank-levels::-webkit-scrollbar { display: none; }
.rank-chip {
  flex: none;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 252, 245, .8);
  border: 1px solid rgba(145, 100, 55, .16);
  font-size: 10px;
  font-weight: 700;
  color: #7A6252;
}
.rank-chip.selected {
  background: linear-gradient(180deg, #FFA65A, #F0782B);
  border-color: transparent;
  color: #FFF9ED;
  box-shadow: 0 3px 0 #B34B11;
}
.rank-mine {
  padding: 9px 11px;
  border-radius: 12px;
  background: #FFFCF5;
  border: 1px solid rgba(145, 100, 55, .14);
  font-size: 10px;
  color: #7A6252;
  margin-bottom: 9px;
}
.rank-mine b { color: #4F382A; }
.rank-list { display: flex; flex-direction: column; gap: 5px; min-height: 160px; }
.rank-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 9px;
  border-radius: 12px;
  background: rgba(255, 252, 245, .8);
  border: 1px solid rgba(145, 100, 55, .1);
}
.rank-no {
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 900;
  color: #A18B71;
  background: #F0E3CD;
}
.rank-row:nth-child(1) .rank-no { background: linear-gradient(150deg, #FFD36E, #EDA31E); color: #6C4300; }
.rank-row:nth-child(2) .rank-no { background: linear-gradient(150deg, #E4E6EA, #B8BEC7); color: #4E5560; }
.rank-row:nth-child(3) .rank-no { background: linear-gradient(150deg, #F2BE92, #C9834E); color: #5A2D0C; }
.rank-avatar {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 900;
  color: #FFF8EC;
  background: linear-gradient(150deg, #E59A55, #B45E20);
}
.rank-copy { flex: 1; min-width: 0; }
.rank-copy b { display: block; font-size: 11px; font-weight: 800; color: #4F382A; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-copy small { display: block; margin-top: 1px; font-size: 8.5px; color: #A18B71; }
.rank-stars { display: flex; gap: 1px; flex: none; }
.rank-stars .mp-icon { width: 11px; height: 11px; color: #D8C6A7; }
.rank-stars .mp-icon.on { color: var(--gold); }
.rank-score { flex: none; text-align: right; font-size: 12px; font-weight: 900; color: var(--orange-deep); min-width: 40px; }
.rank-score small { display: block; font-size: 7px; font-weight: 600; color: #A18B71; }
.rank-empty {
  padding: 26px 14px;
  text-align: center;
  font-size: 10.5px;
  line-height: 1.7;
  color: #A18B71;
  border-radius: 14px;
  border: 1px dashed rgba(145, 100, 55, .24);
}
.rank-note { margin: 10px 0 0; text-align: center; font-size: 9px; color: #A18B71; }

/* 玩家资料 */
.profile-avatar {
  width: 66px;
  height: 66px;
  margin: 4px auto 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 28px;
  font-weight: 900;
  color: #FFF9ED;
  background: linear-gradient(150deg, #FFB05F, #E8671B);
  border: 3px solid #FFF9ED;
  box-shadow: 0 6px 0 #B34B11, 0 12px 24px rgba(232, 103, 27, .26);
  overflow: hidden;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.field-label { display: block; font-size: 10px; font-weight: 800; color: #7A6252; margin-bottom: 6px; letter-spacing: .5px; }
.text-field {
  width: 100%;
  height: 46px;
  padding: 0 13px;
  border-radius: 12px;
  border: 1.5px solid rgba(145, 100, 55, .22);
  background: #FFFCF5;
  font-size: 14px;
  font-weight: 700;
  color: #4F382A;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}
.text-field:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(255, 138, 61, .14); }
.field-hint { margin: 8px 0 16px; font-size: 9.5px; line-height: 1.6; color: #A18B71; }

/* Toast */
.toast-wrap {
  position: fixed;
  top: calc(var(--safe-top) + 74px);
  left: 0;
  right: 0;
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  pointer-events: none;
}
.toast {
  max-width: 84%;
  padding: 9px 15px;
  border-radius: 999px;
  background: rgba(24, 16, 22, .92);
  border: 1px solid rgba(255, 214, 166, .2);
  color: #FFF4E2;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .2px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, .35);
  animation: toastIn .22s ease, toastOut .25s ease 2.35s forwards;
}
.toast.good { border-color: rgba(137, 216, 164, .34); color: #DFFFE8; }
.toast.bad { border-color: rgba(255, 138, 122, .36); color: #FFE1DB; }

/* =========================================================
   动画 & 小屏适配
   ========================================================= */
@keyframes ringPulse {
  0% { transform: scale(.9); opacity: .9; }
  70% { transform: scale(1.22); opacity: 0; }
  100% { transform: scale(1.22); opacity: 0; }
}
@keyframes alarmPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(228, 73, 59, .0); }
  50% { box-shadow: 0 0 0 4px rgba(228, 73, 59, .14); }
}
@keyframes sheetUp {
  from { transform: translateY(30px); opacity: .4; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes popIn {
  from { transform: scale(.94); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
@keyframes starPop {
  from { transform: scale(.4) rotate(-16deg); opacity: 0; }
  to { transform: scale(1) rotate(0); opacity: 1; }
}
@keyframes toastIn {
  from { transform: translateY(-8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes toastOut {
  to { transform: translateY(-8px); opacity: 0; }
}
@keyframes floatBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

@media (max-width: 360px) {
  .brand-title { font-size: 42px; }
  .hero-card { width: 66px; }
  .hud-level { font-size: 10.5px; }
  .stat-pill { padding: 4px 8px 4px 7px; }
  .stat-copy b { font-size: 11.5px; }
  .trail { height: 640px; }
  .map-head h2 { font-size: 18px; }
}
@media (min-height: 820px) {
  .home-hero { height: clamp(340px, 45vh, 420px); }
}
