/* style.css - Estilos Premium para el Minijuego Mundialista (Paleta de Marca) */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;800&display=swap');

:root {
    --bg-color: #fff8ea;
    /* Crema/arena claro */
    --card-bg: rgba(255, 255, 255, 0.75);
    /* Tarjetas blancas semi-transparentes */
    --card-border: rgba(96, 134, 80, 0.2);
    /* Borde verde suave */
    --primary-color: #c9bc48;
    /* Botón amarillo/dorado marca */
    --primary-gradient: linear-gradient(135deg, #c9bc48 0%, #ab9f35 100%);
    --gold-color: #c9bc48;
    --gold-gradient: linear-gradient(135deg, #f0e26b 0%, #c9bc48 100%);
    --silver-gradient: linear-gradient(135deg, #e6eee2 0%, #b0bea9 100%);
    --bronze-gradient: linear-gradient(135deg, #f7ebd9 0%, #d8c2a3 100%);
    --danger-color: #c0392b;
    /* Rojo oscuro para atajadas/afuera */
    --text-color: #608650;
    /* Texto verde bosque marca */
    --text-muted: #7ca36b;
    /* Verde más suave */
    --accent-color: #c9bc48;
    --shadow-color: rgba(96, 134, 80, 0.12);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* --- BANNER BLOQUEO ESCRITORIO --- */
#desktop-blocker {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100vw;
    height: 100vh;
    background: var(--bg-color);
    z-index: 1000;
    position: absolute;
    top: 0;
    left: 0;
    text-align: center;
    padding: 2rem;
}

#desktop-blocker h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 1rem;
    background: linear-gradient(to right, #608650, #c9bc48);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 2px 10px rgba(96, 134, 80, 0.08);
}

#desktop-blocker p {
    color: var(--text-muted);
    font-size: 1.1rem;
    max-width: 400px;
    margin-bottom: 2rem;
    line-height: 1.5;
}

.qr-container {
    background: white;
    padding: 1.5rem;
    border-radius: 1.5rem;
    box-shadow: 0 10px 30px var(--shadow-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 3px solid var(--primary-color);
}

.qr-container img {
    width: 180px;
    height: 180px;
    margin-bottom: 1rem;
}

.qr-container span {
    color: var(--text-color);
    font-weight: 600;
    font-size: 0.9rem;
}

/* --- CONTENEDOR PRINCIPAL SPA (MÓVIL) --- */
#app-container {
    width: 100%;
    height: 100%;
    max-width: 480px;
    /* Tamaño máximo de celular */
    background: var(--bg-color);
    position: relative;
    box-shadow: 0 10px 40px var(--shadow-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* --- PANTALLAS --- */
.screen {
    width: 100%;
    height: 100%;
    display: none;
    /* Se activa con flex */
    flex-direction: column;
    padding: 2rem;
    overflow-y: auto;
    animation: fadeIn 0.4s ease;
}

.screen.active-screen {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

/* Glassmorphism Cards (Estilo Claro) */
.glass-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 1.5rem;
    padding: 2rem 1.5rem;
    width: 100%;
    box-shadow: 0 8px 32px 0 var(--shadow-color);
}

/* --- LOGO Y TÍTULOS --- */
.header-area {
    text-align: center;
    margin-bottom: 2rem;
    margin-top: 1rem;
}

.header-area h1 {
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    text-shadow: 0 2px 10px rgba(96, 134, 80, 0.08);
    background: linear-gradient(135deg, #608650 0%, #c9bc48 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-area .badge {
    background: var(--primary-gradient);
    color: var(--bg-color);
    padding: 0.3rem 0.8rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: inline-block;
    margin-bottom: 0.5rem;
    box-shadow: 0 3px 10px rgba(201, 188, 72, 0.2);
}

/* --- FORMULARIO DE INICIO --- */
.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-field {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--card-border);
    border-radius: 1rem;
    padding: 1rem;
    font-size: 1.1rem;
    color: var(--text-color);
    outline: none;
    transition: all 0.3s ease;
}

.input-field:focus {
    border-color: var(--primary-color);
    background: #ffffff;
    box-shadow: 0 0 15px rgba(201, 188, 72, 0.15);
}

/* BOTONES PREMIUM (Paleta de Marca) */
.btn {
    padding: 1rem;
    border-radius: 1rem;
    border: none;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary-gradient);
    color: #ffffff;
    /* Letras blancas para contraste limpio */
    box-shadow: 0 5px 15px rgba(201, 188, 72, 0.3);
}

.btn-primary:active {
    transform: scale(0.97);
    box-shadow: 0 2px 5px rgba(201, 188, 72, 0.2);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid var(--card-border);
    color: var(--text-color);
    box-shadow: 0 3px 10px rgba(96, 134, 80, 0.05);
}

.btn-secondary:active {
    transform: scale(0.97);
    background: #ffffff;
}

/* Reglas o Descripción en Inicio */
.instructions-card {
    margin-top: 1.5rem;
    background: rgba(96, 134, 80, 0.06);
    border: 1px dashed rgba(96, 134, 80, 0.25);
    border-radius: 1rem;
    padding: 1rem;
}

.instructions-card h3 {
    font-size: 0.95rem;
    color: var(--text-color);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.instructions-card ul {
    list-style-type: none;
}

.instructions-card li {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* --- PANTALLA DE JUEGO --- */
#screen-game {
    padding: 0;
    position: relative;
    overflow: hidden;
}

.game-hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    background: linear-gradient(180deg, rgba(255, 248, 234, 0.95) 0%, rgba(255, 248, 234, 0) 100%);
}

.hud-player {
    display: flex;
    flex-direction: column;
}

.hud-player .player-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-color);
    max-width: 120px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hud-player .player-record {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.hud-score-container {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border-radius: 1rem;
    padding: 0.4rem 1.2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 4px 15px rgba(96, 134, 80, 0.08);
}

.hud-score-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 1px;
}

.hud-score-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-color);
}

.btn-exit {
    background: rgba(192, 57, 43, 0.12);
    border: 1px solid rgba(192, 57, 43, 0.25);
    color: var(--danger-color);
    padding: 0.5rem;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-exit:active {
    transform: scale(0.92);
}

#canvas-container {
    width: 100%;
    height: 100%;
    position: relative;
}

#game-canvas {
    width: 100%;
    height: 100%;
    background-color: #8bc34a;
    display: block;
    touch-action: none;
}

