:root {
  --bg: #10080b;
  --bg-2: #1a0e13;
  --panel: rgba(28, 14, 18, 0.82);
  --line: rgba(232, 197, 106, 0.18);
  --gold: #e8c56a;
  --gold-2: #b8892d;
  --wine: #8b2942;
  --cream: #f6efe4;
  --muted: #cbb8a8;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  --radius: 22px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--cream);
  font-family: Manrope, "Segoe UI", sans-serif;
}

body {
  position: relative;
  overflow-x: hidden;
}

.atmosphere {
  pointer-events: none;
  position: fixed;
  inset: 0;
  background:
    radial-gradient(900px 500px at 8% -10%, rgba(139, 41, 66, 0.38), transparent 60%),
    radial-gradient(700px 420px at 100% 0%, rgba(184, 137, 45, 0.16), transparent 55%),
    linear-gradient(180deg, #160b0f 0%, #0d0709 100%);
  z-index: -1;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.topbar {
  max-width: 1280px;
  margin: 0 auto;
  padding: 22px 24px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  text-align: left;
  cursor: pointer;
}

.catalog {
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 24px 48px;
}

.catalog-head h2 {
  margin: 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 36px;
}

.catalog-head p {
  margin: 8px 0 0;
  color: var(--muted);
}

.series-grid {
  margin-top: 22px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.series-card {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel);
  color: inherit;
  border-radius: 20px;
  overflow: hidden;
  text-align: left;
  cursor: pointer;
  padding: 0;
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.series-card:hover {
  transform: translateY(-3px);
  border-color: rgba(232, 197, 106, 0.45);
}

.series-cover {
  aspect-ratio: 16 / 10;
  display: grid;
  place-items: center;
  background:
    linear-gradient(145deg, rgba(139, 41, 66, 0.85), rgba(26, 14, 19, 0.95)),
    radial-gradient(circle at 30% 20%, rgba(232, 197, 106, 0.35), transparent 55%);
}

.series-cover span {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 42px;
  color: var(--gold);
  letter-spacing: 0.08em;
}

.series-body {
  padding: 16px 18px 18px;
}

.series-body h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.35;
}

.series-meta {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.player-toolbar {
  grid-column: 1 / -1;
}

.player-view.hidden,
.catalog.hidden {
  display: none !important;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background:
    linear-gradient(145deg, var(--gold) 0%, var(--gold-2) 45%, var(--wine) 100%);
  box-shadow: 0 8px 24px rgba(139, 41, 66, 0.35);
}

.brand-kicker {
  margin: 0;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-size: 11px;
  color: var(--gold);
}

.brand h1 {
  margin: 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 32px;
  font-weight: 600;
  line-height: 1;
}

.top-meta { display: flex; gap: 8px; }

.pill {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--gold);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
}

.layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 24px 40px;
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(280px, 0.9fr);
  gap: 22px;
}

.player-shell {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,0.06);
}

html.fs-lock,
body.fs-lock {
  overflow: hidden !important;
  height: 100%;
  overscroll-behavior: none;
  touch-action: none;
}

.player-shell.is-fs,
.player-shell:fullscreen,
.player-shell:-webkit-full-screen {
  position: fixed;
  inset: 0;
  z-index: 10000;
  width: 100%;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  border-radius: 0;
  aspect-ratio: auto;
  border: 0;
  box-shadow: none;
}

.fs-fab {
  display: none;
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  z-index: 6;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.55);
  color: var(--cream);
  place-items: center;
  cursor: pointer;
  backdrop-filter: blur(6px);
}

.fs-fab svg,
.icon-btn .icon-enter-fs,
.icon-btn .icon-exit-fs {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.player-shell.is-fs .player-bar,
.player-shell:fullscreen .player-bar,
.player-shell:-webkit-full-screen .player-bar,
.player-shell.is-fs.show-controls .player-bar {
  opacity: 1;
  transform: none;
  padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
}

video {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
  object-fit: contain;
}

.player-overlay,
.error-card,
.resume-card {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, rgba(0,0,0,0.08), rgba(0,0,0,0.35));
}

.resume-card,
.error-card {
  background: rgba(12, 6, 8, 0.72);
  backdrop-filter: blur(8px);
  gap: 10px;
  text-align: center;
  padding: 24px;
}

.resume-card p,
.error-card p {
  margin: 0;
  font-family: Manrope, "Segoe UI", sans-serif;
  font-size: 20px;
  font-weight: 700;
}

