:root {
  --bg: #15120d;
  --bg-alt: #1b160f;
  --panel: #221c13;
  --line: #3a2f1e;
  --ink: #f1e8d7;
  --ink-dim: #a89880;
  --brass: #c1873c;
  --brass-hi: #e0a75e;
  --teal: #5c8b83;
  --radius: 8px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Archivo', -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, .display {
  font-family: 'Fraunces', Georgia, serif;
  font-optical-sizing: auto;
  font-weight: 600;
  letter-spacing: -0.01em;
}

a { color: inherit; text-decoration: none; }

button { font-family: inherit; }

/* ---- Sprocket motif: a quiet nod to film reel perforations, used once per section break ---- */
.sprocket {
  height: 5px;
  background-image: radial-gradient(circle, var(--line) 1.6px, transparent 1.7px);
  background-size: 15px 5px;
  background-repeat: repeat-x;
  opacity: 0.9;
  margin-bottom: 18px;
}

header.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(18px + var(--safe-t)) 24px 16px;
  position: sticky;
  top: 0;
  background: linear-gradient(to bottom, rgba(21,18,13,0.97) 60%, rgba(21,18,13,0.75));
  backdrop-filter: blur(8px);
  z-index: 20;
}

header.top .brand {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--ink);
}

header.top .brand .dot { color: var(--brass); }

header.top .back {
  font-size: 15px;
  font-weight: 500;
  padding: 10px 16px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  color: var(--ink-dim);
  border: 1px solid var(--line);
  border-radius: 999px;
}

header.top .back:active { border-color: var(--brass); color: var(--ink); }

main { padding: 4px 24px calc(60px + var(--safe-b)); max-width: 1400px; margin: 0 auto; }

section.shelf { margin: 30px 0 8px; }

h2.section-title {
  font-size: clamp(20px, 3vw, 26px);
  margin: 0 0 10px;
  color: var(--ink);
  font-weight: 600;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
}

@media (min-width: 700px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 20px; }
}

.tile {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  background: var(--panel);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.tile:active { transform: scale(0.97); }

@media (hover: hover) {
  .tile:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 26px rgba(0,0,0,0.45), 0 0 0 1px var(--brass);
  }
}

.tile .poster {
  width: 100%;
  aspect-ratio: 2 / 3;
  background: var(--panel) center/cover no-repeat;
  position: relative;
  display: flex;
  align-items: flex-end;
}

.tile .poster.no-image {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  text-align: center;
  color: var(--ink-dim);
  font-family: 'Fraunces', Georgia, serif;
  font-size: 16px;
}

.tile .scrim {
  width: 100%;
  padding: 26px 12px 12px;
  background: linear-gradient(to top, rgba(10,8,5,0.92) 0%, rgba(10,8,5,0.55) 55%, transparent 100%);
}

.tile .tile-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--ink);
}

.tile .tile-meta {
  font-size: 12.5px;
  color: var(--ink-dim);
  margin-top: 2px;
}

.empty-note {
  color: var(--ink-dim);
  padding: 30px 0;
  font-size: 15px;
}

/* Show detail page */
.show-hero {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 8;
  border-radius: var(--radius);
  background: var(--panel) center/cover no-repeat;
  margin-bottom: 22px;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
}

@media (max-width: 560px) {
  .show-hero { aspect-ratio: 4 / 5; }
}

.show-hero .scrim {
  width: 100%;
  padding: 60px 20px 20px;
  background: linear-gradient(to top, rgba(10,8,5,0.95) 0%, rgba(10,8,5,0.35) 60%, transparent 100%);
}

.show-hero h1 {
  margin: 0;
  font-size: clamp(26px, 5vw, 40px);
}

.season-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 10px;
  margin-bottom: 4px;
  scrollbar-width: none;
}

.season-tabs::-webkit-scrollbar { display: none; }

.season-tabs button {
  flex: 0 0 auto;
  padding: 10px 18px;
  min-height: 40px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-dim);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}

.season-tabs button.active {
  background: var(--brass);
  border-color: var(--brass);
  color: #1a1408;
  font-weight: 600;
}

.episode-list { display: flex; flex-direction: column; gap: 2px; margin-top: 10px; }

.episode-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 8px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
  min-height: 56px;
}

.episode-row:last-child { border-bottom: none; }

.episode-row:active { background: var(--panel); }

@media (hover: hover) {
  .episode-row:hover { background: var(--panel); }
  .episode-row:hover .episode-num { border-color: var(--brass); color: var(--brass-hi); }
}

.episode-num {
  width: 34px;
  height: 34px;
  min-width: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-dim);
}

.episode-title { font-size: 16px; font-weight: 500; }

