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

:root {
  --color-bg: #0b0b0e;
  --color-surface: #121217;
  --color-surface-raised: #19191f;
  --color-surface-hover: #202028;
  --color-border: #28283a;
  --color-border-subtle: #1c1c26;
  --color-text: #ecedf0;
  --color-text-secondary: #8888a0;
  --color-text-muted: #50505e;
  --color-accent: #8b6cdb;
  --color-accent-alpha: #8b6cdb2e;
  --color-live: #e53935;
  --color-success: #4caf82;
  --color-error: #e55353;
  --color-info: #4a9ede;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-pill: 999px;
  --shadow-md: 0 4px 14px #0000008c;
  --shadow-toast: 0 8px 28px #000000b8;
  --t-fast: 0.11s cubic-bezier(0.2, 0, 0, 1);
  --t-base: 0.19s cubic-bezier(0.2, 0, 0, 1);
  --chat-width: 340px;
  --toolbar-h: 44px;
}

html,
body {
  width: 100%;
  height: 100%;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}
a {
  color: inherit;
  text-decoration: none;
}
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: 3px;
}
::selection {
  background: var(--color-accent-alpha);
}
[hidden] {
  display: none !important;
}
svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  flex-shrink: 0;
}

/* ---------------- Layout ---------------- */
.layout {
  display: grid;
  width: 100vw;
  height: 100dvh;
  grid-template:
    'player chat' 1fr
    'toolbar toolbar' var(--toolbar-h)
    / 1fr var(--chat-width);
  overflow: hidden;
}
.layout[data-chat='closed'] {
  grid-template:
    'player' 1fr
    'toolbar' var(--toolbar-h)
    / 1fr;
}
.layout[data-chat='closed'] .chat-area {
  display: none;
}
.player-area {
  grid-area: player;
  position: relative;
  background: #000;
  min-height: 0;
  min-width: 0;
}
.chat-area {
  grid-area: chat;
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border-left: 1px solid var(--color-border-subtle);
  min-height: 0;
}
.toolbar {
  grid-area: toolbar;
  display: grid;
  /* columnas laterales iguales => los botones quedan centrados de verdad */
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border-subtle);
  min-width: 0;
}

/* Móvil en vertical: reproductor arriba, barra y chat debajo */
@media (max-width: 768px) and (orientation: portrait) {
  .layout {
    grid-template:
      'player' auto
      'toolbar' var(--toolbar-h)
      'chat' 1fr
      / 1fr;
  }
  .player-area {
    aspect-ratio: 16 / 9;
    width: 100%;
  }
  /* Chat oculto: el reproductor (o la vista offline) ocupa todo y la barra queda abajo */
  .layout[data-chat='closed'] {
    grid-template:
      'player' minmax(0, 1fr)
      'toolbar' var(--toolbar-h)
      / 1fr;
  }
  .layout[data-chat='closed'] .player-area {
    aspect-ratio: auto;
  }
  .layout[data-chat='closed'] .toolbar {
    border-top: 1px solid var(--color-border-subtle);
    border-bottom: none;
  }
  .chat-area {
    border-left: none;
    border-top: 1px solid var(--color-border-subtle);
  }
  .toolbar {
    border-top: none;
    border-bottom: 1px solid var(--color-border-subtle);
  }
}
/* Móvil en horizontal: chat siempre a un lado del reproductor (nunca debajo, fuera de la pantalla) */
@media (max-width: 768px) and (orientation: landscape) {
  .layout {
    --chat-width: min(300px, 42vw);
  }
}
@media (max-width: 768px) {
  .toolbar {
    padding: 0 8px;
    gap: 8px;
  }
  .toolbar {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  }
  .toolbar .tb-start {
    min-width: 0;
  }
  .toolbar .tb-center {
    max-width: calc(100vw - 110px);
  }
  .tb-center .btn.icon-only-mobile .label,
  .vod-btn .label,
  .seg button span,
  .q-label,
  #pipBtn,
  .viewers svg,
  .live-timer svg {
    display: none;
  }
  .toolbar .tb-center .btn {
    padding: 0 10px;
  }
  .toolbar .seg button {
    padding: 0 9px;
  }
  .seg button[data-value='off']::after {
    content: '✕';
    font-size: 11px;
  }
  .ctrl {
    min-width: 32px;
    padding: 0 5px;
  }
  .live-badge {
    margin-left: 2px;
  }
}

