/* ===== Tema oscuro, simple y accesible ===== */
:root {
  --bg: #0b0d12;
  --surface: #141821;
  --surface-2: #1c2230;
  --text: #eef1f6;
  --muted: #a3acbd;
  --accent: #ff5a36;
  --accent-text: #0b0d12;
  --focus: #ffd166;
  --radius: 12px;
  --subs-size: 1.35rem;
  --subs-bg: rgba(0, 0, 0, 0.85);
  --subs-color: #ffffff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari",
    "Noto Sans Bengali", "Noto Sans Thai", "Noto Sans Arabic", "Noto Sans CJK SC", "PingFang SC",
    "Hiragino Sans", "Malgun Gothic", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { min-height: 100vh; display: flex; flex-direction: column; line-height: 1.5; }
a { color: var(--focus); }
button, select, input { font: inherit; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--focus); color: #000; padding: .5rem 1rem;
}
.skip-link:focus { left: 1rem; top: 1rem; }

/* ===== Cabecera ===== */
.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .75rem 1.25rem; background: var(--surface); border-bottom: 1px solid #222a38;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.1rem; }
.live-dot {
  width: .7rem; height: .7rem; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 0 rgba(255, 90, 54, .6); animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 90, 54, .6); }
  70% { box-shadow: 0 0 0 10px rgba(255, 90, 54, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 90, 54, 0); }
}

/* ===== Anuncios ===== */
.ad { display: flex; flex-direction: column; align-items: center; gap: .25rem; }
.ad-label { font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.ad-frame {
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); outline: 1px dashed #2c3547; outline-offset: -1px; border-radius: 8px; overflow: hidden;
}
.ad-frame iframe { border: 0; display: block; }
.ad-placeholder { color: var(--muted); font-size: .8rem; padding: .5rem; text-align: center; }
.ad-header .ad-frame { width: 728px; height: 90px; max-width: 100%; }
.ad-aside .ad-frame { width: 300px; height: 600px; }
.ad-welcome .ad-frame { width: 300px; height: 250px; max-width: 100%; }
.ad-native { margin-top: 1rem; align-items: stretch; }
.ad-native .ad-label { align-self: center; }
.ad-native .ad-frame { width: 100%; height: 320px; }
@media (max-width: 760px) { .ad-native .ad-frame { height: 640px; } }

/* ===== Layout ===== */
.layout {
  flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1.25rem;
  padding: 1.25rem; max-width: 1400px; width: 100%; margin: 0 auto;
}
main { min-width: 0; }
.ad-aside { position: sticky; top: 1rem; align-self: start; }

