:root {
  --bg: #0d0f14;
  --panel: #161a22;
  --panel-2: #1f2430;
  --text: #e8eaed;
  --muted: #9aa0ab;
  --accent: #e23744;
  --accent-2: #3a7afe;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header {
  display: flex;
  align-items: center;
  gap: 16px 24px;
  flex-wrap: wrap;
  padding: 14px 20px;
  background: linear-gradient(180deg, #11141b, #0d0f14);
  border-bottom: 1px solid #20242e;
  position: sticky;
  top: 0;
  z-index: 10;
}

header h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 1px;
  font-weight: 800;
}

.tabs { display: flex; gap: 8px; }
.tabs button {
  background: var(--panel);
  color: var(--muted);
  border: 1px solid #262b36;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  transition: 0.15s;
}
.tabs button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.auth { margin-left: auto; font-size: 13px; color: var(--muted); display: flex; gap: 10px; align-items: center; }
.auth .dot { width: 9px; height: 9px; border-radius: 50%; background: #555; display: inline-block; margin-right: 5px; }
.auth .dot.on { background: #2ecc71; }

main { padding: 24px; max-width: 1200px; margin: 0 auto; }

.controls { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-bottom: 20px; }
#searchForm { display: flex; gap: 8px; flex: 1; min-width: 260px; }
#searchInput {
  flex: 1; padding: 11px 14px; border-radius: var(--radius);
  border: 1px solid #2a2f3b; background: var(--panel); color: var(--text); font-size: 15px;
}
button { font-family: inherit; }
#searchForm button, .quick button {
  padding: 11px 18px; border-radius: var(--radius); border: 1px solid #2a2f3b;
  background: var(--panel-2); color: var(--text); cursor: pointer; font-weight: 600;
}
.quick { display: flex; gap: 8px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 18px;
}
.card {
  background: var(--panel); border: 1px solid #20242e; border-radius: var(--radius);
  overflow: hidden; cursor: pointer; transition: 0.15s; display: flex; flex-direction: column;
}
.card:hover { transform: translateY(-3px); border-color: var(--accent-2); }
.card .thumb { aspect-ratio: 16/9; background: #0a0c10 center/cover; }
.card .thumb.live { display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 800; color: var(--muted); }
.card .thumb { position: relative; }
.brand-badge {
  position: absolute; bottom: 6px; right: 6px; background: rgba(8,10,14,0.8);
  color: #cfe3ff; font: 700 11px system-ui, sans-serif; padding: 2px 7px; border-radius: 999px;
}
.card .body { padding: 10px 12px; }
.card .title { font-weight: 700; font-size: 14px; line-height: 1.3; }
.card .sub { color: var(--muted); font-size: 12px; margin-top: 3px; }

.player-wrap { margin-bottom: 24px; background: #000; border-radius: var(--radius); overflow: hidden; }
.video-holder { position: relative; }
#video { width: 100%; max-height: 70vh; display: block; background: #000; }
.player-meta { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 14px; background: var(--panel); }
#nowPlaying { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-controls { display: flex; gap: 8px; align-items: center; margin-left: auto; }
#qualitySelect {
  background: var(--panel-2); color: var(--text); border: 1px solid #2a2f3b;
  border-radius: 8px; padding: 6px 8px; font-size: 13px; cursor: pointer;
}
#infoToggle {
  background: var(--panel-2); color: var(--text); border: 1px solid #2a2f3b;
  border-radius: 8px; padding: 6px 10px; font-size: 13px; cursor: pointer; white-space: nowrap;
}
#infoToggle.on { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
#castBtn {
  background: var(--panel-2); color: var(--text); border: 1px solid #2a2f3b;
  border-radius: 8px; padding: 6px 10px; font-size: 13px; cursor: pointer; white-space: nowrap;
}
#castBtn.on { background: #1f9d57; border-color: #1f9d57; color: #fff; }
#airplayBtn {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--panel-2); color: var(--text); border: 1px solid #2a2f3b;
  border-radius: 8px; padding: 6px 10px; font-size: 13px; cursor: pointer; white-space: nowrap;
}
#airplayBtn[hidden] { display: none; }
#airplayBtn.on { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
#airplayBtn svg { display: block; }
#closePlayer { background: transparent; border: none; color: var(--muted); cursor: pointer; font-size: 14px; }

