/* Variable y Colores Modernos para la Óptica */
:root {
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    --card-bg: rgba(30, 41, 59, 0.7);
    --card-border: rgba(255, 255, 255, 0.08);
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --accent: #06b6d4;
    --accent-glow: rgba(6, 182, 212, 0.3);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --success: #10b981;
    --danger: #ef4444;
    --font-family: 'Outfit', sans-serif;
    --board-size: 600px;
}

/* Reset y Estilos Globales */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: var(--bg-gradient);
    color: var(--text-main);
    font-family: var(--font-family);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    padding: 2rem 1rem;
}

/* Contenedor de la Aplicación */
.app-container {
    width: 100%;
    max-width: 900px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

/* Encabezado */
.main-header {
    text-align: center;
    animation: fadeIn 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}

.logo .icon-glasses {
    font-size: 1.75rem;
    filter: drop-shadow(0 0 8px var(--accent-glow));
}

.logo .accent-text {
    color: var(--accent);
    text-shadow: 0 0 12px var(--accent-glow);
}

.main-header h1 {
    font-size: 2.25rem;
    font-weight: 800;
    background: linear-gradient(to right, #ffffff, #93c5fd);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.25rem;
}

.main-header .tagline {
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 300;
}

/* Contenedor del Juego y Escenas */
.game-wrapper {
    position: relative;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    perspective: 1000px;
}

/* Tarjetas de Efecto Glassmorphism */
.card.glass {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    padding: 2.5rem;
    width: 100%;
    max-width: 550px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.card.glass h2 {
    font-size: 1.75rem;
    font-weight: 600;
}

.card.glass p {
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1.6;
}

/* Instrucciones */
.instructions {
    text-align: left;
    background: rgba(15, 23, 42, 0.4);
    border-radius: 16px;
    padding: 1.25rem;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.instructions h3 {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    color: var(--accent);
}

.instructions ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.instructions li {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    font-size: 0.95rem;
    line-height: 1.4;
    color: var(--text-main);
}

.instructions .step-num {
    background: var(--primary);
    color: white;
    font-size: 0.8rem;
    font-weight: 800;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}

/* Botones Premium */
.btn {
    font-family: var(--font-family);
    font-size: 1.05rem;
    font-weight: 600;
    padding: 0.85rem 2rem;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.6);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.icon-arrow {
    transition: transform 0.3s ease;
}

.btn-primary:hover .icon-arrow {
    transform: translateX(4px);
}

/* Escenas */
.scene {
    display: none;
}

.scene.active {
    display: flex;
    animation: scaleIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Contenedor del Tablero de Juego */
.game-board-container {
    position: relative;
    width: var(--board-size);
    height: var(--board-size);
    border-radius: 28px;
    overflow: hidden;
    border: 4px solid var(--card-border);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    background: #000;
    display: none; /* Se activa desde JS */
}

.game-board-container.active {
    display: block;
    animation: scaleIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* El Tablero del Burro */
.game-board {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    transition: filter 1s ease-in-out;
}

/* Desenfoque cuando está vendado */
.game-board.blurred {
    filter: blur(16px) contrast(0.9) brightness(0.9);
}

.donkey-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    user-select: none;
    -webkit-user-drag: none;
}

/* Elemento Contenedor de las Gafas */
.glasses-wrapper {
    position: absolute;
    width: 180px;  /* Ajustado para calzar con la cara del burro */
    height: 120px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none; /* Para no interferir con clicks en el tablero */
    z-index: 10;
}

/* Las gafas como canvas o imagen */
.glasses-wrapper canvas {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 8px 16px rgba(0,0,0,0.5));
    transition: transform 0.05s ease-out; /* Suavidad en el movimiento */
}

/* Marcador del centro real (Objetivo) */
.target-center-marker {
    position: absolute;
    width: 24px;
    height: 24px;
    border: 3px solid var(--success);
    background: rgba(16, 185, 129, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    z-index: 9;
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
}

.target-center-marker::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 6px;
    height: 6px;
    background: var(--success);
    border-radius: 50%;
}

.target-center-marker.visible {
    opacity: 1;
    animation: pulseMarker 1.5s infinite;
}

/* Efecto de Venda Física (Overlay) */
.blindfold-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 20;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
    transition: opacity 0.5s ease-in-out;
}

/* Animación de la tela de la venda */
.blindfold-fabric {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(15, 23, 42, 0.85) 0%, rgba(3, 7, 18, 0.98) 100%);
    transform: translateY(-100%);
    transition: transform 0.8s cubic-bezier(0.77, 0, 0.175, 1);
}

.blindfold-overlay.applied .blindfold-fabric {
    transform: translateY(0);
}

/* Contenido de la Venda (Texto e Instrucción) */
.blindfold-content {
    position: relative;
    z-index: 21;
    text-align: center;
    padding: 2rem;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.5s ease 0.4s;
    max-width: 80%;
}

.blindfold-overlay.applied .blindfold-content {
    opacity: 1;
    transform: translateY(0);
}

.blindfold-content h2 {
    font-size: 2rem;
    color: var(--text-main);
    margin-bottom: 0.5rem;
    font-weight: 800;
}

.blindfold-content .subtext {
    color: var(--text-muted);
    font-size: 1rem;
    margin-bottom: 2rem;
}

.blindfold-content .action-prompt {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent);
    background: rgba(6, 182, 212, 0.1);
    border: 1px solid rgba(6, 182, 212, 0.2);
    padding: 0.75rem 1.5rem;
    border-radius: 50px;
    display: inline-block;
    cursor: pointer;
    box-shadow: 0 0 15px rgba(6, 182, 212, 0.15);
    animation: pulseAction 2s infinite;
}

/* Barra de Resultados (Superior, no tapa el burro) */
#scene-result {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: auto;
    z-index: 30;
    background: linear-gradient(to bottom, rgba(15, 23, 42, 0.95) 80%, rgba(15, 23, 42, 0) 100%);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 1.25rem 1.5rem;
    border-bottom: 1.5px solid rgba(255, 255, 255, 0.08);
}