/* ---------------- Player ---------------- */
.player {
  position: absolute;
  inset: 0;
  background: #000;
  overflow: hidden;
  outline: none;
}
.player video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #000;
}
.player-spinner {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  pointer-events: none;
}
.player[data-state='loading'] .player-spinner,
.player[data-buffering] .player-spinner {
  display: grid;
}
.spinner {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 4px solid #ffffff33;
  border-top-color: #fff;
  animation: spin 0.9s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.player-bigplay {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: #000000a6;
  display: none;
  place-items: center;
  transition: transform var(--t-base), background var(--t-base);
}
.player-bigplay svg {
  width: 40px;
  height: 40px;
}
.player-bigplay:hover {
  background: var(--color-accent);
  transform: translate(-50%, -50%) scale(1.06);
}
.player[data-state='paused'] .player-bigplay {
  display: grid;
}
.player-unmute {
  position: absolute;
  top: 14px;
  left: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  background: #000000b3;
  border: 1px solid #ffffff22;
  font-weight: 600;
  backdrop-filter: blur(6px);
  transition: background var(--t-base);
  z-index: 3;
}
.player-unmute:hover {
  background: var(--color-accent);
}

.player-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 28px 10px 8px;
  background: linear-gradient(transparent, #000000d9);
  opacity: 1;
  transition: opacity var(--t-base);
  z-index: 2;
}
.player[data-idle] .player-controls {
  opacity: 0;
  pointer-events: none;
}
.player[data-idle] {
  cursor: none;
}
.ctrl-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.spacer {
  flex: 1;
}
.ctrl {
  height: 36px;
  min-width: 36px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: var(--radius-sm);
  transition: background var(--t-fast);
}
.ctrl:hover {
  background: #ffffff1f;
}
.ctrl svg {
  width: 22px;
  height: 22px;
}
.ctrl-text {
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.04em;
  border: 1px solid #ffffff40;
  height: 26px;
  min-width: 34px;
  padding: 0 6px;
  margin: 0 4px;
  color: #ffffffb3;
}
.ctrl-text[aria-pressed='true'] {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
}
.q-label {
  font-size: 12px;
  font-weight: 600;
}
.player .i-pause,
.player[data-state='playing'] .i-play {
  display: none;
}
.player[data-state='playing'] .i-pause {
  display: block;
}
.player .i-muted,
.player[data-muted] .i-vol {
  display: none;
}
.player[data-muted] .i-muted {
  display: block;
}
.volume {
  display: flex;
  align-items: center;
}
.volume input {
  width: 0;
  opacity: 0;
  transition: width var(--t-base), opacity var(--t-base);
  accent-color: var(--color-accent);
  cursor: pointer;
}
/* El deslizador de volumen solo se despliega en pantallas grandes o en horizontal;
   en teléfonos en vertical no, para no mover el botón EN VIVO (el volumen está en ⚙) */
@media (min-width: 769px), (orientation: landscape) and (min-height: 300px) {
  .volume:hover input,
  .volume input:focus-visible {
    width: 80px;
    opacity: 1;
    margin: 0 6px;
  }
}
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 9px;
  margin-left: 6px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  background: #ffffff26;
  color: #ffffffcc;
}
.live-badge .dot,
.offline-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ffffff80;
}
.player[data-at-live] .live-badge {
  background: var(--color-live);
  color: #fff;
}
.player[data-at-live] .live-badge .dot {
  background: #fff;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}
.live-timer {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #ffffffd9;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.live-timer svg {
  width: 15px;
  height: 15px;
  opacity: 0.85;
}
.viewers {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #ffffffd9;
}
.viewers svg {
  width: 16px;
  height: 16px;
  fill: var(--color-live);
}

.menu-wrap {
  position: relative;
}
.menu {
  position: absolute;
  bottom: 44px;
  right: 0;
  min-width: 170px;
  padding: 6px;
  border-radius: var(--radius-md);
  background: #15151bf2;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(8px);
}
.menu-title {
  padding: 4px 10px 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-secondary);
}
.menu button {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  text-align: left;
  font-size: 13px;
}
.menu button:hover {
  background: var(--color-surface-hover);
}
.menu button[aria-checked='true'] {
  color: var(--color-accent);
  font-weight: 700;
}
.menu button small {
  color: var(--color-text-secondary);
  font-weight: 400;
}

