/* ============================================================
 * 星海绮谭 · 样式
 * 暗色星海奇幻主题 / 响应式 / 抽卡动画 / 品质光效
 * ============================================================ */

:root {
  --bg-0: #07060f;
  --bg-1: #100b24;
  --bg-2: #1b1338;
  --panel: rgba(28, 22, 56, 0.72);
  --panel-solid: #181230;
  --line: rgba(160, 140, 255, 0.18);
  --text: #ece8ff;
  --text-dim: #a79fd0;
  --gold: #ffcf5c;

  --q-R: #5aa9e6;
  --q-SR: #b06bff;
  --q-SSR: #ffcf5c;
  --q-R-glow: rgba(90, 169, 230, .85);
  --q-SR-glow: rgba(176, 107, 255, .9);
  --q-SSR-glow: rgba(255, 207, 92, 1);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 70% -10%, #2a1c5c 0%, transparent 55%),
    radial-gradient(900px 600px at 10% 110%, #14264f 0%, transparent 50%),
    linear-gradient(180deg, var(--bg-1), var(--bg-0));
  background-attachment: fixed;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* 星点背景 */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    radial-gradient(1.5px 1.5px at 20% 30%, rgba(255,255,255,.8), transparent),
    radial-gradient(1.5px 1.5px at 75% 15%, rgba(255,255,255,.6), transparent),
    radial-gradient(1px 1px at 50% 60%, rgba(255,255,255,.7), transparent),
    radial-gradient(1.5px 1.5px at 85% 70%, rgba(190,200,255,.7), transparent),
    radial-gradient(1px 1px at 30% 80%, rgba(255,255,255,.5), transparent),
    radial-gradient(1px 1px at 65% 45%, rgba(255,255,255,.55), transparent);
  background-size: 100% 100%;
  opacity: .6;
}

/* ===================== 顶部栏 ===================== */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  background: linear-gradient(180deg, rgba(10,8,24,.92), rgba(10,8,24,.55));
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; }
.brand-mark { color: var(--gold); filter: drop-shadow(0 0 6px var(--gold)); font-size: 18px; }
.brand-name { font-size: 18px; letter-spacing: 2px; background: linear-gradient(90deg,#fff,#c9b8ff); -webkit-background-clip: text; background-clip: text; color: transparent; }

.tabs { display: flex; gap: 6px; background: rgba(255,255,255,.05); padding: 4px; border-radius: 999px; border: 1px solid var(--line); }
.tab {
  border: 0; background: transparent; color: var(--text-dim);
  font-size: 14px; font-weight: 700; padding: 8px 18px; border-radius: 999px; cursor: pointer;
  transition: .25s;
}
.tab.active { color: #fff; background: linear-gradient(135deg, #7b5cff, #b06bff); box-shadow: 0 4px 14px rgba(123,92,255,.45); }

.collect { text-align: right; line-height: 1.1; }
.collect-num { font-weight: 800; color: var(--gold); font-size: 15px; }
.collect-label { display: block; font-size: 11px; color: var(--text-dim); }

/* ===================== 视图切换 ===================== */
.view { position: relative; z-index: 1; display: none; padding: 16px; max-width: 1180px; margin: 0 auto; }
.view.active { display: block; animation: fadeUp .4s ease; }

/* ===================== 首页 Hero ===================== */
.hero { position: relative; text-align: center; padding: 26px 10px 18px; overflow: hidden; }
.hero-glow {
  position: absolute; left: 50%; top: -40px; transform: translateX(-50%);
  width: 520px; height: 320px; max-width: 110vw;
  background: radial-gradient(closest-side, rgba(176,107,255,.35), transparent 70%);
  filter: blur(8px); pointer-events: none;
}
.hero-title { position: relative; font-size: clamp(20px, 5.5vw, 34px); font-weight: 800; letter-spacing: 1px;
  background: linear-gradient(90deg,#fff,#ffe6a8,#c9b8ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-sub { position: relative; margin-top: 8px; color: var(--text-dim); font-size: clamp(12px,3.4vw,15px); }
.hero-sub b { color: var(--gold); }

.gacha-actions { position: relative; display: flex; gap: 14px; justify-content: center; margin: 24px auto 8px; flex-wrap: wrap; max-width: 560px; }
.pull-btn {
  position: relative; flex: 1 1 160px; min-width: 150px; max-width: 260px;
  border: 0; cursor: pointer; color: #fff; border-radius: 18px;
  padding: 18px 16px 16px; text-align: center; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: transform .12s ease, box-shadow .25s;
}
.pull-btn:active { transform: translateY(2px) scale(.98); }
.pull-main { font-size: 20px; font-weight: 800; letter-spacing: 1px; }
.pull-sub { font-size: 12px; opacity: .8; }
.pull-1 { background: linear-gradient(135deg,#3a7bd5,#5aa9e6); box-shadow: 0 8px 24px rgba(58,123,213,.45), inset 0 1px 0 rgba(255,255,255,.3); }
.pull-10 { background: linear-gradient(135deg,#9b2fff,#ff7ad9); box-shadow: 0 8px 28px rgba(176,47,255,.5), inset 0 1px 0 rgba(255,255,255,.3); }
.pull-badge { position: absolute; top: 8px; right: 8px; font-size: 10px; font-weight: 700; background: var(--gold); color: #4a2d00; padding: 3px 7px; border-radius: 999px; box-shadow: 0 2px 6px rgba(0,0,0,.3); }
.pull-btn::after { content:""; position:absolute; top:0; left:-60%; width:40%; height:100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.45), transparent); transform: skewX(-20deg);
  animation: shimmer 3.5s infinite; }
.rates { text-align: center; color: var(--text-dim); font-size: 12px; margin-top: 6px; }

/* ===================== 剪影墙 ===================== */
.wall { margin-top: 22px; }
.wall-head { text-align: center; margin-bottom: 14px; }
.wall-head h2 { font-size: 18px; letter-spacing: 1px; }
.wall-head p { color: var(--text-dim); font-size: 12px; margin-top: 4px; }

.silhouette-wall {
  position: relative;
  --base-h: clamp(76px, 19vw, 150px);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 30px 14px 22px;
  border-radius: 20px;
  border: 1px solid var(--line);
  overflow: hidden;
  background:
    radial-gradient(150% 80% at 50% 108%, rgba(123,92,255,.24), transparent 72%),
    linear-gradient(180deg, rgba(22,16,48,.55), rgba(8,6,18,.82));
}
.silhouette-wall::after {
  content: ""; position: absolute; left: 4%; right: 4%; bottom: 14px; height: 2px;
  background: linear-gradient(90deg, transparent, rgba(176,107,255,.5), transparent);
  filter: blur(.5px); pointer-events: none;
}
/* 一排合影；后排在前排之后（DOM 顺序在前→被后续前排盖住） */
.wall-row {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  width: 100%;
}
.wall-row + .wall-row { margin-top: calc(var(--base-h) * var(--row-scale, 1) * -0.5); }
.cell {
  position: relative;
  height: calc(var(--base-h) * var(--row-scale, 1));
  margin: 0 calc(var(--base-h) * var(--row-scale, 1) * -0.06);
  display: flex;
  align-items: flex-end;
  cursor: pointer;
  transition: transform .25s ease;
}
.cell .cell-img {
  height: 100%; width: auto; max-width: none;
  object-fit: contain; object-position: bottom;
  filter: brightness(0) saturate(0);
  opacity: .5;
  transition: filter .8s ease, opacity .8s ease;
}
.cell.owned .cell-img { filter: drop-shadow(0 5px 10px rgba(0,0,0,.55)); opacity: 1; }
.cell.owned.q-R   .cell-img { filter: drop-shadow(0 0 9px var(--q-R-glow)); }
.cell.owned.q-SR  .cell-img { filter: drop-shadow(0 0 12px var(--q-SR-glow)); }
.cell.owned.q-SSR .cell-img { filter: drop-shadow(0 0 16px var(--q-SSR-glow)); }
.cell:hover { transform: translateY(-10px); z-index: 50; }
.cell.locked { opacity: .82; }
.cell .cell-name {
  position: absolute; left: 50%; bottom: calc(100% - 10px); transform: translateX(-50%);
  white-space: nowrap; font-size: 11px; font-weight: 700; color: #fff;
  background: rgba(8,6,20,.9); border: 1px solid var(--line);
  padding: 3px 9px; border-radius: 8px; opacity: 0; pointer-events: none;
  transition: opacity .25s; z-index: 60;
}
.cell:hover .cell-name { opacity: 1; }

/* ===================== 图鉴 ===================== */
.filters { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.filter-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: rgba(255,255,255,.04); color: var(--text-dim);
  padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 700; cursor: pointer; transition:.2s; }
.chip.mini { padding: 6px 12px; font-size: 12px; }
.chip.active { color: #fff; background: linear-gradient(135deg,#6b53ff,#b06bff); border-color: transparent; box-shadow: 0 4px 12px rgba(123,92,255,.35); }

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(120px, 30vw, 190px), 1fr));
  gap: 14px;
}

/* ===================== 角色卡片（通用） ===================== */
.card {
  position: relative; aspect-ratio: 3/4.2; border-radius: 16px; overflow: hidden; cursor: pointer;
  background: #0c0a1c; border: 1px solid var(--line);
  transition: transform .2s, box-shadow .3s;
}
.card:active { transform: scale(.97); }
.card-bg { position: absolute; inset: 0; background-size: cover; background-position: center; }
.card-bg.fallback-R { background: radial-gradient(120% 80% at 50% 0%, #2a4a78, #0e1a33); }
.card-bg.fallback-SR { background: radial-gradient(120% 80% at 50% 0%, #4a2a78, #1a0e33); }
.card-bg.fallback-SSR { background: radial-gradient(120% 80% at 50% 0%, #7a5a1a, #33240e); }
.card-char { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); width: 118%; height: 91%; object-fit: contain; object-position: bottom; filter: drop-shadow(0 6px 16px rgba(0,0,0,.5)); }
.card-frame { position: absolute; inset: 0; border-radius: 16px; pointer-events: none; box-shadow: inset 0 0 0 2px rgba(255,255,255,.12); }
.q-R .card-frame { box-shadow: inset 0 0 0 2px var(--q-R), inset 0 0 26px rgba(90,169,230,.35); }
.q-SR .card-frame { box-shadow: inset 0 0 0 2px var(--q-SR), inset 0 0 30px rgba(176,107,255,.4); }
.q-SSR .card-frame { box-shadow: inset 0 0 0 2px var(--q-SSR), inset 0 0 36px rgba(255,207,92,.5); }
.card-info { position: absolute; left: 0; right: 0; bottom: 0; padding: 26px 10px 10px; background: linear-gradient(180deg, transparent, rgba(0,0,0,.82)); }
.card-stars { font-size: 11px; letter-spacing: 1px; }
.q-R .card-stars { color: var(--q-R); }
.q-SR .card-stars { color: var(--q-SR); }
.q-SSR .card-stars { color: var(--q-SSR); text-shadow: 0 0 8px var(--q-SSR-glow); }
.card-name { font-size: 15px; font-weight: 800; margin-top: 2px; }
.card-title { font-size: 11px; color: var(--text-dim); }
.card-cat { position: absolute; top: 8px; left: 8px; font-size: 10px; padding: 2px 7px; border-radius: 8px; background: rgba(0,0,0,.5); border: 1px solid var(--line); }
.card-q { position: absolute; top: 8px; right: 8px; font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 8px; color:#fff; }
.q-R .card-q { background: var(--q-R); }
.q-SR .card-q { background: var(--q-SR); }
.q-SSR .card-q { background: linear-gradient(135deg,#ffcf5c,#ff9a3c); color:#5a3500; }

/* 图鉴里未获得：剪影 */
.card.locked .card-char { filter: brightness(0) saturate(0); opacity: .55; }
.card.locked .card-bg { filter: grayscale(1) brightness(.5); }
.card.locked .card-name, .card.locked .card-title { color: var(--text-dim); }
.card.unimplemented { display: flex; align-items: center; justify-content: center; }
.card.unimplemented .soon-box { text-align: center; color: var(--text-dim); }
.card.unimplemented .soon-box .qm { font-size: 40px; font-weight: 800; }

/* ===================== 遮罩通用 ===================== */
.overlay { position: fixed; inset: 0; z-index: 50; display: none; align-items: center; justify-content: center; }
.overlay.active { display: flex; }
.overlay-bg { position: absolute; inset: 0; background: rgba(4,3,12,.92); backdrop-filter: blur(6px); }

/* ===================== 抽卡舞台 ===================== */
.gacha-overlay .overlay-bg { background: radial-gradient(circle at 50% 40%, rgba(40,20,80,.96), rgba(4,3,12,.98)); }
.skip-btn { position: absolute; top: calc(14px + var(--safe-top)); right: 16px; z-index: 5; background: rgba(255,255,255,.1);
  border: 1px solid var(--line); color: var(--text); padding: 8px 16px; border-radius: 999px; font-size: 13px; cursor: pointer; }
.gacha-stage { position: relative; z-index: 2; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }

/* 翻牌卡 */
.flip-card { width: min(72vw, 300px); aspect-ratio: 3/4.2; perspective: 1400px; }
.flip-inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .7s cubic-bezier(.4,.2,.2,1); }
.flip-card.flipped .flip-inner { transform: rotateY(180deg); }
.flip-face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: 16px; overflow: hidden; }
.flip-back { background: #0c0a1c center/cover; display: flex; align-items: center; justify-content: center; border: 1px solid var(--line); box-shadow: 0 0 40px rgba(123,92,255,.4); }
.flip-back img { width: 100%; height: 100%; object-fit: cover; }
.flip-front { transform: rotateY(180deg); }

/* 品质登场光效 */
.fx { position: absolute; inset: 0; z-index: 1; pointer-events: none; display: flex; align-items: center; justify-content: center; }
.fx .burst { width: 60vmax; height: 60vmax; border-radius: 50%; opacity: 0; }
.fx.show .burst { animation: burst 1.1s ease forwards; }
.fx.q-R .burst { background: radial-gradient(circle, var(--q-R-glow), transparent 60%); }
.fx.q-SR .burst { background: radial-gradient(circle, var(--q-SR-glow), transparent 60%); }
.fx.q-SSR .burst { background: radial-gradient(circle, var(--q-SSR-glow), transparent 62%); }
.fx .rays { position: absolute; width: 140vmax; height: 140vmax; opacity: 0;
  background: repeating-conic-gradient(from 0deg, rgba(255,255,255,.14) 0deg 4deg, transparent 4deg 12deg); }
.fx.q-SSR.show .rays { animation: rays 1.4s ease forwards; }

/* 十连总览 */
.result-summary { position: absolute; inset: 0; z-index: 3; display: none; flex-direction: column;
  padding: calc(60px + var(--safe-top)) 14px calc(20px + var(--safe-bottom)); overflow: auto; }
.result-summary.active { display: flex; }
.result-summary h3 { text-align: center; margin-bottom: 14px; font-size: 18px; letter-spacing: 1px; }
.result-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; max-width: 560px; margin: 0 auto; width: 100%; }
.result-grid .mini-card { aspect-ratio: 3/4.2; }
.summary-actions { display: flex; gap: 12px; justify-content: center; margin-top: 18px; }
.summary-actions button { border: 0; padding: 12px 26px; border-radius: 12px; font-weight: 800; cursor: pointer; font-size: 15px; }
.btn-again { background: linear-gradient(135deg,#9b2fff,#ff7ad9); color: #fff; }
.btn-close { background: rgba(255,255,255,.12); color: #fff; border: 1px solid var(--line); }

.mini-card { position: relative; border-radius: 10px; overflow: hidden; }
.mini-card.new::after { content: "NEW"; position: absolute; top: 4px; left: 4px; font-size: 9px; font-weight: 800; background: var(--gold); color: #4a2d00; padding: 1px 5px; border-radius: 6px; z-index:2; }
.mini-pop { animation: pop .45s ease both; }

/* 单抽信息条 */
.single-info { position: absolute; left: 0; right: 0; bottom: calc(8% + var(--safe-bottom)); z-index: 4; text-align: center; opacity: 0; }
.single-info.show { animation: fadeUp .5s ease forwards; }
.single-info .si-stars { font-size: 18px; letter-spacing: 2px; }
.single-info.q-R .si-stars { color: var(--q-R); }
.single-info.q-SR .si-stars { color: var(--q-SR); }
.single-info.q-SSR .si-stars { color: var(--q-SSR); text-shadow: 0 0 10px var(--q-SSR-glow); }
.single-info .si-name { font-size: 26px; font-weight: 800; margin-top: 4px; }
.single-info .si-title { color: var(--text-dim); font-size: 14px; }
.single-info .si-tip { margin-top: 10px; font-size: 12px; color: var(--text-dim); }

/* ===================== 角色详情 ===================== */
.detail-panel { position: relative; z-index: 2; width: min(94vw, 880px); max-height: 90dvh; overflow: auto;
  background: linear-gradient(160deg, #1a1338, #0e0a22); border: 1px solid var(--line); border-radius: 22px;
  display: grid; grid-template-columns: 1fr 1fr; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.detail-art { position: relative; min-height: 360px; display: flex; align-items: flex-end; justify-content: center; }
.detail-art .d-bg { position: absolute; inset: 0; background-size: cover; background-position: center; }
.detail-art .d-char { position: relative; z-index: 1; width: 100%; height: 100%; object-fit: contain; object-position: bottom; filter: drop-shadow(0 8px 20px rgba(0,0,0,.6)); }
.detail-art .d-grad { position: absolute; inset: 0; background: linear-gradient(90deg, transparent 60%, #140e2c); }
.detail-info { padding: 26px 24px; }
.detail-close { position: absolute; top: 12px; right: 14px; z-index: 5; width: 36px; height: 36px; border-radius: 50%;
  background: rgba(0,0,0,.4); border: 1px solid var(--line); color: #fff; font-size: 18px; cursor: pointer; }
.d-q { display: inline-block; font-weight: 800; font-size: 12px; padding: 3px 10px; border-radius: 8px; color:#fff; }
.q-R .d-q { background: var(--q-R); }
.q-SR .d-q { background: var(--q-SR); }
.q-SSR .d-q { background: linear-gradient(135deg,#ffcf5c,#ff9a3c); color:#5a3500; }
.d-stars { letter-spacing: 2px; margin-left: 8px; }
.q-R .d-stars { color: var(--q-R); } .q-SR .d-stars { color: var(--q-SR); } .q-SSR .d-stars { color: var(--q-SSR); }
.d-name { font-size: 30px; font-weight: 800; margin: 10px 0 2px; }
.d-title { color: var(--gold); font-size: 14px; margin-bottom: 14px; }
.d-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.d-tag { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: rgba(255,255,255,.06); border: 1px solid var(--line); color: var(--text-dim); }
.d-stats { display: flex; gap: 18px; margin-bottom: 16px; }
.d-stat .v { font-size: 22px; font-weight: 800; color: #fff; }
.d-stat .k { font-size: 11px; color: var(--text-dim); }
.d-bio { line-height: 1.9; color: #d9d3ff; font-size: 14px; background: rgba(255,255,255,.04); padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line); }
.d-bio-label { font-size: 12px; color: var(--gold); letter-spacing: 2px; margin-bottom: 8px; }
.d-locked { text-align: center; padding: 40px 10px; color: var(--text-dim); }

/* ===================== 动画 ===================== */
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes shimmer { 0% { left: -60%; } 60%,100% { left: 130%; } }
@keyframes burst { 0% { opacity: 0; transform: scale(.2); } 40% { opacity: .9; } 100% { opacity: 0; transform: scale(1.1); } }
@keyframes rays { 0% { opacity: 0; transform: rotate(0) scale(.5); } 40% { opacity: .7; } 100% { opacity: 0; transform: rotate(40deg) scale(1.2); } }
@keyframes pop { 0% { transform: scale(.5); opacity: 0; } 70% { transform: scale(1.08); } 100% { transform: scale(1); opacity: 1; } }
@keyframes floaty { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

/* ===================== 响应式 ===================== */
@media (max-width: 640px) {
  .detail-panel { grid-template-columns: 1fr; }
  .detail-art { min-height: 300px; }
  .detail-art .d-grad { background: linear-gradient(180deg, transparent 55%, #140e2c); }
  .detail-info { padding: 18px 18px 24px; }
  .d-name { font-size: 24px; }
  .result-grid { grid-template-columns: repeat(5, 1fr); gap: 6px; }
  .tabs .tab { padding: 7px 14px; }
  .topbar { padding-top: calc(8px + var(--safe-top)); }
}
@media (max-width: 380px) {
  .gacha-actions { gap: 10px; }
  .pull-main { font-size: 18px; }
}
@media (min-width: 900px) {
  .view { padding: 24px; }
  .flip-card { width: min(46vh, 440px); }
  .single-info { bottom: calc(11% + var(--safe-bottom)); }
  .single-info .si-stars { font-size: 26px; }
  .single-info .si-name { font-size: 40px; }
  .single-info .si-title { font-size: 18px; }
  .single-info .si-tip { font-size: 14px; }
  .result-summary { padding-top: calc(72px + var(--safe-top)); }
  .result-summary h3 { font-size: 24px; }
  .result-grid { max-width: 920px; gap: 14px; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 20px; }
  .pull-btn { max-width: 320px; min-width: 210px; padding: 24px 20px 20px; border-radius: 22px; }
  .pull-main { font-size: 26px; }
  .pull-sub { font-size: 14px; }
  .silhouette-wall { --base-h: clamp(118px, 12.5vw, 165px); padding: 40px 24px 30px; }
}

/* 减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .05ms !important; }
}