/* Indicador de Deslizamiento (Instrucciones Flotantes Blancas) */
.swipe-tutorial {
    position: absolute;
    bottom: 120px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #ffffff !important;
    opacity: 0.9;
    pointer-events: none;
    animation: bounceTutorial 2s infinite ease-in-out;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8), 0 0 4px rgba(0, 0, 0, 0.5);
}

.swipe-hand {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.swipe-text {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    font-weight: 800;
    color: #ffffff !important;
}

@keyframes bounceTutorial {
    0%,
    100% {
        transform: translate(-50%, 0);
        opacity: 0.6;
    }

    50% {
        transform: translate(-50%, -20px);
        opacity: 1.0;
    }
}

/* --- OVERLAY DE JUEGO TERMINADO --- */
#game-over-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 248, 234, 0.92);
    /* Fondo crema suave */
    z-index: 100;
    display: none;
    /* Se activa con flex */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    animation: fadeIn 0.3s ease;
}

#game-over-overlay.active {
    display: flex;
}

.game-over-card {
    text-align: center;
    width: 100%;
    max-width: 320px;
    background: #ffffff !important;
    border: 1px solid var(--card-border);
    box-shadow: 0 10px 40px rgba(96, 134, 80, 0.15) !important;
}

.game-over-title {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--danger-color);
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 10px rgba(192, 57, 43, 0.15);
}

