* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body {
  width: 100%; min-height: 100dvh; background: #0b0b0f; color: #e8e8ea;
  font-family: "Helvetica Neue", Arial, sans-serif; overflow-x: hidden;
}

/* ── Topbar ─────────────────────────────────────────────────────────── */
#topbar {
  position: sticky; top: 0; left: 0; right: 0; height: 64px;
  display: flex; align-items: center; padding: 0 16px;
  background: #000; z-index: 10; gap: 12px;
}
#topbar::after {
  content: ''; position: absolute; left: 0; right: 0; top: 100%; height: 24px;
  background: linear-gradient(180deg, rgba(0,0,0,.85), rgba(0,0,0,0));
  pointer-events: none;
}
.brand-logo { height: 36px; width: 36px; margin-right: 8px; object-fit: contain; flex-shrink: 0; }

#categories {
  display: flex; gap: 6px; align-items: center;
  overflow-x: auto; flex: 1;
  scrollbar-width: none;
}
#categories::-webkit-scrollbar { display: none; }

.cat svg { display: inline-block; vertical-align: middle; }
.cat {
  padding: 7px 14px; border-radius: 8px; font-size: 14px; font-weight: 600;
  color: #c9c9cf; background: transparent; white-space: nowrap;
  transition: transform .15s, background .15s; flex-shrink: 0; cursor: pointer;
}
.cat.focused { background: #1f1f27; color: #fff; transform: scale(1.05); }
.cat.active { color: #fff; background: #e50914; }
.cat.active.focused { background: #c0000f; }

/* ── Grid ────────────────────────────────────────────────────────────── */
#grid-view { padding: 16px 12px 40px; }
#grid-spinner {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: #0b0b0f; z-index: 20; pointer-events: none;
}
#grid-spinner::after {
  content: ''; width: 48px; height: 48px; border-radius: 50%;
  border: 5px solid rgba(255,255,255,.15); border-top-color: #e50914;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#grid-spinner.hidden { display: none; }
#grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.card {
  position: relative; aspect-ratio: 16/9; background: #15151c;
  border-radius: 8px; overflow: hidden; cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease;
  display: flex; align-items: center; justify-content: center;
}
.card.loading {
  background: linear-gradient(90deg, #15151c 25%, #1f1f2a 50%, #15151c 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}
.card img { width: 100%; height: 100%; object-fit: contain; padding: 8px; }
.card .label {
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 60%;
  display: flex; align-items: flex-end;
  padding: 0 8px 6px;
  font-size: 11px; font-weight: 700;
  background: linear-gradient(to top,
    rgba(0,0,0,1)   0%,
    rgba(0,0,0,.85) 35%,
    rgba(0,0,0,.4)  70%,
    rgba(0,0,0,0)   100%);
  text-shadow: 0 1px 3px rgba(0,0,0,.9);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 1.2;
}
.card .num {
  position: absolute; top: 4px; left: 4px;
  background: rgba(0,0,0,.75); color: #fff;
  font: 700 10px/1 Arial; padding: 2px 5px; border-radius: 4px;
  border: 1px solid rgba(255,255,255,.2);
}
.card .fav {
  position: absolute; top: 4px; right: 4px;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; line-height: 1;
  color: rgba(255,255,255,.45);
  background: none; border: none;
  cursor: pointer;
  transition: transform .12s, color .12s;
}
.card .fav.on { color: #ffd24a; }
.card.focused {
  transform: scale(1.06);
  box-shadow: 0 0 0 3px #e50914;
  z-index: 2;
}

/* ── Player ──────────────────────────────────────────────────────────── */
#player-view {
  position: fixed; inset: 0; background: #000; z-index: 100;
  display: flex; align-items: center; justify-content: center;
}
#video { width: 100%; height: 100%; background: #000; object-fit: contain; }
#video::-moz-pip-button { display: none !important; }
#player-hud {
  position: absolute; left: 16px; bottom: 16px; right: 16px;
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px;
  text-shadow: 0 2px 8px rgba(0,0,0,.9);
  opacity: 1; transition: opacity .4s;
}
#player-hud.hidden { opacity: 0; }
#hud-title { font-size: 20px; font-weight: 800; }
#hud-status { font-size: 14px; color: #bdbdc4; }
#hud-hint { margin-left: auto; font-size: 12px; color: #8c8c93; }

/* ── Search ──────────────────────────────────────────────────────────── */
#topbar.searching #categories .cat:not(.search-chip) { display: none; }
#topbar.searching #categories { flex: 0; overflow: visible; }
#topbar.searching #search-bar { display: flex; flex: 1; }
#search-bar {
  display: none; align-items: center;
}
#search-bar input {
  width: 100%; padding: 7px 12px;
  font-size: 16px; font-weight: 500;
  color: #fff; background: rgba(20,20,28,.95);
  border: 2px solid #e50914; border-radius: 8px;
  outline: none;
}
#search-bar input::placeholder { color: #6c6c75; }

