:root {
  --bg: #12151a;
  --bg-elevated: #1a1f27;
  --panel: #222833;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f2f4f7;
  --muted: #9aa3b2;
  --accent: #a8d86a;
  --accent-solid: #8cc63f;
  --live: #d12127;
  --radius: 10px;
  --font-display: "Bebas Neue", sans-serif;
  --font-body: "DM Sans", sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --menu-width: min(20rem, 88vw);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-user-select: none;
  user-select: none;
}

body {
  position: relative;
  overflow-x: hidden;
  -webkit-touch-callout: none;
}

button,
.icon-btn,
.menu-btn,
.badge,
.brand,
.tile-title,
.tile-head,
.focus-title,
.side-menu-title,
.tagline {
  -webkit-user-select: none;
  user-select: none;
}

video {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

body.menu-open {
  overflow: hidden;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(240, 180, 41, 0.14), transparent 55%),
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: auto, 48px 48px, 48px 48px;
  pointer-events: none;
  z-index: 0;
}

.topbar,
main {
  position: relative;
  z-index: 1;
}

.topbar {
  display: grid;
  gap: 0.35rem;
  padding:
    calc(0.9rem + var(--safe-top))
    calc(1rem + var(--safe-right))
    0.85rem
    calc(1rem + var(--safe-left));
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(26, 31, 39, 0.95), rgba(18, 21, 26, 0.85));
  backdrop-filter: blur(10px);
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.brand {
  display: flex;
  align-items: center;
  line-height: 1;
  min-width: 0;
  text-decoration: none;
}

.brand-logo {
  display: block;
  height: clamp(2.4rem, 7vw, 3.25rem);
  width: auto;
  max-width: min(14rem, 58vw);
  object-fit: contain;
  border: 0;
  background: transparent;
}

.brand-mark {
  font-family: var(--font-display);
  font-size: clamp(1.85rem, 6vw, 2.75rem);
  letter-spacing: 0.04em;
  color: var(--accent-solid);
}

.brand-name {
  font-family: var(--font-display);
  font-size: clamp(1.85rem, 6vw, 2.75rem);
  letter-spacing: 0.08em;
  color: var(--text);
}

.tagline {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.menu-btn {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  padding: 0;
}

.menu-btn-bars,
.menu-btn-bars::before,
.menu-btn-bars::after {
  display: block;
  width: 1.15rem;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  position: relative;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.menu-btn-bars::before,
.menu-btn-bars::after {
  content: "";
  position: absolute;
  left: 0;
}

.menu-btn-bars::before { top: -6px; }
.menu-btn-bars::after { top: 6px; }

body.menu-open .menu-btn-bars {
  background: transparent;
}

body.menu-open .menu-btn-bars::before {
  top: 0;
  transform: rotate(45deg);
}

body.menu-open .menu-btn-bars::after {
  top: 0;
  transform: rotate(-45deg);
}

.menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
}

.side-menu {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 45;
  width: var(--menu-width);
  height: 100%;
  height: 100dvh;
  background: var(--bg-elevated);
  border-left: 1px solid var(--line);
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.35);
  transform: translateX(105%);
  transition: transform 0.28s ease;
  display: flex;
  flex-direction: column;
  padding:
    calc(0.85rem + var(--safe-top))
    calc(1rem + var(--safe-right))
    calc(1rem + var(--safe-bottom))
    1rem;
}

body.menu-open .side-menu {
  transform: translateX(0);
}

.side-menu-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--line);
}

.side-menu-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.7rem;
  letter-spacing: 0.06em;
  font-weight: 400;
}

.side-menu-body.controls {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  align-items: stretch;
}

.side-menu-body .control {
  width: 100%;
}

.side-menu-body .control select,
.side-menu-body .btn {
  width: 100%;
}

.control {
  display: grid;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.control select,
.btn {
  height: 2.55rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 0 0.85rem;
}

.btn {
  cursor: pointer;
  font-weight: 600;
  background: var(--accent-solid);
  color: #1a1400;
  border-color: transparent;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.btn:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--line);
}

.side-menu-body #audioBtn.btn {
  width: 100%;
  min-height: 2.55rem;
  height: 2.55rem;
  white-space: nowrap;
}

main {
  padding:
    1rem
    calc(1rem + var(--safe-right))
    calc(1.5rem + var(--safe-bottom))
    calc(1rem + var(--safe-left));
}

