:root {
  --bg-main: #fffaf5;
  --bg-card: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --border-card: #fed7aa;
  --accent: #f97316;
  --accent-dark: #ea580c;
  --comercio-bg: rgba(249, 115, 22, 0.12);
  --comercio-color: #ea580c;
  --comercio-border: #f97316;
  --duracion-giro-ruleta: 16s;
  --angulo-inicio: 0deg;
  --angulo-fin: 1440deg;
  --vaiven-1: 1440deg;
  --vaiven-2: 1440deg;
  --vaiven-3: 1440deg;
}

body.tema-naranja {
  --bg-main: linear-gradient(135deg, #fb923c 0%, #f97316 50%, #ea580c 100%);
  --bg-card: rgba(15, 23, 42, 0.42);
  --text-primary: #ffffff;
  --text-secondary: #ffedd5;
  --border-card: rgba(255, 255, 255, 0.4);
  --comercio-bg: rgba(15, 23, 42, 0.5);
  --comercio-color: #fde047;
  --comercio-border: #fde047;
}

body.tema-rojo {
  --bg-main: linear-gradient(135deg, #ef4444 0%, #dc2626 55%, #991b1b 100%);
  --bg-card: rgba(15, 23, 42, 0.45);
  --text-primary: #ffffff;
  --text-secondary: #fee2e2;
  --border-card: rgba(254, 202, 202, 0.45);
  --comercio-bg: rgba(15, 23, 42, 0.52);
  --comercio-color: #fde047;
  --comercio-border: #fde047;
}

body.tema-verde {
  --bg-main: linear-gradient(135deg, #22c55e 0%, #16a34a 55%, #166534 100%);
  --bg-card: rgba(15, 23, 42, 0.45);
  --text-primary: #ffffff;
  --text-secondary: #dcfce7;
  --border-card: rgba(187, 247, 208, 0.45);
  --comercio-bg: rgba(15, 23, 42, 0.52);
  --comercio-color: #fde047;
  --comercio-border: #fde047;
}

body.tema-azul {
  --bg-main: linear-gradient(135deg, #3b82f6 0%, #2563eb 55%, #1e3a8a 100%);
  --bg-card: rgba(15, 23, 42, 0.45);
  --text-primary: #ffffff;
  --text-secondary: #dbeafe;
  --border-card: rgba(191, 219, 254, 0.45);
  --comercio-bg: rgba(15, 23, 42, 0.52);
  --comercio-color: #fde047;
  --comercio-border: #fde047;
}

body.tema-amarillo {
  --bg-main: linear-gradient(135deg, #fde047 0%, #facc15 55%, #eab308 100%);
  --bg-card: rgba(15, 23, 42, 0.82);
  --text-primary: #ffffff;
  --text-secondary: #fef9c3;
  --border-card: rgba(15, 23, 42, 0.55);
  --comercio-bg: rgba(254, 240, 138, 0.16);
  --comercio-color: #fde047;
  --comercio-border: #fde047;
}

*, *::before, *::after {
  box-sizing: border-box;
  font-family: 'Poppins', sans-serif;
  user-select: none;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg-main);
  color: var(--text-primary);
  transition: background 0.35s ease, color 0.35s ease;
}

body.modo-giro-puro .ruleta-tv-wrapper:not(.animando-giro-16s) {
  animation: none;
}

.aviso-sin-senal {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translate3d(-50%, -140%, 0);
  z-index: 260;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: rgba(15, 23, 42, 0.94);
  color: #fef2f2;
  border: 2px solid #f87171;
  border-radius: 50px;
  padding: 10px 22px;
  font-size: clamp(0.9rem, 1.25vw, 1.08rem);
  font-weight: 800;
  letter-spacing: 0.2px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35), 0 0 20px rgba(239, 68, 68, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.25s ease;
  max-width: 92vw;
  text-align: center;
  will-change: transform, opacity;
}

.aviso-sin-senal.visible {
  transform: translate3d(-50%, 0, 0);
  opacity: 1;
}

.aviso-sin-senal i {
  color: #f87171;
  font-size: 1.15rem;
  animation: pulsoSenal 1.4s ease-in-out infinite;
}

@keyframes pulsoSenal {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.92); }
}

.login-tv-overlay {
  position: fixed;
  inset: 0;
  background-color: #1c0a00;
  background-image:
    radial-gradient(circle at center, rgba(15, 23, 42, 0.28) 0%, rgba(15, 23, 42, 0.68) 100%),
    url('../img/fondo-tv-ruleta.jpg');
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3vw;
}

.login-tv-overlay.oculto { display: none; }

.login-tv-card {
  position: relative;
  z-index: 2;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 3px solid #fde047;
  border-radius: 32px;
  padding: 4vh 3.5vw;
  max-width: 600px;
  width: 100%;
  text-align: center;
  box-shadow: 0 28px 65px rgba(0, 0, 0, 0.6), 0 0 35px rgba(251, 146, 60, 0.45);
  max-height: 92vh;
  overflow-y: auto;
}

.login-tv-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #f97316, #ea580c);
  color: #ffffff;
  padding: 10px 24px;
  border-radius: 50px;
  font-size: 1.4rem;
  font-weight: 900;
  margin-bottom: 14px;
}

.login-tv-card h1 {
  margin: 0 0 6px 0;
  font-size: 1.9rem;
  font-weight: 900;
  color: #0f172a;
}

.login-tv-card p {
  margin: 0 0 20px 0;
  color: #475569;
  font-size: 1rem;
}

.input-codigo-tv {
  width: 100%;
  padding: 16px;
  border: 3px solid #fdba74;
  border-radius: 18px;
  font-size: 2.1rem;
  font-weight: 900;
  text-align: center;
  letter-spacing: 6px;
  text-transform: uppercase;
  color: #ea580c;
  background: #fffaf5;
  outline: none;
  margin-bottom: 14px;
}

.input-codigo-tv:focus {
  border-color: #ea580c;
  box-shadow: 0 0 0 5px rgba(249, 115, 22, 0.25);
}

.btn-ingresar-tv {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 18px;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #ffffff;
  font-size: 1.25rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(34, 197, 94, 0.35);
  transition: transform 0.14s ease, box-shadow 0.2s ease;
}

.btn-ingresar-tv:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(34, 197, 94, 0.45);
}

