:root {
  --bg0: #fff6ec;
  --bg1: #eaf7ff;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-2: rgba(255, 248, 240, 0.92);
  --text: #3d2f2a;
  --muted: #8a7468;
  --accent: #ff7a8a;
  --accent-2: #5ec8e8;
  --gold: #ffc94a;
  --danger: #ff6b6b;
  --ok: #5fd39a;
  --chain: #fff8e1;
  --line: rgba(255, 150, 120, 0.22);
  --glow: 0 8px 28px rgba(255, 170, 100, 0.35);
  --font: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-display: "M PLUS Rounded 1c", "Nunito", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  color: var(--text);
  font-family: var(--font);
  background: var(--bg0);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  overflow-x: hidden;
}

/* ===== ambient bg：夏日晴空 ===== */
.fx-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background:
    radial-gradient(900px 520px at 12% -8%, rgba(255, 210, 140, 0.55), transparent 58%),
    radial-gradient(800px 480px at 92% 8%, rgba(140, 210, 255, 0.45), transparent 52%),
    radial-gradient(700px 520px at 50% 108%, rgba(255, 170, 190, 0.35), transparent 55%),
    linear-gradient(180deg, #fff9f0 0%, #eef8ff 48%, #ffe8f0 100%);
}
.fx-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(48px);
  opacity: 0.5;
  animation: drift 16s ease-in-out infinite;
}
.fx-orb-a {
  width: 300px; height: 300px;
  left: -50px; top: 18%;
  background: #ffc28a;
}
.fx-orb-b {
  width: 280px; height: 280px;
  right: -40px; bottom: 12%;
  background: #9ad8ff;
  animation-delay: -5s;
}
.fx-orb-c {
  width: 220px; height: 220px;
  left: 38%; top: 62%;
  background: #ffb6c8;
  opacity: 0.38;
  animation-delay: -9s;
}
.fx-dots {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 180, 120, 0.35) 1.5px, transparent 1.6px);
  background-size: 28px 28px;
  mask-image: radial-gradient(ellipse at center, black 25%, transparent 72%);
  opacity: 0.45;
}
.fx-shine {
  position: absolute;
  inset: -20%;
  background: linear-gradient(115deg, transparent 42%, rgba(255, 255, 255, 0.45) 50%, transparent 58%);
  animation: shine 10s linear infinite;
}
@keyframes drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(24px, -18px) scale(1.06); }
}
@keyframes shine {
  0% { transform: translateX(-30%) rotate(0.001deg); }
  100% { transform: translateX(30%) rotate(0.001deg); }
}
@keyframes pulse-glow {
  0%, 100% { filter: drop-shadow(0 4px 10px rgba(255, 180, 100, 0.35)); }
  50% { filter: drop-shadow(0 8px 18px rgba(110, 200, 240, 0.45)); }
}
@keyframes float-y {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
@keyframes node-pop {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
  min-height: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.screen {
  display: none;
  flex-direction: column;
  flex: 1;
  padding: 16px;
  min-height: 100vh;
}
.screen.active { display: flex; animation: fade-in 0.35s ease; }
@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.glass {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  backdrop-filter: blur(14px);
  box-shadow: 0 10px 28px rgba(255, 150, 120, 0.12), inset 0 1px 0 rgba(255,255,255,0.85);
}
.glass-lite {
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.04em;
  transition: transform 0.12s ease, box-shadow 0.2s ease, opacity 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-glow {
  color: #5a3a18;
  background: linear-gradient(135deg, #ffe07a 0%, #ff9a7a 48%, #ff8ab0 100%);
  box-shadow: var(--glow), 0 5px 0 rgba(230, 140, 90, 0.45);
}
.btn-glow:hover { box-shadow: 0 10px 28px rgba(110, 200, 240, 0.4), 0 5px 0 rgba(230, 140, 90, 0.45); }
.btn-ghost {
  background: rgba(255,255,255,0.72);
  color: var(--text);
  border: 1.5px solid rgba(255, 150, 120, 0.28);
  box-shadow: 0 4px 12px rgba(255, 160, 120, 0.1);
}
.btn-sm { padding: 8px 12px; font-size: 13px; }

/* ===== MENU ===== */
.menu-stage {
  margin: auto 0;
  text-align: center;
  padding: 8vh 8px 4vh;
}
.brand-logo {
  display: block;
  width: min(340px, 86vw);
  height: auto;
  margin: 0 auto 8px;
  filter: drop-shadow(0 10px 22px rgba(255, 160, 80, 0.35));
  animation: pulse-glow 3.2s ease-in-out infinite;
}
.brand-logo.hidden { display: none; }
.brand-text.hidden { display: none; }
.brand-en {
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 0.32em;
  color: var(--accent-2);
  margin-bottom: 10px;
  font-weight: 800;
}
.brand-cn {
  font-family: var(--font-display);
  font-size: clamp(48px, 14vw, 64px);
  font-weight: 800;
  line-height: 1.05;
  background: linear-gradient(180deg, #ffb86c 5%, #ff7a8a 48%, #5eb8e8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: pulse-glow 3.2s ease-in-out infinite;
  letter-spacing: 0.06em;
}
.brand-sub {
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
}
.menu-ribbon {
  display: inline-block;
  margin: 22px auto 28px;
  padding: 7px 16px;
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 0.12em;
  font-weight: 700;
  color: #c47820;
  border: 1.5px solid rgba(255, 190, 90, 0.55);
  border-radius: 999px;
  background: rgba(255, 240, 180, 0.55);
  box-shadow: 0 4px 14px rgba(255, 200, 100, 0.25);
}
.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: stretch;
  max-width: 280px;
  margin: 0 auto;
}
.audio-panel {
  max-width: 280px;
  margin: 14px auto 0;
  padding: 10px 12px;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
}
.audio-panel #btn-mute {
  align-self: center;
}
.vol-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.vol-row span {
  width: 2.5em;
  flex-shrink: 0;
}
.vol-row input[type="range"] {
  flex: 1;
  accent-color: #ff8fa3;
  height: 4px;
}
.menu-account {
  max-width: 280px;
  margin: 0 auto 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 252, 248, 0.55);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.account-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.account-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  margin-top: 8px;
}
.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.auth-form input {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
.auth-form .auth-hint {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
  font-weight: 600;
}
.auth-error {
  color: #c62828;
  font-size: 13px;
  font-weight: 700;
  min-height: 1.2em;
  margin: 0;
}

.menu-meta {
  margin: 8px 0 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
}
.menu-tickets {
  margin: 4px 0 0;
  font-size: 13px;
  font-weight: 800;
  color: #2a7a9a;
  text-align: center;
}

.rar-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 900;
  padding: 1px 4px;
  border-radius: 4px;
  margin-left: 4px;
  vertical-align: middle;
  color: #fff;
}
.rar-badge.R { background: #78909c; }
.rar-badge.SR { background: #1e88e5; }
.rar-badge.SSR { background: #8e24aa; }
.rar-badge.UR { background: #f9a825; color: #3e2723; }

.char-chip .avatar { position: relative; }
.char-chip .rar-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  margin: 0;
  font-size: 8px;
}

.gacha-rates {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  padding: 10px 12px;
  margin: 8px 12px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 800;
}
.gacha-rates .rar.R { color: #546e7a; }
.gacha-rates .rar.SR { color: #1565c0; }
.gacha-rates .rar.SSR { color: #6a1b9a; }
.gacha-rates .rar.UR { color: #f57f17; }
.gacha-pity { color: var(--muted); font-weight: 600; }
.gacha-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  padding: 12px;
}
.gacha-result {
  margin: 8px 16px 16px;
  padding: 12px;
  border-radius: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  max-height: 50vh;
  overflow-y: auto;
}
.gacha-result.hidden { display: none; }
.gacha-card {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.5);
}
.gacha-card.UR { border-color: #ffb300; background: rgba(255, 213, 79, 0.25); }
.gacha-card.SSR { border-color: #ce93d8; background: rgba(206, 147, 216, 0.2); }
.gacha-card.SR { border-color: #64b5f6; }
.gacha-av {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 900;
  color: #fff;
  flex-shrink: 0;
}
.gacha-info { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.gacha-info small { color: var(--muted); font-size: 11px; }
.gacha-tip {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding: 0 16px 20px;
}
.menu-tip {
  margin-top: 28px;
  font-size: 12px;
  color: var(--muted);
}

/* ===== topbar ===== */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px 12px;
}
.topbar h2 {
  flex: 1;
  font-size: 18px;
  font-weight: 900;
}
.top-chip {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-2);
  border: 1.5px solid rgba(94, 200, 232, 0.45);
  background: rgba(190, 235, 255, 0.45);
  padding: 4px 8px;
  border-radius: 999px;
}
.top-chip.chip-with-ico {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.chip-lab { font-weight: 700; }
.currency-ico {
  width: 18px;
  height: 18px;
  object-fit: contain;
  display: inline-block;
  vertical-align: -3px;
}
.currency-ico.inline {
  width: 16px;
  height: 16px;
  margin-right: 2px;
}
.star-row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.star-ico {
  width: 12px;
  height: 12px;
  object-fit: contain;
}
.star-ico.off { opacity: 0.35; filter: grayscale(0.4); }
.star-badge .star-ico { width: 11px; height: 11px; }
.mini-star .star-ico { width: 11px; height: 11px; }
.section-lead {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
}
.section-lead b { color: var(--gold); }

/* ===== chars ===== */
.char-rail {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 2px 14px;
  scrollbar-width: none;
}
.char-rail::-webkit-scrollbar { display: none; }
.char-chip {
  flex: 0 0 72px;
  border: 2px solid transparent;
  border-radius: 16px;
  padding: 8px 6px;
  background: var(--panel-2);
  cursor: pointer;
  text-align: center;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.2s;
}
.char-chip:hover { transform: translateY(-3px); }
.char-chip.active {
  border-color: var(--accent);
  box-shadow: 0 8px 20px rgba(255, 122, 138, 0.28);
}
.char-chip .avatar {
  width: 52px;
  height: 52px;
  margin: 0 auto 6px;
  border-radius: 4px;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 20px;
  color: #fff;
  text-shadow: 0 2px 6px rgba(0,0,0,0.45);
  overflow: hidden;
  background-size: cover;
  background-position: center top;
}
.char-chip .name { font-size: 12px; font-weight: 700; }
.char-chip .chip-lv {
  font-size: 10px;
  color: var(--gold);
  margin-top: 2px;
  font-family: var(--font-display);
}
.char-chip.in-party {
  box-shadow: inset 0 0 0 2px rgba(94, 200, 232, 0.55);
}

.char-detail {
  flex: 1;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow-y: auto;
}
.cultivate-panel { animation: none; }
.cultivate-tabs {
  display: flex;
  gap: 8px;
  padding: 0 14px 8px;
}
.cult-tab {
  flex: 1;
  border: 2px solid transparent;
  background: var(--panel);
  color: inherit;
  font: inherit;
  font-weight: 800;
  padding: 10px 12px;
  border-radius: 14px;
  cursor: pointer;
}
.cult-tab.active {
  border-color: var(--accent);
  background: rgba(255, 200, 120, 0.22);
}
.cult-panel.hidden { display: none !important; }
.cult-panel { display: flex; flex-direction: column; flex: 1; min-height: 0; }

.team-slots {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  padding: 0 14px 12px;
}
.team-slot {
  border: 2px dashed rgba(0,0,0,0.18);
  border-radius: 16px;
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: var(--panel);
  cursor: pointer;
  min-height: 110px;
  color: inherit;
  font: inherit;
}
.team-slot .slot-tag {
  font-size: 11px;
  font-weight: 800;
  opacity: 0.8;
}
.team-slot .slot-av {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 900;
  overflow: hidden;
  border: 2px solid transparent;
}
.team-slot.empty .slot-av {
  background: rgba(0,0,0,0.08);
  color: var(--muted);
  font-size: 22px;
}
.team-slot .slot-name {
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}
.team-slot.active {
  border-style: solid;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(255, 180, 80, 0.35);
}
.team-pool-title {
  margin: 0 14px 8px;
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
}
.team-pool {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0 14px 16px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.team-pool-card {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border-radius: 14px;
  border: 2px solid transparent;
  background: var(--panel);
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
}
.team-pool-card .av {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  overflow: hidden;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 900;
}
.team-pool-card.in-line {
  opacity: 0.55;
}
.team-pool-card.selected {
  border-color: var(--accent);
}
.party-confirm .party-option { cursor: default; }
.party-footer-split {
  display: flex;
  gap: 10px;
}
.party-footer-split .btn { flex: 1; }
.char-hero-row {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 14px;
  align-items: center;
}
.char-portrait {
  width: 96px;
  height: 96px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  font-size: 40px;
  font-weight: 900;
  color: #fff;
  box-shadow: 0 10px 24px rgba(255, 160, 120, 0.28);
  position: relative;
  overflow: hidden;
}
.char-portrait::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.28), transparent 45%);
}
.star-badge {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 4px;
  z-index: 1;
  font-size: 9px;
  letter-spacing: 1px;
  color: #ffc94a;
  text-shadow: 0 1px 2px rgba(90, 50, 20, 0.35);
  text-align: center;
}
.char-meta h3 { font-size: 22px; margin-bottom: 4px; }
.char-meta .lv-line { font-size: 12px; color: var(--gold); margin: 4px 0; }
.char-meta .lv-line b { color: var(--text); }
.run-hp-line { font-size: 12px; color: var(--accent-2); margin-top: 4px; }
.run-hp-line b { color: var(--text); }
.stat-up {
  margin-left: 4px;
  font-style: normal;
  font-size: 11px;
  color: var(--ok);
  font-weight: 700;
}
.cultivate-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}
.cultivate-actions .btn {
  width: 100%;
  border-radius: 12px;
  font-size: 13px;
  padding: 12px 8px;
}
.cultivate-tip {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.45;
}
.mini-star {
  font-size: 11px;
  color: var(--gold);
  font-weight: 700;
  letter-spacing: 1px;
}
.char-meta .role {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(94, 200, 232, 0.2);
  color: #2a8fb0;
  margin-bottom: 6px;
}
.char-meta p { font-size: 12px; color: var(--muted); line-height: 1.5; }
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.stat-cell {
  background: rgba(255, 200, 160, 0.14);
  border-radius: 12px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 180, 140, 0.18);
}
.stat-cell span { display: block; font-size: 11px; color: var(--muted); }
.stat-cell b { font-size: 16px; font-variant-numeric: tabular-nums; }
.stat-bar {
  height: 6px;
  background: rgba(255, 180, 140, 0.18);
  border-radius: 999px;
  margin-top: 6px;
  overflow: hidden;
}
.stat-bar i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
}
.trait-box {
  border-left: 3px solid var(--gold);
  padding: 8px 12px;
  background: rgba(255, 220, 120, 0.28);
  border-radius: 0 12px 12px 0;
  font-size: 13px;
  line-height: 1.45;
}
.trait-box b { color: var(--gold); }
.skill-desc {
  margin: -4px 0 10px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

/* ===== party pick ===== */
.party-pick {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}
.party-option {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: 16px;
  border: 2px solid transparent;
  background: var(--panel);
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
  transition: border-color 0.15s, transform 0.12s, box-shadow 0.2s;
}
.party-option .av {
  width: 56px; height: 56px; border-radius: 14px;
  display: grid; place-items: center;
  color: #fff; font-weight: 900; font-size: 22px;
}
.party-option .info strong { display: block; font-size: 16px; }
.party-option .info small { color: var(--muted); font-size: 12px; }
.party-option .mark {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid var(--line);
  display: grid; place-items: center;
  font-size: 14px; color: transparent;
}
.party-option.on {
  border-color: var(--accent);
  box-shadow: 0 8px 22px rgba(255, 122, 138, 0.25);
}
.party-option.on .mark {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.party-footer { margin-top: 14px; }
.party-footer .btn { width: 100%; }

/* ===== run map ===== */
.run-head { flex: 1; text-align: center; }
.run-meta { font-size: 12px; color: var(--muted); }
.run-party-strip {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  overflow-x: auto;
}
.run-mini {
  flex: 1;
  min-width: 70px;
  padding: 8px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  text-align: center;
}
.run-mini .dot {
  width: 28px; height: 28px; margin: 0 auto 4px;
  border-radius: 8px; display: grid; place-items: center;
  color: #fff; font-size: 12px; font-weight: 900;
}
.run-mini .hp {
  height: 4px; background: #ffe0d0; border-radius: 2px; overflow: hidden; margin-top: 4px;
}
.run-mini .hp i { display: block; height: 100%; background: var(--ok); }
.run-mini small { font-size: 10px; color: var(--muted); }

.run-buffs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  padding: 0 4px 8px;
  min-height: 28px;
}
.buff-chip {
  font-size: 11px;
  font-weight: 800;
  color: #2a7a9a;
  background: rgba(126, 200, 255, 0.22);
  border: 1px solid rgba(94, 180, 220, 0.35);
  border-radius: 999px;
  padding: 4px 10px;
}
.buff-chip.empty {
  color: var(--muted);
  font-weight: 600;
  background: rgba(255, 255, 255, 0.45);
  border-color: var(--line);
}

.run-map-wrap {
  position: relative;
  flex: 1;
  min-height: 320px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-radius: 22px;
  border: 2px solid rgba(255, 180, 120, 0.35);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.65),
    0 12px 32px rgba(255, 150, 100, 0.18);
}
.run-map-sky {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 280px at 50% -10%, rgba(255, 255, 255, 0.55), transparent 60%),
    radial-gradient(420px 220px at 12% 88%, rgba(255, 190, 140, 0.35), transparent 70%),
    radial-gradient(480px 240px at 90% 70%, rgba(130, 210, 255, 0.28), transparent 65%),
    linear-gradient(180deg, #dff4ff 0%, #fff6e8 42%, #ffe8d2 100%);
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
}
.run-map-sky.has-art {
  background-color: #cfe8c8;
  /* background-image 由 JS 内联写入 */
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  filter: saturate(1.05) contrast(1.02);
}
.run-map-sky.has-art::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(255, 250, 240, 0.18) 0%,
    rgba(255, 255, 255, 0.05) 40%,
    rgba(40, 60, 40, 0.12) 100%
  );
  opacity: 1;
}
.run-map-sky:not(.has-art)::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.7) 0 2px, transparent 3px),
    radial-gradient(circle at 70% 18%, rgba(255, 255, 255, 0.55) 0 1.5px, transparent 3px),
    radial-gradient(circle at 40% 60%, rgba(255, 220, 160, 0.45) 0 2px, transparent 3px),
    radial-gradient(circle at 85% 55%, rgba(255, 255, 255, 0.4) 0 1.5px, transparent 3px);
  background-size: 120px 90px, 160px 110px, 100px 80px, 140px 100px;
}
.run-path-layer {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 0;
  pointer-events: none;
  overflow: visible;
}
.edge-path {
  position: absolute;
  width: 32px;
  height: auto;
  max-height: 64px;
  object-fit: contain;
  opacity: 0.72;
  filter: drop-shadow(0 1px 2px rgba(40, 30, 10, 0.22));
  transform-origin: center center;
  pointer-events: none;
}
.edge-path.lit {
  opacity: 1;
  filter: drop-shadow(0 0 5px rgba(94, 200, 232, 0.4)) brightness(1.06);
}
.edge-path.worn {
  opacity: 0.38;
  filter: grayscale(0.3);
}
.run-edges {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 0;
  overflow: visible;
}
.run-edge {
  stroke: rgba(120, 90, 50, 0.22);
  stroke-width: 2;
  stroke-linecap: round;
}
.run-edge.worn {
  stroke: rgba(100, 80, 50, 0.12);
  stroke-dasharray: 4 8;
}
.run-edge.lit {
  stroke: rgba(70, 190, 230, 0.35);
  stroke-width: 2.5;
  stroke-dasharray: none;
}
.run-map {
  position: relative;
  z-index: 2;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 10px 18px;
  overflow-y: auto;
  min-height: 280px;
}
.run-floor {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  z-index: 1;
  animation: node-pop 0.35s ease both;
}
.floor-tag {
  flex-shrink: 0;
  width: 36px;
  text-align: center;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #9a6b4a;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(255, 180, 120, 0.35);
  border-radius: 999px;
  padding: 6px 0;
  font-family: var(--font-display);
}
.floor-nodes {
  flex: 1;
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}
.run-node {
  width: 88px;
  min-height: 108px;
  border-radius: 20px;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: default;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 2px;
  font-family: inherit;
  position: relative;
  padding: 2px 4px 6px;
  transition: transform 0.15s;
}
.node-badge {
  position: relative;
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.9), rgba(255, 245, 230, 0.55) 55%, rgba(255, 200, 150, 0.25));
  box-shadow:
    0 6px 14px rgba(120, 80, 40, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}
