:root {
  color-scheme: dark;
  --ink: #06172a;
  --line: rgba(255, 255, 255, 0.16);
  --paper: rgba(255, 255, 255, 0.92);
  --blue: #075ca9;
  --sky: #63c2ff;
  --red: #d90f1a;
  --white: #fff;
}

* {
  box-sizing: border-box;
}

body {
  background:
    linear-gradient(180deg, rgba(5, 25, 46, 0.78), rgba(5, 18, 35, 0.97)),
    radial-gradient(circle at 50% 25%, rgba(28, 141, 220, 0.24), transparent 42%),
    url("/FONDO.webp") center / cover fixed;
  color: var(--white);
  font-family: "Trebuchet MS", "Avenir Next", "Segoe UI", sans-serif;
  margin: 0;
  min-height: 100vh;
}

body.cinema-open {
  overflow: hidden;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.tv-page {
  display: grid;
  gap: 18px;
  margin: 0 auto;
  max-width: 1280px;
  min-height: 100vh;
  padding:
    max(18px, env(safe-area-inset-top))
    max(18px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
}

.tv-header {
  align-items: center;
  display: flex;
  gap: 18px;
  justify-content: space-between;
}

.brand {
  align-items: center;
  color: var(--white);
  display: flex;
  gap: clamp(10px, 1.4vw, 18px);
  min-width: 0;
  text-decoration: none;
}

.brand img {
  background: var(--paper);
  border-radius: 6px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
  display: block;
  height: clamp(54px, 9vw, 110px);
  max-width: min(70vw, 620px);
  object-fit: contain;
  padding: clamp(7px, 1vw, 12px);
}

.brand span {
  background: var(--red);
  border-radius: 6px;
  display: grid;
  font-size: clamp(26px, 4.4vw, 62px);
  font-weight: 800;
  height: clamp(54px, 9vw, 110px);
  letter-spacing: 0;
  line-height: 1;
  place-items: center;
  width: clamp(64px, 11vw, 126px);
}

.signal {
  align-items: center;
  background: rgba(6, 23, 42, 0.82);
  border: 1px solid var(--line);
  border-radius: 6px;
  display: flex;
  flex: 0 0 auto;
  gap: 10px;
  min-height: 48px;
  padding: 0 15px;
  text-transform: uppercase;
}

.signal span {
  background: #f9bd2e;
  border-radius: 50%;
  box-shadow: 0 0 18px currentColor;
  color: #f9bd2e;
  height: 12px;
  width: 12px;
}

.signal strong {
  font-size: 14px;
  letter-spacing: 0;
}

.signal[data-mode="live"] span {
  animation: pulse 1.35s ease infinite;
  background: #ff2530;
  color: #ff2530;
}

.signal[data-mode="programming"] span {
  background: #16c784;
  color: #16c784;
}

.signal[data-mode="offline"] span {
  background: #8ca0b6;
  color: #8ca0b6;
}

.stage {
  align-self: center;
  position: relative;
}

.ticker {
  align-items: center;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  min-height: 54px;
  overflow: hidden;
}

.ticker strong {
  align-items: center;
  align-self: stretch;
  background: var(--red);
  display: flex;
  font-size: 14px;
  letter-spacing: 0;
  padding: 0 18px;
  text-transform: uppercase;
  white-space: nowrap;
  z-index: 1;
}

.ticker-window {
  min-width: 0;
  overflow: hidden;
}

.ticker-track {
  align-items: center;
  display: inline-flex;
  gap: 42px;
  min-width: max-content;
  padding-left: 28px;
  white-space: nowrap;
  animation: ticker 58s linear infinite;
}

.ticker-track a,
.ticker-track span {
  color: var(--white);
  font-size: 16px;
  line-height: 1;
  text-decoration: none;
}

.ticker-track a::after {
  color: var(--red);
  content: " |";
  font-weight: 700;
  padding-left: 42px;
}

.player-shell {
  aspect-ratio: 16 / 9;
  background:
    linear-gradient(120deg, rgba(5, 18, 35, 0.76), rgba(0, 0, 0, 0.92)),
    url("/FONDO.webp") center / cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.42);
  overflow: hidden;
  position: relative;
}

.player-shell.cinema-fullscreen {
  aspect-ratio: auto;
  border-radius: 0;
  height: 100vh;
  inset: 0;
  position: fixed;
  width: 100vw;
  z-index: 20;
}

#stream {
  background: #000;
  display: block;
  height: 100%;
  object-fit: contain;
  width: 100%;
}

.player-glass {
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.18), transparent 24%, transparent 68%, rgba(0, 0, 0, 0.68));
  inset: 0;
  pointer-events: none;
  position: absolute;
}

.playback-card {
  align-content: center;
  background:
    linear-gradient(135deg, rgba(6, 23, 42, 0.92), rgba(1, 7, 15, 0.8));
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  color: var(--white);
  cursor: pointer;
  display: grid;
  gap: 10px;
  left: clamp(16px, 3vw, 38px);
  justify-items: start;
  min-height: min(250px, calc(100% - 32px));
  max-width: min(430px, calc(100% - 32px));
  padding: clamp(16px, 2.7vw, 32px);
  position: absolute;
  text-align: left;
  top: clamp(16px, 3vw, 38px);
  transition: opacity 180ms ease, visibility 180ms ease;
  width: min(430px, calc(100% - 32px));
  z-index: 2;
}

.playback-card img {
  background: rgba(255, 255, 255, 0.94);
  border-radius: 6px;
  display: block;
  height: clamp(44px, 6vw, 70px);
  max-width: 100%;
  object-fit: contain;
  padding: 7px;
}

