:root {
  --bg: #030505;
  --panel: rgba(7, 10, 12, 0.86);
  --panel-strong: rgba(10, 12, 15, 0.96);
  --panel-line: rgba(203, 255, 53, 0.15);
  --text: #f4f7f1;
  --muted: #8c978d;
  --lime: #c9ff2f;
  --magenta: #ff4d9e;
  --cyan: #27d3ff;
  --gold: #ffd85b;
  --shadow-neon: 0 0 24px rgba(201, 255, 47, 0.18);
  --label-width: 10.5rem;
  --row-height: 7rem;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Barlow Condensed", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(201, 255, 47, 0.09), transparent 24%),
    radial-gradient(circle at top right, rgba(39, 211, 255, 0.11), transparent 28%),
    radial-gradient(circle at bottom center, rgba(255, 77, 158, 0.1), transparent 34%),
    linear-gradient(135deg, #020303 0%, #050707 48%, #020304 100%);
  letter-spacing: 0.04em;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}

body::before {
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 2.5rem 2.5rem;
  mask-image: linear-gradient(to bottom, transparent, black 10%, black 90%, transparent);
}

body::after {
  background:
    linear-gradient(120deg, transparent 0 72%, rgba(201, 255, 47, 0.08) 72% 72.6%, transparent 72.6%),
    linear-gradient(180deg, transparent 0 82%, rgba(39, 211, 255, 0.05) 82% 82.4%, transparent 82.4%);
}

.app-shell {
  width: min(1600px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 8px 0 20px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  margin-bottom: 0.45rem;
}

.page-header h1,
.section-head h2,
.chat-header h2,
#playerStageName,
.status-rail h3 {
  margin: 0;
  font-family: "Orbitron", sans-serif;
}

.page-header h1 {
  font-size: clamp(1.75rem, 2.6vw, 2.95rem);
  color: var(--lime);
  text-shadow: 0 0 20px rgba(201, 255, 47, 0.4);
}

.header-copy {
  max-width: 24rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  text-align: right;
}

.eyebrow,
.player-label,
.meta-label,
.stat-label {
  margin: 0 0 0.25rem;
  color: var(--lime);
  font-size: 0.9rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.layout-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.9fr) minmax(320px, 0.72fr);
  align-items: start;
  gap: 1rem;
}

.main-stack {
  display: grid;
  gap: 1rem;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(250px, 0.55fr);
  gap: 1rem;
}

.panel {
  position: relative;
  background: linear-gradient(180deg, rgba(11, 14, 16, 0.92), rgba(6, 8, 10, 0.95));
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 1.2rem;
  box-shadow:
    inset 0 0 0 1px rgba(201, 255, 47, 0.04),
    0 24px 80px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.panel::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid rgba(255, 255, 255, 0.04);
  pointer-events: none;
}

.player-card,
.chat-panel,
.timetable-panel,
.stat-card {
  backdrop-filter: blur(16px);
}

.player-card {
  padding: 0.85rem 0.9rem 0.8rem;
}

.player-topbar {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 0.65rem;
}

.stage-chip {
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: rgba(255, 77, 158, 0.12);
  border: 1px solid rgba(255, 77, 158, 0.45);
  color: #ffdce9;
  font-family: "Orbitron", sans-serif;
  font-size: 0.9rem;
}

#playerStageName {
  font-size: clamp(1.35rem, 2vw, 2rem);
}

.player-frame {
  position: relative;
  border-radius: 1rem;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.05),
    0 0 0 1px rgba(201, 255, 47, 0.05);
}

.player-frame::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 16%);
  z-index: 1;
}

.player-frame iframe {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 7.8;
  border: 0;
  background: #000;
}

.player-footer {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
  margin-top: 0.7rem;
  padding-top: 0.7rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.meta-value {
  margin: 0;
  font-size: 1rem;
}

.status-rail {
  display: grid;
  gap: 0.75rem;
}

.stat-card {
  padding: 0.72rem 0.82rem;
}

.clock {
  margin: 0;
  font-family: "Orbitron", sans-serif;
  font-size: clamp(2rem, 3.2vw, 3rem);
  color: var(--gold);
  text-shadow: 0 0 22px rgba(255, 216, 91, 0.28);
}

.date-line,
.next-meta,
.countdown {
  margin: 0.2rem 0 0;
  color: var(--muted);
}

.status-list {
  display: grid;
  gap: 0.7rem;
}

.status-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0.85rem;
  border-radius: 0.9rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
}

