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

:root {
  --bg: #12121c;
  --bg2: #1e1e2e;
  --fg: #ffffff;
  --sub: #b9b9cc;
  --accent: #ff6b35;
  --green: #22c55e;
}

html, body {
  margin: 0; padding: 0; height: 100%; width: 100%;
  background: var(--bg); color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
}

[hidden] { display: none !important; }

.screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  width: 100%; height: 100%;
}

/* ---------- 加载 / 错误 ---------- */
.loading-screen, .error-screen {
  align-items: center; justify-content: center;
  text-align: center; padding: 32px;
}
.loader {
  width: 72px; height: 72px;
  border: 8px solid rgba(255,255,255,.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { margin-top: 28px; font-size: 24px; color: var(--sub); }
.big-emoji { font-size: 84px; line-height: 1; }
.error-screen h1 { font-size: 30px; margin: 24px 0 8px; }
.error-screen p { font-size: 22px; color: var(--sub); line-height: 1.5; margin: 8px 0 32px; }

.big-btn {
  display: inline-block;
  min-width: 220px; padding: 18px 32px;
  font-size: 26px; font-weight: 700;
  color: #fff; background: var(--accent);
  border: 0; border-radius: 18px;
  cursor: pointer;
}
.big-btn.green { background: var(--green); }
.big-btn.ghost { background: rgba(255,255,255,.12); margin-top: 16px; }
.big-btn:active { transform: scale(.97); }

/* ---------- 首页 ---------- */
.home-header {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 20px 14px;
  background: linear-gradient(180deg, #23233a, var(--bg));
}
.home-title { display: flex; align-items: center; gap: 12px; font-size: 30px; font-weight: 800; }
.title-icon { font-size: 34px; }
/* 退出按钮默认隐藏：避免长辈误触离开。长按 3 秒仍可退出。 */
.exit-btn {
  font-size: 22px; line-height: 1;
  width: 44px; height: 44px;
  border: 0; border-radius: 50%;
  background: rgba(255,255,255,.08); color: rgba(255,255,255,.35);
  opacity: .25;
}
.video-grid {
  flex: 1 1 auto;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  padding: 18px 16px 24px;
  align-content: start;
}
@media (min-width: 720px) { .video-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1100px) { .video-grid { grid-template-columns: repeat(4, 1fr); } }

.video-card {
  position: relative;
  background: var(--bg2);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(0,0,0,.35);
  cursor: pointer;
  transition: transform .08s;
}
.video-card:active { transform: scale(.96); }
.card-poster {
  width: 100%; aspect-ratio: 16 / 10;
  object-fit: cover; display: block; background: #2a2a40;
}
.poster-placeholder {
  width: 100%; aspect-ratio: 16 / 10;
  display: flex; align-items: center; justify-content: center;
  font-size: 64px; font-weight: 800;
  background: linear-gradient(135deg, #3a2a5e, #1f4e5f);
}
.card-body { padding: 12px 12px 14px; }
.card-title {
  font-size: 21px; font-weight: 700; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; min-height: 52px;
}
.card-num {
  position: absolute; top: 10px; left: 10px;
  min-width: 42px; height: 42px; padding: 0 8px;
  border-radius: 12px;
  background: rgba(0,0,0,.65); color: #fff;
  font-size: 22px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.card-play {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 68px; height: 68px; border-radius: 50%;
  background: rgba(0,0,0,.55);
  border: 3px solid rgba(255,255,255,.85);
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; padding-left: 4px;
}
.card-progress {
  position: absolute; bottom: 0; left: 0; height: 6px;
  background: var(--accent); width: 0;
}
.empty-state {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
  padding: 32px;
}
.empty-state p { font-size: 26px; margin: 16px 0 0; }
.empty-state .sub { font-size: 20px; color: var(--sub); }
.home-footer {
  flex: 0 0 auto; text-align: center;
  padding: 10px 0 calc(12px + env(safe-area-inset-bottom));
  font-size: 19px; color: var(--sub);
  background: var(--bg);
}

/* ---------- 播放器 ---------- */
.player-screen { background: #000; }
#video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.tap-area { position: absolute; inset: 0; z-index: 5; }
.video-fallback {
  position: absolute; inset: 0; z-index: 8;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: #000; text-align: center; padding: 32px;
}
.video-fallback p { font-size: 24px; color: var(--sub); }

.controls {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 10;
  padding: 20px 20px calc(24px + env(safe-area-inset-bottom));
  background: linear-gradient(0deg, rgba(0,0,0,.92) 0%, rgba(0,0,0,.65) 60%, transparent 100%);
  transition: opacity .25s, transform .25s;
}
.controls.hidden { opacity: 0; transform: translateY(20px); pointer-events: none; }
.controls-top { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.now-title { flex: 1; text-align: center; font-size: 24px; font-weight: 700; }
.ctrl-btn {
  color: #fff; border: 0; background: rgba(255,255,255,.14);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.ctrl-btn:active { background: rgba(255,255,255,.3); }
.ctrl-btn.round { width: 62px; height: 62px; border-radius: 50%; font-size: 28px; }
.ctrl-btn.giant {
  width: 84px; height: 84px; border-radius: 24px; font-size: 40px;
  background: rgba(255,255,255,.16);
}
.controls-center { display: flex; align-items: center; justify-content: center; gap: 26px; margin-bottom: 22px; }
#playBtn { width: 104px; height: 104px; border-radius: 50%; font-size: 52px; background: var(--accent); }

.seek-wrap { display: flex; align-items: center; gap: 14px; }
.time { font-size: 20px; color: #ddd; min-width: 66px; text-align: center; font-variant-numeric: tabular-nums; }
.seek {
  flex: 1; height: 10px; border-radius: 6px;
  -webkit-appearance: none; appearance: none;
  background: rgba(255,255,255,.28); outline: none;
}
.seek::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); border: 3px solid #fff;
}
.seek::-moz-range-thumb {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); border: 3px solid #fff;
}

/* ---------- 下一部提示 ---------- */
.next-overlay {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.85); padding: 28px;
}
.next-card { text-align: center; width: 100%; max-width: 520px; }
.next-label { font-size: 22px; color: var(--sub); }
.next-title { font-size: 34px; font-weight: 800; margin: 16px 0 32px; line-height: 1.3; }
