/* ==========================================================================
   Lounge: dark media-hub theme
   ========================================================================== */

:root {
  --bg: #0b0c12;
  --bg-2: #101219;
  --surface: #161923;
  --surface-2: #1e2230;
  --surface-3: #262b3c;
  --border: #2a2f42;
  --text: #eef0f7;
  --muted: #a0a6bd;
  --faint: #6f7590;
  --accent: #8b7bff;
  --accent-2: #ff6b8b;
  --accent-grad: linear-gradient(135deg, #8b7bff 0%, #c56cf0 50%, #ff6b8b 100%);
  --good: #3ddc97;
  --warn: #ffb547;
  --bad: #ff5d6c;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --topbar-h: 64px;
  --tabbar-h: 0px;
  --player-h: 76px;
  --gutter: clamp(16px, 4vw, 40px);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--topbar-h) + 12px);
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(1200px 600px at 10% -10%, rgba(139, 123, 255, 0.12), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(255, 107, 139, 0.08), transparent 60%), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body.modal-open {
  overflow: hidden;
}

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

a:hover {
  color: #fff;
}

img {
  display: block;
  max-width: 100%;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.icon {
  display: inline-flex;
  flex: none;
}

.muted {
  color: var(--muted);
}

.clamp-2,
.clamp-3 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.clamp-2 {
  -webkit-line-clamp: 2;
}

.clamp-3 {
  -webkit-line-clamp: 3;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 8px;
  background: var(--accent);
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  z-index: 100;
}

.skip-link:focus {
  left: 8px;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Top bar & navigation ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-h);
  background: rgba(11, 12, 18, 0.78);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.topbar-inner {
  max-width: 1480px;
  margin: 0 auto;
  height: 100%;
  padding: 0 var(--gutter);
  display: flex;
  align-items: center;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.02em;
}

.nav {
  display: flex;
  gap: 4px;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  transition: background 0.15s, color 0.15s;
}

.nav a:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.nav a.active {
  color: #fff;
  background: rgba(139, 123, 255, 0.18);
}

.nav a.active .icon {
  color: var(--accent);
}

/* ---------- Layout ---------- */

.main {
  max-width: 1480px;
  margin: 0 auto;
  padding: 24px var(--gutter) 40px;
  min-height: calc(100vh - var(--topbar-h) - 120px);
  outline: none;
}

body.has-player .main {
  padding-bottom: calc(var(--player-h) + 40px);
}

.view {
  animation: fade-in 0.25s ease;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: 8px 0 20px;
}

.page-head h1 {
  font-size: clamp(26px, 3.4vw, 38px);
  font-weight: 800;
}

.page-head p {
  margin: 6px 0 0;
  color: var(--muted);
  max-width: 640px;
}

.section {
  margin: 34px 0;
}

.section-title {
  font-size: 20px;
  font-weight: 750;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.footer {
  max-width: 1480px;
  margin: 0 auto;
  padding: 24px var(--gutter) 40px;
  color: var(--faint);
  font-size: 12.5px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.footer a {
  color: var(--muted);
  text-decoration: underline;
  text-decoration-color: rgba(255, 255, 255, 0.2);
}

.footer p {
  margin: 4px 0;
}

body.has-player .footer {
  padding-bottom: calc(var(--player-h) + 30px);
}

body[data-page='games'] .footer {
  display: none;
}

/* ---------- Buttons, inputs, chips ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 650;
  font-size: 14.5px;
  white-space: nowrap;
  transition: transform 0.1s, background 0.15s, border-color 0.15s, opacity 0.15s;
}

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

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn-primary {
  background: var(--accent-grad);
  color: #fff;
  box-shadow: 0 6px 20px rgba(139, 123, 255, 0.3);
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn-light {
  background: #fff;
  color: #111;
}

.btn-light:hover {
  color: #111;
  background: #e9e9f2;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn-sm {
  height: 34px;
  padding: 0 14px;
  font-size: 13.5px;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.select {
  height: 38px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  max-width: 220px;
}

.search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 6px 6px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  width: 100%;
  max-width: 720px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search:focus-within {
  border-color: rgba(139, 123, 255, 0.7);
  box-shadow: 0 0 0 4px rgba(139, 123, 255, 0.15);
}

.search > .icon {
  color: var(--faint);
}

.search-input {
  flex: 1;
  min-width: 0;
  height: 40px;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 15.5px;
}

.search-input::-webkit-search-cancel-button {
  filter: invert(0.7);
}

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 8px;
  margin: 0 -2px 12px;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: none;
  height: 36px;
  padding: 0 15px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
  font-size: 13.5px;
  transition: all 0.15s;
}

.chip:hover {
  color: var(--text);
  border-color: var(--surface-3);
}

.chip.active {
  color: #fff;
  background: rgba(139, 123, 255, 0.22);
  border-color: rgba(139, 123, 255, 0.6);
}

.tabs {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 18px;
  max-width: 100%;
  overflow-x: auto;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 650;
  white-space: nowrap;
}

.tab.active {
  background: var(--surface-3);
  color: #fff;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.toolbar .spacer {
  flex: 1;
}

/* ---------- Rows & scrollers ---------- */

.row {
  margin: 30px 0;
}

.row-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.row-head h2 {
  font-size: 19px;
  font-weight: 750;
}

.row-sub {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13.5px;
}

.row-link {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--muted);
  font-weight: 600;
  font-size: 13.5px;
  white-space: nowrap;
}

.scroller-wrap {
  position: relative;
}

.scroller {
  display: grid;
  grid-auto-flow: column;
  gap: 14px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding: 0 2px;
  padding: 4px 2px 12px;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}

.scroller::-webkit-scrollbar {
  display: none;
}

.scroller > * {
  scroll-snap-align: start;
}

.scroller-poster {
  grid-auto-columns: clamp(128px, 15vw, 176px);
}

.scroller-video {
  grid-auto-columns: clamp(240px, 24vw, 320px);
}

.scroller-square {
  grid-auto-columns: clamp(140px, 14vw, 180px);
}

.scroller-game {
  grid-auto-columns: clamp(220px, 22vw, 290px);
}

.scroll-btn {
  position: absolute;
  top: 38%;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(16, 18, 25, 0.9);
  color: #fff;
  opacity: 0;
  transition: opacity 0.2s;
}

.scroll-btn.left {
  left: -14px;
}

.scroll-btn.right {
  right: -14px;
}

.scroller-wrap:hover .scroll-btn {
  opacity: 1;
}

@media (hover: none) {
  .scroll-btn {
    display: none;
  }
}

/* ---------- Grids ---------- */

.grid {
  display: grid;
  gap: 18px 14px;
}

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

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

.grid-game {
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 18px;
}

.grid-station {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.load-more {
  display: flex;
  justify-content: center;
  margin: 26px 0 8px;
}

/* ---------- Cards ---------- */

.card {
  display: block;
  position: relative;
  border: 0;
  padding: 0;
  background: none;
  text-align: left;
  color: inherit;
  min-width: 0;
}

.card-media {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  isolation: isolate;
}

.card-media img,
.card-media .img-fallback {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.35s ease;
}

.card:hover .card-media img {
  transform: scale(1.05);
}

.card-media::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  pointer-events: none;
}

.ratio-poster {
  aspect-ratio: 2 / 3;
}

.ratio-video {
  aspect-ratio: 16 / 9;
}

.ratio-square {
  aspect-ratio: 1;
}

.ratio-game {
  aspect-ratio: 16 / 10;
}

.card-play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, transparent 40%, rgba(0, 0, 0, 0.55));
  opacity: 0;
  transition: opacity 0.2s;
}

