/* =========================================================
 * 星海抽卡者 · 视觉层  —  深空星云 / 玻璃拟态 / 稀有度分层
 * ========================================================= */
:root {
  --bg0: #04050c;
  --bg1: #0a0c16;
  --panel: rgba(17, 22, 40, 0.62);
  --panel-solid: #101425;
  --border: rgba(122, 152, 224, 0.18);
  --border-strong: rgba(140, 170, 240, 0.34);
  --text: #e9edff;
  --muted: #8b96bb;
  --dim: #5d688c;
  --r3: #6fb3ff;
  --r4: #b57dff;
  --r5: #ffc247;
  --gold: #ffc247;
  --gain: #55e6a5;
  --lose: #ff6b7a;
  --radius: 16px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  --glass: saturate(150%) blur(16px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 800px at 12% -8%, rgba(90, 70, 200, 0.28), transparent 60%),
    radial-gradient(1000px 700px at 100% 0%, rgba(40, 110, 220, 0.22), transparent 55%),
    radial-gradient(900px 900px at 50% 120%, rgba(180, 120, 60, 0.14), transparent 60%),
    linear-gradient(180deg, var(--bg1), var(--bg0) 70%);
  min-height: 100%;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

#starfield {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
}
#app { position: relative; z-index: 1; max-width: 1180px; margin: 0 auto; padding: 14px 16px 22px; }

/* ── 顶栏 ── */
.topbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 12px 16px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--border);
  backdrop-filter: var(--glass); -webkit-backdrop-filter: var(--glass);
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: baseline; gap: 9px; }
.brand .logo {
  font-size: 22px; color: var(--gold);
  text-shadow: 0 0 14px rgba(255, 194, 71, 0.8);
  animation: spin 9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.brand .title { font-size: 19px; font-weight: 800; letter-spacing: 1px; }
.brand .sub { font-size: 10px; color: var(--dim); letter-spacing: 3px; font-weight: 700; }

.stats { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.stat {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px 7px 10px; border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  transition: border-color 0.25s, box-shadow 0.25s;
}
.stat .ico { font-size: 16px; filter: drop-shadow(0 0 6px rgba(120, 160, 255, 0.5)); }
.stat .meta { display: flex; flex-direction: column; line-height: 1.1; }
.stat .meta i { font-style: normal; font-size: 10px; color: var(--muted); letter-spacing: 1px; }
.stat .meta b { font-size: 15px; font-weight: 700; }
.stat.gems .meta b { color: var(--gold); }
.stat.pity .meta b { color: var(--r5); }
.stat.hot { border-color: rgba(255, 194, 71, 0.65); box-shadow: 0 0 18px rgba(255, 194, 71, 0.32); animation: pulse 1.4s ease-in-out infinite; }
.stat.low .meta b { color: var(--lose); }
@keyframes pulse { 50% { box-shadow: 0 0 26px rgba(255, 194, 71, 0.6); } }

.top-actions { display: flex; gap: 8px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; cursor: pointer;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border); color: var(--text);
  font-size: 17px; transition: all 0.2s;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.12); border-color: var(--border-strong); transform: translateY(-1px); }
.icon-btn.off { opacity: 0.45; }

/* ── 主布局 ── */
.layout {
  display: grid; grid-template-columns: 1.05fr 0.95fr; gap: 16px; margin-top: 16px;
}
@media (max-width: 860px) { .layout { grid-template-columns: 1fr; } }

.panel {
  border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--border);
  backdrop-filter: var(--glass); -webkit-backdrop-filter: var(--glass);
  box-shadow: var(--shadow);
  padding: 14px; min-height: 300px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.panel-head h2 { font-size: 15px; font-weight: 700; letter-spacing: 0.5px; }
.power { font-size: 12px; color: var(--muted); }
.power b { color: var(--gold); font-size: 14px; }
.floor-badge {
  font-size: 12px; padding: 4px 12px; border-radius: 999px;
  background: rgba(110, 90, 220, 0.22); border: 1px solid rgba(150, 130, 255, 0.4);
  color: #cfc6ff;
}

/* ── 队伍卡片 ── */
.team-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 520px) { .team-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 340px) { .team-grid { grid-template-columns: 1fr; } }