.status-item.is-selected {
  border-color: rgba(201, 255, 47, 0.42);
  box-shadow: var(--shadow-neon);
}

.status-name {
  font-size: 1.15rem;
}

.status-meta {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.status-light {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 999px;
  box-shadow: 0 0 14px currentColor;
}

.timetable-panel {
  padding: 0.82rem 0.9rem 0.85rem;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.4rem;
}

.section-note {
  display: none;
}

.legend-dot {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  margin-right: 0.35rem;
  border-radius: 999px;
}

.legend-selected {
  background: var(--lime);
  box-shadow: 0 0 12px rgba(201, 255, 47, 0.7);
}

.legend-live {
  background: var(--magenta);
  box-shadow: 0 0 12px rgba(255, 77, 158, 0.7);
}

.timetable-frame {
  position: relative;
}

.timetable-frame.is-video-mode .row-now-line {
  display: none;
}

.time-scale-wrap {
  position: relative;
  display: grid;
  grid-template-columns: var(--label-width) minmax(0, 1fr);
  margin-bottom: 0.5rem;
}

.time-scale-spacer {
  min-height: 1.65rem;
}

.time-scale {
  position: relative;
  display: flex;
  justify-content: space-between;
  min-height: 1.65rem;
  padding-inline: 0.15rem;
  color: rgba(255, 255, 255, 0.82);
}

.time-tick {
  position: relative;
  font-size: 0.92rem;
}

.time-tick::after {
  content: "";
  position: absolute;
  top: 1.25rem;
  left: 50%;
  width: 1px;
  height: calc(var(--row-height) * 3 + 1.25rem);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 92%);
}

.time-indicator {
  position: absolute;
  inset: 0 0 auto var(--label-width);
  pointer-events: none;
}

.time-indicator span {
  position: absolute;
  left: var(--current-left, 0%);
  top: -0.7rem;
  transform: translateX(-50%);
  padding: 0.12rem 0.46rem;
  border-radius: 999px;
  background: rgba(201, 255, 47, 0.12);
  border: 1px solid rgba(201, 255, 47, 0.42);
  color: var(--lime);
  font-family: "Orbitron", sans-serif;
  font-size: 0.88rem;
  box-shadow: var(--shadow-neon);
}

.timetable-rows {
  display: grid;
  gap: 0.55rem;
}

.timetable-row {
  display: grid;
  grid-template-columns: var(--label-width) minmax(0, 1fr);
  align-items: stretch;
  gap: 0.8rem;
}

.stage-label {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: var(--row-height);
  padding: 0.75rem 0.9rem;
  border-radius: 1rem;
  color: #050607;
  font-family: "Orbitron", sans-serif;
  line-height: 1.1;
  text-transform: uppercase;
}

.stage-label small {
  margin-top: 0.4rem;
  font-size: 0.75rem;
  opacity: 0.8;
}

.track {
  position: relative;
  min-height: var(--row-height);
  border-radius: 1rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.018), rgba(255, 255, 255, 0.01)),
    rgba(0, 0, 0, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.05);
  overflow: hidden;
}

.track::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: calc(100% / 8) 100%;
  pointer-events: none;
}

.row-now-line {
  position: absolute;
  inset: 0 auto 0 var(--current-left, 0%);
  width: 2px;
  background: linear-gradient(180deg, transparent, rgba(201, 255, 47, 0.95) 15%, rgba(201, 255, 47, 0.95) 85%, transparent);
  box-shadow: 0 0 22px rgba(201, 255, 47, 0.65);
  z-index: 0;
}

.row-now-line::before {
  content: "";
  position: absolute;
  top: -0.15rem;
  left: 50%;
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 999px;
  transform: translate(-50%, -50%);
  background: var(--lime);
  box-shadow: 0 0 18px rgba(201, 255, 47, 0.9);
}

.program-card {
  position: absolute;
  top: 0.5rem;
  bottom: 0.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0.55rem 0.8rem;
  border-radius: 0.9rem;
  background: linear-gradient(180deg, rgba(10, 12, 14, 0.92), rgba(7, 8, 11, 0.96));
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease,
    background 180ms ease;
  z-index: 1;
}

.program-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.32);
}

.program-card:focus-visible {
  outline: 2px solid white;
  outline-offset: 2px;
}

.program-card.is-live {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.program-card.is-selected {
  box-shadow: 0 0 26px color-mix(in srgb, var(--card-color) 48%, transparent);
  border-color: color-mix(in srgb, var(--card-color) 72%, white 18%);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--card-color) 18%, rgba(15, 16, 18, 0.92)), rgba(7, 8, 11, 0.98));
}