.btn-ingresar-tv:focus { outline: 4px solid #facc15; }

.login-tv-error {
  margin-top: 12px;
  color: #dc2626;
  font-weight: 800;
  font-size: 0.98rem;
  min-height: 22px;
}

.historial-tv-box {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 2px dashed #fed7aa;
  text-align: left;
  display: none;
}

.historial-tv-box.visible { display: block; }

.historial-tv-titulo {
  font-size: 0.92rem;
  font-weight: 800;
  color: #475569;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.historial-tv-lista {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.historial-tv-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.btn-codigo-guardado {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-radius: 18px;
  border: 3px solid #fed7aa;
  background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
  color: #ffffff;
  cursor: pointer;
  text-align: left;
  box-shadow: 0 10px 24px rgba(234, 88, 12, 0.32);
  transition: transform 0.16s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.btn-codigo-guardado:hover,
.btn-codigo-guardado:focus {
  border-color: #fef08a;
  outline: 3px solid #facc15;
  transform: translateY(-2px) scale(1.015);
  box-shadow: 0 14px 30px rgba(234, 88, 12, 0.45);
}

.guardado-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.guardado-comercio {
  font-size: 1.05rem;
  font-weight: 800;
  color: #ffedd5;
  text-transform: uppercase;
}

.guardado-codigo {
  font-size: 1.45rem;
  font-weight: 900;
  color: #ffffff;
  letter-spacing: 3px;
}

.guardado-accion {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #ffffff;
  padding: 10px 16px;
  border-radius: 12px;
  border: 2px solid #dcfce7;
  font-size: 1rem;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-eliminar-guardado {
  background: #fee2e2;
  color: #dc2626;
  border: 2px solid #fca5a5;
  border-radius: 16px;
  padding: 14px 16px;
  cursor: pointer;
  font-size: 1.05rem;
  flex-shrink: 0;
  transition: transform 0.14s ease, background 0.14s ease;
}

.btn-eliminar-guardado:hover,
.btn-eliminar-guardado:focus {
  background: #fecaca;
  transform: scale(1.04);
  outline: 3px solid #facc15;
}

.marca-superior-izq { position: fixed; top: 16px; left: 20px; z-index: 50; }

.marca-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #f97316, #ea580c);
  color: #ffffff;
  padding: 8px 20px;
  border-radius: 50px;
  font-size: clamp(1rem, 1.55vw, 1.4rem);
  font-weight: 900;
  letter-spacing: 0.5px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
  border: 2px solid #fde047;
}

.marca-texto-bordeado {
  color: #ffffff;
  -webkit-text-stroke: 1.6px #000000;
  paint-order: stroke fill;
  text-shadow:
    -1.5px -1.5px 0 #000000,
     1.5px -1.5px 0 #000000,
    -1.5px  1.5px 0 #000000,
     1.5px  1.5px 0 #000000,
     0px    2px   3px rgba(0, 0, 0, 0.65);
}

.btn-util-tv {
  background: rgba(15, 23, 42, 0.88);
  color: #ffffff;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  padding: 10px 16px;
  border-radius: 14px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  transition: transform 0.14s ease, background 0.18s ease, border-color 0.18s ease;
}

.btn-util-tv:hover {
  background: rgba(30, 41, 59, 0.96);
  border-color: #fde047;
  transform: translateY(-1px);
}

.btn-util-tv:focus { outline: 3px solid #facc15; }

.tv-container {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  padding: clamp(10px, 1.8vh, 22px) 2.2vw clamp(10px, 1.8vh, 22px) 2vw;
  align-items: center;
  gap: 2.2vw;
  overflow: hidden;
}

.columna-ruleta {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  position: relative;
  contain: layout style;
}

.visor-casino-vivo {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translate3d(-50%, -140%, 0);
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #facc15;
  border: 3px solid #facc15;
  border-radius: 50px;
  padding: 10px 26px;
  font-size: clamp(1.05rem, 1.55vw, 1.4rem);
  font-weight: 900;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45), 0 0 24px rgba(250, 204, 21, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.22s ease, border-color 0.15s ease;
  max-width: 52vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  will-change: transform, opacity;
}

.visor-casino-vivo.activo {
  transform: translate3d(-50%, 0, 0);
  opacity: 1;
}

.visor-casino-vivo.es-premio {
  border-color: #22c55e;
  color: #86efac;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45), 0 0 28px rgba(34, 197, 94, 0.7);
}

.visor-casino-vivo i {
  color: #facc15;
  animation: destelloCasino 0.45s ease-in-out infinite alternate;
}

@keyframes destelloCasino {
  from { transform: scale(0.9); opacity: 0.7; }
  to { transform: scale(1.18); opacity: 1; }
}

.ruleta-tv-wrapper {
  position: relative;
  width: min(86dvh, 51vw);
  height: min(86dvh, 51vw);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulsoAtractivo 3.2s ease-in-out infinite;
  will-change: transform;
}

.ruleta-tv-wrapper.girando-ahora {
  animation: none;
  transform: scale3d(1.02, 1.02, 1);
}

.ruleta-tv-wrapper.animando-giro-16s {
  animation: giroRuletaCasino var(--duracion-giro-ruleta) cubic-bezier(0.14, 0.88, 0.22, 1) forwards;
}

@keyframes giroRuletaCasino {
  0% {
    transform: rotate(var(--angulo-inicio));
  }
  100% {
    transform: rotate(var(--angulo-fin));
  }
}

@keyframes pulsoAtractivo {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.018); }
}

.ruleta-tv-aro {
  position: absolute;
  inset: -20px;
  border-radius: 50%;
  background: radial-gradient(circle, #1e293b 60%, #090d16 100%);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.35), 0 0 32px rgba(250, 204, 21, 0.65), inset 0 0 0 5px #facc15;
  z-index: 1;
}

.bombilla-tv {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fef08a;
  box-shadow: 0 0 10px #fde047;
  z-index: 3;
  will-change: opacity;
  transition: opacity 0.08s linear;
}

.bombilla-tv.apagada {
  background: #451a03;
  box-shadow: none;
  opacity: 0.35;
}

#canvas-ruleta-tv {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #0f172a;
  cursor: pointer;
  transform: translate3d(0, 0, 0);
  will-change: transform;
}

.puntero-tv {
  position: absolute;
  top: -38px;
  left: 50%;
  transform: translate3d(-50%, 0, 0) rotate(0deg);
  z-index: 10;
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.5));
  transform-origin: 50% 18%;
  will-change: transform;
}

