/* ===== 玫瑰战争 移动端样式 ===== */
:root {
  --bg: #0d0d10;
  --bg-soft: #16161b;
  --card: #1c1c22;
  --line: #2a2a33;
  --fg: #e8e8ec;
  --fg-dim: #8b8b98;
  --gold: #d0ac67;
  --gold-soft: rgba(208, 172, 103, 0.14);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body { display: flex; flex-direction: column; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 12px;
  background: linear-gradient(180deg, #17171c 0%, #111116 100%);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.brand { display: flex; align-items: center; gap: 9px; min-width: 0; }

.dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 10px var(--gold);
  flex-shrink: 0;
}

.topbar h1 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg-soft);
  color: var(--fg-dim);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.18s;
}
.icon-btn:active { transform: scale(0.92); color: var(--gold); border-color: var(--gold); }
.icon-btn.spin svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 顶栏右侧按钮组 */
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* 自动连播开关：开启时高亮 */
.icon-btn.toggle.on {
  color: var(--gold);
  border-color: rgba(208, 172, 103, 0.55);
  background: var(--gold-soft);
}

/* ---------- 播放器 ---------- */
.player-wrap {
  position: relative;
  background: #000;
  width: 100%;
  aspect-ratio: 16 / 9;
  flex-shrink: 0;
}

.player { width: 100%; height: 100%; }

/* 播放器空状态提示 */
.tip {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--fg-dim);
  font-size: 13px;
  letter-spacing: 0.5px;
  pointer-events: none;
  background: radial-gradient(circle at 50% 45%, #191920 0%, #0a0a0d 100%);
  transition: opacity 0.3s;
}
.tip.hide { opacity: 0; }

/* 加载中 */
.tip.loading { color: var(--gold); }
.tip.loading::after {
  content: "";
  display: block;
  width: 18px; height: 18px;
  margin: 10px auto 0;
  border: 2px solid rgba(208, 172, 103, 0.25);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ---------- 选集面板 ---------- */
.episode-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: var(--safe-b);
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 16px 16px 10px;
  flex-shrink: 0;
}

.panel-head h2 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--fg);
}

.count { font-size: 12px; color: var(--fg-dim); }

.episodes {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 9px;
  padding: 4px 16px 20px;
  align-content: start;
}

.ep {
  position: relative;
  display: grid;
  place-items: center;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--fg);
  font-size: 14px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.18s, background 0.18s;
  user-select: none;
}

.ep:active { transform: scale(0.94); }

.ep.active {
  border-color: var(--gold);
  background: var(--gold-soft);
  color: var(--gold);
  font-weight: 700;
}

/* 正在解析的这一集 */
.ep.loading {
  color: var(--gold);
  border-color: rgba(208, 172, 103, 0.5);
}
.ep.loading::after {
  content: "";
  position: absolute;
  width: 15px; height: 15px;
  border: 2px solid rgba(208, 172, 103, 0.22);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
.ep.loading span { opacity: 0.25; }

/* 解析失败 */
.ep.failed { border-color: #7a2f2f; color: #d97a7a; }

.ep span { pointer-events: none; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + var(--safe-b));
  transform: translate(-50%, 16px);
  max-width: 82vw;
  padding: 10px 18px;
  border-radius: 10px;
  background: rgba(30, 30, 38, 0.96);
  border: 1px solid var(--line);
  color: var(--fg);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.24s, transform 0.24s;
  backdrop-filter: blur(12px);
  z-index: 9999;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 横屏优化 ---------- */
@media (orientation: landscape) and (max-height: 520px) {
  .player-wrap { aspect-ratio: auto; height: 100vh; }
  .topbar, .episode-panel { display: none; }
}