.unit {
  position: relative; border-radius: 13px; overflow: hidden;
  background: var(--panel-solid);
  border: 1.5px solid var(--border);
  aspect-ratio: 3 / 4;
  animation: unitIn 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
  transition: transform 0.22s, box-shadow 0.22s;
  cursor: default;
}
@keyframes unitIn { from { opacity: 0; transform: translateY(14px) scale(0.94); } }
.unit:hover { transform: translateY(-3px); }
.unit-art { position: absolute; inset: 0; }
.unit-art img { width: 100%; height: 100%; object-fit: cover; object-position: center 18%; display: block; }
.unit-glow {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, transparent 42%, rgba(4, 6, 14, 0.55) 66%, rgba(4, 6, 14, 0.94) 100%);
}
.unit-rarity {
  position: absolute; top: 6px; left: 0; right: 0; text-align: center;
  font-size: 10px; letter-spacing: 1.5px;
}
.unit-name {
  position: absolute; bottom: 40px; left: 0; right: 0; text-align: center;
  font-size: 13px; font-weight: 800; text-shadow: 0 2px 8px #000;
}
.unit-stats {
  position: absolute; bottom: 22px; left: 0; right: 0;
  display: flex; justify-content: center; gap: 10px; font-size: 11px; font-weight: 700;
}
.s-atk { color: #ff9f7a; } .s-hp { color: #8fe0a8; }
.copy-badge {
  position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%);
  font-size: 10px; padding: 2px 9px; border-radius: 999px; white-space: nowrap;
  background: rgba(255, 194, 71, 0.16); border: 1px solid rgba(255, 194, 71, 0.5); color: var(--gold);
  font-weight: 700;
}
.copy-badge.muted { background: rgba(255, 255, 255, 0.05); border-color: var(--border); color: var(--dim); }

/* 稀有度分层 */
.unit.r3 { border-color: rgba(111, 179, 255, 0.55); }
.unit.r3:hover { box-shadow: 0 10px 30px rgba(111, 179, 255, 0.3); }
.unit.r3 .unit-rarity { color: var(--r3); }
.unit.r4 { border-color: rgba(181, 125, 255, 0.65); box-shadow: 0 0 0 1px rgba(181, 125, 255, 0.2) inset; }
.unit.r4:hover { box-shadow: 0 12px 34px rgba(181, 125, 255, 0.42); }
.unit.r4 .unit-rarity { color: var(--r4); text-shadow: 0 0 8px var(--r4); }
.unit.r5 { border-color: rgba(255, 194, 71, 0.8); box-shadow: 0 0 0 1px rgba(255, 194, 71, 0.25) inset; }
.unit.r5:hover { box-shadow: 0 14px 40px rgba(255, 194, 71, 0.5); }
.unit.r5 .unit-rarity { color: var(--r5); text-shadow: 0 0 10px var(--r5); }
.unit.r5::after {
  content: ""; position: absolute; inset: -1px; border-radius: 13px; pointer-events: none;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 230, 150, 0.55) 48%, transparent 62%);
  background-size: 260% 100%; animation: shine 3.4s linear infinite; mix-blend-mode: screen;
}
@keyframes shine { from { background-position: 160% 0; } to { background-position: -160% 0; } }

.unit-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; border-style: dashed; opacity: 0.5; }
.unit-empty .empty-mark { font-size: 24px; color: var(--dim); }
.unit-empty .unit-name { position: static; font-size: 11px; color: var(--dim); font-weight: 500; }

.team-hint { margin-top: 10px; font-size: 11.5px; color: var(--muted); text-align: center; }

