/* Carrera de Caballos – pantalla TV */
.carrera-tv {
	--car-fondo: #0f3d1e; --car-pista: #7a4a24; --car-acento: #f5b700; --car-texto: #fff;
	position: relative; box-sizing: border-box; width: 100%; min-height: 80vh; overflow: hidden;
	background: radial-gradient(ellipse at top, rgba(255,255,255,.08), transparent 60%), var(--car-fondo);
	--tv-titulos: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif; --tv-texto: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	color: var(--car-texto); font-family: var(--tv-texto); font-variant-numeric: tabular-nums;
	display: flex; flex-direction: column; padding: 5vh 4vw; border-radius: 0; line-height: 1.2;
}
.carrera-tv *, .carrera-tv *::before, .carrera-tv *::after { box-sizing: border-box; }
.carrera-tv:fullscreen, .carrera-tv:-webkit-full-screen, .carrera-tv.tv-fs-falso {
	width: 100vw; height: 100vh; min-height: 0; border-radius: 0; cursor: none;
}
.carrera-tv.tv-fs-falso { position: fixed; inset: 0; z-index: 999999; }
.carrera-tv h1, .carrera-tv h2, .carrera-tv h3, .carrera-tv p { color: inherit; margin: 0; }
.carrera-tv .car-ico { width: 1em; height: 1em; flex: 0 0 auto; vertical-align: -.15em; }
.tv-titulo, .tv-centro h2, .tv-lobby-texto, .tv-lobby-lista h2, .tv-ranking h3, .tv-cuenta span, .tv-final-titulo, .tv-ganador, .tv-escalon-nombre, .tv-escalon-bloque span, .tv-carril-num, .tv-num, .tv-figura-nombre { font-family: var(--tv-titulos); }

.tv-cabecera { display: flex; align-items: center; gap: 2vw; margin-bottom: 2vh; }
.tv-logo { height: 9vh; width: auto; max-width: 20vw; object-fit: contain; }
.tv-titulos { flex: 1; min-width: 0; }
.tv-titulo { font-size: clamp(24px, 6vh, 76px); font-weight: 800; line-height: 1; letter-spacing: .02em; text-transform: uppercase; color: var(--car-acento) !important; text-shadow: 0 3px 0 rgba(0,0,0,.35); }
.tv-sub { font-size: clamp(14px, 2.6vh, 32px); opacity: .85; }
.tv-fs { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; background: rgba(0,0,0,.35); color: var(--car-texto); border: 1px solid rgba(255,255,255,.3); border-radius: 10px; padding: 8px 16px; font: 600 15px/1 var(--tv-texto); cursor: pointer; transition: background-color 150ms ease-out; }
.tv-fs:hover { background: rgba(0,0,0,.55); }
.tv-fs:focus-visible { outline: 3px solid var(--car-acento); outline-offset: 3px; }
.carrera-tv:fullscreen .tv-fs, .carrera-tv:-webkit-full-screen .tv-fs { opacity: 0; }
.carrera-tv:fullscreen .tv-fs:hover { opacity: 1; }

.tv-cuerpo { flex: 1; display: flex; min-height: 0; }
.tv-centro { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3vh; text-align: center; }
.tv-centro h2 { font-size: clamp(24px, 6vh, 72px); }