.status {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: 1px solid rgba(240, 180, 41, 0.35);
  background: rgba(240, 180, 41, 0.1);
  color: var(--accent);
  font-size: 0.9rem;
}

.status[hidden] {
  display: none !important;
}

.grid {
  display: grid;
  gap: 0.85rem;
}

.grid.cols-1 { grid-template-columns: 1fr; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 1100px) {
  .grid.cols-3,
  .grid.cols-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .tagline {
    font-size: 0.8rem;
  }

  .grid.cols-2,
  .grid.cols-3,
  .grid.cols-4 {
    grid-template-columns: 1fr;
  }

  .tile-head {
    padding: 0.55rem 0.65rem;
    gap: 0.45rem;
  }

  .tile-title {
    font-size: 0.84rem;
  }

  .badge {
    display: none;
  }

  .frame-wrap {
    aspect-ratio: 16 / 9;
  }

  .focus-bar {
    flex-wrap: wrap;
    padding:
      calc(0.65rem + var(--safe-top))
      calc(0.75rem + var(--safe-right))
      0.65rem
      calc(0.75rem + var(--safe-left));
  }

  .focus-title {
    order: 3;
    flex: 1 1 100%;
    font-size: 0.95rem;
  }

  .focus-actions {
    margin-left: auto;
  }

  .focus-actions .btn {
    height: 2.2rem;
    padding: 0 0.7rem;
    font-size: 0.82rem;
  }
}

.tile {
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 0;
  animation: rise 0.45s ease both;
}

.tile:nth-child(1) { animation-delay: 0.02s; }
.tile:nth-child(2) { animation-delay: 0.06s; }
.tile:nth-child(3) { animation-delay: 0.1s; }
.tile:nth-child(4) { animation-delay: 0.14s; }
.tile:nth-child(5) { animation-delay: 0.18s; }
.tile:nth-child(6) { animation-delay: 0.22s; }
.tile:nth-child(7) { animation-delay: 0.26s; }
.tile:nth-child(8) { animation-delay: 0.3s; }
.tile:nth-child(9) { animation-delay: 0.34s; }

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.8rem;
  border-bottom: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
}

.tile-title {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.badge {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
}

.badge.live {
  background: rgba(239, 68, 68, 0.18);
  color: #f87171;
}

.icon-btn {
  width: 1.8rem;
  height: 1.8rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  text-decoration: none;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.06);
}

.frame-wrap {
  position: relative;
  aspect-ratio: 16 / 10;
  background: #000;
}

.frame-wrap video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  pointer-events: none;
}

/* Kill native play/pause / media chrome */
.frame-wrap video::-webkit-media-controls,
.frame-wrap video::-webkit-media-controls-enclosure,
.frame-wrap video::-webkit-media-controls-panel,
.frame-wrap video::-webkit-media-controls-start-playback-button,
.focus-video-wrap video::-webkit-media-controls,
.focus-video-wrap video::-webkit-media-controls-start-playback-button {
  display: none !important;
  -webkit-appearance: none;
  opacity: 0;
  pointer-events: none;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.5rem 0.28rem 0.4rem;
  border-radius: 6px;
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.35);
  -webkit-user-select: none;
  user-select: none;
  flex-shrink: 0;
}

.live-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.55);
  animation: live-pulse 1.4s ease-out infinite;
  flex-shrink: 0;
}

.live-text {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #f87171;
  line-height: 1;
}

@keyframes live-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.55);
  }
  70% {
    box-shadow: 0 0 0 0.45rem rgba(239, 68, 68, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

.frame-wrap.solo {
  aspect-ratio: 16 / 9;
  min-height: 70vh;
}

.hidden {
  display: none !important;
}

body.focus-mode .topbar,
body.focus-mode main,
body.focus-mode .side-menu,
body.focus-mode .menu-backdrop {
  display: none !important;
}

.focus-layer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  grid-template-rows: auto 1fr;
  background: #000;
}

.focus-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: rgba(18, 21, 26, 0.95);
  border-bottom: 1px solid var(--line);
}

.focus-title {
  margin: 0;
  flex: 1;
  font-size: 1.05rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.focus-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.focus-stage {
  min-height: 0;
  display: grid;
  place-items: center;
  background: #000;
  padding-bottom: var(--safe-bottom);
}

.focus-video-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
}

.focus-video-wrap video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  pointer-events: none;
}
