/* PURA SANGRE — apuestas hípicas */

:root {
  --ps-bg: #0d1117;
  --ps-card: #161b22;
  --ps-border: #30363d;
  --ps-text: #e6edf3;
  --ps-muted: #8b949e;
  --ps-accent: #c9a227;
  --ps-accent-dim: #8f7320;
  --ps-error: #f85149;
  --ps-font: system-ui, "Segoe UI", Roboto, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--ps-font);
  background: var(--ps-bg);
  color: var(--ps-text);
}

html,
body {
  height: 100%;
}

/* Login */
.ps-login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: radial-gradient(ellipse at top, #1a2332 0%, var(--ps-bg) 55%);
}

.ps-login-card {
  width: 100%;
  max-width: 400px;
  padding: 2rem;
  border: 1px solid var(--ps-border);
  border-radius: 12px;
  background: var(--ps-card);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.ps-login-brand {
  text-align: center;
  margin-bottom: 1.75rem;
}

.ps-logo {
  width: 72px;
  height: 72px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--ps-accent), var(--ps-accent-dim));
  color: #111;
  font-weight: 800;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: -0.05em;
}

.ps-login-brand h1 {
  margin: 0;
  font-size: 1.5rem;
  letter-spacing: 0.12em;
  font-weight: 700;
}

.ps-tagline {
  margin: 0.35rem 0 0;
  color: var(--ps-muted);
  font-size: 0.95rem;
}

.ps-error {
  color: var(--ps-error);
  font-size: 0.9rem;
  margin: 0 0 1rem;
}

.ps-login-form label {
  display: block;
  margin-bottom: 1rem;
}

.ps-login-form span {
  display: block;
  font-size: 0.8rem;
  color: var(--ps-muted);
  margin-bottom: 0.35rem;
}

.ps-login-form input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--ps-border);
  border-radius: 8px;
  background: #0d1117;
  color: var(--ps-text);
  font-size: 1rem;
}

.ps-btn-primary {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.75rem 1rem;
  border: none;
  border-radius: 8px;
  background: linear-gradient(180deg, var(--ps-accent), var(--ps-accent-dim));
  color: #111;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
}

.ps-btn-primary:hover {
  filter: brightness(1.05);
}

.ps-login-note {
  margin: 1.25rem 0 0;
  font-size: 0.8rem;
  color: var(--ps-muted);
  text-align: center;
}

/* App */
.ps-app-body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.ps-hidden-iframe {
  position: absolute;
  width: 0;
  height: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.ps-app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--ps-border);
  background: var(--ps-card);
  flex-shrink: 0;
}

.ps-app-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  font-size: 1rem;
}

.ps-app-brand-text {
  color: #ffe9e9;
  -webkit-text-stroke: 0.7px #b90d0d;
  text-shadow:
    0 0 1px #b90d0d,
    0 0 6px rgba(185, 13, 13, 0.65);
}

.ps-logout {
  color: var(--ps-muted);
  text-decoration: none;
  font-size: 0.9rem;
}

.ps-logout:hover {
  color: var(--ps-accent);
}

.ps-support-whatsapp {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.42rem 0.8rem;
  border-radius: 999px;
  border: 1px solid #1fae52;
  background: #25d366;
  color: #ffffff;
  text-decoration: none;
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1;
}

.ps-whatsapp-icon {
  width: 16px;
  height: 16px;
  display: block;
  fill: #ffffff;
  flex-shrink: 0;
}

.ps-support-whatsapp:hover {
  filter: brightness(1.06);
}

.ps-embed-wrap {
  flex: 1 1 auto;
  /* Evita colapso a 0 px en flex (iframe height:100% sin altura del padre = negro). */
  min-height: min(72vh, calc(100dvh - 3.5rem));
  position: relative;
  display: flex;
}

.ps-main-iframe {
  display: block;
  width: 100%;
  height: 100%;
  min-height: min(65vh, 520px);
  border: 0;
  /* Si el documento aún no pinta, algo visible distinto al negro puro ayuda a diagnosticar */
  background: #0d1117;
  isolation: isolate;
}