.puntero-tv.tension-final,
.puntero-tv.tensión-final {
  animation: toquePunteroCasino 0.65s ease-in-out infinite alternate;
}

@keyframes toquePunteroCasino {
  0% {
    transform: translate3d(-50%, 0, 0) rotate(-14deg);
  }
  100% {
    transform: translate3d(-50%, 0, 0) rotate(11deg);
  }
}

.columna-info {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: stretch;
  width: 100%;
  height: 100%;
  max-height: 100%;
  gap: clamp(8px, 1.3vh, 16px);
  padding: 0;
  overflow: hidden;
  contain: layout style;
}

.panel-texto {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  border: 2px solid var(--border-card);
  border-radius: clamp(20px, 2.8vh, 32px);
  padding: clamp(10px, 1.5vh, 18px) 2vw;
  width: 100%;
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.12);
  animation: pulsoAtractivo 3.2s ease-in-out infinite;
  text-align: center;
  overflow: hidden;
}

.nombre-comercio {
  flex: 0 0 auto;
  font-size: clamp(1.9rem, min(4.2vw, 5.8vh), 4.2rem);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  line-height: 1.08;
  color: var(--comercio-color);
  margin: 0 auto clamp(4px, 0.8vh, 10px) auto;
  display: block;
  width: 100%;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: break-word;
  background: var(--comercio-bg);
  padding: clamp(6px, 1vh, 12px) 20px;
  border-radius: 18px;
  border-left: 8px solid var(--comercio-border);
  border-right: 8px solid var(--comercio-border);
  text-align: center;
}