.run-node .node-ico {
  width: 58px;
  height: 58px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 2px 4px rgba(60, 40, 20, 0.2));
  position: relative;
  z-index: 1;
}
.run-node .ico {
  font-size: 28px;
  line-height: 1;
  font-weight: 900;
  z-index: 1;
}
.run-node .lab {
  margin-top: 4px;
  font-size: 12px;
  font-weight: 900;
  font-family: var(--font-display);
  letter-spacing: 0.04em;
}
.run-node .sub {
  font-size: 10px;
  color: var(--muted);
  max-width: 84px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.node-glow {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(94, 200, 232, 0.85);
  box-shadow: 0 0 14px rgba(94, 200, 232, 0.55);
  animation: pulse-glow 1.8s ease-in-out infinite;
  pointer-events: none;
}
.node-check {
  position: absolute;
  right: 2px;
  bottom: 2px;
  z-index: 2;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #5fd39a;
  box-shadow: 0 2px 6px rgba(40, 120, 80, 0.35);
}
.node-check::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 3px;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.run-node.available {
  cursor: pointer;
}
.run-node.available:hover { transform: translateY(-5px) scale(1.05); }
.run-node.available:hover .node-badge {
  box-shadow:
    0 10px 22px rgba(94, 200, 232, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.85);
}
.run-node.done {
  opacity: 0.55;
}
.run-node.done .node-badge {
  filter: grayscale(0.25);
}
.run-node.current .node-badge {
  box-shadow:
    0 0 0 3px rgba(255, 201, 74, 0.85),
    0 8px 20px rgba(255, 180, 60, 0.45);
}
.run-node.locked {
  opacity: 0.4;
  filter: grayscale(0.45);
}
.run-node.type-boss .node-badge {
  width: 76px;
  height: 76px;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 230, 230, 0.95), rgba(255, 150, 150, 0.35) 60%, rgba(255, 100, 120, 0.2));
}
.run-node.type-boss .node-ico {
  width: 66px;
  height: 66px;
}
.run-hint {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 10px 0 4px;
}