/* ── 日志 ── */
.battle-panel { display: flex; flex-direction: column; }
.log {
  flex: 1; overflow-y: auto; max-height: 420px; min-height: 260px;
  font-size: 12.5px; line-height: 1.75;
  font-family: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
  padding-right: 4px;
}
.log::-webkit-scrollbar { width: 8px; }
.log::-webkit-scrollbar-thumb { background: rgba(120, 150, 220, 0.25); border-radius: 4px; }
.log-line { padding: 2px 6px; border-radius: 6px; animation: logIn 0.25s ease both; }
@keyframes logIn { from { opacity: 0; transform: translateX(-6px); } }
.line-title { font-size: 14px; font-weight: 700; margin-bottom: 2px; }
.line-floor { margin-top: 8px; border-left: 2px solid rgba(150, 130, 255, 0.6); padding-left: 8px; }
.line-round { color: #b9c3e6; }
.line-round:hover { background: rgba(255, 255, 255, 0.04); }
.line-dim { color: var(--dim); }
.line-win { color: var(--gain); font-weight: 600; }
.line-lose { color: var(--lose); font-weight: 600; }
.c-floor { color: #b9a8ff; font-weight: 700; }
.c-win { color: var(--gain); } .c-lose { color: var(--lose); }
.c-gem { color: var(--gold); } .c-title { color: var(--gold); }
.dmg-out { color: #ffb08a; } .dmg-in { color: #ff8f9d; }
.c3 { color: var(--r3); } .c4 { color: var(--r4); } .c5 { color: var(--r5); }

/* ── 底部按钮 ── */
.actions {
  display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px;
  padding: 12px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--border);
  backdrop-filter: var(--glass); -webkit-backdrop-filter: var(--glass);
  box-shadow: var(--shadow);
}
.btn {
  border: none; cursor: pointer; border-radius: 12px; font-family: inherit;
  font-size: 14px; font-weight: 700; padding: 12px 20px; color: #fff;
  transition: transform 0.16s, box-shadow 0.22s, filter 0.2s;
  letter-spacing: 0.5px;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; filter: grayscale(0.4); }
.btn-primary {
  flex: 1; min-width: 180px;
  background: linear-gradient(135deg, #ff9a5a, #ff6f3c 55%, #ff4d6d);
  box-shadow: 0 10px 26px rgba(255, 110, 70, 0.4);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 14px 34px rgba(255, 110, 70, 0.6); }
.btn-draw {
  background: linear-gradient(135deg, #6f7bff, #a05cff 60%, #c34bff);
  box-shadow: 0 10px 24px rgba(150, 90, 255, 0.36);
}
.btn-draw .cost { font-size: 11.5px; opacity: 0.9; font-weight: 600; }
.btn-ghost {
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--border); color: var(--text);
}
.btn-ghost:hover:not(:disabled) { background: rgba(255, 255, 255, 0.12); }

/* ── 遮罩 & 弹窗 ── */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 18px;
  background: rgba(3, 4, 10, 0.72);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: fade 0.22s ease both;
}
.overlay.hidden { display: none; }
@keyframes fade { from { opacity: 0; } }

/* 抽卡弹窗 */
.gacha-box {
  width: 100%; max-width: 780px; max-height: 92vh; overflow-y: auto;
  border-radius: 20px; padding: 22px;
  background: linear-gradient(180deg, rgba(24, 20, 46, 0.96), rgba(12, 12, 28, 0.98));
  border: 1px solid rgba(160, 130, 255, 0.4);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.7), 0 0 60px rgba(140, 90, 255, 0.18) inset;
  animation: boxIn 0.34s cubic-bezier(0.2, 0.9, 0.3, 1.15) both;
}
@keyframes boxIn { from { opacity: 0; transform: scale(0.9) translateY(14px); } }
.gacha-title {
  text-align: center; font-size: 18px; font-weight: 800; letter-spacing: 3px; margin-bottom: 18px;
  background: linear-gradient(90deg, #ffd98a, #fff, #ffd98a); -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 0 30px rgba(255, 200, 100, 0.4);
}
.gacha-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.gacha-grid:not(.ten) { grid-template-columns: repeat(auto-fit, minmax(140px, 180px)); justify-content: center; }
@media (max-width: 560px) { .gacha-grid { grid-template-columns: repeat(3, 1fr); } }

.gacha-card {
  position: relative; border-radius: 12px; overflow: hidden; aspect-ratio: 3 / 4;
  background: var(--panel-solid); border: 1.5px solid var(--border);
  animation: cardPop 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.4) both;
}
@keyframes cardPop { 0% { opacity: 0; transform: scale(0.4) rotate(-6deg); } 60% { transform: scale(1.06) rotate(1deg); } 100% { opacity: 1; transform: scale(1) rotate(0); } }
.gc-art { position: absolute; inset: 0; }
.gc-art img { width: 100%; height: 100%; object-fit: cover; object-position: center 18%; }
.gacha-card::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 55%, rgba(4, 6, 14, 0.9));
}
.gc-rarity { position: absolute; top: 5px; left: 0; right: 0; text-align: center; font-size: 9px; letter-spacing: 1px; z-index: 2; }
.gc-name { position: absolute; bottom: 6px; left: 0; right: 0; text-align: center; font-size: 12px; font-weight: 800; z-index: 2; text-shadow: 0 2px 8px #000; }
.gc-new {
  position: absolute; top: 22px; right: -26px; z-index: 3; transform: rotate(45deg);
  background: linear-gradient(90deg, #ff4d6d, #ff7a59); color: #fff;
  font-size: 9px; font-weight: 800; padding: 2px 28px; letter-spacing: 1px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
}
.gacha-card.r3 { border-color: rgba(111, 179, 255, 0.6); }
.gacha-card.r3 .gc-rarity { color: var(--r3); }
.gacha-card.r4 { border-color: rgba(181, 125, 255, 0.75); box-shadow: 0 0 22px rgba(181, 125, 255, 0.4); }
.gacha-card.r4 .gc-rarity { color: var(--r4); }
.gacha-card.r5 { border-color: rgba(255, 194, 71, 0.9); box-shadow: 0 0 30px rgba(255, 194, 71, 0.6); }
.gacha-card.r5 .gc-rarity { color: var(--r5); }
.gacha-card.r5::before {
  content: ""; position: absolute; inset: -1px; z-index: 1; pointer-events: none;
  background: linear-gradient(115deg, transparent 32%, rgba(255, 235, 170, 0.7) 48%, transparent 64%);
  background-size: 250% 100%; animation: shine 2.8s linear infinite;
}
.gacha-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; flex-wrap: wrap; }
.gacha-summary { font-size: 12.5px; color: var(--muted); }
.gacha-summary b { font-weight: 800; }

/* 图鉴 */
.codex-box {
  width: 100%; max-width: 900px; max-height: 92vh; display: flex; flex-direction: column;
  border-radius: 20px; padding: 20px;
  background: linear-gradient(180deg, rgba(16, 20, 38, 0.97), rgba(10, 12, 24, 0.99));
  border: 1px solid var(--border-strong);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.7);
  animation: boxIn 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.15) both;
}
.codex-tabs { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.tab {
  padding: 7px 16px; border-radius: 999px; cursor: pointer; font-family: inherit;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border); color: var(--muted);
  font-size: 12.5px; font-weight: 700; transition: all 0.2s;
}
.tab:hover { color: var(--text); }
.tab.active { background: rgba(255, 194, 71, 0.16); border-color: rgba(255, 194, 71, 0.6); color: var(--gold); }
.codex-body {
  flex: 1; overflow-y: auto; display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); padding-right: 4px;
}
.codex-body::-webkit-scrollbar { width: 8px; }
.codex-body::-webkit-scrollbar-thumb { background: rgba(120, 150, 220, 0.25); border-radius: 4px; }
.codex-card {
  display: flex; gap: 10px; padding: 10px; border-radius: 13px;
  background: rgba(255, 255, 255, 0.03); border: 1px solid var(--border);
  transition: border-color 0.2s, transform 0.2s;
}
.codex-card:hover { transform: translateY(-2px); }
.codex-card.r3 { border-left: 3px solid var(--r3); }
.codex-card.r4 { border-left: 3px solid var(--r4); }
.codex-card.r5 { border-left: 3px solid var(--r5); }
.codex-card.locked { opacity: 0.62; }
.cx-art { width: 74px; height: 98px; border-radius: 9px; overflow: hidden; flex-shrink: 0; background: #0a0c16; }
.cx-art img { width: 100%; height: 100%; object-fit: cover; object-position: center 15%; }
.codex-card.locked .cx-art img { filter: grayscale(1) brightness(0.4); }
.cx-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.cx-name { font-size: 14px; font-weight: 800; display: flex; align-items: center; gap: 6px; }
.cx-tag { font-size: 10px; font-weight: 600; color: var(--muted); background: rgba(255, 255, 255, 0.06); padding: 1px 7px; border-radius: 999px; }
.cx-rarity { font-size: 10px; letter-spacing: 1px; }
.codex-card.r3 .cx-rarity { color: var(--r3); }
.codex-card.r4 .cx-rarity { color: var(--r4); }
.codex-card.r5 .cx-rarity { color: var(--r5); }
.cx-stats { font-size: 12px; color: #b9c3e6; font-weight: 700; }
.cx-copy { font-size: 11px; color: var(--gold); }
.cx-locked { font-size: 12px; color: var(--dim); font-style: italic; }

/* 帮助 */
.help-box {
  width: 100%; max-width: 560px; border-radius: 20px; padding: 20px;
  background: linear-gradient(180deg, rgba(16, 20, 38, 0.97), rgba(10, 12, 24, 0.99));
  border: 1px solid var(--border-strong); box-shadow: 0 30px 90px rgba(0, 0, 0, 0.7);
  animation: boxIn 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.15) both;
}
.help-body p { font-size: 13px; line-height: 1.9; color: #c4cce8; }
.help-body b { color: var(--gold); }

/* 结算 */
.over-box {
  width: 100%; max-width: 420px; border-radius: 20px; padding: 28px; text-align: center;
  background: linear-gradient(180deg, rgba(28, 16, 26, 0.97), rgba(12, 10, 22, 0.99));
  border: 1px solid rgba(255, 107, 122, 0.35); box-shadow: 0 30px 90px rgba(0, 0, 0, 0.7);
  animation: boxIn 0.34s cubic-bezier(0.2, 0.9, 0.3, 1.15) both;
}
.over-icon { font-size: 46px; margin-bottom: 6px; animation: pulse 2s ease-in-out infinite; }
.over-box h2 { font-size: 22px; font-weight: 800; letter-spacing: 2px; }
.over-sub { font-size: 13px; color: var(--muted); margin: 6px 0 18px; }
.over-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.ov-item { padding: 10px; border-radius: 11px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--border); }
.ov-item i { display: block; font-style: normal; font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.ov-item b { font-size: 16px; font-weight: 800; }
.over-box .btn { width: 100%; }

.hidden { display: none !important; }