.titulo-principal {
  flex: 0 0 auto;
  font-size: clamp(1.3rem, min(2.6vw, 3.8vh), 2.7rem);
  font-weight: 900;
  line-height: 1.08;
  margin: 0 auto clamp(6px, 1vh, 12px) auto;
  text-align: center;
  width: 100%;
}

.btn-girar-tv {
  position: relative;
  flex: 1 1 auto;
  min-height: clamp(64px, 11vh, 210px);
  width: 100%;
  padding: clamp(10px, 1.8vh, 32px) 20px;
  border-radius: clamp(18px, 2.4vh, 26px);
  border: 3px solid #fef08a;
  border-bottom: clamp(5px, 0.9vh, 9px) solid #15803d;
  background: linear-gradient(180deg, #4ade80 0%, #22c55e 45%, #16a34a 100%);
  color: #ffffff;
  font-size: clamp(1.75rem, min(3.2vw, 4.5vh), 3.35rem);
  font-weight: 900;
  letter-spacing: 0.5px;
  line-height: 1.08;
  text-transform: uppercase;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  overflow: hidden;
  box-shadow:
    0 14px 28px rgba(22, 163, 74, 0.42),
    0 0 24px rgba(250, 204, 21, 0.35),
    inset 0 2px 2px rgba(255, 255, 255, 0.55);
  transition: transform 0.14s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.25s ease;
}

.btn-girar-tv span {
  display: inline-block;
  max-width: 100%;
  text-align: center;
  word-break: break-word;
}

.btn-girar-tv i {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: clamp(78px, 11.5vh, 130px);
  height: clamp(78px, 11.5vh, 130px);
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.28);
  border: 3.5px solid rgba(255, 255, 255, 0.85);
  color: #fef08a;
  font-size: clamp(2.6rem, 4.4vh, 3.6rem);
  padding-left: 6px;
  flex-shrink: 0;
}