.card-play > .icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  color: #111;
  box-shadow: var(--shadow);
}

.card:hover .card-play,
.card:focus-visible .card-play {
  opacity: 1;
}

.card-body {
  padding: 9px 2px 0;
}

.card-title {
  font-weight: 650;
  font-size: 14px;
  line-height: 1.3;
}

.card-meta {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12.5px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  align-items: center;
}

.badge {
  position: absolute;
  z-index: 2;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
}

.badge-br {
  right: 7px;
  bottom: 7px;
}

.badge-tl {
  left: 7px;
  top: 7px;
}

.badge-free {
  background: var(--good);
  color: #062b1c;
}

.badge-live {
  background: var(--bad);
}

.rating {
  color: var(--warn);
  font-weight: 700;
}

.img-fallback {
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--surface-2), var(--surface-3));
  color: var(--faint);
}

/* ---------- Skeletons ---------- */

.skel {
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite linear;
}

.skel-poster {
  aspect-ratio: 2 / 3;
}

.skel-video {
  aspect-ratio: 16 / 9;
}

.skel-square {
  aspect-ratio: 1;
}

.skel-game {
  aspect-ratio: 16 / 10;
}

.skel-line {
  height: 58px;
  margin-bottom: 8px;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* ---------- States ---------- */

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  grid-column: 1 / -1;
}