/* Overlay de carga sobre el embed (solo visual). Sin pointer-events:none el overlay capta los clics
   y el iframe no recibe el submit → Red vacía y login imposible. */
.ps-embed-loading {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  text-align: center;
  background: radial-gradient(ellipse at 50% 20%, #1a2332 0%, rgba(13, 17, 23, 0.98) 55%, #0d1117 100%);
  pointer-events: none;
}

.ps-embed-loading[hidden] {
  display: none !important;
}

.ps-embed-loading-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  max-width: 20rem;
}

.ps-embed-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--ps-border);
  border-top-color: var(--ps-accent);
  border-radius: 50%;
  animation: ps-embed-spin 0.85s linear infinite;
}

@keyframes ps-embed-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ps-embed-spinner {
    animation: none;
    border-top-color: var(--ps-accent);
    opacity: 0.9;
  }
}

.ps-embed-loading-brand {
  margin: 0;
  font-weight: 800;
  letter-spacing: 0.12em;
  font-size: 1.05rem;
  color: #ffe9e9;
  -webkit-text-stroke: 0.7px #b90d0d;
  text-shadow:
    0 0 1px #b90d0d,
    0 0 6px rgba(185, 13, 13, 0.55);
}

.ps-embed-loading-msg {
  margin: 0;
  font-size: 0.95rem;
  color: var(--ps-muted);
  letter-spacing: 0.06em;
}

/* Aviso visible fuera del embed (Plan B): no depende del pintado del iframe. */
.ps-embed-flash-error {
  position: fixed;
  left: 50%;
  top: 4.1rem;
  transform: translateX(-50%);
  z-index: 140;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 0.6rem 0.9rem;
  width: min(94vw, 680px);
  text-align: center;
  background: rgba(93, 15, 15, 0.97);
  border: 1px solid #d95c5c;
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}

.ps-embed-flash-error[hidden] {
  display: none !important;
}

.ps-embed-flash-error-inner {
  max-width: 100%;
}

.ps-embed-flash-error-title {
  margin: 0;
  font-size: clamp(1rem, 2.8vw, 1.2rem);
  font-weight: 800;
  line-height: 1.2;
  color: #f0f6fc;
  letter-spacing: 0.02em;
}

.ps-embed-flash-error-sub {
  margin: 0.45rem 0 0;
  font-size: 0.9rem;
  color: #f7d9d9;
  line-height: 1.4;
}

/*
 * Móvil: la altura útil del embed la fija app.js (layoutEmbedHeight) — Android Chrome suele ignorar solo CSS.
 * El iframe en absolute rellena el rectángulo que marca JS.
 *
 * Zoom visual ~10% “hacia afuera” (equivalente a alejar un poco con el dedo): scale + tamaño compensado.
 * Para desactivar: .ps-embed-wrap { --ps-embed-mzoom: 1; } en este mismo media (o quitar la regla del iframe).
 */
@media (max-width: 768px) {
  body.ps-app-body {
    overflow-x: hidden;
  }

  .ps-embed-wrap {
    --ps-embed-mzoom: 0.9;
    flex: 1 1 auto;
    position: relative;
    width: 100%;
    min-height: 50vh;
    overflow: hidden;
  }

  /* Ajuste fino: Android casi al 100%; iOS suele necesitar un poco más de “alejar”. */
  body.ps-client-android.ps-app-body .ps-embed-wrap {
    --ps-embed-mzoom: 0.88;
  }

  body.ps-client-ios.ps-app-body .ps-embed-wrap {
    --ps-embed-mzoom: 0.82;
  }

  .ps-main-iframe {
    position: absolute;
    top: 0;
    left: 50%;
    right: auto;
    bottom: auto;
    width: calc(100% / var(--ps-embed-mzoom));
    height: calc(100% / var(--ps-embed-mzoom));
    min-height: calc(100% / var(--ps-embed-mzoom));
    margin-left: calc(-50% / var(--ps-embed-mzoom));
    transform: translateZ(0) scale(var(--ps-embed-mzoom));
    transform-origin: top center;
    -webkit-transform: translateZ(0) scale(var(--ps-embed-mzoom));
  }
}