/* ── Toast ───────────────────────────────────────────────────────────── */
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: rgba(20,20,28,.95); padding: 12px 20px; border-radius: 10px;
  font-size: 16px; z-index: 200; border: 1px solid #2a2a35;
  white-space: nowrap;
}

/* ── Hover (pointer devices) ─────────────────────────────────────────── */
@media (hover: hover) {
  .card:hover {
    transform: scale(1.04);
    box-shadow: 0 0 0 3px rgba(229,9,20,.7);
    z-index: 1;
  }
  .card.focused:hover { transform: scale(1.06); box-shadow: 0 0 0 3px #e50914; }
  .card .fav:hover { transform: scale(1.15); color: #ffd24a; }
  .cat:hover { background: #1a1a22; color: #fff; }
}

/* ── Narrow phone < 400px: 1 column ─────────────────────────────────── */
@media (max-width: 399px) {
  #grid { grid-template-columns: 1fr; gap: 8px; }
  .card .label { font-size: 14px; }
}

/* ── Tablet ≥ 600px ──────────────────────────────────────────────────── */
@media (min-width: 600px) {
  #topbar { height: 72px; padding: 0 24px; }
  .brand-logo { height: 44px; width: 44px; margin-right: 20px; }
  .cat { font-size: 16px; padding: 8px 18px; }
  #grid-view { padding: 20px 20px 48px; }
  #grid { grid-template-columns: repeat(4, 1fr); gap: 14px; }
  .card .label { font-size: 13px; padding: 0 10px 8px; }
  .card .num { font-size: 11px; }
  #player-hud { left: 32px; bottom: 32px; right: 32px; gap: 16px; }
  #hud-title { font-size: 26px; }
  #hud-status { font-size: 16px; }
  #hud-hint { font-size: 14px; }
}

/* ── Desktop / TV ≥ 1024px ───────────────────────────────────────────── */
@media (min-width: 1024px) {
  #topbar { height: 96px; padding: 0 60px; }
  .brand-logo { height: 60px; width: 60px; margin-right: 60px; }
  .cat { font-size: 22px; padding: 10px 22px; }
  #grid-view { padding: 40px 60px 60px; }
  #grid { grid-template-columns: repeat(6, 1fr); gap: 28px; }
  .card .label { font-size: 18px; height: 80px; padding: 0 14px 10px; }
  .card .num { font-size: 14px; top: 8px; left: 8px; padding: 4px 8px; border-radius: 6px; }
  .card .fav { width: 36px; height: 36px; font-size: 22px; top: 6px; right: 6px; }
  .card.focused { transform: scale(1.08); box-shadow: 0 0 0 4px #e50914; }
  #player-hud { left: 60px; bottom: 60px; right: 60px; gap: 30px; flex-wrap: nowrap; }
  #hud-title { font-size: 36px; }
  #hud-status { font-size: 20px; }
  #hud-hint { font-size: 18px; }
  #search-bar input { font-size: 22px; padding: 10px 16px; }
  #toast { font-size: 22px; padding: 18px 28px; }
}