/* ---------------- Offline ---------------- */
.offline {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at center, #1a1626 0%, var(--color-bg) 70%);
}
.offline-embed {
  position: absolute;
  inset: 0;
}
.offline-embed iframe {
  width: 100%;
  height: 100%;
  border: 0;
}
.offline-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  padding: 24px;
}
.offline[data-has-embed] .offline-card {
  display: none;
}
.offline-logo {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--color-accent);
}
.offline-name {
  font-size: 26px;
  font-weight: 800;
}
.offline-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 14px;
  border-radius: var(--radius-pill);
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  font-weight: 600;
  font-size: 13px;
}
.offline-msg {
  max-width: 420px;
  color: var(--color-text-secondary);
}

/* ---------------- Miniplayers de plataforma ---------------- */
.layout[data-panels] {
  --chat-width: 400px;
}
@media (max-width: 768px) and (orientation: landscape) {
  .layout[data-panels] {
    --chat-width: min(320px, 45vw);
  }
}
.layout[data-chat='closed'] .chat-head,
.layout[data-chat='closed'] #chatFrame,
.layout[data-chat='closed'] .chat-empty {
  display: none;
}
/* Chat oculto con miniplayers: el reproductor ocupa todo el ancho, pero los miniplayers
   siguen cargados fuera de la vista (sin recargarse) para no dejar de contar. */
.layout[data-panels][data-chat='closed'] .chat-area {
  display: flex;
  position: fixed;
  left: 0;
  top: 0;
  width: 400px;
  height: 560px;
  clip-path: inset(100%);
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}

/* Franja para mostrar/ocultar los miniplayers (no tapa nunca el iframe del chat) */
.panels-toggle {
  display: none;
  flex-shrink: 0;
  height: 26px;
  padding: 0 10px;
  align-items: center;
  gap: 6px;
  width: 100%;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--color-text-secondary);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border-subtle);
  transition: color var(--t-fast), background var(--t-fast);
}
.layout[data-panels] .panels-toggle {
  display: flex;
}
/* Celulares en horizontal: sin botón (los miniplayers quedan ocultos, solo tablets/escritorio lo ven) */
@media (pointer: coarse) and (max-height: 600px) {
  .layout[data-panels] .panels-toggle {
    display: none;
  }
}
.panels-toggle:hover {
  color: var(--color-text);
  background: var(--color-surface-hover);
}
.panels-toggle svg {
  width: 15px;
  height: 15px;
}
.panels-toggle .pt-label {
  flex: 1;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.panels-toggle .chev {
  width: 6px;
  height: 6px;
  transform: rotate(-135deg);
  margin-top: 3px;
}
.layout[data-panels-collapsed] .panels-toggle .chev {
  transform: rotate(45deg);
  margin-top: -3px;
}
.panels-toggle .i-show,
.layout[data-panels-collapsed] .panels-toggle .i-hide {
  display: none;
}
.layout[data-panels-collapsed] .panels-toggle .i-show {
  display: block;
}

.platform-panels {
  display: flex;
  flex-direction: column;
  flex-shrink: 1;
  min-height: 0;
  /* El chat siempre conserva al menos la mitad del alto */
  max-height: 55%;
  border-bottom: 1px solid var(--color-border-subtle);
}
/* Miniplayers ocultos por el espectador: fuera de la vista, pero siguen cargados */
.layout[data-panels-collapsed] .platform-panels {
  position: fixed;
  left: 0;
  top: 0;
  width: 400px;
  height: 525px;
  max-height: none;
  clip-path: inset(100%);
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}
.platform-panel {
  position: relative;
  width: 100%;
  flex: 0 1 225px;
  min-height: 0;
  background: #000;
}
.platform-panel[data-platform='twitch'] {
  flex-basis: 300px;
}
.platform-panel iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}
.platform-panel + .platform-panel {
  border-top: 1px solid var(--color-border-subtle);
}
.chat-area #chatFrame,
.chat-area .chat-empty {
  min-height: 0;
}

