:root {
  --bg: #0e0b0a;
  --bg-2: #17120f;
  --card: #201914;
  --line: #34291f;
  --text: #f6ece0;
  --muted: #a8988a;
  --gold: #f5b83d;
  --gold-2: #ffd77d;
  --red: #c8323c;
  --radius: 14px;
  --display: "Arial Narrow", "Roboto Condensed", "Helvetica Neue", system-ui, sans-serif;
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(120% 60% at 50% -10%, #2a1b12 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--ui);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
img { display: block; }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 650;
  transition: transform .12s, background .2s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #1d1206; }
.btn.primary:hover { background: var(--gold-2); }
.btn.big { width: 100%; padding: 14px; font-size: 16px; }
.icon-btn {
  background: rgba(0,0,0,.35);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 999px;
  min-width: 40px; height: 40px;
  padding: 0 10px;
  font-size: 15px; font-weight: 700;
  display: inline-grid; place-items: center;
}

/* ---------- loading / message screen ---------- */
.screen {
  min-height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 22px; padding: 32px 20px; text-align: center;
}
.screen-msg { color: var(--muted); max-width: 340px; margin: 0; }
.marquee {
  font: 900 56px/0.95 var(--display);
  letter-spacing: 4px;
  color: var(--gold);
  padding: 18px 26px;
  border-radius: 12px;
  display: flex; flex-direction: column; align-items: center;
  background:
    radial-gradient(circle, var(--gold-2) 2.5px, transparent 3px) 0 0 / 18px 18px repeat-x,
    radial-gradient(circle, var(--gold-2) 2.5px, transparent 3px) 0 100% / 18px 18px repeat-x,
    #1a110b;
  box-shadow: 0 0 0 2px #3c2a18, 0 0 60px rgba(245,184,61,.18);
  text-shadow: 0 0 18px rgba(245,184,61,.45);
  animation: bulbs 1.2s steps(2) infinite;
}
.marquee span:last-child { color: var(--text); letter-spacing: 5px; font-size: 15px; margin-top: 6px; }
@keyframes bulbs { 50% { background-position: 9px 0, 9px 100%, 0 0; } }
.name-form { width: min(360px, 100%); display: grid; gap: 10px; }
.name-form label { font-weight: 650; }
.name-form .row { display: flex; gap: 8px; }
.name-form input {
  flex: 1; min-width: 0;
  background: var(--card); border: 1px solid var(--line); color: var(--text);
  border-radius: 999px; padding: 10px 16px; font: inherit;
}
.name-form small { color: var(--muted); }

/* ---------- lobby ---------- */
.lobby { padding: 0 max(16px, env(safe-area-inset-right, 0px)) 110px max(16px, env(safe-area-inset-left, 0px)); max-width: 1100px; margin: 0 auto; overflow-x: clip; }
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 0 12px;
  background: linear-gradient(var(--bg) 70%, transparent);
}
.logo { font: 800 20px/1 var(--display); letter-spacing: 3px; color: var(--text); white-space: nowrap; min-width: 0; }
@media (max-width: 430px) { .logo { font-size: 17px; letter-spacing: 2px; } .viewers .count .word { display: none; } }
.logo b { color: var(--gold); }
.badge {
  margin-left: 8px; font: 700 10px/1 var(--ui); letter-spacing: 1px;
  background: var(--red); color: #fff; padding: 4px 6px; border-radius: 6px; vertical-align: 3px;
}
.viewers { display: flex; align-items: center; }
.viewers .av { margin-left: -8px; border: 2px solid var(--bg); }
.viewers .av:first-child { margin-left: 0; }
.viewers .count { margin-left: 8px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.av {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; flex: none;
  font-size: 12px; font-weight: 800; color: #fff; overflow: hidden;
}
.av img { width: 100%; height: 100%; object-fit: cover; }
.viewers.small .av { width: 26px; height: 26px; font-size: 11px; border-color: #000; }

.search {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px;
  padding: 0 16px; margin: 4px 0 18px;
}
.search svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; flex: none; }
.search input {
  flex: 1; min-width: 0; background: none; border: 0; outline: 0;
  color: var(--text); font: inherit; padding: 12px 0;
}
.search:focus-within { border-color: var(--gold); }

.section { margin-bottom: 22px; }
h2 {
  font: 800 13px/1 var(--display); letter-spacing: 2.5px; text-transform: uppercase;
  color: var(--muted); margin: 0 0 12px;
}
.rail {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 72%);
  gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory;
  margin: 0 -16px; padding: 0 16px 6px; scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
@media (min-width: 700px) { .rail { grid-auto-columns: 320px; } }
.wide-card {
  position: relative; border: 0; padding: 0; text-align: left;
  border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 9;
  background: var(--card); scroll-snap-align: start;
}
.wide-card img { width: 100%; height: 100%; object-fit: cover; }
.wide-card .label {
  position: absolute; inset: auto 0 0 0; padding: 30px 12px 10px;
  background: linear-gradient(transparent, rgba(0,0,0,.85));
  font-weight: 700;
}
.wide-card .label small { display: block; color: var(--muted); font-weight: 500; }

.tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.tab {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  border-radius: 999px; padding: 8px 16px; font-weight: 650;
}
.tab.active { background: var(--text); color: var(--bg); border-color: var(--text); }

.grid {
  display: grid; gap: 14px 12px;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
}
@media (min-width: 700px) { .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); } }
.poster { border: 0; padding: 0; background: none; text-align: left; }
.poster .art {
  aspect-ratio: 2 / 3; border-radius: 10px; overflow: hidden; background: var(--card);
  box-shadow: 0 6px 18px rgba(0,0,0,.35); transition: transform .15s;
}
.poster:hover .art, .poster:focus-visible .art { transform: translateY(-3px); }
.poster .art img { width: 100%; height: 100%; object-fit: cover; }
.poster .art .fallback {
  height: 100%; display: grid; place-items: center; padding: 10px; text-align: center;
  font: 800 14px/1.1 var(--display); letter-spacing: 1px; color: var(--gold);
}
.poster .name { margin-top: 7px; font-size: 13px; font-weight: 650; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.poster .sub { font-size: 12px; color: var(--muted); }
.empty { color: var(--muted); grid-column: 1 / -1; padding: 30px 0; text-align: center; }

.now-playing {
  position: fixed; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  width: min(560px, calc(100% - 24px)); z-index: 8;
  display: flex; align-items: center; gap: 12px; text-align: left;
  background: var(--gold); color: #1d1206; border: 0; border-radius: 16px; padding: 12px 16px;
  box-shadow: 0 12px 30px rgba(0,0,0,.5);
}
.np-text { flex: 1; min-width: 0; }
.np-text small { display: block; font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; opacity: .7; }
.np-text b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-go { font-weight: 800; white-space: nowrap; }
.np-eq { display: flex; gap: 3px; align-items: flex-end; height: 18px; }
.np-eq i { width: 4px; background: #1d1206; border-radius: 2px; animation: eq 0.9s ease-in-out infinite; }
.np-eq i:nth-child(2) { animation-delay: -.3s; }
.np-eq i:nth-child(3) { animation-delay: -.6s; }
@keyframes eq { 0%,100% { height: 5px; } 50% { height: 18px; } }

/* ---------- sheet ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.6); animation: fade .2s; }
.sheet {
  position: relative; width: min(620px, 100%); max-height: 92%; overflow-y: auto;
  background: var(--bg-2); border-radius: 22px 22px 0 0; border: 1px solid var(--line); border-bottom: 0;
  animation: up .25s cubic-bezier(.2,.8,.2,1);
}
@media (min-width: 700px) { .sheet-wrap { align-items: center; } .sheet { border-radius: 22px; border-bottom: 1px solid var(--line); } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
.sheet-close { position: absolute; top: 12px; right: 12px; z-index: 2; }
.sheet-art { aspect-ratio: 16 / 9; background: var(--card); overflow: hidden; }
.sheet-art img { width: 100%; height: 100%; object-fit: cover; }
.sheet-body { padding: 4px 18px 26px; margin-top: -30px; position: relative; }
.sheet-body h3 { font: 800 28px/1.05 var(--display); letter-spacing: .5px; margin: 0 0 6px; text-shadow: 0 2px 12px rgba(0,0,0,.8); }
.meta { color: var(--muted); margin: 0 0 12px; font-size: 14px; }
.overview { margin: 0 0 18px; color: #dacbbd; }
.seasons { display: flex; gap: 8px; overflow-x: auto; margin: 4px 0 12px; scrollbar-width: none; }
.seasons .tab { flex: none; }
.episodes { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.ep {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px;
}
.ep img { width: 108px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; background: #000; flex: none; }
.ep .ep-text { flex: 1; min-width: 0; }
.ep b { display: block; font-size: 14px; }
.ep small { color: var(--muted); font-size: 12px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ep .ep-play { color: var(--gold); font-size: 20px; padding: 0 6px; }

/* ---------- player ---------- */
.player { position: fixed; inset: 0; background: #000; z-index: 10; }
.stage { position: absolute; inset: 0; display: grid; place-items: center; }
.stage video, .stage canvas { width: 100%; height: 100%; object-fit: contain; background: #000; }
.buffering {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 14px;
  align-items: center; justify-content: center; pointer-events: none;
}
.buffering p { margin: 0; font-weight: 650; color: #f6ece0; text-shadow: 0 2px 8px #000; }
.buffering p:empty { display: none; }
.buffering span {
  width: 44px; height: 44px; border-radius: 50%;
  border: 4px solid rgba(255,255,255,.2); border-top-color: var(--gold);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.controls {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between;
  background: linear-gradient(rgba(0,0,0,.7), transparent 22%, transparent 70%, rgba(0,0,0,.8));
  transition: opacity .25s;
}
.player.idle .controls { opacity: 0; }
.player.idle { cursor: none; }
.ctl-top {
  display: flex; align-items: center; gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) 14px 0;
}
.ctl-title { flex: 1; min-width: 0; }
.ctl-title b { display: block; font: 800 18px/1.15 var(--display); letter-spacing: .5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctl-title small { color: #cdbfb2; font-size: 12px; }
.big-play {
  align-self: center; width: 76px; height: 76px; border-radius: 50%;
  background: rgba(0,0,0,.45); border: 2px solid rgba(255,255,255,.25);
  display: grid; place-items: center;
}
.big-play svg { width: 34px; height: 34px; fill: #fff; }
.big-play .i-pause { display: none; }
.player.playing .big-play .i-play { display: none; }
.player.playing .big-play .i-pause { display: block; }
.ctl-bottom { padding: 0 14px max(12px, env(safe-area-inset-bottom)); }
.ctl-row { display: flex; align-items: center; gap: 8px; }
.spacer { flex: 1; }
.time { font-variant-numeric: tabular-nums; font-size: 13px; color: #e8dccf; white-space: nowrap; }
@media (max-width: 430px) {
  .ctl-row { gap: 5px; }
  .ctl-row .icon-btn { min-width: 36px; height: 36px; padding: 0 7px; font-size: 13px; }
  .time { font-size: 12px; }
}
.seek { position: relative; padding: 10px 0 4px; }
#seek {
  -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; margin: 0;
}
#seek::-webkit-slider-runnable-track {
  height: 5px; border-radius: 3px;
  background: linear-gradient(90deg, var(--gold) var(--pct, 0%), rgba(255,255,255,.25) var(--pct, 0%));
}
#seek::-moz-range-track { height: 5px; border-radius: 3px; background: rgba(255,255,255,.25); }
#seek::-moz-range-progress { height: 5px; border-radius: 3px; background: var(--gold); }
#seek::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: #fff; margin-top: -5.5px; border: 0;
}
#seek::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 0; }
.seek-tip {
  position: absolute; bottom: 34px; transform: translateX(-50%);
  background: #000; border: 1px solid #444; padding: 3px 8px; border-radius: 6px; font-size: 12px;
}
.sound-chip, .join-chip {
  position: absolute; left: 50%; top: 64px; transform: translateX(-50%);
  background: var(--gold); color: #1d1206; border: 0; border-radius: 999px;
  padding: 10px 18px; font-weight: 800; box-shadow: 0 8px 24px rgba(0,0,0,.5); z-index: 3;
}
.join-chip { top: 50%; transform: translate(-50%, -50%); font-size: 17px; padding: 16px 24px; }

#cc.on { background: var(--gold); color: #1d1206; border-color: var(--gold); }
.cc-menu {
  position: absolute; right: max(14px, env(safe-area-inset-right, 0px)); bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  background: rgba(24,18,14,.97); border: 1px solid var(--line); border-radius: 12px;
  padding: 6px; display: grid; min-width: 180px; max-height: 50%; overflow-y: auto; z-index: 4;
  box-shadow: 0 12px 30px rgba(0,0,0,.5);
}
.cc-menu .menu-title {
  padding: 6px 12px 4px; font-size: 11px; font-weight: 800; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--muted);
}
.cc-menu button {
  background: none; border: 0; text-align: left; padding: 9px 12px; border-radius: 8px; font-size: 14px;
}
.cc-menu button:hover, .cc-menu button:focus-visible { background: rgba(255,255,255,.08); }
.cc-menu button[aria-checked="true"]::before { content: "✓ "; color: var(--gold); }
video::cue { background: rgba(0,0,0,.72); color: #fff; font-family: var(--ui); }

.stats {
  position: absolute; left: max(14px, env(safe-area-inset-left, 0px)); top: calc(64px + env(safe-area-inset-top, 0px));
  width: min(320px, calc(100% - 28px)); z-index: 4;
  background: rgba(24,18,14,.97); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px 12px;
  box-shadow: 0 12px 30px rgba(0,0,0,.5); font-size: 14px;
}
.stats .menu-title { padding: 0 0 6px; font-size: 11px; font-weight: 800; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); }
.stat { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-top: 1px solid var(--line); }
.stat span { color: var(--muted); }
.stat b { text-align: right; font-weight: 650; }
.stat b.good { color: #7bd88f; }
.stat b.bad { color: #ff8a7a; }
.verdict { margin: 8px 0 4px; color: #dacbbd; font-size: 13px; }
.stats small, .version { color: var(--muted); font-size: 12px; }
.version { text-align: center; margin: 28px 0 0; }

/* ---------- toasts ---------- */
.toasts {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 40;
  display: grid; gap: 8px; width: min(420px, calc(100% - 24px)); pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  background: rgba(30,23,18,.96); border: 1px solid var(--line); border-radius: 12px;
  padding: 9px 12px; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.4);
  animation: drop .25s cubic-bezier(.2,.8,.2,1);
}
.toast.out { opacity: 0; transform: translateY(-6px); transition: .3s; }
@keyframes drop { from { opacity: 0; transform: translateY(-10px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