.empty-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.error-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: rgba(255, 93, 108, 0.08);
  border: 1px solid rgba(255, 93, 108, 0.3);
  color: #ffc9cf;
  grid-column: 1 / -1;
}

.setup-card {
  display: flex;
  gap: 16px;
  padding: 18px 20px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(139, 123, 255, 0.12), rgba(255, 107, 139, 0.06));
  border: 1px solid rgba(139, 123, 255, 0.35);
  grid-column: 1 / -1;
  max-width: 820px;
}

.setup-card h3 {
  font-size: 16px;
  margin-bottom: 6px;
}

.setup-card ol {
  margin: 6px 0;
  padding-left: 20px;
  color: var(--text);
}

.setup-card li {
  margin: 3px 0;
}

.setup-card p {
  margin: 6px 0 0;
  font-size: 13.5px;
}

.setup-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(139, 123, 255, 0.2);
  color: var(--accent);
}

.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 13.5px;
  margin-bottom: 18px;
}

.notice .icon {
  color: var(--accent);
  margin-top: 1px;
}

/* ---------- Home hero ---------- */

.hero {
  position: relative;
  overflow: hidden;
  padding: clamp(28px, 5vw, 56px);
  border-radius: 24px;
  background: radial-gradient(600px 300px at 85% 20%, rgba(255, 107, 139, 0.25), transparent 70%),
    radial-gradient(700px 400px at 0% 100%, rgba(139, 123, 255, 0.3), transparent 70%), var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.hero h1 {
  font-size: clamp(30px, 4.6vw, 54px);
  font-weight: 850;
  letter-spacing: -0.03em;
  max-width: 720px;
}

.hero h1 span {
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero p {
  color: var(--muted);
  font-size: 16.5px;
  max-width: 560px;
  margin: 12px 0 24px;
}

.hero .tabs {
  margin-bottom: 12px;
}

.quick-links {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 18px;
}

.quick {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  font-weight: 700;
  transition: transform 0.15s, border-color 0.15s;
}

.quick:hover {
  transform: translateY(-2px);
  border-color: var(--surface-3);
}

.quick small {
  display: block;
  font-weight: 500;
  color: var(--muted);
  font-size: 12.5px;
}

.quick-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  flex: none;
}

/* ---------- Movies: detail page ---------- */

.detail-hero {
  position: relative;
  isolation: isolate;
  margin: -24px calc(var(--gutter) * -1) 0;
  padding: 60px var(--gutter) 34px;
  min-height: 420px;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}

.detail-backdrop {
  position: absolute;
  inset: 0;
  z-index: -1;
}

.detail-backdrop img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 20%;
  opacity: 0.45;
}

.detail-backdrop::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, var(--bg) 2%, rgba(11, 12, 18, 0.55) 55%, rgba(11, 12, 18, 0.35)),
    linear-gradient(90deg, rgba(11, 12, 18, 0.9) 0%, transparent 70%);
}

.detail-main {
  display: flex;
  gap: 28px;
  align-items: flex-end;
  width: 100%;
}

.detail-poster {
  flex: none;
  width: clamp(130px, 18vw, 230px);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  aspect-ratio: 2 / 3;
  background: var(--surface-2);
}

.detail-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.detail-info h1 {
  font-size: clamp(26px, 4vw, 46px);
  font-weight: 850;
  letter-spacing: -0.02em;
}

.detail-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  color: var(--muted);
  margin: 10px 0;
  font-size: 14px;
}

.detail-tagline {
  font-style: italic;
  color: var(--muted);
  margin: 6px 0 0;
}

.detail-overview {
  max-width: 760px;
  margin: 10px 0 18px;
  color: #d9dcea;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 14px;
}

.providers {
  display: grid;
  gap: 14px;
}