/* ---------------- Cambiar tamaño del chat ---------------- */
/* El tirador va FUERA del chat (pegado a su borde izquierdo), nunca encima:
   Twitch bloquea el chat a dueño/mods si cualquier elemento tapa su iframe. */
.chat-resizer {
  position: absolute;
  z-index: 5;
  top: 0;
  bottom: 0;
  right: 100%;
  width: 10px;
  cursor: col-resize;
  touch-action: none;
}
.chat-resizer::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 4px;
  height: 36px;
  transform: translate(-50%, -50%);
  border-radius: 99px;
  background: var(--color-border);
  opacity: 0;
  transition: opacity var(--t-base), background var(--t-base);
}
.chat-area:hover .chat-resizer::before,
.chat-resizer:focus-visible::before {
  opacity: 1;
}
.chat-resizer:hover::before,
body.is-resizing .chat-resizer::before {
  opacity: 1;
  background: var(--color-accent);
}
.layout[data-chat='closed'] .chat-resizer {
  display: none;
}
body.is-resizing {
  user-select: none;
}
body.is-resizing.resize-x,
body.is-resizing.resize-x * {
  cursor: col-resize !important;
}
body.is-resizing.resize-y,
body.is-resizing.resize-y * {
  cursor: row-resize !important;
}
/* Los iframes (chat, miniplayers) no deben "robar" el arrastre */
body.is-resizing iframe {
  pointer-events: none;
}
@media (max-width: 768px) and (orientation: portrait) {
  /* En móvil vertical el tirador ocupa su propia franja arriba del chat (no se superpone) */
  .chat-resizer {
    position: relative;
    z-index: auto;
    flex-shrink: 0;
    top: auto;
    bottom: auto;
    right: auto;
    width: auto;
    height: 14px;
    cursor: row-resize;
  }
  .chat-resizer::before {
    top: 6px;
    width: 40px;
    height: 4px;
    opacity: 1;
  }
  .layout[data-chat-h]:not([data-chat='closed']) {
    grid-template:
      'player' minmax(0, 1fr)
      'toolbar' var(--toolbar-h)
      'chat' var(--chat-h)
      / 1fr;
  }
  .layout[data-chat-h]:not([data-chat='closed']) .player-area {
    aspect-ratio: auto;
  }
}

/* ---------------- Chat ---------------- */
.chat-head {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  border-bottom: 1px solid var(--color-border-subtle);
  flex-shrink: 0;
}
.chat-area iframe {
  flex: 1;
  width: 100%;
  border: 0;
  background: var(--color-surface);
}
.chat-empty {
  flex: 1;
  display: grid;
  place-items: center;
  color: var(--color-text-muted);
}

