/* ===========================================
   VARIABLES Y BASE (igual que antes)
=========================================== */
:root {
  --color-primary: #BB0015;
  --color-primary-dark: rgba(156, 0, 19, 0.67);
  --color-bg: #000000;
  --color-text: #ffffff;
  --color-accent: #777;
  --border-radius: 1.2rem;
  --box-shadow-inset: 0px -3px 9px 5px var(--color-primary-dark) inset;
  --transition: all 0.2s ease;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

@font-face {
  font-family: "Roboto Condensed";
  src: url('../fonts/RobotoCondensed-VariableFont_wght.ttf') format('truetype');
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: "Roboto Condensed", sans-serif;
  font-optical-sizing: auto;
  font-weight: 400;
  font-style: normal;
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  padding: 0.5rem 0.2rem 0 0.2rem;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===========================================
   LAYOUT BASE - MÓVIL FIRST
=========================================== */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

/* Resto de estilos base (header, player-box, etc.) igual que antes */
header {
  text-align: center;
  margin-bottom: 1.5rem;
  position: relative;
  flex-shrink: 0;
  z-index: 10;
}

.header-logo {
  display: flex;
  justify-content: center;
  align-items: center;
}

header img {
  width: 50%;
  filter: drop-shadow(0px 0px 20px var(--color-primary));
}

.player-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  flex-shrink: 0;
}

.player-box iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: none;
  border-radius: var(--border-radius) var(--border-radius) 0 0;
  max-width: 100%;
  height: auto;
}

.player-info {
  display: flex;
  flex-direction: row;
  background-color: var(--color-primary);
  padding: 0.5rem;
  border-radius: 0 0 var(--border-radius) var(--border-radius);
  width: 100%;
  box-shadow: var(--box-shadow-inset);
}

.match-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin: 0 0 0 1rem;
}

.player-info p {
  margin: 0.2rem 0;
}

#match-info-tournament-hour {
  font-size: 0.8rem;
  display: flex;
  flex-direction: row;
  gap: 0.5rem;
}

#match-info-teams {
  font-size: 1.2rem;
}

#match-info-img {
  max-width: 30px;
  margin: 1rem;
}

#match-info-img-button {
  border: 0;
  background: transparent;
  cursor: pointer;
  transition: var(--transition);
}

#match-info-img-button:active {
  transform: scale(0.98);
}

.gamelist {
  flex: 1;
  overflow-y: auto;
  padding-right: 0.5rem;
  min-height: 0;
}

.gamelist h2 {
  font-size: 1.2rem;
  position: sticky;
  top: 0;
  background-color: var(--color-bg);
  z-index: 1;
  padding: 0.8rem;
}

.match {
  display: flex;
  flex-direction: row;
  background-color: var(--color-primary);
  padding: 0.5rem;
  margin-bottom: 0.5rem;
  border-radius: var(--border-radius);
  width: 100%;
  box-shadow: var(--box-shadow-inset);
  transition: var(--transition);
}

.match.active {
  color: var(--color-primary);
  background-color: var(--color-text);
  box-shadow: 0px -3px 9px 5px rgba(190, 190, 190, 0.67) inset;
}

.match-a {
  display: flex;
  text-decoration: none;
  color: inherit;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

.ad {
  background-color: yellow;
  padding: 1rem;
  text-align: center;
  margin-bottom: 1rem;
  flex-shrink: 0;
}

footer {
  background-color: var(--color-primary);
  text-align: center;
  font-size: 0.9rem;
  color: var(--color-accent);
  display: none;
}

#loader {
  width: 100%;
  height: 80%;
  background: transparent;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 5px solid var(--color-text);
  border-top: 5px solid var(--color-primary);
  border-radius: 50%;
  animation: girar 1s linear infinite;
  box-shadow: var(--box-shadow-inset);
}

@keyframes girar {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ===========================================
   LAYOUTS ESPECÍFICOS POR CLASE
=========================================== */

/* Layout Desktop - Pantallas anchas */
.layout-desktop main {
  display: grid !important;
  grid-template-columns: 60% 40% !important;
  grid-template-rows: repeat(2, 1fr) !important;
  gap: 0.5rem !important;
}

.layout-desktop .player-box {
  justify-content: flex-start;
}

.layout-desktop .player-box iframe {
  aspect-ratio: 21 / 9 !important;
}

.layout-desktop .ad {
  grid-column: span 2;
  margin: 0;
  max-height: 120px;
  min-height: 120px;
}

.layout-desktop .logo-img {
  max-width: 20%;
}

/* Layout Móvil - Siempre flexbox vertical */
.layout-mobile main,
.webview-android main {
  display: flex !important;
  flex-direction: column !important;
  grid-template-columns: none !important;
  grid-template-rows: none !important;
}

.layout-mobile .player-box iframe,
.webview-android .player-box iframe {
  aspect-ratio: 16/9 !important;
}

.layout-mobile .ad {
  max-height: 10vh;
}

/* Layout Tablet */
.layout-tablet main {
  display: flex !important;
  flex-direction: column !important;
}

.layout-tablet footer {
  display: block;
  align-content: center;
  font-size: 1rem;
  min-height: 50px;
}

/* Estilos específicos para WebView Android */
.webview-android {
  /* Forzar recálculo de layout */
  transform: translateZ(0);
}

.webview-android main {
  /* Asegurar que el flexbox funcione */
  min-height: 0;
  height: 100%;
}