.provider-group h4 {
  margin: 0 0 8px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.provider-group.free h4 {
  color: var(--good);
}

.provider-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.provider {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 6px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13.5px;
  font-weight: 600;
}

.provider img {
  width: 28px;
  height: 28px;
  border-radius: 8px;
}

.panel {
  padding: 18px 20px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
}

.free-here {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-radius: var(--radius);
  background: rgba(61, 220, 151, 0.08);
  border: 1px solid rgba(61, 220, 151, 0.35);
  margin: 18px 0 0;
}

.cast {
  grid-auto-columns: 120px;
}

.person {
  text-align: center;
  font-size: 13px;
}

.person .card-media {
  border-radius: 50%;
  aspect-ratio: 1;
  margin: 0 auto 8px;
  width: 96px;
}

.person small {
  display: block;
  color: var(--muted);
}

.episodes {
  display: grid;
  gap: 10px;
}

.episode {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 14px;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
}

.episode .card-media {
  aspect-ratio: 16 / 9;
}

.episode h4 {
  margin: 2px 0 4px;
  font-size: 14.5px;
}

.episode p {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
}

/* ---------- YouTube watch page ---------- */

.watch {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 24px;
  align-items: start;
}

.watch-player {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  box-shadow: var(--shadow);
}

.watch-player iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.watch-title {
  font-size: 20px;
  font-weight: 750;
  margin: 14px 0 6px;
}

.watch-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
}

.up-next {
  display: grid;
  gap: 10px;
}

.mini-video {
  display: grid;
  grid-template-columns: 168px 1fr;
  gap: 10px;
  border-radius: var(--radius-sm);
  padding: 4px;
  transition: background 0.15s;
}

.mini-video:hover {
  background: var(--surface);
}

.mini-video.active {
  background: rgba(139, 123, 255, 0.14);
}

.mini-video .card-title {
  font-size: 13.5px;
}

/* ---------- Music ---------- */

.tracks {
  display: grid;
  gap: 2px;
}

.track {
  display: grid;
  grid-template-columns: 34px 48px minmax(0, 1fr) 140px 60px;
  align-items: center;
  gap: 12px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 0;
  background: transparent;
  text-align: left;
  width: 100%;
  transition: background 0.12s;
}

.track:hover {
  background: var(--surface);
}

.track.playing {
  background: rgba(139, 123, 255, 0.13);
}

.track.playing .track-title {
  color: #c4bbff;
}

.track-num {
  color: var(--faint);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.track:hover .track-num .num,
.track.playing .track-num .num {
  display: none;
}

.track-num .icon {
  display: none;
  color: var(--text);
}

.track:hover .track-num .icon,
.track.playing .track-num .icon {
  display: inline-flex;
}

.track-art {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-2);
}