/* ---------------- Toolbar ---------------- */
.tb-start,
.tb-end {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: max-content;
}
.tb-end {
  justify-content: flex-end;
}
.switch-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-secondary);
}
.switch input:checked ~ .switch-label {
  color: var(--color-text);
}
.tb-center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  min-width: 0;
}
.tb-center::-webkit-scrollbar {
  display: none;
}
.btn {
  --brand: var(--color-accent);
  --brand-text: #fff;
  height: 30px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
  background: var(--brand);
  color: var(--brand-text);
  transition: filter var(--t-fast), transform var(--t-fast), box-shadow var(--t-base);
  flex-shrink: 0;
}
.btn svg {
  width: 16px;
  height: 16px;
}
.btn:hover {
  filter: brightness(1.12);
  transform: translateY(-1px);
}
.btn.highlight {
  box-shadow: 0 0 14px -2px var(--brand);
}
.btn .btn-img {
  width: 16px;
  height: 16px;
  object-fit: contain;
}
.vod-btn {
  --brand: var(--color-surface-raised);
  --brand-text: var(--color-text);
  box-shadow: inset 0 0 0 1px var(--color-border);
}
.vod-btn:hover {
  box-shadow: inset 0 0 0 1px var(--color-accent);
}
.btn[data-kind='youtube'] {
  --brand: #e00;
}
.btn[data-kind='kick'] {
  --brand: #53fc18;
  --brand-text: #000;
}
.btn[data-kind='twitch'] {
  --brand: #6441a4;
}
.btn[data-kind='patreon'] {
  --brand: #e6461a;
}
.btn[data-kind='discord'] {
  --brand: #5865f2;
}
.btn[data-kind='x'] {
  --brand: #000;
  box-shadow: inset 0 0 0 1px #ffffff33;
}
.btn[data-kind='instagram'] {
  --brand: #c13584;
}
.btn[data-kind='tiktok'] {
  --brand: #111;
  box-shadow: inset 0 0 0 1px #ffffff33;
}
.btn[data-kind='facebook'] {
  --brand: #1877f2;
}
.btn[data-kind='paypal'] {
  --brand: #003087;
}
.btn[data-kind='link'] {
  --brand: var(--color-surface-raised);
  box-shadow: inset 0 0 0 1px var(--color-border);
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--color-text-secondary);
}
.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.switch .track {
  width: 32px;
  height: 18px;
  border-radius: var(--radius-pill);
  background: var(--color-border);
  position: relative;
  transition: background var(--t-base);
}
.switch .thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: transform var(--t-base);
}
.switch input:checked + .track {
  background: var(--color-accent);
}
.switch input:checked + .track .thumb {
  transform: translateX(14px);
}
.switch input:focus-visible + .track {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
.switch .bell {
  width: 16px;
  height: 16px;
}

.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: var(--radius-pill);
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
}
.seg button {
  height: 24px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background var(--t-fast), color var(--t-fast);
}
.seg button svg {
  width: 14px;
  height: 14px;
}
.seg button:hover {
  color: var(--color-text);
}
.seg button[aria-checked='true'] {
  background: var(--color-accent);
  color: #fff;
}

/* ---------------- Toasts ---------------- */
.toasts {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 50;
  pointer-events: none;
  width: min(92vw, 420px);
}
.toast {
  pointer-events: auto;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-info);
  box-shadow: var(--shadow-toast);
  font-weight: 500;
  animation: toast-in 0.25s ease-out;
}
.toast[data-type='error'] {
  border-left-color: var(--color-error);
}
.toast[data-type='success'] {
  border-left-color: var(--color-success);
}
.toast[data-type='live'] {
  border-left-color: var(--color-live);
}
.toast.out {
  opacity: 0;
  transform: translateY(-6px);
  transition: all 0.3s;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* Pantalla completa */
.player:fullscreen video {
  object-fit: contain;
}

/* ---------------- Controles nuevos del reproductor ---------------- */
.player-top-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #00000080;
  color: #fff;
  z-index: 3;
  transition: opacity var(--t-base), background var(--t-fast), transform 0.4s;
}
.player-top-btn svg {
  width: 24px;
  height: 24px;
}
.player-top-btn:hover {
  background: var(--color-accent);
}
.player-top-btn.spin svg {
  animation: spin 0.6s linear;
}
.player[data-idle] .player-top-btn {
  opacity: 0;
  pointer-events: none;
}
.ctrl-pill {
  height: 28px;
  min-width: 52px;
  padding: 0 10px;
  margin: 0 2px;
  border: 1.5px solid #ffffffcc;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 700;
}
.ctrl-pill:hover {
  background: #ffffff26;
}
.range {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: #ffffff40;
  accent-color: var(--color-accent);
  cursor: pointer;
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: none;
}
.range::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: none;
}

