* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
}

:root {
  --bg-color: #080c14;
  --surface-color: #121826;
  --surface-light: #1c2438;
  --surface-active: #242f49;
  --primary-color: #00e5ff;
  --primary-glow: rgba(0, 229, 255, 0.4);
  --live-red: #ff2d55;
  --text-primary: #ffffff;
  --text-secondary: #94a3b8;
  --divider: rgba(255, 255, 255, 0.08);
}

body {
  width: 100%;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
}

/* App Container */
#app {
  width: 100%;
  min-height: 100vh;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* Header */
.tv-header {
  height: 90px;
  padding: 20px 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--divider);
  background: linear-gradient(180deg, rgba(18, 24, 38, 0.8) 0%, transparent 100%);
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-icon {
  width: 44px;
  height: 44px;
  background: rgba(0, 229, 255, 0.15);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-color);
  font-size: 24px;
}

.logo-text {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #ffffff;
}

.header-info {
  display: flex;
  align-items: center;
  gap: 20px;
}

.tv-pill {
  padding: 8px 16px;
  background: var(--surface-light);
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  border: 1px solid var(--divider);
}

.live-count-badge {
  background: rgba(255, 45, 85, 0.2);
  color: var(--live-red);
  border-color: rgba(255, 45, 85, 0.4);
}

/* Category Filter Bar */
.category-bar-wrapper {
  padding: 16px 48px 12px 48px;
  overflow: hidden;
}

.category-bar {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scrollbar-width: none;
}
.category-bar::-webkit-scrollbar {
  display: none;
}

.category-chip {
  padding: 10px 24px;
  background: var(--surface-color);
  border: 1.5px solid var(--divider);
  border-radius: 24px;
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
}

.category-chip.active {
  background: rgba(0, 229, 255, 0.15);
  color: var(--primary-color);
  border-color: var(--primary-color);
}

.category-chip:hover {
  background: var(--surface-light);
  border-color: rgba(0, 229, 255, 0.4);
}

.category-chip.focused {
  transform: scale(1.08);
  outline: 3px solid var(--primary-color);
  box-shadow: 0 0 16px var(--primary-glow);
  background: var(--surface-light);
  color: #ffffff;
}

/* Main Content Area */
.tv-main {
  flex: 1;
  padding: 12px 36px 36px 36px;
  overflow-y: auto;
  scrollbar-width: none;
}
.tv-main::-webkit-scrollbar {
  display: none;
}

/* Match Grid */
.match-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
}

.match-card {
  background: var(--surface-color);
  border: 1.5px solid var(--divider);
  border-radius: 18px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 185px;
  transition: transform 0.2s cubic-bezier(0.2, 0, 0, 1), outline 0.2s, box-shadow 0.2s;
  cursor: pointer;
}

.match-card:hover {
  background: var(--surface-light);
  border-color: rgba(0, 229, 255, 0.5);
}

.match-card.focused {
  transform: scale(1.04);
  outline: 3.5px solid var(--primary-color);
  box-shadow: 0 8px 30px rgba(0, 229, 255, 0.35);
  background: var(--surface-light);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.league-tag {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  max-width: 70%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.match-badge {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.match-badge.live {
  background: rgba(255, 45, 85, 0.25);
  color: var(--live-red);
  border: 1px solid rgba(255, 45, 85, 0.5);
  display: flex;
  align-items: center;
  gap: 6px;
}

.match-badge.live::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--live-red);
  border-radius: 50%;
  animation: pulse 1s infinite alternate;
}

@keyframes pulse {
  0% { opacity: 0.4; }
  100% { opacity: 1; }
}

.match-badge.upcoming {
  background: var(--surface-light);
  color: var(--text-secondary);
  border: 1px solid var(--divider);
}

/* Teams row */
.teams-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 6px 0;
}

.team {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 40%;
  text-align: center;
}

.team-logo {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--surface-light);
  display: flex;
  align-items: center;
  justify-content: center;
  object-fit: cover;
}

.team-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vs-badge {
  padding: 6px 12px;
  background: rgba(0, 229, 255, 0.12);
  color: var(--primary-color);
  font-size: 12px;
  font-weight: 800;
  border-radius: 12px;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--divider);
  font-size: 12px;
  color: var(--text-secondary);
}

/* Loading & Empty States */
.state-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 60vh;
  gap: 20px;
  text-align: center;
}

.spinner {
  width: 54px;
  height: 54px;
  border: 4px solid var(--surface-light);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Fullscreen Video Player View */
#player-view {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #000000;
  z-index: 100;
  display: none;
}

#player-view.active {
  display: block;
}

#video-element {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000000;
}

/* Player Overlay Controls */
.player-controls-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 105;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: linear-gradient(180deg, rgba(0,0,0,0.85) 0%, transparent 40%, transparent 60%, rgba(0,0,0,0.9) 100%);
  padding: 32px 48px;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.player-controls-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.player-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.player-title-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.player-back-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 2px solid transparent;
  font-size: 22px;
}

.player-back-btn.focused {
  outline: 3px solid var(--primary-color);
  background: var(--primary-color);
  color: #000000;
  transform: scale(1.1);
}

.player-match-title {
  font-size: 24px;
  font-weight: 700;
}

.player-center-status {
  align-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}

.player-center-status.visible {
  opacity: 1;
  transform: scale(1);
}

.play-pause-icon {
  font-size: 48px;
  color: var(--primary-color);
  background: rgba(0, 0, 0, 0.75);
  border-radius: 50%;
  width: 88px;
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--primary-color);
  box-shadow: 0 0 30px var(--primary-glow);
}

.player-bottom-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.servers-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.server-btn {
  padding: 8px 20px;
  background: rgba(255, 255, 255, 0.15);
  border: 1.5px solid var(--divider);
  border-radius: 20px;
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.server-btn.active {
  background: var(--primary-color);
  color: #000000;
  font-weight: 700;
  border-color: var(--primary-color);
}

.server-btn.focused {
  outline: 3px solid #ffffff;
  box-shadow: 0 0 16px #ffffff;
  transform: scale(1.1);
}

.player-instruction-hint {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ============================================================
   Responsive Media Queries for Mobile Phones, Tablets & TVs
   ============================================================ */
@media (max-width: 900px) {
  body {
    width: 100vw;
    height: auto;
    min-height: 100vh;
    overflow-y: auto;
  }

  #app {
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .tv-header {
    padding: 12px 16px;
    height: auto;
  }

  .logo-text {
    font-size: 18px;
  }

  .logo-icon {
    width: 34px;
    height: 34px;
    font-size: 18px;
  }

  .tv-pill:not(.live-count-badge) {
    display: none;
  }

  .category-bar-wrapper {
    padding: 8px 16px;
  }

  .category-chip {
    padding: 8px 16px;
    font-size: 13px;
  }

  .tv-main {
    padding: 8px 16px 36px 16px;
    overflow-y: visible;
  }

  .match-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .match-card {
    min-height: auto;
    padding: 14px;
  }

  .team-logo {
    width: 38px;
    height: 38px;
  }

  .team-name {
    font-size: 13px;
  }

  .player-controls-overlay {
    padding: 14px 16px;
  }

  .player-match-title {
    font-size: 15px;
  }

  .player-instruction-hint {
    display: none;
  }
}

@media (min-width: 901px) and (max-width: 1350px) {
  .match-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