.btn-girar-tv:hover {
  transform: translateY(-2px) scale(1.01);
  box-shadow:
    0 18px 34px rgba(22, 163, 74, 0.5),
    0 0 32px rgba(250, 204, 21, 0.5),
    inset 0 2px 3px rgba(255, 255, 255, 0.65);
}

.btn-girar-tv:active,
.btn-girar-tv:focus {
  outline: 4px solid #facc15;
  transform: translateY(3px) scale(1.005);
  border-bottom-width: 4px;
}

.btn-girar-tv:disabled {
  opacity: 1;
  cursor: not-allowed;
}

.btn-girar-tv.en-giro,
.btn-girar-tv.en-giro-casino {
  background: linear-gradient(180deg, #fb923c 0%, #f97316 45%, #ea580c 100%);
  border-color: #fde047;
  border-bottom-color: #9a3412;
  color: #ffffff;
  font-size: clamp(1.75rem, min(3.2vw, 4.5vh), 3.35rem);
  animation: llamaBotonGiro 0.55s ease-in-out infinite alternate;
}

.btn-girar-tv.en-giro i,
.btn-girar-tv.en-giro-casino i {
  width: clamp(52px, 7.6vh, 84px);
  height: clamp(52px, 7.6vh, 84px);
  font-size: clamp(1.55rem, 3vh, 2.35rem);
  background: rgba(15, 23, 42, 0.45);
  border: 3px solid #fde047;
  color: #fde047;
  padding-left: 0;
  animation: parpadeoLlamaIcono 0.4s ease-in-out infinite alternate;
}

@keyframes parpadeoLlamaIcono {
  0% { transform: scale(0.95) rotate(-5deg); color: #fde047; }
  100% { transform: scale(1.16) rotate(5deg); color: #ffffff; }
}

@keyframes llamaBotonGiro {
  0% {
    box-shadow:
      0 12px 28px rgba(234, 88, 12, 0.65),
      0 -6px 22px rgba(250, 204, 21, 0.7),
      0 0 34px rgba(239, 68, 68, 0.6),
      inset 0 2px 4px rgba(255, 255, 255, 0.6);
    transform: scale(1);
  }
  100% {
    box-shadow:
      0 18px 40px rgba(220, 38, 38, 0.82),
      0 -10px 30px rgba(254, 240, 138, 0.92),
      0 0 48px rgba(249, 115, 22, 0.85),
      inset 0 2px 6px rgba(255, 255, 255, 0.8);
    transform: scale(1.015);
  }
}

.recuadro-mensaje-consola {
  position: relative;
  flex: 1 1 auto;
  min-height: clamp(110px, 19vh, 210px);
  background: var(--bg-card);
  border: 2px solid var(--border-card);
  border-radius: clamp(18px, 2.5vh, 26px);
  padding: clamp(12px, 1.6vh, 18px) 22px;
  width: 100%;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.14);
  color: var(--text-primary);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.recuadro-mensaje-consola.con-mensaje {
  min-height: clamp(115px, 20vh, 215px);
}

.borde-luz-consola {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 4;
  opacity: 0;
  transition: opacity 0.35s ease;
}

.borde-luz-consola.activa {
  opacity: 1;
}

.borde-luz-consola rect {
  fill: none;
  stroke-width: 6;
  stroke-linecap: round;
}

#texto-mensaje-consola {
  position: relative;
  z-index: 2;
  font-size: clamp(1.85rem, min(3.1vw, 4.4vh), 3.3rem);
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: 0.3px;
  width: 100%;
  max-height: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: pre-line;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}

.fila-inferior-derecha {
  flex: 0 1 auto;
  min-height: 0;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  margin: 0;
  width: 100%;
  overflow: hidden;
}

.reloj-digital-tv {
  position: relative;
  width: 100%;
  min-height: clamp(92px, 16vh, 180px);
  background: #0f172a;
  color: #facc15;
  border: 3px solid #facc15;
  border-radius: clamp(18px, 2.5vh, 28px);
  padding: clamp(10px, 1.6vh, 22px) 18px;
  font-size: clamp(1.85rem, min(3.5vw, 5.2vh), 3.9rem);
  font-weight: 900;
  letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  overflow: hidden;
}

#contenido-ticker-tv {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: 100%;
  max-height: 100%;
  line-height: 1.14;
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.35s ease;
}

#contenido-ticker-tv.salida-izq {
  transform: translate3d(-65px, 0, 0);
  opacity: 0;
}

