:root {
    --bg-dark: #09090b;
    --primary: #ef4444;
    --primary-glow: rgba(239, 68, 68, 0.4);
    --secondary: #18181b;
    --glass-bg: rgba(24, 24, 27, 0.6);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
}

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

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    overflow-x: hidden;
    overflow-y: auto;
    min-height: 100vh;
    min-height: 100dvh;
    touch-action: manipulation;
    display: flex;
    flex-direction: column;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at top, rgba(239, 68, 68, 0.15) 0%, rgba(9, 9, 11, 1) 70%);
    z-index: -1;
}

.header {
    position: relative;
    width: 100%;
    padding: 15px 5%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1000;
    flex-shrink: 0;
}

.header-logo {
    font-family: 'Outfit', sans-serif;
    font-size: clamp(1.2rem, 3vw, 1.6rem);
    font-weight: 800;
    color: var(--primary);
    margin: 0;
    letter-spacing: 2px;
}

.header-links-container {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.header-link {
    color: var(--text-muted);
    text-decoration: none;
    font-family: 'Inter', sans-serif;
    font-size: clamp(0.7rem, 1.5vw, 0.9rem);
    font-weight: 500;
    transition: all 0.3s ease;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.header-link:hover {
    color: var(--text-main);
}

.header-logout {
    background: transparent;
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid var(--primary);
    color: var(--primary);
    display: none;
}

.header-logout:hover {
    background: var(--primary-glow);
    color: white;
}

.header-logout.activo {
    display: inline-block;
}

.btn-mute {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 5px;
    transition: color 0.3s;
}

.btn-mute:hover {
    color: var(--text-main);
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 5%;
    gap: clamp(15px, 4vh, 60px);
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.premio-pantalla {
    color: #facc15;
    font-family: 'Outfit', sans-serif;
    font-size: clamp(1rem, 3vw, 1.8rem);
    font-weight: 800;
    letter-spacing: 2px;
    text-align: center;
    text-transform: uppercase;
    text-shadow: 0 0 15px rgba(250, 204, 21, 0.4);
    word-break: break-word;
    padding: 0 10px;
    line-height: 1.2;
}

.tiempo-pantalla {
    color: var(--text-main);
    font-family: 'Outfit', sans-serif;
    font-size: clamp(1.2rem, 4vw, 2.5rem);
    font-weight: 700;
    letter-spacing: 2px;
    text-align: center;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: clamp(8px, 2vh, 12px) clamp(20px, 4vw, 30px);
    border-radius: 100px;
    border: 1px solid var(--glass-border);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    width: 100%;
    max-width: max-content;
}

.bloque-destacado {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 700px;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: clamp(15px, 4vh, 40px) 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.bloque-destacado::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
    opacity: 0.5;
}

.palabra-actual {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    color: var(--text-main);
    font-size: clamp(1.8rem, 6vw, 4.5rem);
    text-align: center;
    word-break: break-all;
    line-height: 1.1;
    text-transform: uppercase;
    text-shadow: 0 0 20px rgba(239, 68, 68, 0.2);
    margin: clamp(15px, 3vh, 30px) 0;
    transition: color 0.3s ease, text-shadow 0.3s ease;
}

.palabra-dorada {
    color: #facc15 !important;
    text-shadow: 0 0 30px rgba(250, 204, 21, 0.5) !important;
}

hr {
    width: 40px;
    border: none;
    border-top: 2px solid var(--glass-border);
    margin: 0;
}

.tiempo-supervivencia {
    font-family: 'Inter', sans-serif;
    color: var(--primary);
    font-size: clamp(0.85rem, 2vw, 1rem);
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
    text-align: center;
}

.form-palabra {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 600px;
    gap: clamp(10px, 2vh, 20px);
    flex-shrink: 0;
}

.form-palabra input {
    width: 100%;
    height: clamp(50px, 7vh, 70px);
    text-align: center;
    font-size: clamp(1.1rem, 3vw, 1.5rem);
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    color: var(--text-main);
    background-color: var(--secondary);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    outline: none;
    transition: all 0.3s ease;
    letter-spacing: 1px;
}

.form-palabra input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 15px var(--primary-glow);
}

.form-palabra button {
    width: 100%;
    height: clamp(50px, 7vh, 70px);
    border-radius: 16px;
    color: white;
    background: var(--primary);
    font-size: clamp(1.1rem, 2.5vw, 1.2rem);
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    border: none;
    outline: none;
    transition: all 0.3s ease;
    cursor: pointer;
    letter-spacing: 1px;
}

.form-palabra button:hover:not(:disabled) {
    background: #dc2626;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(239, 68, 68, 0.4);
}

.btn-cooldown {
    position: relative;
    overflow: hidden;
    color: #f8fafc !important;
    background: #18181b !important;
    border: 1px solid var(--glass-border);
    box-shadow: none !important;
    transform: none !important;
    cursor: not-allowed;
}

.btn-cooldown span {
    position: relative;
    z-index: 2;
}

.btn-cooldown::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background-color: rgba(239, 68, 68, 0.3);
    width: 0%;
    z-index: 1;
    animation: fillBar 5s linear forwards;
}

@keyframes fillBar {
    from {
        width: 0%;
    }

    to {
        width: 100%;
    }
}

.grupo-botones {
    display: flex;
    gap: 15px;
    flex-shrink: 0;
}

.btn-trofeo {
    width: clamp(45px, 8vw, 56px);
    height: clamp(45px, 8vw, 56px);
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
}

.btn-trofeo:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-3px);
}