.battle-hint {
  margin: 0 0 8px;
  text-align: center;
  font-size: 11px;
  line-height: 1.4;
  color: var(--muted);
  padding: 0 4px;
}

#grid.path-invalid {
  outline: 2px solid rgba(255, 110, 120, 0.55);
  outline-offset: 2px;
  border-radius: 12px;
  animation: path-shake 0.35s ease;
}
@keyframes path-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 14%;
  transform: translateX(-50%);
  z-index: 80;
  max-width: min(90vw, 360px);
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(40, 36, 48, 0.88);
  color: #fff8f0;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(40, 30, 20, 0.25);
  animation: toast-in 0.25s ease;
}
.toast.hidden { display: none; }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.hit-flash {
  position: fixed;
  inset: 0;
  z-index: 70;
  pointer-events: none;
  background: rgba(255, 255, 255, 0);
  transition: background 0.05s;
}
.hit-flash.on {
  background: rgba(255, 250, 230, 0.28);
}
.hit-flash.crit {
  background: rgba(255, 200, 80, 0.32);
}
.hit-flash.hurt {
  background: rgba(255, 80, 90, 0.22);
}
.hit-flash.skill {
  background: rgba(180, 230, 255, 0.24);
}

/* ===== battle ===== */
#screen-battle { padding: 10px 12px; }
.battle-layout {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 10px;
  min-height: 0;
}
.battle-main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}
.battle-top {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  margin-bottom: 8px;
}
.battle-titles { flex: 1; text-align: center; }
.lv-line { font-size: 11px; color: var(--muted); }
.turn-label {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #2a9fc4;
  text-shadow: 0 2px 0 rgba(255,255,255,0.8);
}
.board-tag {
  font-family: var(--font-display);
  font-size: 10px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
}