/* Watch page */
.player-wrap {
  position: relative;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}

video {
  width: 100%;
  display: block;
  max-height: 76vh;
  background: #000;
}

.now-playing {
  max-width: 1100px;
  margin: 20px auto 0;
  padding: 0 4px;
}

.now-playing h1 {
  font-size: clamp(19px, 3vw, 24px);
  margin: 0 0 4px;
}

.now-playing .sub {
  color: var(--ink-dim);
  font-size: 15px;
}

.cast-launcher-wrap {
  display: flex;
  align-items: center;
  min-width: 44px;
  min-height: 44px;
  justify-content: center;
}

google-cast-launcher {
  width: 30px;
  height: 30px;
  --connected-color: var(--brass-hi);
  --disconnected-color: var(--ink);
}

/* Custom video controls */

.player-wrap:fullscreen,
.player-wrap:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  border-radius: 0;
  display: flex;
  align-items: center;
}

.player-wrap:fullscreen video,
.player-wrap:-webkit-full-screen video {
  max-height: 100vh;
  height: 100%;
  object-fit: contain;
}

.player-wrap.controls-hidden { cursor: none; }

.tap-toggle {
  position: absolute;
  inset: 0;
  z-index: 5;
  cursor: pointer;
}

.center-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(15,12,8,0.6);
  border: 1px solid rgba(241,232,215,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  z-index: 6;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.center-play.show { opacity: 1; }
.center-play svg { width: 30px; height: 30px; margin-left: 3px; }

.controls-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 15;
  background: linear-gradient(to top, rgba(6,5,3,0.92) 0%, rgba(6,5,3,0.6) 60%, transparent 100%);
  padding: 34px 14px 10px;
  opacity: 1;
  transition: opacity 0.25s ease;
}

.controls-bar.hidden { opacity: 0; pointer-events: none; }

.progress-row {
  padding: 9px 2px;
  cursor: pointer;
  touch-action: none;
}

.progress-track {
  position: relative;
  height: 4px;
  border-radius: 3px;
  background: rgba(241,232,215,0.22);
}

.progress-buffered,
.progress-played {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  border-radius: 3px;
  width: 0%;
}

.progress-buffered { background: rgba(241,232,215,0.35); }
.progress-played { background: var(--brass); }

.progress-thumb {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--brass-hi);
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 5px rgba(224,167,94,0.22);
}

.controls-row {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 2px;
}

.controls-left { display: flex; align-items: center; gap: 0px; }
.controls-right { display: flex; align-items: center; gap: 0px; margin-left: auto; }

.controls-center {
  flex: 1;
  min-width: 0;
  text-align: center;
  padding: 0 10px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.controls-center .ct-show {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  font-size: 15px;
}

.controls-center .ct-ep {
  color: var(--ink-dim);
  font-size: 13px;
  margin-left: 8px;
}

@media (max-width: 560px) {
  .controls-center { display: none; }
}

.ctrl-btn {
  background: transparent;
  border: none;
  color: var(--ink);
  width: 42px;
  height: 42px;
  min-width: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
}

.ctrl-btn svg { width: 21px; height: 21px; }
#btn-play svg { width: 23px; height: 23px; }

.ctrl-btn:active { background: rgba(241,232,215,0.12); }
.ctrl-btn[hidden] { display: none; }

@media (hover: hover) {
  .ctrl-btn:hover { color: var(--brass-hi); }
}

.time-display {
  font-size: 13px;
  color: var(--ink-dim);
  margin-left: 6px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 480px) {
  .time-display { display: none; }
}

.next-overlay {
  position: absolute;
  right: 14px;
  top: 14px;
  width: min(320px, 82%);
  background: rgba(20,17,12,0.96);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: none;
  z-index: 10;
}

.next-overlay.show { display: block; }

.next-overlay .label {
  font-size: 13px;
  color: var(--ink-dim);
  margin-bottom: 4px;
}

.next-overlay .title {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 12px;
}

.next-overlay .bar-track {
  height: 4px;
  background: var(--line);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 14px;
}

.next-overlay .bar-fill {
  height: 100%;
  background: var(--brass);
  width: 100%;
  transition: width 1s linear;
}

.next-overlay .actions { display: flex; gap: 10px; }

.next-overlay button {
  flex: 1;
  padding: 10px 0;
  min-height: 40px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.next-overlay .play-now { background: var(--brass); border-color: var(--brass); color: #1a1408; }
.next-overlay .cancel { background: transparent; color: var(--ink-dim); }

.on-tv-note {
  max-width: 1100px;
  margin: 12px auto 0;
  color: var(--ink-dim);
  font-size: 13px;
  padding: 0 4px;
}
