:root {
  --bg: #07080d;
  --bg-2: #0c0f1a;
  --card: rgba(255, 255, 255, 0.045);
  --card-hover: rgba(255, 255, 255, 0.08);
  --stroke: rgba(255, 255, 255, 0.09);
  --text: #eef1f8;
  --muted: #8c93a8;
  --brand: #6d5efc;
  --brand-2: #16d6c4;
  --live: #ff3b5c;
  --radius: 16px;
  --shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.7);
  --ease: cubic-bezier(.22, 1, .36, 1);
  --sidebar-w: 248px;
  --font-head: "Space Grotesk", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--bg); color: var(--text); min-height: 100vh; overflow-x: hidden;
  -webkit-font-smoothing: antialiased; letter-spacing: -.01em;
  -webkit-tap-highlight-color: transparent;
}
html { scroll-padding-top: 80px; }
h1, h2, h3, .brand-text, .card-title, .row-head h2, .source-name, .stream-view h1, .back-btn { font-family: var(--font-head); }
.hidden { display: none !important; }

/* ---------- Animated background ---------- */
.bg-aurora { position: fixed; inset: 0; z-index: -1; background: radial-gradient(120% 120% at 70% 0%, var(--bg-2), var(--bg) 60%); overflow: hidden; }
.blob { position: absolute; border-radius: 50%; filter: blur(90px); opacity: .5; will-change: transform; }
.blob-1 { width: 460px; height: 460px; background: #6d5efc; top: -120px; left: 10%; animation: drift1 18s var(--ease) infinite alternate; }
.blob-2 { width: 420px; height: 420px; background: #16d6c4; top: 30%; right: -120px; animation: drift2 22s var(--ease) infinite alternate; }
.blob-3 { width: 360px; height: 360px; background: #ff3b5c; bottom: -140px; left: 40%; opacity: .35; animation: drift3 26s var(--ease) infinite alternate; }
@keyframes drift1 { to { transform: translate(120px, 80px) scale(1.15); } }
@keyframes drift2 { to { transform: translate(-100px, 120px) scale(1.1); } }
@keyframes drift3 { to { transform: translate(80px, -90px) scale(1.2); } }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; align-self: flex-start;
  width: var(--sidebar-w); height: 100vh; height: 100dvh; flex-shrink: 0;
  display: flex; flex-direction: column; gap: 4px;
  padding: 20px 14px; border-right: 1px solid var(--stroke);
  background: rgba(8, 9, 15, 0.6); backdrop-filter: blur(18px) saturate(140%);
  overflow-y: auto; -webkit-overflow-scrolling: touch; scrollbar-width: thin; z-index: 60;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--stroke); border-radius: 4px; }

.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: var(--text); padding: 6px 8px 18px; }
.brand-mark { width: 40px; height: 40px; flex-shrink: 0; filter: drop-shadow(0 8px 18px rgba(109,94,252,.35)); transition: transform .4s var(--ease); }
.brand-mark svg { width: 100%; height: 100%; display: block; }
.brand:hover .brand-mark { transform: scale(1.06) rotate(-3deg); }
.brand-text { font-weight: 700; font-size: 1.22rem; letter-spacing: -.03em; }
.brand-text span { background: linear-gradient(90deg, var(--brand), var(--brand-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }

.side-nav { display: flex; flex-direction: column; gap: 3px; }
.side-link {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  padding: 10px 12px; border-radius: 11px; cursor: pointer; font-size: .9rem; font-weight: 600;
  background: transparent; border: 1px solid transparent; color: var(--muted);
  transition: all .2s var(--ease);
}
.side-link:hover { color: var(--text); background: var(--card); }
.side-link.active { color: #fff; background: rgba(109,94,252,.16); border-color: rgba(109,94,252,.45); }
.side-link.active .side-ico { color: var(--brand-2); }
.side-ico { width: 20px; height: 20px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; color: currentColor; opacity: .85; }
.side-ico svg { width: 19px; height: 19px; }
.side-foot { margin-top: auto; padding: 16px 10px 4px; font-size: .72rem; color: var(--muted); opacity: .7; }

.side-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); backdrop-filter: blur(3px); z-index: 55; }
.side-overlay.show { display: block; animation: fadeIn .3s var(--ease); }
@keyframes fadeIn { from { opacity: 0; } }
.menu-toggle { display: none; position: fixed; top: calc(12px + env(safe-area-inset-top)); left: calc(12px + env(safe-area-inset-left)); z-index: 70; width: 44px; height: 44px; border-radius: 11px; background: rgba(12,15,26,.85); backdrop-filter: blur(10px); border: 1px solid var(--stroke); color: var(--text); cursor: pointer; place-items: center; }

.content { flex: 1; min-width: 0; }

/* ---------- Topbar ---------- */
.topbar { position: sticky; top: 0; z-index: 50; padding: 14px 32px; display: flex; align-items: center; gap: 14px; backdrop-filter: blur(14px); background: rgba(7,8,13,.5); border-bottom: 1px solid transparent; transition: border-color .4s var(--ease), background .4s var(--ease); }
.topbar.scrolled { border-color: var(--stroke); background: rgba(7,8,13,.82); }
.topbar-brand { display: none; text-decoration: none; font-family: var(--font-head); font-weight: 700; font-size: 1.1rem; letter-spacing: -.03em; color: var(--text); flex-shrink: 0; }
.topbar-brand span { background: linear-gradient(90deg, var(--brand), var(--brand-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.search-wrap { position: relative; max-width: 460px; flex: 1; display: flex; align-items: center; }
.search-icon { position: absolute; left: 14px; color: var(--muted); pointer-events: none; }
#searchInput { width: 100%; padding: 11px 14px 11px 42px; border-radius: 12px; background: var(--card); border: 1px solid var(--stroke); color: var(--text); font-size: .92rem; outline: none; transition: border-color .3s, background .3s, box-shadow .3s; }
#searchInput:focus { border-color: var(--brand); background: var(--card-hover); box-shadow: 0 0 0 4px rgba(109,94,252,.15); }
#searchInput::placeholder { color: var(--muted); }

/* ---------- Home / sections ---------- */
.home { padding: 12px 32px 60px; }
.page-loader { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 90px 0; color: var(--muted); }

.row-section { margin-bottom: 34px; }
.row-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.row-head h2 { display: flex; align-items: center; gap: 9px; font-size: 1.25rem; font-weight: 700; letter-spacing: -.02em; }
.row-ico { display: inline-flex; align-items: center; color: var(--brand-2); }
.row-ico svg { width: 21px; height: 21px; }
.row-count { font-size: .72rem; font-weight: 700; color: var(--muted); background: var(--card); border: 1px solid var(--stroke); padding: 3px 9px; border-radius: 999px; }

.row-scroll { display: flex; gap: 16px; overflow-x: auto; padding: 4px 4px 14px; scroll-snap-type: x proximity; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.row-scroll::-webkit-scrollbar { height: 8px; }
.row-scroll::-webkit-scrollbar-thumb { background: var(--stroke); border-radius: 4px; }
.row-scroll::-webkit-scrollbar-thumb:hover { background: var(--card-hover); }
.row-scroll > .card { flex: 0 0 290px; scroll-snap-align: start; }

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

/* ---------- Card ---------- */
.card { position: relative; border-radius: var(--radius); overflow: hidden; cursor: pointer; background: var(--card); border: 1px solid var(--stroke); transition: transform .4s var(--ease), border-color .4s var(--ease), box-shadow .4s var(--ease); opacity: 0; transform: translateY(14px); animation: cardIn .5s var(--ease) forwards; }
@keyframes cardIn { to { opacity: 1; transform: translateY(0); } }
.card:hover { transform: translateY(-6px); border-color: rgba(109,94,252,.5); box-shadow: var(--shadow); }
.card-poster { position: relative; aspect-ratio: 16/9; overflow: hidden; background: linear-gradient(135deg, #161a2b, #0d1018); }
.card-poster img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s var(--ease); }
.card:hover .card-poster img { transform: scale(1.07); }
.card-fallback { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 14px; padding: 16px; }
.fallback-team { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; max-width: 40%; }
.fallback-team img { width: 48px; height: 48px; object-fit: contain; filter: drop-shadow(0 4px 10px rgba(0,0,0,.5)); }
.fallback-team span { font-size: .72rem; color: var(--muted); font-weight: 600; line-height: 1.2; }
.fallback-vs { font-weight: 800; color: var(--brand-2); font-size: .85rem; }

.badge-live { position: absolute; top: 10px; left: 10px; z-index: 2; display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; font-size: .7rem; font-weight: 800; letter-spacing: .04em; background: var(--live); color: #fff; box-shadow: 0 6px 16px -6px var(--live); }
.badge-live .live-dot { background: #fff; box-shadow: none; animation: none; }
.badge-date { position: absolute; top: 10px; left: 10px; z-index: 2; padding: 5px 10px; border-radius: 999px; font-size: .7rem; font-weight: 700; background: rgba(0,0,0,.55); backdrop-filter: blur(6px); color: var(--text); border: 1px solid var(--stroke); }
.badge-views { position: absolute; bottom: 10px; right: 10px; z-index: 2; display: inline-flex; align-items: center; gap: 5px; padding: 5px 9px; border-radius: 999px; font-size: .72rem; font-weight: 700; background: rgba(0,0,0,.6); backdrop-filter: blur(6px); color: #fff; border: 1px solid rgba(255,255,255,.14); }
.badge-views svg { width: 13px; height: 13px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--live); }

.play-overlay { position: absolute; inset: 0; display: grid; place-items: center; z-index: 1; background: linear-gradient(to top, rgba(7,8,13,.85), rgba(7,8,13,.12) 60%, transparent); opacity: 0; transition: opacity .35s var(--ease); }
.card:hover .play-overlay { opacity: 1; }
.play-btn { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.12); backdrop-filter: blur(8px); border: 1px solid rgba(255,255,255,.3); color: #fff; transform: scale(.8); transition: transform .35s var(--ease); }
.card:hover .play-btn { transform: scale(1); }

.card-body { padding: 13px 15px 15px; }
.card-title { font-weight: 700; font-size: .95rem; line-height: 1.3; letter-spacing: -.01em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-info { display: flex; align-items: center; gap: 8px; margin-top: 9px; flex-wrap: wrap; }
.tag { font-size: .72rem; font-weight: 600; padding: 4px 9px; border-radius: 8px; background: var(--card-hover); color: var(--muted); text-transform: capitalize; }
.tag.time { color: var(--brand-2); }

/* ---------- Empty ---------- */
.empty { text-align: center; padding: 70px 20px; color: var(--muted); }
.empty.small { padding: 30px 20px; }
.empty-ico { display: inline-flex; color: var(--muted); margin-bottom: 14px; opacity: .6; }
.empty-ico svg { width: 46px; height: 46px; }
.empty h3 { color: var(--text); font-size: 1.2rem; margin-bottom: 6px; }

/* ---------- Spinner ---------- */
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 3px solid rgba(255,255,255,.15); border-top-color: var(--brand-2); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Schedule view ---------- */
.schedule-view { padding: 18px 32px 60px; max-width: 1000px; margin-inline: auto; }
.sched-head { margin-bottom: 24px; }
.sched-head h1 { font-size: clamp(1.5rem, 3vw, 2.1rem); font-weight: 700; letter-spacing: -.03em; }
.sched-head .meta { margin-top: 4px; }
.sched-day { margin-bottom: 28px; }
.sched-day-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; position: sticky; top: 66px; background: rgba(7,8,13,.7); backdrop-filter: blur(10px); padding: 8px 0; z-index: 10; }
.sched-day-head h2 { font-size: 1.15rem; font-weight: 700; letter-spacing: -.02em; }
.sched-day-count { font-size: .78rem; color: var(--muted); font-weight: 600; }
.sched-rows { display: flex; flex-direction: column; gap: 8px; }
.sched-row { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; padding: 13px 16px; border-radius: 12px; cursor: pointer; background: var(--card); border: 1px solid var(--stroke); color: var(--text); transition: all .2s var(--ease); }
.sched-row:hover { background: var(--card-hover); transform: translateX(4px); border-color: rgba(109,94,252,.4); }
.sched-time { flex-shrink: 0; width: 76px; font-family: var(--font-head); font-weight: 700; font-size: .9rem; color: var(--brand-2); display: inline-flex; align-items: center; gap: 6px; }
.sched-time.is-live { color: var(--live); font-size: .76rem; letter-spacing: .04em; }
.sched-time .live-dot { background: var(--live); box-shadow: 0 0 0 0 rgba(255,59,92,.6); animation: pulse 1.8s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(255,59,92,.6);} 70% { box-shadow: 0 0 0 7px rgba(255,59,92,0);} 100% { box-shadow: 0 0 0 0 rgba(255,59,92,0);} }
.sched-ico { flex-shrink: 0; display: inline-flex; color: var(--muted); }
.sched-ico svg { width: 19px; height: 19px; }
.sched-title { flex: 1; min-width: 0; font-weight: 600; font-size: .94rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sched-sport { flex-shrink: 0; font-size: .72rem; font-weight: 600; padding: 4px 10px; border-radius: 8px; background: var(--card-hover); color: var(--muted); text-transform: capitalize; }
@media (max-width: 560px) {
  .sched-sport { display: none; }
  .sched-time { width: 60px; }
}

/* ---------- Stream view ---------- */
.stream-view { padding: 18px 32px 60px; max-width: 1180px; margin-inline: auto; }
.back-btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 15px; border-radius: 11px; cursor: pointer; font-size: .88rem; font-weight: 600; background: var(--card); border: 1px solid var(--stroke); color: var(--text); transition: all .25s var(--ease); margin-bottom: 18px; }
.back-btn:hover { background: var(--card-hover); transform: translateX(-3px); }
.stream-view h1 { font-size: clamp(1.3rem, 3vw, 1.9rem); font-weight: 800; letter-spacing: -.03em; }
.stream-help { color: var(--muted); font-size: .9rem; margin: 8px 0 18px; max-width: 70ch; }

.player-frame { position: relative; aspect-ratio: 16/9; background: #000; border-radius: 16px; overflow: hidden; border: 1px solid var(--stroke); width: 100%; }
.player-frame iframe { width: 100%; height: 100%; border: 0; }

/* Theatre mode (default) */
.theatre-stage { display: grid; place-items: center; border-radius: 18px; }
.theatre-stage.theatre {
  background: radial-gradient(120% 130% at 50% 0%, #14182a, #06070c 80%);
  border: 1px solid var(--stroke);
  padding: clamp(12px, 2.4vw, 32px);
}
.theatre-stage .player-frame { transition: width .35s var(--ease); }
.theatre-stage.theatre .player-frame { width: min(100%, calc(80vh * 16 / 9)); width: min(100%, calc(80dvh * 16 / 9)); }
.player-loader { position: absolute; inset: 0; display: grid; place-items: center; background: #000; transition: opacity .3s; pointer-events: none; }
.player-loader.loaded { opacity: 0; visibility: hidden; }

.player-toolbar { display: flex; align-items: center; gap: 8px; padding: 14px 0 0; flex-wrap: wrap; }
.tool-btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px; border-radius: 11px; cursor: pointer; font-size: .82rem; font-weight: 600; background: var(--card); border: 1px solid var(--stroke); color: var(--text); text-decoration: none; transition: all .25s var(--ease); }
.tool-btn:hover { background: var(--card-hover); transform: translateY(-1px); }
.tool-btn svg { width: 16px; height: 16px; }

.sources-meta { color: var(--muted); font-size: .85rem; margin: 26px 0 14px; font-weight: 600; }

/* ---------- Brave / popup-blocker tip ---------- */
.brave-tip { margin-top: 18px; padding: 18px 20px; border-radius: 16px; background: linear-gradient(135deg, rgba(255,80,40,.12), rgba(109,94,252,.1)); border: 1px solid var(--stroke); display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.brave-tip-head { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brave-ico { display: grid; place-items: center; width: 44px; height: 44px; flex-shrink: 0; border-radius: 12px; background: linear-gradient(135deg, #fb542b, #ff7a45); color: #fff; box-shadow: 0 8px 20px -8px rgba(251,84,43,.7); }
.brave-ico svg { width: 24px; height: 24px; }
.brave-tip-head strong { font-family: var(--font-head); font-size: 1rem; font-weight: 700; display: block; }
.brave-tip-head p { color: var(--muted); font-size: .85rem; margin-top: 3px; max-width: 52ch; line-height: 1.45; }
.brave-links { display: flex; gap: 9px; flex-wrap: wrap; }
.brave-btn { display: inline-flex; align-items: center; gap: 7px; padding: 10px 15px; border-radius: 11px; text-decoration: none; font-size: .84rem; font-weight: 600; background: var(--card); border: 1px solid var(--stroke); color: var(--text); transition: all .25s var(--ease); }
.brave-btn:hover { background: #fb542b; border-color: #fb542b; color: #fff; transform: translateY(-2px); box-shadow: 0 10px 22px -10px rgba(251,84,43,.8); }
.brave-btn svg { width: 16px; height: 16px; }
@media (max-width: 620px) { .brave-links { width: 100%; } .brave-btn { flex: 1; justify-content: center; } }
.sources-list { display: flex; flex-direction: column; gap: 14px; }
.source-group { background: var(--card); border: 1px solid var(--stroke); border-radius: 14px; overflow: hidden; }
.source-head { display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--stroke); flex-wrap: wrap; }
.source-name { font-weight: 800; font-size: .98rem; }
.source-desc { color: var(--muted); font-size: .82rem; }
.source-count { margin-left: auto; font-size: .72rem; font-weight: 700; color: var(--brand-2); background: rgba(22,214,196,.1); padding: 4px 9px; border-radius: 999px; }
.source-streams { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; padding: 14px 16px; }

.stream-row { display: flex; align-items: center; gap: 10px; padding: 11px 13px; border-radius: 11px; cursor: pointer; background: rgba(255,255,255,.025); border: 1px solid var(--stroke); color: var(--text); transition: all .2s var(--ease); text-align: left; }
.stream-row:hover { background: var(--card-hover); transform: translateY(-2px); border-color: rgba(109,94,252,.4); }
.stream-row.active { border-color: var(--brand-2); background: rgba(22,214,196,.12); box-shadow: 0 0 0 3px rgba(22,214,196,.12); }
.stream-row .q { flex-shrink: 0; font-size: .62rem; font-weight: 800; padding: 3px 6px; border-radius: 6px; letter-spacing: .03em; }
.stream-row .q.hd { background: rgba(22,214,196,.18); color: var(--brand-2); }
.stream-row .q.sd { background: rgba(255,255,255,.1); color: var(--muted); }
.stream-row .s-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.stream-row .s-name { font-weight: 700; font-size: .85rem; white-space: nowrap; }
.stream-row .s-lang { font-size: .72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stream-row .s-views { flex-shrink: 0; display: inline-flex; align-items: center; gap: 4px; font-size: .76rem; color: #ff8a4a; font-weight: 600; white-space: nowrap; }
.stream-row .s-views svg { width: 13px; height: 13px; flex-shrink: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .menu-toggle { display: grid; }
  .sidebar { position: fixed; top: 0; left: 0; height: 100dvh; transform: translateX(-100%); transition: transform .35s var(--ease); padding-top: calc(20px + env(safe-area-inset-top)); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow); }
  .side-link { padding: 12px 12px; font-size: .95rem; }

  .topbar { padding: 12px 16px 12px 64px; padding-right: calc(16px + env(safe-area-inset-right)); }
  .topbar-brand { display: inline-flex; }

  .home { padding: 12px 16px 70px; }
  .stream-view, .schedule-view { padding-left: 16px; padding-right: 16px; padding-bottom: 70px; }

  .row-section { margin-bottom: 26px; }
  .row-head h2 { font-size: 1.12rem; }
  .row-scroll > .card { flex: 0 0 260px; }

  .theatre-stage.theatre { padding: 10px; border-radius: 14px; }
  .player-toolbar { gap: 7px; }
  .tool-btn { padding: 10px 12px; font-size: .8rem; flex: 1; justify-content: center; }
}

@media (max-width: 600px) {
  .topbar-brand { display: none; }
  .row-scroll > .card { flex: 0 0 78vw; }
  .grid { grid-template-columns: 1fr; }
  .source-streams { grid-template-columns: 1fr; }
  .source-head { gap: 6px 10px; }
  .source-desc { flex-basis: 100%; order: 3; }
  .sched-day-head { top: 60px; }
  .brave-tip { padding: 16px; }
  /* iOS: prevent input zoom on focus */
  #searchInput { font-size: 16px; }
}

@media (max-width: 380px) {
  .home, .stream-view, .schedule-view { padding-left: 12px; padding-right: 12px; }
  .sched-row { gap: 10px; padding: 12px; }
  .sched-time { width: 54px; font-size: .82rem; }
  .tool-btn span, .tool-btn { font-size: .76rem; }
}

/* Lighter background on small screens for performance */
@media (max-width: 700px) {
  .blob { filter: blur(60px); opacity: .4; }
  .blob-1 { width: 300px; height: 300px; }
  .blob-2 { width: 280px; height: 280px; }
  .blob-3 { width: 260px; height: 260px; }
}

/* Disable sticky hover transforms on touch devices to avoid stuck states */
@media (hover: none) {
  .card:hover { transform: none; }
  .card:active { transform: scale(.985); }
  .sched-row:hover { transform: none; }
  .card:hover .card-poster img { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