.game-over-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 2rem;
}

.game-over-stats {
    background: rgba(96, 134, 80, 0.05);
    border: 1px solid var(--card-border);
    border-radius: 1.2rem;
    padding: 1.5rem;
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-color);
}

.stat-value.highlight {
    color: var(--gold-color);
    text-shadow: 0 2px 5px rgba(201, 188, 72, 0.2);
}

.record-alert {
    background: rgba(201, 188, 72, 0.12);
    border: 1px solid var(--primary-color);
    color: var(--text-color);
    padding: 0.5rem 1rem;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-top: -1rem;
    margin-bottom: 1.5rem;
    display: none;
    animation: pulseBorder 1.5s infinite;
}

@keyframes pulseBorder {

    0%,
    100% {
        box-shadow: 0 0 5px rgba(201, 188, 72, 0.2);
    }

    50% {
        box-shadow: 0 0 15px rgba(201, 188, 72, 0.4);
    }
}

.game-over-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* --- TABLA DE POSICIONES (LEADERBOARD) --- */
#screen-leaderboard {
    padding: 1.5rem;
}

.leaderboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.leaderboard-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.leaderboard-title h2 {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-color);
}

/* Badge "EN VIVO" Verde-Amarillo */
.live-badge {
    background: rgba(96, 134, 80, 0.1);
    border: 1px solid var(--text-color);
    color: var(--text-color);
    padding: 0.25rem 0.6rem;
    border-radius: 50px;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.live-dot {
    width: 6px;
    height: 6px;
    background-color: var(--text-color);
    border-radius: 50%;
    display: inline-block;
    animation: flashDot 1s infinite alternate;
}

@keyframes flashDot {
    from {
        opacity: 0.2;
    }

    to {
        opacity: 1;
    }
}

/* EL PODIO (TOP 3) */
.podium-container {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 0.6rem;
    height: 180px;
    margin-bottom: 2rem;
    padding-bottom: 0.5rem;
}

.podium-step {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    border-radius: 1rem 1rem 0.5rem 0.5rem;
    transition: all 0.3s ease;
}

.podium-step.first {
    height: 100%;
    background: var(--gold-gradient);
    z-index: 2;
    box-shadow: 0 8px 25px rgba(201, 188, 72, 0.3);
    border: 2px solid var(--primary-color);
}

.podium-step.second {
    height: 75%;
    background: var(--silver-gradient);
    z-index: 1;
    box-shadow: 0 5px 15px rgba(96, 134, 80, 0.06);
    border: 1px solid rgba(96, 134, 80, 0.15);
}

.podium-step.third {
    height: 60%;
    background: var(--bronze-gradient);
    z-index: 1;
    box-shadow: 0 5px 15px rgba(96, 134, 80, 0.05);
    border: 1px solid rgba(96, 134, 80, 0.12);
}

.podium-avatar {
    position: absolute;
    top: -50px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #fff8ea;
    border: 2px solid var(--text-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text-color);
    box-shadow: 0 4px 10px rgba(96, 134, 80, 0.15);
}

.podium-step.first .podium-avatar {
    width: 52px;
    height: 52px;
    top: -60px;
    border-color: var(--text-color);
    font-size: 1.5rem;
    background: #fff8ea;
    box-shadow: 0 0 15px rgba(201, 188, 72, 0.4);
}

.crown {
    position: absolute;
    top: -85px;
    font-size: 1.5rem;
    animation: floatCrown 2s infinite ease-in-out;
}

@keyframes floatCrown {

    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }

    50% {
        transform: translateY(-5px) rotate(3deg);
    }
}

.podium-info {
    width: 100%;
    text-align: center;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100%;
    color: #2e3d26;
    /* Contraste verde oscuro para legibilidad */
}

.podium-name {
    font-size: 0.8rem;
    font-weight: 800;
    max-width: 95%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.2rem;
}