.resume-time {
  color: var(--gold) !important;
  font-family: Manrope, sans-serif !important;
  font-size: 16px !important;
}

.resume-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

.hidden { display: none !important; }

.play-giant {
  width: 84px;
  height: 84px;
  border: 0;
  border-radius: 50%;
  background: rgba(232, 197, 106, 0.92);
  color: #1a0e13;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 12px 30px rgba(0,0,0,0.35);
}

.play-giant svg { width: 36px; height: 36px; fill: currentColor; margin-left: 4px; }

.player-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px 14px;
  background: linear-gradient(transparent, rgba(0,0,0,0.78));
  opacity: 0;
  transform: translateY(8px);
  transition: 0.2s ease;
}

.player-shell:hover .player-bar,
.player-shell:focus-within .player-bar,
.player-shell.show-controls .player-bar {
  opacity: 1;
  transform: none;
}

.icon-btn,
.speed-wrap select {
  border: 0;
  background: rgba(255,255,255,0.08);
  color: var(--cream);
  border-radius: 10px;
  min-width: 40px;
  height: 36px;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
}

.icon-btn svg { width: 18px; height: 18px; fill: currentColor; }

.time {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: #f0e6d6;
  min-width: 42px;
}

.scrub {
  position: relative;
  flex: 1;
  height: 18px;
  display: grid;
  align-items: center;
}

.scrub-fill {
  position: absolute;
  left: 0;
  height: 4px;
  width: 0;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--wine), var(--gold));
  pointer-events: none;
}

#seek {
  position: relative;
  z-index: 1;
  width: 100%;
  appearance: none;
  background: rgba(255,255,255,0.2);
  height: 4px;
  border-radius: 99px;
}

#seek::-webkit-slider-thumb {
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--gold);
  border: 0;
}

.now-playing {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding: 16px 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
}

.now-kicker {
  margin: 0;
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.now-playing h2 {
  margin: 4px 0 0;
  font-family: Manrope, "Segoe UI", sans-serif;
  font-size: 24px;
  font-weight: 700;
}

.nav-eps { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  border: 0;
  border-radius: 12px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.btn.primary {
  background: linear-gradient(180deg, var(--gold), var(--gold-2));
  color: #1b100c;
}

.btn.ghost {
  background: transparent;
  color: var(--cream);
  border: 1px solid var(--line);
}

.btn.compact { padding: 8px 12px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  backdrop-filter: blur(10px);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.panel h2 {
  margin: 0;
  font-family: Manrope, "Segoe UI", sans-serif;
  font-size: 22px;
  font-weight: 700;
}

.auto-next {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.jump-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  margin: 16px 0;
}

.jump-row label { color: var(--muted); font-size: 13px; }

.jump-row input {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.28);
  color: var(--cream);
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
}

.episode-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  max-height: 52vh;
  overflow: auto;
  padding-right: 4px;
}

.ep {
  appearance: none;
  border: 1px solid transparent;
  background: rgba(255,255,255,0.05);
  color: var(--cream);
  border-radius: 12px;
  min-height: 44px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.ep:hover { border-color: var(--gold); }
.ep.current {
  background: linear-gradient(180deg, var(--gold), var(--gold-2));
  color: #1b100c;
}
.ep.watched:not(.current) {
  background: rgba(139, 41, 66, 0.35);
  color: #f3d9b0;
}
.ep.unavailable:not(.current) {
  opacity: 0.45;
  text-decoration: line-through;
}

.hint {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .episode-grid { max-height: none; grid-template-columns: repeat(6, 1fr); }
  .brand h1 { font-size: 26px; }
  .fs-fab { display: grid; }
  .player-shell.show-controls .player-bar,
  .player-shell.is-fs .player-bar {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 640px) {
  .topbar, .layout, .catalog { padding-left: 14px; padding-right: 14px; }
  .brand h1, #page-title { font-size: 22px; }
  .catalog-head h2 { font-size: 28px; }
  .now-playing, .panel-head, .nav-eps { flex-direction: column; align-items: stretch; }
  .episode-grid { grid-template-columns: repeat(5, 1fr); }
  .player-bar { gap: 4px; padding-left: 8px; padding-right: 8px; }
  #btn-pip, .speed-wrap { display: none; }
  .icon-btn { min-width: 44px; height: 44px; }
}