.playback-card strong {
  font-size: clamp(20px, 2.6vw, 38px);
  line-height: 1.05;
}

.playback-card span {
  color: rgba(255, 255, 255, 0.82);
  font-size: clamp(14px, 1.3vw, 17px);
  line-height: 1.35;
}

.player-shell[data-playback="playing"] .playback-card {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.player-shell[data-playback="blocked"] .playback-card::after,
.player-shell[data-playback="error"] .playback-card::after {
  background: var(--red);
  border-radius: 6px;
  content: "Reproducir";
  display: inline-flex;
  font-size: 15px;
  font-weight: 700;
  min-height: 42px;
  padding: 12px 15px;
  text-transform: uppercase;
}

.player-controls {
  bottom: clamp(12px, 2vw, 20px);
  display: flex;
  gap: 10px;
  position: absolute;
  right: clamp(12px, 2vw, 20px);
  z-index: 3;
}

.player-controls button,
#close-ad {
  align-items: center;
  background: rgba(5, 18, 35, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 6px;
  color: var(--white);
  cursor: pointer;
  display: inline-flex;
  height: 48px;
  justify-content: center;
  width: 48px;
}

.player-controls button:focus-visible,
.playback-card:focus-visible,
.socials a:focus-visible {
  outline: 3px solid var(--sky);
  outline-offset: 2px;
}

.player-controls svg {
  fill: none;
  height: 25px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 25px;
}

.socials {
  align-content: start;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding-bottom: 10px;
}

.socials a {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--white);
  min-height: 43px;
  padding: 12px 15px;
  text-decoration: none;
}

.socials a:first-child {
  background: var(--white);
  color: var(--ink);
}

.ad {
  background: rgba(0, 0, 0, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  bottom: clamp(14px, 2vw, 26px);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  max-height: calc(100% - 28px);
  max-width: min(calc(100% - 28px), 560px);
  overflow: hidden;
  position: absolute;
  right: clamp(14px, 2vw, 26px);
  width: min(calc(100% - 28px), 42%);
  z-index: 5;
}

.ad[hidden] {
  display: none;
}

#ad-media a,
#ad-media div,
#ad-media img,
#ad-media video {
  display: block;
}

#ad-media,
#ad-media a,
#ad-media div {
  max-height: inherit;
  width: 100%;
}

#ad-media img,
#ad-media video {
  height: auto;
  max-height: min(68vh, calc(100vh - 130px));
  object-fit: contain;
  width: 100%;
}

#close-ad {
  font-size: 18px;
  font-weight: 700;
  height: 40px;
  position: absolute;
  right: 10px;
  top: 10px;
  width: 40px;
  z-index: 1;
}

.tv-footer {
  align-items: center;
  color: rgba(255, 255, 255, 0.76);
  display: flex;
  flex-wrap: wrap;
  font-size: 13px;
  gap: 8px 14px;
  justify-content: center;
  line-height: 1.35;
  padding: 4px 0 10px;
  text-align: center;
}

.tv-footer a {
  color: var(--white);
  text-decoration: none;
}

.tv-footer a:hover {
  text-decoration: underline;
}

@keyframes pulse {
  50% {
    box-shadow: 0 0 0 8px rgba(255, 37, 48, 0.18);
  }
}

@keyframes ticker {
  to {
    transform: translateX(-100%);
  }
}

@media (max-width: 760px) {
  body {
    background-attachment: scroll;
  }

  .tv-page {
    align-content: start;
    gap: 16px;
    padding:
      max(14px, env(safe-area-inset-top))
      max(14px, env(safe-area-inset-right))
      max(18px, env(safe-area-inset-bottom))
      max(14px, env(safe-area-inset-left));
  }

  .tv-header {
    align-items: stretch;
    flex-direction: column;
  }

  .brand {
    align-items: stretch;
    width: 100%;
  }

  .brand img {
    flex: 1 1 auto;
    height: 64px;
    max-width: calc(100vw - 108px);
  }

  .brand span {
    flex: 0 0 78px;
    font-size: 33px;
    height: 64px;
    width: 78px;
  }

  .signal {
    align-self: flex-start;
  }

  .ticker-track a,
  .ticker-track span {
    font-size: 15px;
  }

  .player-shell {
    aspect-ratio: 16 / 9;
    min-height: 210px;
  }

  .playback-card {
    gap: 7px;
    left: 12px;
    min-height: 0;
    max-width: calc(100% - 24px);
    padding: 13px;
    top: 12px;
    width: calc(100% - 24px);
  }

  .playback-card img {
    height: 39px;
    padding: 5px;
  }

  .playback-card strong {
    font-size: 20px;
  }

  .playback-card span {
    font-size: 13px;
  }

  .player-controls button {
    height: 44px;
    width: 44px;
  }

  .socials a {
    flex: 1 1 calc(50% - 5px);
    text-align: center;
  }

  .ticker {
    grid-template-columns: 1fr;
  }

  .ticker strong {
    min-height: 38px;
  }

  .ticker-track {
    animation-duration: 72s;
    min-height: 46px;
  }

  .ad {
    bottom: 12px;
    max-height: min(72vh, calc(100% - 24px));
    max-width: calc(100% - 24px);
    right: 12px;
    width: calc(100% - 24px);
  }

  #ad-media img,
  #ad-media video {
    max-height: min(64vh, calc(100vh - 150px));
  }
}

@media (max-width: 460px) {
  .player-controls {
    bottom: 10px;
    gap: 8px;
    right: 10px;
  }

  .player-controls button {
    height: 42px;
    width: 42px;
  }
}