.icono-trofeo {
    width: 24px;
    height: 24px;
    stroke: var(--primary);
    transition: transform 0.3s ease;
}

.banner-patrocinador {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: clamp(250px, 20vw, 400px);
    border-radius: 16px;
    overflow: hidden;
    display: block;
    border: 1px solid var(--glass-border);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    z-index: 100;
    background: black;
}

.banner-patrocinador iframe {
    width: 100%;
    aspect-ratio: 16/9;
    border: none;
    display: block;
}

.banner-patrocinador.izq {
    left: 2%;
}

.banner-patrocinador.der {
    right: 2%;
}

.banner-patrocinador:hover {
    transform: translateY(-50%) scale(1.03);
    box-shadow: 0 15px 40px rgba(239, 68, 68, 0.3);
    border-color: var(--primary);
}

.banner-patrocinador img,
.banner-patrocinador video,
.banner-patrocinador iframe {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
    padding: 20px;
}

.modal-overlay.activo {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    background: rgba(24, 24, 27, 0.9);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: clamp(20px, 4vh, 40px) clamp(15px, 4vw, 30px);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    transform: translateY(30px) scale(0.95);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-content::-webkit-scrollbar {
    width: 6px;
}

.modal-content::-webkit-scrollbar-track {
    background: transparent;
}

.modal-content::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 10px;
}

.modal-overlay.activo .modal-content {
    transform: translateY(0) scale(1);
}

.btn-cerrar {
    position: absolute;
    top: 15px;
    right: 20px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.3s ease;
    padding: 5px;
    z-index: 10;
}

.btn-cerrar:hover {
    color: white;
}

.modal-content h3 {
    margin-top: 0;
    margin-bottom: 20px;
    font-family: 'Outfit', sans-serif;
    font-size: clamp(1.4rem, 4vw, 1.8rem);
    color: var(--primary);
    letter-spacing: 1px;
}

.leaderboard-scroll {
    width: 100%;
    max-height: 50vh;
    overflow-y: auto;
    padding-right: 10px;
}

.fila {
    display: flex;
    justify-content: space-between;
    padding: 12px 10px;
    border-bottom: 1px solid var(--glass-border);
    font-family: 'Inter', sans-serif;
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    color: var(--text-main);
}

.fila:last-child {
    border-bottom: none;
}