.grid-frame {
  position: relative;
  margin: 0 auto;
  padding: 10px;
  border-radius: 22px;
  background:
    linear-gradient(135deg, rgba(255, 180, 140, 0.28), transparent 42%),
    linear-gradient(225deg, rgba(140, 210, 255, 0.28), transparent 42%),
    rgba(255, 255, 255, 0.75);
  box-shadow: 0 0 0 1.5px rgba(255, 170, 130, 0.28), 0 14px 32px rgba(255, 160, 120, 0.18);
}
.grid-wrap {
  position: relative;
  display: flex;
  justify-content: center;
}
#grid {
  display: block;
  border-radius: 10px;
  touch-action: none;
  max-width: 100%;
}

.chain-banner {
  position: absolute;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, #ff9a6a, #ff7a9a);
  color: #fffdf5;
  font-weight: 900;
  font-size: 16px;
  padding: 6px 16px;
  border-radius: 999px;
  border: 2px solid #ffe9a8;
  pointer-events: none;
  letter-spacing: 0.04em;
  box-shadow: 0 6px 18px rgba(255, 120, 100, 0.4);
}
.chain-banner.hidden { display: none; }

.fx-pop {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.fx-pop.hidden { display: none; }
.fx-pop img {
  width: min(280px, 78%);
  height: auto;
  filter: drop-shadow(0 8px 20px rgba(255, 140, 60, 0.45));
  animation: fx-pop-anim 0.85s ease-out both;
}
@keyframes fx-pop-anim {
  0% { transform: scale(0.55); opacity: 0; }
  18% { transform: scale(1.12); opacity: 1; }
  70% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.05); opacity: 0; }
}