/* Menú de configuración */
.menu.settings {
  min-width: 270px;
  padding: 8px;
}
.mpage[hidden] {
  display: none;
}
.mitem,
.mback {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}
.mitem:hover,
.mback:hover {
  background: var(--color-surface-hover);
}
.mitem svg {
  width: 18px;
  height: 18px;
  opacity: 0.85;
}
.mitem > span:not(.mini-switch) {
  flex: 1;
}
.mitem small {
  color: var(--color-text-secondary);
  font-size: 13px;
}
.mback {
  font-weight: 700;
  border-bottom: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  margin-bottom: 4px;
}
.chev {
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  opacity: 0.7;
  flex-shrink: 0;
}
.chev.back {
  transform: rotate(135deg);
}
.mtoggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.mini-switch {
  flex: 0 0 36px;
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: #3a3a4a;
  position: relative;
  flex-shrink: 0;
  transition: background var(--t-base);
}
.mini-switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: transform var(--t-base);
}
.mtoggle input:checked + .mini-switch {
  background: var(--color-accent);
}
.mtoggle input:checked + .mini-switch::after {
  transform: translateX(16px);
}
.mrow {
  padding: 10px 10px 12px;
  border-radius: var(--radius-sm);
  background: #ffffff0a;
  margin-bottom: 6px;
}
.mrow-head {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-bottom: 10px;
}
.mrow .range {
  width: 100%;
}
.mhint {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 10px;
}
.mobile-only {
  display: none;
}
#speedList button,
#qualityList2 button {
  width: 100%;
}
.menu-backdrop {
  display: none;
}

/* Móvil: los menús salen como hoja inferior, fáciles de tocar */
@media (max-width: 768px), (pointer: coarse) {
  .mobile-only {
    display: block;
  }
}
@media (max-width: 768px) {
  .menu,
  .menu.settings {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: 8px;
    top: auto;
    min-width: 0;
    max-height: 70vh;
    overflow-y: auto;
    z-index: 60;
    padding: 10px;
    border-radius: 14px;
  }
  .menu-backdrop:not([hidden]) {
    display: block;
    position: fixed;
    inset: 0;
    background: #00000080;
    /* debajo de los controles (z-index 2, donde vive el menú) y encima del resto */
    z-index: 1;
  }
  .mitem,
  .mback,
  .menu button {
    padding: 13px 12px;
    font-size: 15px;
  }
  .player-top-btn {
    top: 8px;
    right: 8px;
    width: 38px;
    height: 38px;
  }
}

/* ---------------- Enviar a TV ---------------- */
.player-top-btn.left {
  right: auto;
  left: 12px;
}
.player-top-btn.casting {
  background: var(--color-accent);
}
/* El aviso "Activar sonido" se corre a la derecha del botón de TV */
.player:has(#castBtn:not([hidden])) .player-unmute {
  left: 64px;
}
.cast-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: radial-gradient(ellipse at center, #1a1626 0%, #050507 75%);
  z-index: 1;
  text-align: center;
  padding: 20px;
  font-weight: 600;
}
.cast-overlay svg {
  width: 56px;
  height: 56px;
  color: var(--color-accent);
}
.cast-stop {
  margin-top: 4px;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  font-weight: 600;
}
.cast-stop:hover {
  background: var(--color-accent);
}
@media (max-width: 768px) {
  .player-top-btn.left {
    left: 8px;
  }
  .player:has(#castBtn:not([hidden])) .player-unmute {
    left: 54px;
  }
}