/* Stream-info overlay */
.info-panel {
  position: absolute; top: 10px; right: 10px; max-width: 280px;
  background: rgba(8, 10, 14, 0.82); color: #cfe3ff; border: 1px solid #2a3550;
  border-radius: 10px; padding: 10px 12px; backdrop-filter: blur(4px);
  font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; pointer-events: none;
}
.info-panel .row { display: flex; justify-content: space-between; gap: 16px; }
.info-panel .k { color: #8aa0c0; }
.info-panel .v { color: #eaf2ff; font-weight: 600; }

#message { color: var(--muted); min-height: 20px; }
.bbc-only.hidden { display: none; }

/* ---------- World Cup schedule ---------- */
/* The hidden attribute must win over component display rules. */
[hidden] { display: none !important; }
/* The schedule isn't a card grid — let it be full-width block flow. */
.grid.as-schedule { display: block; }
.wc-tab.active { background: #1f9d57; border-color: #1f9d57; }
.wc-tznote { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.schedule { display: flex; flex-direction: column; }
.wc-date {
  margin: 22px 0 8px; font-size: 15px; color: #6ee7a0; font-weight: 800;
  letter-spacing: 0.3px; border-bottom: 1px solid #20242e; padding-bottom: 6px;
}
.wc-date:first-child { margin-top: 0; }
.wc-fixture {
  display: flex; align-items: center; gap: 14px; padding: 12px 8px;
  border-bottom: 1px solid #181c24;
}
.wc-time { font: 700 15px ui-monospace, Menlo, monospace; color: var(--text); min-width: 56px; flex: none; white-space: nowrap; }
.wc-main { flex: 1; min-width: 0; }
.wc-teams { font-weight: 700; font-size: 15px; }
.wc-comp { color: var(--muted); font-size: 12px; margin-top: 2px; }
.wc-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.wc-play {
  background: #1f9d57; color: #fff; border: none; border-radius: 999px;
  padding: 8px 14px; font-weight: 700; font-size: 13px; cursor: pointer; white-space: nowrap;
  transition: 0.15s;
}
.wc-play:hover { background: #25b766; transform: translateY(-1px); }
.wc-noplay { color: var(--muted); font-size: 12px; }

/* LIVE NOW */
.wc-live {
  display: none; margin-left: 8px; color: #fff; background: var(--accent);
  border-radius: 4px; padding: 1px 6px; font: 800 10px/1.7 system-ui, sans-serif;
  vertical-align: middle; animation: wc-pulse 1.6s ease-in-out infinite;
}
.live-now .wc-live { display: inline-block; }
.live-now { background: rgba(226, 55, 68, 0.08); border-left: 3px solid var(--accent); border-radius: 6px; }
@keyframes wc-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

@media (max-width: 640px) {
  .wc-fixture { flex-wrap: wrap; gap: 8px 12px; }
  .wc-actions { flex: 1 1 100%; justify-content: flex-start; }
}

/* ---------- Responsive / mobile ---------- */
@media (max-width: 640px) {
  header { gap: 10px 14px; padding: 12px 14px; }
  header h1 { font-size: 18px; width: 100%; }
  .tabs { flex: 1; }
  .tabs button { flex: 1; padding: 9px 10px; }
  .auth { margin-left: 0; }

  main { padding: 14px; }

  .controls { gap: 10px; }
  #searchForm { min-width: 100%; }

  /* Two columns on phones, with room for titles. */
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
  .card .title { font-size: 13px; }

  #video { max-height: 56vh; }
  .player-wrap { margin-bottom: 16px; border-radius: 8px; }
  .player-meta { flex-wrap: wrap; }
  #nowPlaying { flex: 1 1 100%; }
  .player-controls { margin-left: 0; }
  .info-panel { max-width: 200px; font-size: 11px; top: 6px; right: 6px; padding: 8px; }
}

/* Larger, comfortable tap targets on touch devices. */
@media (hover: none) and (pointer: coarse) {
  .tabs button, #searchForm button, .quick button, #searchInput { min-height: 44px; }
  .card { -webkit-tap-highlight-color: transparent; }
}

/* Avoid iOS auto-zoom on input focus (needs >=16px font). */
@media (max-width: 640px) {
  #searchInput { font-size: 16px; }
}