/* El iframe del embed suele capturar clics por encima del modal; sin esto, «Ver» no responde. */
.ps-app-body.ps-overlay-open #ps-main-embed {
  pointer-events: none;
}

/* FAB */
.ps-fab {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 50;
  width: 36px;
  height: 72px;
  border: 1px solid var(--ps-border);
  border-left: none;
  border-radius: 0 10px 10px 0;
  background: var(--ps-card);
  color: var(--ps-accent);
  cursor: pointer;
  padding: 0;
  box-shadow: 2px 0 12px rgba(0, 0, 0, 0.35);
}

.ps-fab-pulse {
  animation: ps-pulse 1.4s ease-in-out infinite;
}

@keyframes ps-pulse {
  0%,
  100% {
    box-shadow: 2px 0 12px rgba(201, 162, 39, 0.35);
  }
  50% {
    box-shadow: 2px 0 20px rgba(201, 162, 39, 0.85);
  }
}

.ps-fab-icon {
  display: block;
  font-size: 1.75rem;
  line-height: 1;
  transform: rotate(0deg);
  transition: transform 0.2s ease;
}

.ps-fab[aria-expanded="true"] .ps-fab-icon {
  transform: rotate(180deg);
}

.ps-fab-panel {
  position: fixed;
  left: 44px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 51;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ps-fab-panel[hidden] {
  display: none !important;
}

.ps-fab-action {
  padding: 0.6rem 1rem;
  border: 1px solid var(--ps-border);
  border-radius: 8px;
  background: var(--ps-card);
  color: var(--ps-text);
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
  text-align: left;
}

.ps-fab-action:hover {
  border-color: var(--ps-accent);
  color: var(--ps-accent);
}

/* Overlays */
.ps-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.ps-overlay[hidden] {
  display: none !important;
}

.ps-overlay-mag-pdf {
  z-index: 120;
}

.ps-modal {
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow: auto;
  background: var(--ps-card);
  border: 1px solid var(--ps-border);
  border-radius: 12px;
  padding: 0;
}

.ps-modal-video {
  max-width: min(960px, 100%);
}

.ps-modal-mag-pdf {
  max-width: min(960px, 100%);
  width: 100%;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
}

.ps-mag-pdf-frame-wrap {
  flex: 1;
  min-height: 0;
  padding: 0 1rem 1rem;
}

.ps-mag-pdf-frame {
  width: 100%;
  min-height: min(75vh, 720px);
  height: 70vh;
  border: 0;
  border-radius: 8px;
  background: #1a1a1a;
}

.ps-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--ps-border);
}

.ps-modal-head h2 {
  margin: 0;
  font-size: 1.1rem;
}

.ps-close {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}

.ps-close-inner {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: linear-gradient(180deg, #c53030, #8b1a1a);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  padding: 0.4rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.ps-close-x {
  font-size: 1.35rem;
  line-height: 1;
  font-weight: 700;
}

.ps-close-text {
  text-transform: uppercase;
}

.ps-close:hover .ps-close-inner,
.ps-close:focus-visible .ps-close-inner {
  filter: brightness(1.1);
  outline: 2px solid rgba(255, 255, 255, 0.35);
  outline-offset: 2px;
}

.ps-video-list {
  padding: 0.75rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ps-video-item {
  text-align: left;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--ps-border);
  border-radius: 8px;
  background: #0d1117;
  color: var(--ps-text);
  cursor: pointer;
  font-size: 0.95rem;
}

.ps-video-item:hover {
  border-color: var(--ps-accent);
}

.ps-video-stage {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0 1rem 1rem;
}

.ps-video-fs-wrap {
  position: relative;
  width: 100%;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
}

.ps-video-fs-wrap:fullscreen,
.ps-video-fs-wrap:-webkit-full-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border-radius: 0;
  background: #000;
}