#contenido-ticker-tv.entrada-der {
  transform: translate3d(65px, 0, 0);
  opacity: 0;
  transition: none;
}

#contenido-ticker-tv.modo-info-secundaria {
  font-size: clamp(1.6rem, min(2.8vw, 4vh), 3rem);
  letter-spacing: 0.2px;
  color: #fef08a;
}

#contenido-ticker-tv.modo-info-estadistica {
  font-size: clamp(1.6rem, min(2.8vw, 4vh), 3rem);
  letter-spacing: 0.2px;
  color: #ffffff;
}

#contenido-ticker-tv.modo-info-estadistica i {
  color: #facc15;
  font-size: 1.25em;
  flex-shrink: 0;
}

#reloj-hora-texto {
  max-width: 100%;
  overflow-wrap: break-word;
  word-break: break-word;
}

.modal-resultado {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.88);
  z-index: 150;
  align-items: center;
  justify-content: center;
  padding: 4vw;
  overflow: hidden;
}

.modal-resultado.activo { display: flex; }
.modal-resultado.ganador-flash { animation: alarmaVictoria 0.48s ease-in-out 11; }

@keyframes alarmaVictoria {
  0%, 100% { background: rgba(15, 23, 42, 0.88); }
  50% { background: rgba(234, 88, 12, 0.82); }
}

.modal-box {
  position: relative;
  background: #ffffff;
  color: #0f172a;
  border-radius: 36px;
  padding: 4vh 4vw;
  max-width: min(760px, 90vw);
  width: 100%;
  margin: 0 auto;
  text-align: center;
  border: 6px solid #facc15;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.55), 0 0 50px rgba(250, 204, 21, 0.65);
}