#scene-result.active {
    display: flex !important;
    animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.result-bar.glass {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
}

.result-info {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex: 1;
    text-align: left;
}

.score-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.7);
    border: 2px solid var(--accent);
    border-radius: 18px;
    width: 80px;
    height: 80px;
    box-shadow: 0 0 15px rgba(6, 182, 212, 0.25);
    flex-shrink: 0;
}

.score-container .score-badge {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--accent);
    text-shadow: 0 0 12px var(--accent-glow);
    line-height: 1;
}

.score-container .score-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
    margin-top: 2px;
}

.result-text {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.result-text h2 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-main);
}

.result-text p {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.45;
}

/* Botón de Colocar Gafas flotante */
#btn-place-mobile {
    position: absolute;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%) scale(0);
    z-index: 25;
    display: flex;
    padding: 0.85rem 2.2rem;
    font-size: 1.05rem;
    border-radius: 50px;
    background: var(--accent);
    box-shadow: 0 4px 20px rgba(6, 182, 212, 0.4);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
    opacity: 0;
}

#btn-place-mobile.visible {
    transform: translateX(-50%) scale(1);
    pointer-events: auto;
    opacity: 1;
}

#btn-place-mobile:hover {
    background: #0891b2;
    transform: translateX(-50%) scale(1.05);
    box-shadow: 0 6px 25px rgba(6, 182, 212, 0.6);
}

/* Alerta de Bloqueo de Puntero (Instrucciones Flotantes) */
.pointer-lock-alert {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(50px);
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid var(--accent);
    color: var(--text-main);
    padding: 0.75rem 1.5rem;
    border-radius: 50px;
    font-size: 0.95rem;
    font-weight: 600;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), 0 0 15px rgba(6, 182, 212, 0.2);
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    text-align: center;
}

.pointer-lock-alert.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Animaciones */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

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

@keyframes pulseAction {
    0%, 100% {
        box-shadow: 0 0 15px rgba(6, 182, 212, 0.2);
        border-color: rgba(6, 182, 212, 0.2);
    }
    50% {
        box-shadow: 0 0 25px rgba(6, 182, 212, 0.5);
        border-color: rgba(6, 182, 212, 0.6);
        transform: scale(1.02);
    }
}

@keyframes pulseMarker {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    70% {
        box-shadow: 0 0 0 12px rgba(16, 185, 129, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

/* Responsividad */
@media (max-width: 650px) {
    :root {
        --board-size: 340px;
    }
    
    .glasses-wrapper {
        width: 110px;
        height: 73px;
    }

    .main-header h1 {
        font-size: 1.75rem;
    }

    .card.glass {
        padding: 1.5rem;
    }

    /* Ajustes específicos para móviles en la barra de resultados superior */
    #scene-result {
        padding: 0.65rem 0.85rem;
        border-bottom-width: 1px;
    }
    
    .result-bar.glass {
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
    }
    
    .result-info {
        gap: 0.75rem;
        width: 100%;
    }
    
    .score-container {
        width: 55px;
        height: 55px;
        border-radius: 12px;
        border-width: 1.5px;
    }
    
    .score-container .score-badge {
        font-size: 1.75rem;
    }
    
    .score-container .score-label {
        font-size: 0.55rem;
    }
    
    .result-text {
        gap: 1px;
    }
    
    .result-text h2 {
        font-size: 1.05rem;
    }
    
    .result-text p {
        font-size: 0.72rem;
        line-height: 1.3;
    }
    
    #scene-result .btn {
        padding: 0.45rem 1.25rem;
        font-size: 0.85rem;
        width: 100%;
        border-radius: 8px;
    }

    /* Botón flotante en móviles ligeramente más pequeño */
    #btn-place-mobile {
        bottom: 15px;
        padding: 0.65rem 1.75rem;
        font-size: 0.95rem;
    }
}