.ps-video-fs-wrap:fullscreen .ps-video-player,
.ps-video-fs-wrap:-webkit-full-screen .ps-video-player {
  width: 100%;
  height: 100%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ps-video-fs-wrap:fullscreen .ps-video-player iframe,
.ps-video-fs-wrap:-webkit-full-screen .ps-video-player iframe {
  width: 100%;
  height: 100%;
  min-height: 100%;
  border-radius: 0;
}

.ps-video-player {
  padding: 0;
}

.ps-video-player iframe {
  width: 100%;
  min-height: 240px;
  border: 0;
  border-radius: 8px;
  background: #000;
  display: block;
}

.ps-video-fullscreen-btn {
  width: 100%;
  box-sizing: border-box;
  padding: 0.65rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #0d1117;
  border: 1px solid var(--ps-accent-dim);
  border-radius: 8px;
  cursor: pointer;
  background: linear-gradient(180deg, var(--ps-accent), var(--ps-accent-dim));
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.ps-video-fullscreen-btn:hover,
.ps-video-fullscreen-btn:focus-visible {
  filter: brightness(1.08);
  outline: none;
}

.ps-video-fullscreen-btn:focus-visible {
  box-shadow: 0 0 0 2px var(--ps-bg), 0 0 0 4px var(--ps-accent);
}

/*
 * iOS Safari: Fullscreen API no aplica bien a un div con iframe (YouTube).
 * Modo “casi pantalla completa”: overlay fijo + ocultar cabecera/lista del modal.
 */
body.ps-video-ios-fs {
  overflow: hidden !important;
}

body.ps-video-ios-fs #ps-overlay-video {
  position: fixed !important;
  inset: 0 !important;
  z-index: 10000 !important;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px)
    env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px) !important;
  align-items: stretch !important;
  justify-content: stretch !important;
  background: #000 !important;
}

body.ps-video-ios-fs #ps-overlay-video .ps-modal-video {
  max-width: 100% !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 100dvh !important;
  max-height: none !important;
  border-radius: 0 !important;
  border: none !important;
  display: flex !important;
  flex-direction: column !important;
}

body.ps-video-ios-fs #ps-overlay-video .ps-modal-head,
body.ps-video-ios-fs #ps-overlay-video .ps-video-list {
  display: none !important;
}

body.ps-video-ios-fs .ps-video-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0 0 calc(0.35rem + env(safe-area-inset-bottom, 0px));
}

body.ps-video-ios-fs .ps-video-fs-wrap {
  flex: 1 1 auto;
  min-height: 0;
  border-radius: 0;
  display: flex;
  flex-direction: column;
}

body.ps-video-ios-fs .ps-video-player {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

body.ps-video-ios-fs .ps-video-player iframe {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  border-radius: 0;
}

.ps-mag-list {
  list-style: none;
  margin: 0;
  padding: 0.75rem 1rem 1rem;
}

.ps-mag-list li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--ps-border);
  font-size: 0.9rem;
}

.ps-mag-list li:last-child {
  border-bottom: none;
}

.ps-mag-name {
  word-break: break-word;
}

.ps-mag-link {
  color: var(--ps-accent);
  text-decoration: none;
  font-size: 0.85rem;
}

.ps-mag-link:hover {
  text-decoration: underline;
}

a.ps-mag-view-btn {
  display: inline;
}

.ps-mag-view-btn {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  cursor: pointer;
  color: var(--ps-accent);
  text-decoration: none;
  font-size: 0.85rem;
  text-align: left;
}

.ps-mag-view-btn:hover {
  text-decoration: underline;
}

.ps-empty {
  color: var(--ps-muted);
  margin: 0;
  font-size: 0.9rem;
}

@media (max-width: 520px) {
  .ps-mag-list li {
    grid-template-columns: 1fr;
    gap: 0.35rem;
  }
}