.tv-qr { background: #fff; padding: 1.2vh; border-radius: 14px; width: min(38vh, 80vw); line-height: 0; }
.tv-qr svg { width: 100%; height: auto; display: block; }
.tv-url { font-size: clamp(12px, 2vh, 22px); opacity: .8; word-break: break-all; }

/* Lobby */
.tv-lobby { flex: 1; display: flex; gap: 4vw; align-items: center; }
.tv-lobby-qr { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 2vh; text-align: center; max-width: 45vw; }
.tv-lobby-texto { font-size: clamp(18px, 4vh, 48px); font-weight: 800; max-width: 40vw; }
.tv-lobby-lista { flex: 1; align-self: stretch; display: flex; flex-direction: column; gap: 2vh; min-width: 0; }
.tv-lobby-lista h2 { font-size: clamp(20px, 4.5vh, 54px); display: flex; justify-content: space-between; gap: 1em; }
.tv-lobby-cupos { color: var(--car-acento); }
.tv-premio .car-ico { color: var(--car-acento); }
.tv-premio { display: flex; align-items: center; gap: .5em; font-weight: 700; background: rgba(0,0,0,.3); border-left: 6px solid var(--car-acento); padding: 1.2vh 1.5vw; border-radius: 8px; font-size: clamp(16px, 3vh, 36px); }
.tv-jugadores { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5vh 1.5vw; }
.tv-jugador { display: flex; align-items: center; gap: 1vw; background: rgba(0,0,0,.28); border-radius: 12px; padding: 1.4vh 1vw; border-left: 8px solid var(--c); font-size: clamp(16px, 3.4vh, 42px); font-weight: 700; animation: tv-entra .5s cubic-bezier(.2,1.4,.4,1); }
.tv-jugador .tv-nombre { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv-vacio { grid-column: 1 / -1; opacity: .7; font-size: clamp(16px, 3.4vh, 40px); padding: 2vh 0; }
.tv-num { display: inline-flex; align-items: center; justify-content: center; min-width: 1.6em; height: 1.6em; border-radius: 50%; background: var(--c, #555); color: #fff; font-weight: 900; text-shadow: 0 1px 2px rgba(0,0,0,.5); flex: 0 0 auto; font-size: .9em; }
.tv-mini { font-size: 1.2em; line-height: 1; }
@keyframes tv-entra { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }

/* Pista */
.tv-pista-wrap { flex: 1; display: flex; gap: 1.5vw; min-height: 0; }
.tv-pista { flex: 1; display: flex; flex-direction: column; gap: .6vh; background: var(--car-pista); border-radius: 12px; padding: 1vh .8vw; box-shadow: inset 0 0 0 4px rgba(255,255,255,.15); min-width: 0; }
.tv-carril { position: relative; flex: 1; display: flex; align-items: center; border-bottom: 2px dashed rgba(255,255,255,.25); min-height: 0; }
.tv-carril:last-child { border-bottom: 0; }
.tv-carril-num { flex: 0 0 auto; width: 2.4em; height: 2.4em; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--c); color: #fff; font-weight: 900; font-size: clamp(12px, calc(40vh / var(--n) / 2.4), 30px); text-shadow: 0 1px 2px rgba(0,0,0,.5); margin-right: .8vw; }
.tv-carril-int { position: relative; flex: 1; height: 100%; }
.tv-meta-linea { position: absolute; right: 0; top: 0; bottom: 0; width: 1.4vw; background: repeating-linear-gradient(0deg, #fff 0 8px, #111 8px 16px); opacity: .9; }
.tv-figura { position: absolute; top: 0; left: 0; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; margin-top: 0; will-change: left, transform; }
.tv-figura-caballo { font-size: clamp(18px, calc(40vh / var(--n)), 120px); line-height: 1; filter: drop-shadow(0 4px 0 rgba(0,0,0,.35)); }
.tv-figura-caballo .carrera-caballo-emoji { display: inline-block; transform: scaleX(-1); }
.tv-figura-caballo .carrera-caballo-img { height: 1em; width: auto; display: block; }
/* El nombre no suma ancho a la figura: así todos los caballos quedan alineados aunque los nombres midan distinto. */
.tv-figura-nombre { width: 0; display: flex; justify-content: center; font-size: clamp(10px, calc(14vh / var(--n)), 26px); margin-top: -.15em; }
.tv-figura-nombre > span { font-weight: 800; background: var(--c); color: #fff; padding: 0 .5em; border-radius: 99px; white-space: nowrap; text-shadow: 0 1px 1px rgba(0,0,0,.5); }
.tv-carril.corriendo .tv-figura-caballo { animation: tv-galope .28s ease-in-out infinite alternate; }
.tv-carril.llego .tv-figura-nombre > span { box-shadow: 0 0 0 3px var(--car-acento); }
.tv-carril.desconectado { opacity: .55; }
@keyframes tv-galope { from { transform: translateY(0) rotate(-3deg); } to { transform: translateY(-12%) rotate(3deg); } }

.tv-ranking { flex: 0 0 22vw; max-width: 340px; background: rgba(0,0,0,.3); border-radius: 12px; padding: 1.5vh 1vw; display: flex; flex-direction: column; gap: 1vh; }
.tv-ranking h3 { font-size: clamp(14px, 2.8vh, 32px); color: var(--car-acento); text-transform: uppercase; }
.tv-ranking ol { margin: 0; padding: 0; list-style: none; counter-reset: pos; display: flex; flex-direction: column; gap: .7vh; }
.tv-ranking li { counter-increment: pos; display: flex; align-items: center; gap: .5vw; font-size: clamp(13px, 2.6vh, 30px); font-weight: 700; background: rgba(0,0,0,.25); border-radius: 8px; padding: .6vh .6vw; overflow: hidden; white-space: nowrap; }
.tv-ranking li::before { content: counter(pos) "º"; color: var(--car-acento); min-width: 1.8em; }
.tv-ranking li small { margin-left: auto; opacity: .75; font-weight: 600; }
.tv-ranking .tv-premio { font-size: clamp(12px, 2.2vh, 26px); }
.tv-qr-mini { margin-top: auto; align-self: center; background: #fff; padding: .6vh; border-radius: 8px; width: min(16vh, 100%); line-height: 0; }
.tv-qr-mini svg { width: 100%; height: auto; }

/* Cuenta regresiva y final */
.tv-overlay { position: absolute; inset: 0; pointer-events: none; display: flex; align-items: center; justify-content: center; }
.tv-cuenta { width: 40vh; height: 40vh; border-radius: 50%; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; }
.tv-cuenta span { font-size: 26vh; font-weight: 800; line-height: 1; color: var(--car-acento); text-shadow: 0 6px 0 rgba(0,0,0,.4); }
.tv-ya span { font-size: 14vh; }
.tv-cuenta.pulso, .tv-ya { animation: tv-pulso .6s ease-out; }
@keyframes tv-pulso { from { transform: scale(1.6); opacity: .2; } to { transform: scale(1); opacity: 1; } }

.tv-final { position: absolute; inset: 0; background: rgba(0,0,0,.72); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2vh; text-align: center; animation: tv-aparece .6s ease-out; }
.tv-final-titulo { font-size: clamp(18px, 4vh, 48px); text-transform: uppercase; letter-spacing: .1em; color: var(--car-acento); font-weight: 800; }
.tv-ganador { font-size: clamp(40px, 13vh, 180px); font-weight: 800; line-height: 1; text-transform: uppercase; display: flex; align-items: center; gap: .3em; text-shadow: 0 6px 0 rgba(0,0,0,.4); animation: tv-entra .8s cubic-bezier(.2,1.4,.4,1); }
.tv-ganador.varios { font-size: clamp(28px, 7vh, 96px); flex-wrap: wrap; justify-content: center; gap: .4em .8em; max-width: 92vw; }
.tv-ganador-uno { display: inline-flex; align-items: center; gap: .3em; }
.tv-escalon-premio { font-size: clamp(12px, 2.2vh, 26px); font-weight: 800; background: var(--car-acento); color: #111; border-radius: 99px; padding: .3vh 1vw; margin-bottom: .6vh; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: .3em; }
.tv-escalon-premio .car-ico { width: 1em; height: 1em; color: #111; flex: none; }
.tv-reclamar { font-weight: 700; font-size: clamp(14px, 2.6vh, 32px); background: rgba(0,0,0,.35); border-radius: 8px; padding: 1vh 1.5vw; }
.tv-final .tv-reclamar { margin-top: 1vh; max-width: 90vw; }
.tv-final .tv-premio { border-left: 0; background: var(--car-acento); color: #111; font-weight: 800; }
.tv-final .tv-premio .car-ico { color: #111; }
.tv-podio { display: flex; align-items: flex-end; gap: 1.5vw; margin-top: 2vh; }
.tv-escalon { width: 18vw; max-width: 260px; display: flex; flex-direction: column; align-items: center; }
.tv-escalon.vacio { visibility: hidden; }
.tv-escalon-caballo { font-size: clamp(30px, 9vh, 110px); line-height: 1; }
.tv-escalon-caballo .carrera-caballo-emoji { display: inline-block; transform: scaleX(-1); }
.tv-escalon-caballo .carrera-caballo-img { height: 1em; }
.tv-escalon-nombre { font-size: clamp(14px, 3vh, 36px); font-weight: 800; margin: .5vh 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv-escalon-bloque { width: 100%; background: var(--c); border-radius: 10px 10px 0 0; display: flex; align-items: flex-start; justify-content: center; padding-top: 1vh; box-shadow: inset 0 -8px 0 rgba(0,0,0,.2); }
.tv-escalon-bloque span { font-size: clamp(24px, 6vh, 80px); font-weight: 900; color: #fff; text-shadow: 0 3px 0 rgba(0,0,0,.4); }
.lugar-1 .tv-escalon-bloque { height: 22vh; }
.lugar-2 .tv-escalon-bloque { height: 15vh; }
.lugar-3 .tv-escalon-bloque { height: 10vh; }
@keyframes tv-aparece { from { opacity: 0; } to { opacity: 1; } }

.tv-confeti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.tv-red { position: absolute; bottom: 1.5vh; left: 50%; transform: translateX(-50%); background: #b32d2e; color: #fff; padding: 6px 14px; border-radius: 99px; font-size: 14px; display: none; }
.carrera-tv.sin-red .tv-red { display: block; }

.carrera-no-disponible { padding: 40px 28px; text-align: center; font-size: 20px; font-weight: 700; background: #f6f7f7; border-radius: 0; color: #50575e; }

/* Botón "Iniciar carrera" (solo administradores) y aviso de sonido */
.tv-admin { display: flex; flex-direction: column; gap: 1vh; margin-top: auto; padding-top: 2vh; }
.tv-iniciar { display: flex; align-items: center; justify-content: center; gap: .5em; width: 100%; min-height: 64px; border: 0; border-radius: 12px; cursor: pointer;
	font: 800 clamp(20px, 3.6vh, 40px)/1 var(--tv-titulos); letter-spacing: .03em; text-transform: uppercase;
	background: var(--car-acento); color: #111; box-shadow: 0 5px 0 rgba(0,0,0,.35); transition: filter 150ms ease-out, box-shadow 150ms ease-out; }
.tv-iniciar:hover:not([disabled]) { filter: brightness(1.06); }
.tv-iniciar:active:not([disabled]) { box-shadow: 0 1px 0 rgba(0,0,0,.35); }
.tv-iniciar:focus-visible { outline: 3px solid var(--car-texto); outline-offset: 3px; }
.tv-iniciar[disabled] { cursor: not-allowed; background: rgba(255,255,255,.18); color: rgba(255,255,255,.75); box-shadow: none; font-size: clamp(16px, 2.6vh, 28px); }
.tv-admin small { font-size: clamp(12px, 1.8vh, 18px); opacity: .75; text-align: center; }
.tv-admin .tv-error { color: #fff; background: #c0392b; padding: .6vh 1vw; border-radius: 8px; font-weight: 600; }
.carrera-tv.tv-es-admin:fullscreen, .carrera-tv.tv-es-admin:-webkit-full-screen, .carrera-tv.tv-es-admin.tv-fs-falso { cursor: auto; }
.tv-sonido { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 16px; border-radius: 10px;
	border: 1px solid rgba(255,255,255,.3); background: rgba(0,0,0,.45); color: var(--car-texto); font: 600 15px/1 var(--tv-texto); cursor: pointer; }
.tv-sonido[hidden] { display: none; }
.tv-sonido:focus-visible { outline: 3px solid var(--car-acento); outline-offset: 3px; }

@media (max-width: 700px) {
	.tv-lobby, .tv-pista-wrap { flex-direction: column; }
	.tv-lobby-texto, .tv-lobby-qr { max-width: none; }
	.tv-ranking { flex: none; max-width: none; }
	.tv-jugadores { grid-template-columns: 1fr; }
	.tv-qr-mini { display: none; }
}
@media (prefers-reduced-motion: reduce) {
	.tv-carril.corriendo .tv-figura-caballo, .tv-jugador, .tv-ganador, .tv-cuenta.pulso, .tv-ya, .tv-final { animation: none; }
	.tv-fs { transition: none; }
}

/* Colores propios: la TV no depende del tema. */
.carrera-tv { background-color: var(--car-fondo) !important; color: var(--car-texto) !important; }
.carrera-tv h1, .carrera-tv h2, .carrera-tv h3 { background: none; border: 0; padding: 0; }
.carrera-tv a { color: var(--car-texto) !important; }