.program-card::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--card-color), transparent);
  opacity: 0.78;
}

.slot-time {
  color: color-mix(in srgb, var(--card-color) 76%, white 16%);
  font-size: 0.82rem;
}

.slot-title {
  margin: 0.15rem 0 0;
  font-size: 1.15rem;
  line-height: 1.05;
  font-style: italic;
  text-transform: uppercase;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.slot-badge {
  align-self: flex-end;
  padding: 0.12rem 0.46rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--card-color) 60%, white 10%);
  color: color-mix(in srgb, var(--card-color) 80%, white 10%);
  font-size: 0.74rem;
}

.chat-panel {
  position: sticky;
  top: 10px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: min(34rem, calc(100vh - 18px));
  max-height: calc(100vh - 18px);
  padding: 0.85rem 0.85rem 0.8rem;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 1rem;
  margin-bottom: 0.65rem;
}

.chat-title-line {
  display: grid;
}

.chat-stage-pill {
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(201, 255, 47, 0.35);
  color: var(--lime);
  font-family: "Orbitron", sans-serif;
  font-size: 0.85rem;
}

.chat-body {
  display: grid;
  min-height: 0;
}

.youtube-chat {
  gap: 0.55rem;
  grid-template-rows: minmax(0, 1fr) auto;
}

.youtube-chat iframe {
  width: 100%;
  height: 100%;
  min-height: 19.5rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.9rem;
  background: rgba(0, 0, 0, 0.35);
}

.chat-help {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

@media (max-width: 1180px) {
  .layout-grid,
  .hero-grid {
    grid-template-columns: 1fr;
  }

  .chat-panel {
    position: static;
    top: auto;
    max-height: none;
    min-height: 38rem;
  }
}

@media (max-width: 820px) {
  :root {
    --label-width: 7.4rem;
    --row-height: 6.8rem;
  }

  .page-header {
    display: none;
  }

  .layout-grid {
    gap: 0.7rem;
  }

  .main-stack,
  .hero-grid {
    display: contents;
  }

  .player-card {
    display: contents;
  }

  .player-topbar {
    order: 1;
    padding: 0.75rem 0.75rem 0;
    gap: 0.7rem;
    margin-bottom: 0.65rem;
  }

  .stage-chip {
    padding: 0.25rem 0.55rem;
    font-size: 0.78rem;
  }

  #playerStageName {
    font-size: 1.15rem;
  }

  .player-label {
    font-size: 0.72rem;
  }

  .player-frame {
    order: 2;
    position: sticky;
    top: 6px;
    z-index: 40;
    margin: 0 0.75rem;
    border-radius: 0.9rem;
    background: #000;
    box-shadow:
      0 10px 28px rgba(0, 0, 0, 0.5),
      0 0 0 1px rgba(201, 255, 47, 0.08);
  }

  body.is-chat-focus .player-frame {
    position: relative;
    top: auto;
  }

  .player-footer {
    display: none;
  }

  .chat-panel {
    order: 2;
    padding: 0.75rem;
    border-radius: 1rem;
    min-height: calc(100svh - 19rem);
    max-height: none;
  }

  .status-rail {
    order: 3;
  }

  .timetable-panel {
    order: 4;
  }

  .app-shell {
    width: min(100vw - 12px, 100%);
    padding-top: 6px;
    padding-bottom: 16px;
  }

  .page-header,
  .section-head,
  .chat-header {
    flex-direction: column;
    align-items: start;
  }

  .header-copy {
    text-align: left;
  }

  .chat-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.55rem;
    margin-bottom: 0.55rem;
  }

  .chat-title-line {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 0;
  }

  .chat-title-line .eyebrow,
  .chat-header h2 {
    margin: 0;
    white-space: nowrap;
  }

  .chat-title-line .eyebrow {
    font-size: 0.62rem;
    letter-spacing: 0.12em;
  }

  .chat-header h2 {
    font-size: 0.98rem;
  }

  .chat-stage-pill {
    padding: 0.28rem 0.55rem;
    font-size: 0.68rem;
    white-space: nowrap;
  }

  .youtube-chat iframe {
    min-height: calc(100svh - 24rem);
    border-radius: 0.8rem;
  }

  .section-note {
    flex-wrap: wrap;
  }

  .status-rail {
    gap: 0.7rem;
  }

  .stat-card,
  .timetable-panel {
    border-radius: 1rem;
  }

  .slot-title {
    font-size: 1.1rem;
  }
}