.modal-art {
  display: block;
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  object-position: center 28%;
  border-radius: 14px;
  margin-bottom: 14px;
  box-shadow: 0 8px 22px rgba(255, 150, 100, 0.25);
}
.modal-art.hidden { display: none; }

.party-hp {
  margin: 10px 0 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
}
.party-hp-bar {
  flex: 1;
  height: 10px;
  background: #ffe4d6;
  border-radius: 999px;
  overflow: hidden;
}
.party-hp-bar i {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #7ee0ad, #6ec8f0);
  box-shadow: 0 0 10px rgba(110, 220, 180, 0.4);
}
#party-hp-text { font-size: 11px; color: var(--muted); white-space: nowrap; }

.battle-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.auto-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
  background: rgba(255,255,255,0.72);
  border: 1.5px solid rgba(255, 150, 120, 0.28);
  border-radius: 999px;
  padding: 7px 12px;
  cursor: pointer;
  user-select: none;
}
.auto-toggle input {
  width: 16px;
  height: 16px;
  accent-color: #ff7a8a;
}
.auto-tools {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.debug-only {
  display: none !important;
}
body.debug-auto .auto-tools.debug-only {
  display: inline-flex !important;
}
body.debug-auto .auto-log-view.debug-only {
  display: block !important;
}
.auto-log-view {
  margin: 0 0 8px;
  max-height: 88px;
  overflow: auto;
  font-size: 10px;
  line-height: 1.35;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 8px;
  white-space: pre-wrap;
  word-break: break-all;
  font-family: ui-monospace, Consolas, monospace;
}

.mobile-preview {
  margin: 2px 0 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  min-height: 1.35em;
  line-height: 1.35;
}

.mobile-info {
  margin-top: 6px;
  padding: 8px 10px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.m-pv-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  justify-content: center;
  font-size: 11px;
  color: var(--muted);
}
.m-pv-stats b {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.mpv-perfect.good { color: var(--ok); font-weight: 800; }
.mobile-log-list {
  max-height: 4.2em;
  overflow-y: auto;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.35;
  text-align: left;
}
.mobile-log-list .entry {
  padding: 2px 0;
  border-bottom: 1px solid rgba(255, 180, 140, 0.15);
}

.run-relics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  padding: 0 4px 8px;
  min-height: 0;
}
.relic-chip {
  font-size: 11px;
  font-weight: 800;
  color: #8a5a20;
  background: rgba(255, 200, 120, 0.28);
  border: 1px solid rgba(230, 160, 80, 0.4);
  border-radius: 999px;
  padding: 4px 10px;
}

.char-chip.locked { opacity: 0.55; }
.char-chip .lock-tag {
  font-size: 9px;
  color: var(--muted);
}
.team-pool-card.locked {
  opacity: 0.5;
  cursor: not-allowed;
}

.party-bar {
  display: flex;
  gap: 6px;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 6px;
}
.portrait {
  flex: 1;
  background: var(--panel);
  border-radius: 14px;
  padding: 6px 4px 8px;
  border: 1px solid var(--line);
  text-align: center;
  cursor: pointer;
  min-width: 0;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.portrait.moved { opacity: 0.45; }
.portrait.dead {
  opacity: 0.35;
  filter: grayscale(0.85);
  cursor: default;
}
.portrait.ready {
  border-color: var(--gold);
  box-shadow: 0 6px 16px rgba(255, 201, 74, 0.4);
}
.portrait-art {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 10px;
  display: grid;
  place-items: center;
  margin-bottom: 4px;
  position: relative;
  overflow: hidden;
}
.portrait-art::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, rgba(255,255,255,0.25), transparent 40%);
}
.portrait-label {
  font-size: 18px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.55);
  position: relative;
  z-index: 1;
}
.portrait-name {
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  justify-content: center;
  align-items: center;
  margin: 2px 0 1px;
  min-height: 14px;
}
.status-icon {
  width: 14px;
  height: 14px;
  object-fit: contain;
  image-rendering: auto;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.45));
}
.status-chip {
  font-size: 8px;
  font-weight: 800;
  line-height: 1.2;
  padding: 1px 3px;
  border-radius: 4px;
  background: rgba(0,0,0,0.2);
  color: #fff;
}
.status-chip.poison { background: #7cb342; }
.status-chip.weaken { background: #7e57c2; }
.status-chip.wound { background: #e53935; }
.status-chip.seal { background: #546e7a; }
.portrait.sealed {
  border-color: #78909c;
  box-shadow: inset 0 0 0 1px rgba(120, 144, 156, 0.5);
}
.hp {
  height: 5px;
  background: #2a2448;
  border-radius: 2px;
  margin: 3px 2px 1px;
  overflow: hidden;
}
.hp i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #66bb6a, #43a047);
}
.hp-n { font-size: 9px; color: var(--muted); }
.energy {
  height: 4px;
  background: #ffe0ec;
  border-radius: 2px;
  margin: 4px 2px 2px;
  overflow: hidden;
}
.energy i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #ffb0c8, #ff9a70);
}
.energy-n { font-size: 9px; color: var(--muted); }

.log {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  min-height: 2.4em;
  line-height: 1.4;
}

.side-panel { display: none; }
.side-block {
  padding: 12px 14px;
}
.side-block h3 {
  font-size: 12px;
  color: var(--accent-2);
  margin-bottom: 8px;
  letter-spacing: 0.08em;
  font-family: var(--font-display);
}
.side-text { font-size: 14px; line-height: 1.45; }
.side-muted { font-size: 12px; color: var(--muted); line-height: 1.45; margin-top: 6px; }
.preview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.preview-grid > div {
  background: rgba(255, 200, 160, 0.16);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border: 1px solid rgba(255, 180, 140, 0.2);
}
.preview-grid span { font-size: 11px; color: var(--muted); }
.preview-grid b { font-size: 16px; font-variant-numeric: tabular-nums; }
.preview-grid b.good { color: var(--ok); }
.side-heroes { display: flex; flex-direction: column; gap: 8px; }
.side-hero-row {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 8px;
  align-items: center;
}
.side-hero-dot {
  width: 28px; height: 28px; border-radius: 8px;
  display: grid; place-items: center;
  color: #fff; font-size: 12px; font-weight: 800;
}
.side-hero-meta { font-size: 12px; line-height: 1.35; }
.side-hero-meta small { color: var(--muted); }
.side-log {
  max-height: 160px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}
.side-log .entry { padding-bottom: 6px; border-bottom: 1px solid var(--line); }

.modal {
  position: absolute;
  inset: 0;
  background: rgba(255, 236, 220, 0.72);
  display: grid;
  place-items: center;
  z-index: 30;
  padding: 24px;
  backdrop-filter: blur(8px);
}
.modal.hidden { display: none; }
.modal-card {
  padding: 26px 22px;
  width: min(340px, 100%);
  text-align: center;
  max-height: min(90vh, 720px);
  overflow-y: auto;
}
.modal-card h3 {
  font-size: 26px;
  margin-bottom: 10px;
  font-family: var(--font-display);
  background: linear-gradient(90deg, #ffc94a, #ff7a8a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.modal-card p { color: var(--muted); font-size: 14px; margin-bottom: 18px; line-height: 1.5; }
.modal-actions { display: flex; flex-direction: column; gap: 8px; }
.modal-actions .btn { width: 100%; }

.hidden { display: none !important; }

@media (min-width: 900px) {
  body {
    display: flex;
    justify-content: center;
  }
  .shell {
    max-width: 1120px;
    width: min(1120px, 96vw);
    min-height: 100vh;
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
    background: rgba(255, 252, 248, 0.55);
  }
  #screen-menu,
  #screen-chars,
  #screen-gacha,
  #screen-party,
  #screen-run {
    max-width: 560px;
    margin: 0 auto;
    width: 100%;
  }
  #screen-battle { padding: 18px 22px; }
  .battle-layout {
    flex-direction: row;
    align-items: stretch;
    gap: 18px;
  }
  .battle-main { flex: 1.15; }
  .side-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 320px;
    flex-shrink: 0;
  }
  .side-log-block { flex: 1; min-height: 0; }
  .side-log { max-height: none; flex: 1; }
  .mobile-log { display: none; }
  .mobile-preview { display: none; }
  .mobile-info { display: none; }
  .turn-label { font-size: 24px; }
}