.modal-box.ganador-box {
  background: linear-gradient(180deg, #ffffff 0%, #fefce8 100%);
  border-color: #facc15;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.55), 0 0 55px rgba(250, 204, 21, 0.78);
}

.modal-box.perdedor-box {
  background: linear-gradient(180deg, #ffffff 0%, #fffbeb 100%);
  border-color: #f97316;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.55), 0 0 40px rgba(249, 115, 22, 0.45);
}

.borde-luz-modal {
  position: absolute;
  inset: -6px;
  width: calc(100% + 12px);
  height: calc(100% + 12px);
  pointer-events: none;
  z-index: 6;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.borde-luz-modal.activa {
  opacity: 1;
}

.borde-luz-modal rect {
  fill: none;
  stroke: #ffffff;
  stroke-width: 7;
  stroke-linecap: round;
}

.modal-icono { font-size: 5.5rem; color: #f97316; margin-bottom: 10px; line-height: 1; }

.trofeo-ganador-vivo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  animation: celebrarTrofeo 1.6s ease-in-out infinite;
}

.trofeo-ganador-vivo svg {
  width: 138px;
  height: 138px;
  filter: drop-shadow(0 12px 24px rgba(245, 158, 11, 0.5));
}

@keyframes celebrarTrofeo {
  0%, 100% { transform: translateY(0) scale(1) rotate(0deg); }
  25% { transform: translateY(-7px) scale(1.06) rotate(-4deg); }
  50% { transform: translateY(0) scale(1.02) rotate(0deg); }
  75% { transform: translateY(-7px) scale(1.06) rotate(4deg); }
}

.carita-triste-viva {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  animation: flotarTriste 2.2s ease-in-out infinite;
}

.carita-triste-viva svg {
  width: 132px;
  height: 132px;
  filter: drop-shadow(0 12px 24px rgba(245, 158, 11, 0.42));
}

@keyframes flotarTriste {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  35% { transform: translateY(-4px) rotate(-3deg); }
  70% { transform: translateY(2px) rotate(3deg); }
}

.modal-titulo {
  font-size: clamp(1.9rem, 3.3vw, 2.9rem);
  font-weight: 900;
  margin: 6px 0 10px 0;
  color: #ea580c;
  line-height: 1.08;
}

.modal-box.ganador-box .modal-titulo {
  font-size: clamp(2.45rem, 4.2vw, 3.7rem);
  letter-spacing: 0.5px;
  text-shadow: 0 3px 14px rgba(234, 88, 12, 0.25);
}

.modal-box.perdedor-box .modal-titulo {
  font-size: clamp(2.55rem, 4.4vw, 3.85rem);
  letter-spacing: 0.5px;
  text-shadow: 0 3px 12px rgba(239, 68, 68, 0.22);
}

.modal-premio {
  font-size: clamp(1.8rem, 3.3vw, 2.8rem);
  font-weight: 900;
  background: #fff7ed;
  border: 3px dashed #f97316;
  padding: 18px 26px;
  border-radius: 22px;
  margin: 16px 0 16px 0;
  color: #0f172a;
  line-height: 1.25;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.modal-box.ganador-box .modal-premio {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border: 3.5px solid #f59e0b;
  color: #0f172a;
  box-shadow: inset 0 0 0 2px #fde047;
}

.modal-box.perdedor-box .modal-premio {
  background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
  border: 3px solid #f97316;
  color: #1e3a8a;
  box-shadow: inset 0 0 0 2px #fde047;
}

.modal-submensaje-ganador {
  display: none;
  font-size: clamp(1.15rem, 1.8vw, 1.5rem);
  font-weight: 800;
  color: #15803d;
  background: #dcfce7;
  border: 2px solid #86efac;
  border-radius: 16px;
  padding: 10px 20px;
  margin: 0 auto 16px auto;
  max-width: 92%;
}

.modal-box.ganador-box .modal-submensaje-ganador.visible {
  display: block;
}

.modal-banner-qr-factura {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #fde047;
  border: 3px solid #facc15;
  border-radius: 20px;
  padding: 14px 22px;
  margin: 0 auto 18px auto;
  max-width: 94%;
  font-size: clamp(1.05rem, 1.55vw, 1.35rem);
  font-weight: 800;
  line-height: 1.3;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.28);
}

.modal-banner-qr-factura i {
  font-size: 2rem;
  color: #22c55e;
  flex-shrink: 0;
}

.modal-box.perdedor-box .modal-banner-qr-factura.visible {
  display: flex;
}

.modal-hint { font-size: 1.1rem; color: #475569; font-weight: 700; }

.controles-superiores {
  position: fixed;
  top: 0;
  right: 0;
  min-width: 340px;
  min-height: 92px;
  padding: 18px 22px 36px 56px;
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  gap: 10px;
  z-index: 90;
  opacity: 0;
  visibility: visible;
  pointer-events: auto;
  transform: translate3d(0, -6px, 0);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.controles-superiores.visible,
.controles-superiores:hover,
.controles-superiores:focus-within {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

.controles-superiores.controles-ocultos:not(:hover):not(:focus-within) {
  opacity: 0;
  transform: translate3d(0, -6px, 0);
}

.modal-resultado.es-ganador .modal-box.ganador-box {
  animation: pulsoCajaGanador 0.75s ease-in-out infinite alternate;
}

@keyframes pulsoCajaGanador {
  0% {
    transform: scale(1);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.55), 0 0 45px rgba(250, 204, 21, 0.75);
  }
  100% {
    transform: scale(1.025);
    box-shadow: 0 30px 70px rgba(0, 0, 0, 0.65), 0 0 80px rgba(239, 68, 68, 0.85);
  }
}