.leaderboard-scroll::-webkit-scrollbar {
    width: 6px;
}

.leaderboard-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.leaderboard-scroll::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 10px;
}

.auth-subtitulo {
    font-family: 'Inter', sans-serif;
    font-size: clamp(0.85rem, 2.5vw, 1rem);
    margin-bottom: 20px;
    color: var(--text-muted);
}

.form-auth {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.form-auth input {
    width: 100%;
    height: 50px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: var(--secondary);
    color: white;
    text-align: center;
    font-family: 'Inter', sans-serif;
    font-size: 1.1rem;
    outline: none;
    transition: all 0.3s ease;
}

.form-auth input:focus {
    border-color: var(--primary);
}

.form-auth button {
    height: 50px;
    border-radius: 12px;
    border: none;
    background: var(--primary);
    color: white;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 5px;
}

.form-auth button:hover {
    background: #dc2626;
    transform: translateY(-2px);
}

.auth-error {
    color: #fca5a5;
    font-family: 'Inter', sans-serif;
    margin-top: 15px;
    font-size: 0.9rem;
    min-height: 1.5rem;
}

#toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    z-index: 10000;
    pointer-events: none;
    width: 90%;
    max-width: 400px;
}

.toast {
    background: rgba(24, 24, 27, 0.95);
    backdrop-filter: blur(10px);
    border-left: 4px solid var(--primary);
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    animation: slideDown 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    width: 100%;
    text-align: center;
}

.toast.fade-out {
    animation: slideUp 0.4s ease forwards;
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(0);
        opacity: 1;
    }

    to {
        transform: translateY(-50px);
        opacity: 0;
    }
}

.battle-feed {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 300px;
    max-width: 80vw;
    display: flex;
    flex-direction: column-reverse;
    gap: 10px;
    z-index: 900;
    pointer-events: none;
}