.podium-step.first .podium-name {
    font-size: 0.95rem;
}

.podium-score {
    font-size: 1.1rem;
    font-weight: 800;
}

.podium-number {
    position: absolute;
    bottom: 5px;
    font-size: 2.2rem;
    font-weight: 900;
    opacity: 0.12;
    color: var(--text-color);
}

/* LA TABLA PARA EL RESTO (TOP 4 y 5) */
.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-bottom: 1.5rem;
}

.leaderboard-row {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid var(--card-border);
    border-radius: 1rem;
    padding: 0.9rem 1.2rem;
    display: flex;
    align-items: center;
    transition: all 0.3s ease;
    box-shadow: 0 3px 10px rgba(96, 134, 80, 0.03);
}

.leaderboard-row:hover {
    background: #ffffff;
    border-color: rgba(96, 134, 80, 0.35);
}

.leaderboard-rank {
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--text-muted);
    width: 30px;
}

.leaderboard-row-name {
    font-weight: 600;
    color: var(--text-color);
    flex-grow: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 1rem;
}

.leaderboard-row-score {
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--primary-color);
}

.empty-leaderboard {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem 0;
    font-size: 0.95rem;
}

/* MODO PANTALLA COMPLETA LEADERBOARD (para TV/pantalla externa) */
.full-screen-leaderboard {
    width: 100vw !important;
    height: 100vh !important;
    max-width: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
    padding: 3rem 5rem !important;
    box-shadow: none !important;
    border: none !important;
    background: var(--bg-color) !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
}

.full-screen-leaderboard .podium-container {
    height: 250px;
    margin-bottom: 3rem;
}

.full-screen-leaderboard .podium-avatar {
    width: 60px;
    height: 60px;
    top: -70px;
    font-size: 1.6rem;
}

.full-screen-leaderboard .podium-step.first .podium-avatar {
    width: 75px;
    height: 75px;
    top: -85px;
    font-size: 2rem;
}

.full-screen-leaderboard .crown {
    top: -120px;
    font-size: 2.2rem;
}

.full-screen-leaderboard .podium-name {
    font-size: 1.1rem;
}

.full-screen-leaderboard .podium-step.first .podium-name {
    font-size: 1.3rem;
}

.full-screen-leaderboard .podium-score {
    font-size: 1.5rem;
}

.full-screen-leaderboard .leaderboard-row {
    padding: 1.2rem 2rem;
}

.full-screen-leaderboard .leaderboard-row-name {
    font-size: 1.2rem;
}

.full-screen-leaderboard .leaderboard-row-score {
    font-size: 1.5rem;
}

/* --- RESPONSIVIDAD Y MEDIA QUERIES --- */
@media (min-width: 481px) {
    body:not(.tv-leaderboard-view) #desktop-blocker {
        display: flex;
    }

    body:not(.tv-leaderboard-view) #app-container {
        display: none;
    }
}

body.tv-leaderboard-view #app-container {
    max-width: 800px;
    height: 90vh;
    border-radius: 2rem;
    border: 2px solid var(--card-border);
    box-shadow: 0 20px 50px rgba(96, 134, 80, 0.15);
}

body.tv-leaderboard-view #desktop-blocker {
    display: none !important;
}

.canvas-msg-popup {
    position: absolute;
    top: 35%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.5);
    font-size: 3rem;
    font-weight: 900;
    text-transform: uppercase;
    pointer-events: none;
    z-index: 50;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.canvas-msg-popup.active {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

.canvas-msg-popup.goal {
    color: var(--primary-color);
    text-shadow: 0 0 20px rgba(201, 188, 72, 0.6), 0 0 40px rgba(201, 188, 72, 0.4);
}

.canvas-msg-popup.save {
    color: var(--danger-color);
    text-shadow: 0 0 20px rgba(192, 57, 43, 0.6), 0 0 40px rgba(192, 57, 43, 0.4);
}