.track-art img,
.track-art .img-fallback {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.track-title {
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-artist {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-genre {
  color: var(--faint);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-dur {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.station {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  text-align: left;
  width: 100%;
  min-width: 0;
  transition: border-color 0.15s, background 0.15s;
}

.station:hover {
  border-color: var(--surface-3);
  background: var(--surface-2);
}

.station.playing {
  border-color: rgba(139, 123, 255, 0.7);
  background: rgba(139, 123, 255, 0.12);
}

.station-logo {
  flex: none;
  width: 52px;
  height: 52px;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  display: grid;
  place-items: center;
}

.station-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.station-logo .img-fallback,
.station-logo .initial {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 20px;
  color: #fff;
  background: var(--accent-grad);
}

.card-media .station-logo {
  width: 100%;
  height: 100%;
  border-radius: 0;
}

.card-media .station-logo .initial {
  font-size: 44px;
}

.station-text {
  min-width: 0;
  flex: 1;
}

.station-name {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.station-tags {
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fav-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  color: var(--faint);
}

.fav-btn:hover {
  color: var(--warn);
  background: rgba(255, 255, 255, 0.06);
}

.fav-btn.on {
  color: var(--warn);
}

.spotify-embed {
  width: 100%;
  border: 0;
  border-radius: 12px;
  background: var(--surface);
}

.shelf {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.shelf-item {
  position: relative;
}

.shelf-item .remove {
  position: absolute;
  top: -10px;
  right: -10px;
  z-index: 2;
}

/* ---------- Games ---------- */

.game-card .card-media {
  border-radius: var(--radius);
}

.game-card .card-body {
  padding-top: 11px;
}

.game-card .card-title {
  font-size: 16px;
  font-weight: 750;
}

.game-card .card-desc {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.tag {
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.game-stage {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.game-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.game-bar h1 {
  font-size: 20px;
  font-weight: 800;
  margin-right: auto;
}

.game-frame-wrap {
  position: relative;
  width: 100%;
  height: calc(100vh - var(--topbar-h) - 150px);
  min-height: 360px;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  box-shadow: var(--shadow);
}

body.has-player .game-frame-wrap {
  height: calc(100vh - var(--topbar-h) - 150px - var(--player-h));
}

.game-frame-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.game-help {
  color: var(--muted);
  font-size: 13.5px;
}

.kbd {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 6px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  background: var(--surface);
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}

/* ---------- Modal (theater) ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 5, 9, 0.86);
  backdrop-filter: blur(6px);
  animation: fade-in 0.2s ease;
}

.modal-box {
  width: min(1180px, 100%);
  max-height: 100%;
  overflow: auto;
  border-radius: 18px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.modal-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px 10px 18px;
}

.modal-title {
  font-weight: 750;
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.theater {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
}

.theater iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.modal-foot {
  padding: 12px 18px 16px;
}

.modal-foot p {
  margin: 0 0 10px;
  font-size: 14px;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ---------- Audio player bar ---------- */

.player {
  position: fixed;
  left: 0;
  right: 0;
  bottom: var(--tabbar-h);
  z-index: 50;
  height: var(--player-h);
  background: rgba(16, 18, 25, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  --progress: 0%;
}

.player[hidden] {
  display: none;
}

.p-progress {
  position: absolute;
  top: -1px;
  left: 0;
  height: 2px;
  width: var(--progress);
  background: var(--accent-grad);
  transition: width 0.25s linear;
}

.player.is-live .p-progress {
  animation: live-pulse 2s infinite ease-in-out;
}

@keyframes live-pulse {
  50% {
    opacity: 0.35;
  }
}

.p-inner {
  height: 100%;
  max-width: 1480px;
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, 1fr);
  align-items: center;
  gap: 16px;
}

.p-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.p-art {
  flex: none;
  width: 50px;
  height: 50px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-2);
}

.p-art img,
.p-art .img-fallback {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.player.is-live .p-art img {
  object-fit: contain;
  background: #fff;
}

.p-text {
  min-width: 0;
}

.p-title {
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.p-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.p-artist {
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.p-link {
  color: var(--faint);
  display: inline-flex;
}

.p-link[hidden] {
  display: none;
}

.p-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.p-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pbtn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  color: var(--muted);
}

.pbtn:hover:not(:disabled) {
  color: #fff;
  background: rgba(255, 255, 255, 0.07);
}

.pbtn:disabled {
  opacity: 0.35;
  cursor: default;
}

.pbtn-main {
  width: 42px;
  height: 42px;
  background: #fff;
  color: #111;
}

.pbtn-main:hover:not(:disabled) {
  background: #fff;
  color: #111;
  transform: scale(1.05);
}

.player.loading .pbtn-main {
  animation: live-pulse 1s infinite;
}

.p-seek {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 520px;
}

.p-time {
  color: var(--faint);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  min-width: 34px;
}

.p-time:first-child {
  text-align: right;
}

.live-badge {
  display: none;
  padding: 1px 8px;
  border-radius: 6px;
  background: var(--bad);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.player.is-live .live-badge {
  display: inline-block;
}

.player.is-live .seek,
.player.is-live .p-time {
  display: none;
}

.player.is-live .p-seek {
  justify-content: center;
}

.p-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 4px;
  background: var(--surface-3);
  outline: none;
  cursor: pointer;
}

input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
}

input[type='range']::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 0;
  border-radius: 50%;
  background: #fff;
}

.seek {
  flex: 1;
}

.vol {
  width: 100px;
}

/* ---------- Docked YouTube player (music) ---------- */

.ytdock {
  position: fixed;
  right: 16px;
  bottom: calc(var(--tabbar-h) + var(--player-h) + 12px);
  z-index: 49;
  width: 356px;
  max-width: calc(100vw - 32px);
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.ytdock[hidden] {
  display: none;
}

.ytdock iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* ---------- Toasts ---------- */

.toasts {
  position: fixed;
  z-index: 90;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 20px);
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  width: min(420px, calc(100% - 32px));
  pointer-events: none;
}

body.has-player .toasts {
  bottom: calc(var(--tabbar-h) + var(--player-h) + 16px);
}

.toast {
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--surface-3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow);
  font-size: 14px;
  animation: fade-in 0.2s ease;
  transition: opacity 0.4s, transform 0.4s;
}

.toast-error {
  border-color: rgba(255, 93, 108, 0.5);
}

.toast.out {
  opacity: 0;
  transform: translateY(8px);
}

.noscript {
  padding: 40px;
  text-align: center;
}

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
  .watch {
    grid-template-columns: 1fr;
  }
  .quick-links {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 900px) {
  .p-inner {
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 8px;
  }
  .p-right .vol,
  .p-right [aria-label='Mute'] {
    display: none;
  }
  .p-seek {
    display: none;
  }
  .p-center {
    flex-direction: row;
  }
  .p-buttons .pbtn:not(.pbtn-main) {
    width: 34px;
  }
  .track {
    grid-template-columns: 30px 44px minmax(0, 1fr) 50px;
  }
  .track-genre {
    display: none;
  }
}

@media (max-width: 760px) {
  :root {
    --topbar-h: 56px;
    --tabbar-h: calc(62px + env(safe-area-inset-bottom));
    --player-h: 64px;
  }
  .topbar {
    /* backdrop-filter would turn the header into the containing block of the fixed tab bar */
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(11, 12, 18, 0.97);
  }
  .topbar-inner {
    justify-content: center;
  }
  .nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    height: var(--tabbar-h);
    padding: 6px 6px env(safe-area-inset-bottom);
    background: rgba(13, 14, 21, 0.97);
    backdrop-filter: blur(16px);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    justify-content: space-around;
    gap: 0;
  }
  .nav a {
    flex: 1;
    flex-direction: column;
    gap: 3px;
    padding: 6px 2px;
    border-radius: 12px;
    font-size: 11px;
    background: none !important;
  }
  .nav a.active {
    color: #fff;
  }
  .main {
    padding-top: 16px;
    padding-bottom: calc(var(--tabbar-h) + 30px);
  }
  body.has-player .main {
    padding-bottom: calc(var(--tabbar-h) + var(--player-h) + 30px);
  }
  .footer {
    padding-bottom: calc(var(--tabbar-h) + 30px);
  }
  body.has-player .footer {
    padding-bottom: calc(var(--tabbar-h) + var(--player-h) + 30px);
  }
  .search .btn {
    padding: 0 14px;
  }
  .detail-hero {
    margin-top: -16px;
    padding-top: 30px;
    min-height: 0;
  }
  .detail-main {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
  .detail-poster {
    width: 120px;
  }
  .episode {
    grid-template-columns: 120px 1fr;
  }
  .mini-video {
    grid-template-columns: 140px 1fr;
  }
  .grid-poster {
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    gap: 14px 10px;
  }
  .grid-video {
    grid-template-columns: 1fr;
  }
  .modal {
    padding: 0;
    align-items: start;
  }
  .modal-box {
    border-radius: 0;
    border: 0;
    min-height: 100%;
  }
  .game-frame-wrap {
    height: calc(100vh - var(--topbar-h) - var(--tabbar-h) - 96px);
    height: calc(100dvh - var(--topbar-h) - var(--tabbar-h) - 96px);
  }
  body.has-player .game-frame-wrap {
    height: calc(100vh - var(--topbar-h) - var(--tabbar-h) - var(--player-h) - 96px);
    height: calc(100dvh - var(--topbar-h) - var(--tabbar-h) - var(--player-h) - 96px);
  }
  .game-bar {
    flex-wrap: nowrap;
  }
  .game-bar h1 {
    font-size: 17px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .game-bar .btn-label {
    display: none;
  }
  .game-bar .btn {
    padding: 0 11px;
  }
  .game-help {
    display: none;
  }
  .p-art {
    width: 44px;
    height: 44px;
  }
  .ytdock {
    width: 220px;
    right: 10px;
    bottom: calc(var(--tabbar-h) + var(--player-h) + 8px);
  }
  .hero p {
    font-size: 15px;
  }
  .card-title {
    font-size: 13px;
  }
}

@media (max-width: 420px) {
  .quick-links {
    grid-template-columns: 1fr 1fr;
  }
  .quick {
    padding: 12px;
    gap: 10px;
  }
  .quick-icon {
    width: 36px;
    height: 36px;
  }
}

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