.feed-item {
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    border-left: 3px solid var(--primary);
    color: var(--text-main);
    padding: 10px 15px;
    border-radius: 0 8px 8px 0;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    animation: slideInLeft 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.feed-item span {
    color: #facc15;
    font-weight: bold;
    font-family: 'Outfit', sans-serif;
}

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes shake {
    0% {
        transform: translate(1px, 1px) rotate(0deg);
    }

    10% {
        transform: translate(-1px, -2px) rotate(-1deg);
    }

    20% {
        transform: translate(-3px, 0px) rotate(1deg);
    }

    30% {
        transform: translate(3px, 2px) rotate(0deg);
    }

    40% {
        transform: translate(1px, -1px) rotate(1deg);
    }

    50% {
        transform: translate(-1px, 2px) rotate(-1deg);
    }

    60% {
        transform: translate(-3px, 1px) rotate(0deg);
    }

    70% {
        transform: translate(3px, 1px) rotate(-1deg);
    }

    80% {
        transform: translate(-1px, -1px) rotate(1deg);
    }

    90% {
        transform: translate(1px, 2px) rotate(0deg);
    }

    100% {
        transform: translate(1px, -2px) rotate(-1deg);
    }
}

.shake {
    animation: shake 0.4s;
}

@media (max-height: 800px) and (min-width: 1024px) {
    .header {
        padding: 10px 5%;
    }

    .main-content {
        gap: 15px;
    }

    .tiempo-pantalla {
        font-size: 1.5rem;
        padding: 8px 20px;
    }

    .bloque-destacado {
        padding: 15px 20px;
    }

    .palabra-actual {
        margin: 10px 0;
        font-size: 3rem;
    }

    .form-palabra {
        gap: 10px;
    }

    .form-palabra input,
    .form-palabra button {
        height: 50px;
    }
}

@media (max-width: 1200px) {
    .banners-mobile-container {
        display: flex !important;
        flex-direction: column;
        gap: 20px;
        width: 100%;
        max-width: 90%;
        margin: 0 auto;
    }

    .banner-patrocinador {
        position: static;
        transform: none;
        width: 100%;
        max-width: 800px;
        margin: 0 auto;
    }

    .banner-patrocinador.der {
        display: none !important;
    }

    .banner-patrocinador:hover {
        transform: translateY(-5px);
    }
}
/* --- OPTIMIZACIÓN EXTREMA PARA MÓVILES (LIMPIEZA VISUAL) --- */
@media (max-width: 600px) {
    body {
        overflow-y: auto;
    }

    /* 1. Header más discreto */
    .header {
        flex-direction: row; /* Volvemos a fila para ahorrar espacio vertical */
        padding: 10px 4%;
        justify-content: space-between;
    }

    .header-logo {
        font-size: 1.1rem;
    }

    .header-links-container {
        gap: 8px;
    }

    .header-link {
        font-size: 0.65rem;
    }

    /* 2. Contenido principal con menos aire (espacios) */
    .main-content {
        padding: 5px 4%;
        gap: 15px; /* Reducimos la separación entre elementos */
        justify-content: flex-start;
    }

    /* 3. Cronómetro y Rey más integrados */
    .premio-pantalla {
        font-size: 0.9rem;
        margin-bottom: -5px;
    }

    .tiempo-pantalla {
        font-size: 1.2rem;
        padding: 6px 15px;
        border-radius: 50px;
    }

    /* 4. EL MURO: El protagonista debe respirar */
    .bloque-destacado {
        padding: 20px 10px;
        border-radius: 16px;
        border-width: 1px;
    }

    .palabra-actual {
        font-size: 2.2rem; /* Tamaño ideal para no romper líneas */
        margin: 15px 0;
    }

    /* 5. Inputs y botones más delgados */
    .form-palabra input, 
    .form-palabra button {
        height: 55px;
        font-size: 1rem;
        border-radius: 12px;
    }

    /* 6. OCULTAR ELEMENTOS QUE SATURAN */
    .battle-feed {
        display: none !important; /* En móvil estorba demasiado */
    }

    .banners-mobile-container {
        margin-top: 10px;
        width: 100%;
    }

    .banner-patrocinador {
        max-width: 100%;
        min-height: 100px;
    }

    /* 7. Ajuste de modales para que el teclado no los tape */
    .modal-content {
        padding: 20px;
        width: 95%;
    }
}

/* PANTALLAS MUY PEQUEÑAS (iPhone SE, etc) */
@media (max-height: 670px) and (max-width: 600px) {
    .palabra-actual {
        font-size: 1.8rem;
        margin: 10px 0;
    }
    .main-content {
        gap: 10px;
    }
    .header {
        padding: 5px 4%;
    }
}
/* --- ESTILOS DEL TUTORIAL (DRIVER.JS CUSTOM) --- */
.driverjs-theme {
    background-color: #18181b !important;
    color: #f8fafc !important;
    border: 1px solid var(--glass-border) !important;
    border-top: 3px solid #ef4444 !important;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8) !important;
    border-radius: 16px !important;
    font-family: 'Inter', sans-serif !important;
}
.driverjs-theme .driver-popover-title {
    color: #facc15 !important;
    font-family: 'Outfit', sans-serif !important;
    font-size: 1.2rem !important;
    font-weight: bold !important;
}
.driverjs-theme .driver-popover-description { color: #94a3b8 !important; }
.driverjs-theme button {
    background-color: #ef4444 !important;
    color: white !important;
    text-shadow: none !important;
    border-radius: 8px !important;
    border: none !important;
    font-family: 'Outfit', sans-serif !important;
    font-weight: bold !important;
    text-transform: uppercase;
}
.driverjs-theme button:hover { background-color: #dc2626 !important; }
.driverjs-theme .driver-popover-close-btn { color: #94a3b8 !important; background: transparent !important; }
.driverjs-theme .driver-popover-close-btn:hover { color: white !important; }

/* Evitar que se pueda cerrar el Modal Auth pulsando fuera o en la X */
#modalAuth .btn-cerrar {
    display: none;
}