* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Poppins, sans-serif;
  background: #0b0f19;
  color: #fff;
}

header {
  background: #111827;
  border-bottom: 1px solid #1f2937;
  padding: 12px 5%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header a {
  text-decoration: none;
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
}

main {
  max-width: 1400px;
  margin: auto;
  padding: 30px 20px;
  box-sizing: border-box;
}

/* Lock theater mode to exact viewport height on mobile, 55" TV, and 65"+ TVs */
body.theater-active {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

body.theater-active header {
  flex: 0 0 auto;
}

body.theater-active main {
  flex: 1 1 auto;
  width: 100%;
  max-width: 1600px;
  padding: 12px 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.league-nav-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 20px 0 30px 0;
}

.league-btn {
  background: #111827;
  border: 1px solid #1f2937;
  color: #9ca3af;
  padding: 8px 16px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.league-btn:hover {
  border-color: #374151;
  color: #fff;
}

.league-btn.active {
  background: #3b82f6;
  color: #fff;
  border-color: #3b82f6;
  font-weight: 600;
}

.events-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  align-items: start;
  margin-bottom: 40px;
}

.event-card {
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 16px;
  overflow: hidden;
  transition: transform 0.2s ease, border-color 0.2s ease;
  padding: 20px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.event-card:hover {
  transform: translateY(-2px);
  border-color: #374151;
}

.card-header-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.league-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 13px;
  color: #9ca3af;
}

.league-icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.match-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 14px;
  line-height: 1.4;
}

.match-meta-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid #1f2937;
  padding-top: 12px;
  font-size: 13px;
  color: #9ca3af;
}

.card-live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #ff4a4a;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  background: rgba(255, 74, 74, 0.1);
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 74, 74, 0.2);
}

.card-upcoming-badge {
  display: inline-block;
  color: #3b82f6;
  font-weight: 600;
  font-size: 12px;
  background: rgba(59, 130, 246, 0.1);
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.card-ended-badge {
  display: inline-block;
  color: #9ca3af;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  background: rgba(156, 163, 175, 0.1);
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid rgba(156, 163, 175, 0.2);
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ff4a4a;
  position: relative;
  display: inline-block;
}

.loading-status {
  text-align: center;
  font-size: 16px;
  color: #9ca3af;
  padding: 40px;
  grid-column: 1 / -1;
}

#player-view {
  display: none;
  flex-direction: column;
  width: 100%;
  height: 100%;
  flex: 1 1 auto;
  overflow: hidden;
  margin-top: 0;
}

.top-nav-bar {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 10px;
}

.back-btn {
  background: #1f2937;
  border: 1px solid #374151;
  color: #fff;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.back-btn:hover {
  background: #374151;
}

.server-switcher {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.srv-btn {
  background: #1f2937;
  border: 1px solid #374151;
  color: #9ca3af;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}

.srv-btn.active {
  background: #3b82f6;
  color: #fff;
  border-color: #3b82f6;
}

.player-container {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  max-height: 100%;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #1f2937;
  margin-bottom: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(11, 15, 25, 0.8);
  backdrop-filter: blur(5px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-box {
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 16px;
  padding: 30px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
  transform: scale(0.95);
  transition: transform 0.25s ease;
}

.modal-overlay.active .modal-box {
  transform: scale(1);
}

.modal-icon {
  font-size: 36px;
  margin-bottom: 15px;
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 10px;
  color: #fff;
}

.modal-message {
  font-size: 14px;
  color: #9ca3af;
  margin-bottom: 24px;
  line-height: 1.5;
}

.modal-btn {
  background: #3b82f6;
  border: none;
  color: #fff;
  padding: 10px 24px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}

.modal-btn:hover {
  background: #2563eb;
}

.movie-frame {
  flex: 1;
  border: none;
  width: 100%;
  height: calc(100% + 45px);
  margin-top: -45px;
}

#iframe-holder {
  position: relative;
  width: 100%;
  height: 100%;
  max-height: 100%;
  background: #000;
}

#iframe-holder iframe,
#iframe-holder video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  border: none;
  object-fit: contain;
}

@keyframes tm-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@media (max-width: 600px) {
  body.theater-active main {
    padding: 8px 10px;
  }
  .top-nav-bar {
    margin-bottom: 8px;
    gap: 6px;
  }
  .back-btn,
  .srv-btn {
    padding: 6px 10px;
    font-size: 12px;
  }
}