:root {
  --bg-1: #0b1021;
  --bg-2: #091a2b;
  --bg-3: #1b1f3b;
  --panel: rgba(8, 17, 33, 0.78);
  --panel-border: rgba(126, 240, 255, 0.35);
  --text: #f1f8ff;
  --muted: #b5c8df;
  --accent: #62f4ff;
  --accent-2: #ffb156;
  --live: #43f281;
  --warn: #ffd166;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-family: "Rajdhani", "Segoe UI", sans-serif;
  background: radial-gradient(circle at 20% 20%, #1b3558 0%, transparent 35%),
    radial-gradient(circle at 80% 10%, #3a1c4d 0%, transparent 35%),
    linear-gradient(120deg, var(--bg-1), var(--bg-2), var(--bg-3));
  background-size: 140% 140%;
  animation: pulseBg 18s ease-in-out infinite;
}

@keyframes pulseBg {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.page-wrap {
  height: 100dvh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 10px;
  gap: 10px;
  overflow: hidden;
}

.topbar {
  display: flex;
  flex: 0 0 auto;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: rgba(4, 9, 20, 0.45);
  backdrop-filter: blur(8px);
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1rem, 2.2vw, 1.5rem);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.topbar .meta {
  color: var(--muted);
  font-size: 0.86rem;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.grid-quad {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 10px;
  overflow: hidden;
}

.grid-single {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  overflow: hidden;
}

.arena-cell {
  position: relative;
  display: flex;
  min-height: 0;
  overflow: hidden;
  border-radius: 14px;
  background: #000;
  border: 1px solid rgba(98, 244, 255, 0.35);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05), 0 20px 40px rgba(0, 0, 0, 0.45);
}

.arena-cell.focused {
  border-color: rgba(255, 177, 86, 0.9);
  box-shadow: inset 0 0 0 1px rgba(255, 177, 86, 0.35), 0 20px 40px rgba(0, 0, 0, 0.55);
}

.arena-cell.audio-primary {
  border-color: rgba(67, 242, 129, 0.8);
}

.grid-quad.is-single {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.grid-quad.is-single .arena-cell {
  display: none;
  min-height: 0;
}

.grid-quad.is-single .arena-cell.focused {
  display: flex;
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
  align-items: center;
  justify-content: center;
}

.player-frame {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  background: #000;
}

.grid-quad.is-single .arena-cell.focused .player-frame {
  flex: 0 1 auto;
  height: 100%;
  width: auto;
  max-height: 100%;
  max-width: 100%;
  aspect-ratio: 16 / 9;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #7b8ca2;
  font-size: 1.05rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  pointer-events: none;
}

.hud {
  position: absolute;
  left: 10px;
  top: 10px;
  width: min(94%, 390px);
  max-height: calc(100% - 20px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  backdrop-filter: blur(10px);
  overflow: hidden;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.grid-quad.is-single .arena-cell.focused .hud {
  width: min(94%, 470px);
}

.hud.is-hidden {
  transform: translateY(-8px);
  opacity: 0;
  pointer-events: none;
}

.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.hud-title {
  font-size: 0.9rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #d8ecff;
}

.hud-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.glow-btn,
.pill-btn,
.match-btn,
select {
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  font-family: inherit;
}

.glow-btn {
  padding: 6px 10px;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
}

.glow-btn:hover,
.pill-btn:hover,
.match-btn:hover {
  transform: translateY(-1px);
}

.glow-btn.audio-main {
  border-color: rgba(67, 242, 129, 0.8);
  background: rgba(67, 242, 129, 0.22);
  color: #e8fff0;
}

.pill-wrap {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.pill-btn {
  padding: 7px 8px;
  font-size: 0.78rem;
  color: #eaf6ff;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.sport-icon {
  font-size: 0.95rem;
  line-height: 1;
}

.pill-btn.active {
  border-color: rgba(98, 244, 255, 0.95);
  background: rgba(98, 244, 255, 0.18);
  box-shadow: 0 0 12px rgba(98, 244, 255, 0.34);
}

.league-select {
  width: 100%;
  padding: 8px 10px;
  font-size: 0.88rem;
}

.match-list {
  overflow: auto;
  display: grid;
  gap: 6px;
  padding-right: 2px;
}

.match-list::-webkit-scrollbar {
  width: 7px;
}

.match-list::-webkit-scrollbar-thumb {
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.24);
}

.match-btn {
  cursor: pointer;
  text-align: left;
  padding: 8px 10px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
}

.match-btn .time {
  color: var(--accent-2);
  font-size: 0.8rem;
  min-width: 44px;
}

.match-btn .title {
  font-size: 0.85rem;
  line-height: 1.05rem;
}

.status {
  font-size: 0.72rem;
  padding: 3px 6px;
  border-radius: 999px;
  border: 1px solid transparent;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status.live {
  color: #001b08;
  border-color: rgba(67, 242, 129, 0.8);
  background: var(--live);
  animation: blinkLive 1.2s linear infinite;
}

@keyframes blinkLive {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(0.78); }
}

.status.upcoming {
  color: #342100;
  border-color: rgba(255, 209, 102, 0.8);
  background: var(--warn);
}

.status.finished,
.status.postponed,
.status.unknown {
  color: #d7e1ee;
  border-color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.12);
}

.match-btn.playing {
  border-color: rgba(98, 244, 255, 0.95);
  box-shadow: 0 0 14px rgba(98, 244, 255, 0.35);
}

.hud-note {
  color: var(--muted);
  font-size: 0.76rem;
}

.open-menu {
  position: absolute;
  left: 10px;
  top: 10px;
  z-index: 5;
  display: none;
}

.fullscreen-fab {
  position: absolute;
  right: 10px;
  top: 10px;
  z-index: 6;
}

.arena-cell.menu-hidden .open-menu {
  display: inline-flex;
}

@media (max-width: 980px) {
  .grid-quad {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(4, minmax(300px, 1fr));
  }

  .hud {
    width: calc(100% - 20px);
  }

  .pill-wrap {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hud-top {
    flex-direction: column;
  }

  .hud-actions {
    justify-content: flex-start;
  }
}

.guide-panel {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid rgba(98, 244, 255, 0.35);
  border-radius: 0;
  background: rgba(5, 15, 30, 0.92);
  backdrop-filter: blur(8px);
  padding: 12px;
  overflow: hidden;
}

.guide-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.guide-title {
  font-size: 1.2rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.guide-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.guide-label {
  font-size: 0.96rem;
  color: #c8d8ea;
}

.guide-days {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.guide-day {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.94rem;
  color: #eaf6ff;
  text-align: center;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.05);
}

.guide-day-today {
  min-width: 118px;
}

.guide-day-note {
  color: #b9cde4;
  font-size: 0.98rem;
}

.guide-day.active {
  border-color: rgba(98, 244, 255, 0.9);
  background: rgba(98, 244, 255, 0.22);
}

.guide-timeline {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: rgba(3, 12, 26, 0.82);
}

.guide-loading {
  min-height: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
}

.guide-loading-spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(255, 255, 255, 0.18);
  border-top-color: rgba(98, 244, 255, 0.95);
  border-radius: 50%;
  animation: guideSpin 0.85s linear infinite;
}

@keyframes guideSpin {
  to { transform: rotate(360deg); }
}

.guide-loading-text {
  color: #d9ecff;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.guide-loading-bar {
  width: min(480px, 86%);
  height: 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.guide-loading-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, rgba(98, 244, 255, 0.75), rgba(67, 242, 129, 0.75));
  transition: width 0.2s ease;
}

body.tv-guide-open .topbar,
body.tv-guide-open #quadGrid {
  visibility: hidden;
}

body.tv-guide-open .guide-panel {
  visibility: visible;
}

.guide-row {
  display: grid;
  grid-template-columns: var(--guide-label-width) var(--guide-track-width);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  min-height: 74px;
}

.guide-row-label {
  position: sticky;
  left: 0;
  z-index: 3;
  padding: 11px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 1rem;
  color: #e7f2ff;
  line-height: 1.35rem;
  background: rgba(6, 16, 30, 0.98);
}

button.guide-row-label {
  width: 100%;
  text-align: left;
  font-family: inherit;
  border: 0;
  cursor: pointer;
}

.guide-row-label-toggle:hover {
  background: rgba(14, 31, 52, 0.98);
}

.guide-row-label-child {
  color: #b8cbe1;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.86rem;
}

.guide-row-icon {
  display: inline-block;
  width: 28px;
  margin-right: 8px;
  font-size: 1.3rem;
  text-align: center;
}

.guide-row-track {
  position: relative;
  min-height: 74px;
  background: linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px) 0 0 / 160px 100%;
}

.guide-row-track-collapsed {
  display: flex;
  align-items: center;
}

.guide-collapsed-note {
  margin-left: 14px;
  color: #a8bfd8;
  font-size: 0.9rem;
}

.guide-grid {
  width: calc(var(--guide-label-width) + var(--guide-track-width));
  min-width: calc(var(--guide-label-width) + var(--guide-track-width));
}

.guide-time-head {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: var(--guide-label-width) var(--guide-track-width);
  min-height: 42px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(6, 16, 30, 0.98);
}

.guide-time-label {
  position: sticky;
  left: 0;
  z-index: 6;
  padding: 10px;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.9rem;
  color: #d1e6fc;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.guide-time-track {
  position: relative;
  height: 42px;
}

.guide-hour-tick {
  position: absolute;
  top: 9px;
  transform: translateX(-50%);
  font-size: 0.82rem;
  color: #b9cde4;
  white-space: nowrap;
}

.guide-block {
  position: absolute;
  top: 8px;
  bottom: 8px;
  border: 1px solid rgba(98, 244, 255, 0.7);
  background: rgba(98, 244, 255, 0.12);
  border-radius: 8px;
  padding: 8px;
  font-size: 0.88rem;
  color: #ecf8ff;
  overflow: hidden;
  cursor: pointer;
}

.guide-block:hover {
  background: rgba(98, 244, 255, 0.22);
}

.guide-block .time {
  color: var(--accent-2);
}

.guide-now-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(255, 97, 97, 0.95);
  box-shadow: 0 0 10px rgba(255, 97, 97, 0.55);
  z-index: 2;
}

.guide-now-line.is-head {
  top: 0;
  bottom: 0;
}

.guide-context-menu {
  position: fixed;
  z-index: 10020;
  display: grid;
  gap: 6px;
  min-width: 180px;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid rgba(98, 244, 255, 0.5);
  background: rgba(6, 16, 30, 0.96);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
}

.guide-context-title {
  font-size: 0.9rem;
  color: #cbe2f8;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.guide-context-menu button {
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #eef8ff;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.94rem;
  text-align: left;
  padding: 9px 11px;
  cursor: pointer;
}

.guide-context-menu button:hover {
  background: rgba(98, 244, 255, 0.22);
}