.player-wrap {
  position: relative; width: 100%; aspect-ratio: 16 / 9;
  background: #000; border-radius: var(--radius); overflow: hidden;
}
.player, .player-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
/* ===== Video + chat ===== */
.stage { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
@media (min-width: 1200px) {
  .stage { grid-template-columns: minmax(0, 1fr) 340px; align-items: stretch; }
  /* El chat toma exactamente la altura del video */
  .chat { height: 0; min-height: 100%; max-height: none; }
  .stage.no-chat { grid-template-columns: minmax(0, 1fr); }
}

.chat {
  display: flex; flex-direction: column; background: var(--surface); border-radius: var(--radius);
  border: 1px solid #222a38; min-height: 380px; max-height: 520px; overflow: hidden;
}
.chat-head { display: flex; align-items: center; justify-content: space-between; padding: .7rem 1rem; border-bottom: 1px solid #222a38; }
.chat-head h2 { margin: 0; font-size: 1rem; }
.chat-status { color: var(--muted); font-size: .8rem; }
.chat-list { list-style: none; margin: 0; padding: .5rem .75rem; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: .35rem; }
.chat-list li { display: flex; gap: .4rem; align-items: flex-start; line-height: 1.35; word-break: break-word; }
.chat-list .nick { font-weight: 700; flex-shrink: 0; }
.chat-list .text { flex: 1; color: var(--text); }
.chat-list .report {
  background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0 .25rem; min-width: 32px; min-height: 32px;
  opacity: .55; font-size: .9rem;
}
.chat-list .report:hover, .chat-list .report:focus-visible { opacity: 1; }
.chat-list .system { color: var(--muted); font-style: italic; }
.chat-rules { margin: 0; padding: .4rem 1rem; color: var(--muted); font-size: .75rem; border-top: 1px solid #222a38; }
.chat-form { display: flex; flex-direction: column; gap: .5rem; padding: .5rem .75rem .75rem; }
.chat-row { display: flex; gap: .5rem; }
.chat-form input {
  flex: 1; min-width: 0; background: var(--surface-2); color: var(--text); border: 1px solid #2c3547;
  border-radius: 8px; padding: .55rem .7rem; min-height: 44px;
}
.chat-form.has-nick #chat-nick { display: none; }
.chat-msg { margin: 0; padding: 0 1rem .6rem; font-size: .85rem; color: var(--focus); min-height: 1.2em; }

.player-empty {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  color: var(--muted); padding: 1rem;
}

.disclaimer { color: var(--muted); font-size: .85rem; margin-top: 1rem; }

/* ===== Footer ===== */
.site-footer {
  display: flex; gap: 1.5rem; justify-content: center; padding: 1rem;
  border-top: 1px solid #222a38; font-size: .9rem;
}
.link-btn { background: none; border: 0; color: var(--focus); text-decoration: underline; cursor: pointer; padding: 0; }

/* ===== Botones ===== */
.btn {
  border-radius: 10px; padding: .7rem 1.2rem; min-height: 44px; cursor: pointer;
  background: var(--surface-2); color: var(--text); border: 1px solid #2c3547; font-weight: 600;
}
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: center; }

/* ===== Ventanas (bienvenida, idioma) ===== */
.overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: rgba(5, 6, 9, .92); padding: 1rem; overflow-y: auto;
}
.overlay[hidden] { display: none; }
.welcome-card, .dialog-card {
  width: min(560px, 100%); background: var(--surface); border-radius: 16px; padding: 1.5rem;
  text-align: center; display: flex; flex-direction: column; gap: .9rem; align-items: center;
  border: 1px solid #222a38;
}
.welcome-card h1 { margin: 0; font-size: 1.5rem; }
.welcome-card p, .dialog-card p { margin: 0; color: var(--muted); }
.dialog-card p { color: var(--text); font-size: 1.15rem; }
.intro-media {
  position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden;
  background: #000;
}
.intro-media video { width: 100%; height: 100%; object-fit: cover; display: block; }
.intro-fallback {
  position: absolute; inset: 0; display: none;
  background: radial-gradient(circle at 30% 30%, #ff5a36 0, transparent 45%),
              radial-gradient(circle at 70% 70%, #3a6df0 0, transparent 50%), #0b0d12;
}
.intro-media.no-video video { display: none; }
.intro-media.no-video .intro-fallback { display: block; }

/* ===== Cookies ===== */
.cookie-banner {
  position: fixed; left: 1rem; right: 1rem; bottom: 1rem; z-index: 60;
  max-width: 760px; margin: 0 auto; background: var(--surface-2); border: 1px solid #2c3547;
  border-radius: 14px; padding: 1rem 1.25rem; box-shadow: 0 10px 40px rgba(0, 0, 0, .5);
}
.cookie-banner p { margin: 0 0 .75rem; }

/* ===== Página de privacidad ===== */
.page { max-width: 820px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }
.page h2 { margin-top: 1.75rem; }

/* ===== Escritura de derecha a izquierda (árabe) ===== */
[dir="rtl"] .controls, [dir="rtl"] .site-header { direction: rtl; }

/* ===== Responsive ===== */
@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; }
  .ad-aside { position: static; }
  .ad-aside .ad-frame { width: 300px; height: 250px; }
}
@media (max-width: 760px) {
  .ad-header .ad-frame { width: 320px; height: 50px; }
  .site-header { justify-content: center; }
  .layout { padding: .75rem; }
}

@media (prefers-reduced-motion: reduce) {
  .live-dot { animation: none; }
  * { scroll-behavior: auto !important; }
}

/* ===== Panel de moderación ===== */
.admin-table { width: 100%; border-collapse: collapse; margin-top: 1rem; font-size: .9rem; }
.admin-table th, .admin-table td { border-bottom: 1px solid #222a38; padding: .5rem; text-align: left; vertical-align: top; }
.admin-table td:nth-child(4) { word-break: break-word; max-width: 420px; }
.admin-table .btn { padding: .3rem .6rem; min-height: 32px; margin: 0 .25rem .25rem 0; font-size: .8rem; }
.admin-table tr.is-hidden td { opacity: .5; }
.page { max-width: 1100px; }
