/* styles.css */
:root {
    --panel-opacity: 0.55;
    /* 0.0 a 1.0 (Transparencia de los paneles UI) */
}

@import url('https://fonts.googleapis.com/css2?family=VT323&family=Orbitron:wght@400;700;900&display=swap');

/* Reset bÃ¡sico */
* {
    box-sizing: border-box;
    user-select: none;
}

html,
body {
    background-color: #000c1d !important;
}

body {
    background-color: #000c1d;
    /* Azul marino profundo para evitar flash blanco */
    /* Mezcla de imagen de fondo del nivel y un degradado oscuro radial */
    background: radial-gradient(circle, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0.95) 100%), url('Assets/delta_background.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: scroll;
    /* 'fixed' da problemas en móviles/iOS */
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    font-family: 'VT323', monospace;
    color: #fff;
    margin: 0;
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    width: 100%;
}

/* --- CABECERA --- */
.header-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 5px;
    padding: 20px;
    background: none;
    /* SIN FONDO */
    backdrop-filter: none;
    /* SIN BLUR */
    width: 100%;
    max-width: 900px;
}

.header-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    /* CENTRADO */
    justify-content: center;
    text-align: center;
    /* CENTRADO */
}

.game-logo {
    height: 80px;
    width: auto;
    filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.6));
    transition: transform 0.3s;
}

.game-logo:hover {
    transform: scale(1.1) rotate(-5deg);
}

.game-title {
    /* Título limpio: solo degradado blanco-amarillo */
    position: relative;
    font-family: 'Luckiest Guy', cursive;
    /* Fuente arcade/gaming redonda */
    font-weight: 400;
    font-size: 68px;
    margin: 0;
    line-height: 0.9;
    letter-spacing: 1px;
    text-transform: uppercase;

    /* Gradiente Vertical Blanco a Amarillo */
    background: linear-gradient(180deg, #FFFFFF 30%, #FFD700 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;

    /* Sin efectos, sin sombras, sin neón */
    filter: none;
    text-shadow: none;
}

@keyframes titleGlint {
    0% {
        filter: drop-shadow(0 0 15px rgba(255, 200, 0, 0.5)) brightness(1);
    }

    50% {
        filter: drop-shadow(0 0 25px rgba(255, 200, 0, 0.8)) brightness(1.2);
    }

    100% {
        filter: drop-shadow(0 0 15px rgba(255, 200, 0, 0.5)) brightness(1);
    }
}

.game-subtitle {
    font-family: 'Oswald', sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: #f0f0ff;
    margin: 0;
    margin-top: 2px;
    margin-left: 5px;
    text-transform: uppercase;
    letter-spacing: 4px;
    text-align: left;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5), 2px 2px 4px rgba(0, 0, 0, 0.8);
    opacity: 0.95;
}

/* --- PANEL DE PUNTUACIÃN REFINADO --- */
.score-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 740px;
    padding: 12px 30px;
    background: linear-gradient(135deg,
            rgba(20, 30, 40, var(--panel-opacity)) 0%,
            rgba(5, 5, 5, calc(var(--panel-opacity) + 0.1)) 100%);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(0, 242, 255, 0.3);
    border-top: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), inset 0 0 20px rgba(0, 242, 255, 0.05);
    position: relative;
    overflow: hidden;
}

.score-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.05), transparent);
    animation: panScore 4s infinite linear;
}

@keyframes panScore {
    0% {
        left: -100%;
    }

    100% {
        left: 200%;
    }
}

.score-separator {
    width: 2px;
    height: 30px;
    background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.2), transparent);
    margin: 0 5px;
}

.score-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.score-item .label {
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.score-item .value {
    font-size: 34px;
    font-weight: 700;
}

.score-item:not(:last-child)::after {
    content: '';
    position: absolute;
    right: 0;
    top: 10%;
    height: 80%;
    width: 1px;
    background: linear-gradient(to bottom, transparent, #555, transparent);
}

.score-item .label {
    color: #AAA;
    font-size: 14px;
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 2px;
    text-shadow: 1px 1px 0 #000;
}

.score-item .value {
    color: #FFF;
    font-family: 'VT323', monospace;
    font-size: 32px;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.8);
    line-height: 1;
}

#level-val {
    color: #00ddff;
    text-shadow: 0 0 8px #00ddff;
    transition: color 0.3s;
}

#score {
    color: #ffff00;
    text-shadow: 0 0 8px #ffff00;
}

#highScore {
    color: #ff8800;
    text-shadow: 0 0 8px #ff8800;
}

@keyframes pulsate {
    0% {
        transform: scale(1);
        box-shadow: 0 0 25px rgba(221, 36, 118, 0.6);
    }

    50% {
        transform: scale(1.05);
        box-shadow: 0 0 40px rgba(221, 36, 118, 0.9);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 25px rgba(221, 36, 118, 0.6);
    }
}

.hidden {
    display: none !important;
}

/* ANIMACION 'GLOW' AL COMER COC (Sincronizado con Power Mode) */
@keyframes textGlow {
    0% {
        color: #00ddff;
        text-shadow: 0 0 8px #00ddff;
    }

    10% {
        color: #fff;
        text-shadow: 0 0 20px #FFD700, 0 0 40px #FFD700, 0 0 60px #FF4500;
    }

    90% {
        color: #fff;
        text-shadow: 0 0 20px #FFD700, 0 0 40px #FFD700, 0 0 60px #FF4500;
    }

    100% {
        color: #00ddff;
        text-shadow: 0 0 8px #00ddff;
    }
}

.text-glow-effect {
    animation: textGlow 8s linear forwards;
}

/* --- CANVAS DEL JUEGO (Marco) --- */
#gameCanvas {
    background-color: transparent;
    /* Forzado transparente para ver el fondo */
    border: 8px solid #222;
    outline: 2px solid #B8860B;
    border-radius: 4px;
    box-shadow:
        0 0 0 4px #000,
        0 20px 40px rgba(0, 0, 0, 0.8),
        0 0 30px rgba(0, 150, 255, 0.2);
    image-rendering: pixelated;
    transition: box-shadow 0.3s ease;
}

#gameCanvas:hover {
    box-shadow:
        0 0 0 4px #000,
        0 25px 50px rgba(0, 0, 0, 0.9),
        0 0 40px rgba(0, 150, 255, 0.3);
}

/* --- ÃREA DE JUEGO Y PANEL LATERAL --- */
.play-area {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    /* Alinear arriba */
    gap: 20px;
}

.inventory-panel {
    width: auto;
    min-width: 140px;
    height: 636px;
    /* Ajustado para cuadrar con el tablero (620px + 16px de bordes) */
    background: rgba(10, 15, 20, var(--panel-opacity));
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 242, 255, 0.2);
    border-radius: 12px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow:
        0 4px 6px rgba(0, 0, 0, 0.5),
        inset 0 0 20px rgba(0, 0, 0, 0.8);
    box-sizing: border-box;
    padding-bottom: 30px;
}

.inventory-panel h3 {
    color: #ffffff;
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 16px;
    text-align: center;
    margin: 0 !important;
    /* Sin margen superior ni inferior */
    text-shadow: 0 0 5px #FFD700;
    padding: 0 !important;
    /* Sin padding */
    width: 100%;
    display: block;
    /* Asegurar comportamiento de bloque */
}

#trophy-grid {
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    /* Cada 4 items (aprox) salta a nueva columna */
    align-content: flex-start;
    max-height: 570px;
    /* Altura ideal para 4 trofeos de 130px + gaps */
    gap: 15px;
    width: auto;
    align-items: center;
}

/* --- ITEM DEL TROFEO REDISEÃADO COMPACTO --- */
.trophy-item {
    width: 110px;
    height: 130px;
    /* Reducido de 160px a 130px */
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 8px 4px;
    /* Padding reducido */
    position: relative;
    transition: all 0.5s ease;
}

/* Estado: OBJETIVO ACTUAL (Locked) */
.trophy-item.locked {
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed #444;
}

.trophy-item.locked .trophy-img {
    filter: grayscale(100%) blur(3px) opacity(0.4);
    transform: scale(0.9);
}

.trophy-item.locked .recipe-btn {
    opacity: 0.3;
    pointer-events: none;
    background: #333;
    color: #555;
    border: 1px solid #444;
}

.trophy-item.locked .trophy-title {
    color: #888;
    filter: blur(4px) grayscale(100%);
    opacity: 0.3;
}

/* Estado: CONSEGUIDO (Unlocked) */
.trophy-item.unlocked {
    background: rgba(255, 215, 0, 0.1);
    border: 2px solid #FFD700;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.2);
    transform: scale(1.05);
    /* Pop */
}

.trophy-item.unlocked .trophy-img {
    filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.6));
    animation: popIn 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    opacity: 1;
}

.trophy-item.unlocked .trophy-title {
    color: #FFD700;
    text-shadow: 0 0 5px #B8860B;
}

/* Elementos internos */
.trophy-title {
    font-family: 'VT323', monospace;
    font-size: 14px;
    text-align: center;
    line-height: 1;
    margin-bottom: 2px;
    width: 100%;
}

.trophy-img {
    width: 55px;
    height: 55px;
    /* Reducido ligeramente */
    object-fit: contain;
    transition: all 0.5s ease;
}

.recipe-btn {
    display: inline-block;
    padding: 3px 8px;
    /* Compacto */
    background: #B8860B;
    color: #000;
    text-decoration: none;
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 10px;
    border-radius: 4px;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 1px;
    border: 1px solid #FFD700;
    margin-top: 5px;
    /* Menos margen */
    cursor: pointer;
}

.recipe-btn:hover {
    background: #FFD700;
    transform: scale(1.1);
    box-shadow: 0 0 10px #FFD700;
}

@keyframes popIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    80% {
        transform: scale(1.2);
        opacity: 1;
    }

    100% {
        transform: scale(1);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ALERTA DE RECETA (Cuando tienes los 4 Cocs) */
#recipe-alert {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    background: rgba(0, 10, 20, 0.95);
    border: 3px solid #FFD700;
    color: #FFD700;
    padding: 30px 40px;
    border-radius: 15px;
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 32px;
    text-align: center;
    z-index: 10000;
    /* Encima de todo */
    box-shadow:
        0 0 0 100vh rgba(0, 0, 0, 0.5),
        /* Oscurecer fondo */
        0 0 50px rgba(255, 215, 0, 0.8);
    pointer-events: none;
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-shadow: 2px 2px 0 #000;
    width: 600px;
    max-width: 90%;
}

#recipe-alert.visible {
    transform: translate(-50%, -50%) scale(1);
}

#recipe-alert small {
    display: block;
    margin-top: 10px;
    font-family: 'VT323', monospace;
    font-size: 24px;
    color: #00ffff;
    text-shadow: none;
}

/* --- DISEÃO RESPONSIVO (iPhone y MÃ³viles) --- */
@media screen and (max-width: 1180px) {
    body {
        padding: 5px;
        align-items: flex-start;
        /* Scroll si hace falta */
        overflow-x: hidden;
    }

    .game-container {
        gap: 8px;
        width: 100%;
    }

    .header-container {
        margin-bottom: 5px;
        padding-top: 10px;
    }

    .game-logo {
        height: 35px;
    }

    .game-title {
        font-size: 34px;
        /* Mantener fuente y gradiente global */
    }

    .game-subtitle {
        font-size: 13px;
        letter-spacing: 1px;
        margin-top: -2px;
    }

    .score-panel {
        padding: 5px 15px;
        max-width: 98%;
        gap: 5px;
        border-radius: 12px;
        background: linear-gradient(180deg, rgba(20, 30, 40, var(--panel-opacity)) 0%, rgba(5, 5, 5, calc(var(--panel-opacity) + 0.15)) 100%);
    }

    .score-item {
        padding: 0 8px;
    }

    .score-item .label {
        font-size: 9px;
        opacity: 0.8;
    }

    .score-item .value {
        font-size: 24px;
    }

    .score-item-record {
        display: flex;
        /* Recuperado para XS */
    }

    .play-area {
        flex-direction: column;
        align-items: center;
        justify-content: flex-start !important;
        width: 100%;
        gap: 0px !important;
        margin-top: -10px !important;
        padding-bottom: 100px !important;
        /* Espacio para los controles fijos */
    }

    .canvas-wrapper {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    #gameCanvas {
        max-width: 95vw;
        height: auto;
        border-width: 4px;
    }

    .inventory-panel {
        width: 100%;
        min-height: auto;
        padding: 0 !important;
        margin: 0 !important;
        cursor: pointer;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
    }

    .inventory-title {
        margin: 0 0 5px 0 !important;
        padding: 0 !important;
    }

    .inventory-panel:hover {
        background: rgba(15, 25, 35, 0.95);
    }

    #trophy-grid {
        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: center;
        height: 120px !important;
        /* Reducir altura del contenedor */
        position: relative;
        margin-top: 5px !important;
        perspective: 1000px;
        width: 100%;
    }

    .trophy-item {
        position: absolute;
        width: 100px;
        height: 130px;
        transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
        box-shadow: -5px 0 15px rgba(0, 0, 0, 0.7);
        background: rgba(15, 20, 25, 0.95) !important;
        /* MÃ¡s opaco para evitar que se vean las de abajo */
        backdrop-filter: blur(10px);
        border: 1px solid rgba(255, 255, 255, 0.1);
    }

    /* Efecto Baraja Re-centrado: Actual en el centro, anteriores a la izquierda */
    .trophy-item:nth-last-child(1) {
        z-index: 10;
        transform: translateX(0px) scale(1.15);
        /* Â¡CENTRADITO! */
        box-shadow: 0 0 25px rgba(0, 242, 255, 0.5);
        border: 2px solid rgba(0, 242, 255, 0.6);
    }

    .trophy-item:nth-last-child(2) {
        z-index: 9;
        transform: translateX(-45px) rotateY(-15deg) scale(0.95);
        opacity: 0.9;
    }

    .trophy-item:nth-last-child(3) {
        z-index: 8;
        transform: translateX(-85px) rotateY(-25deg) scale(0.85);
        opacity: 0.8;
    }

    .trophy-item:nth-last-child(4) {
        z-index: 7;
        transform: translateX(-125px) rotateY(-35deg) scale(0.75);
        opacity: 0.7;
    }

    .trophy-item:nth-last-child(n+5) {
        z-index: 6;
        transform: translateX(-165px) rotateY(-45deg) scale(0.65);
        opacity: 0.5;
    }

    /* ESTADO EXPANDIDO: Mostrar todo cuadradito */
    #trophy-grid.expanded {
        height: auto;
        flex-wrap: wrap;
        gap: 10px;
        padding: 10px 0;
        perspective: none;
    }

    #trophy-grid.expanded .trophy-item {
        position: relative;
        transform: none !important;
        opacity: 1 !important;
        left: auto !important;
        z-index: 1 !important;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
        margin: 5px;
        width: 90px;
        height: 120px;
    }

    .trophy-img {
        width: 45px;
        height: 45px;
    }

    .trophy-title {
        font-size: 12px;
    }

    .recipe-btn {
        font-size: 10px;
        padding: 3px 6px;
    }

    /* --- CONTROLES MÃVILES (D-PAD HORIZONTAL COMPACTO) --- */
    .mobile-controls {
        display: flex !important;
        flex-direction: row;
        justify-content: center;
        align-items: center;
        gap: 12px;
        margin-top: 10px;
        background: rgba(0, 0, 0, 0.4);
        padding: 10px 20px;
        border-radius: 12px;
        border: 1px solid rgba(255, 215, 0, 0.2);
        width: 100%;
        max-width: 360px;
        align-self: center !important;
    }

    .dpad-row {
        display: flex !important;
        flex-direction: row !important;
        gap: 8px !important;
        margin: 0 !important;
    }
}

.dpad-btn {
    width: 65px !important;
    height: 65px !important;
    flex: none !important;
    background: linear-gradient(135deg, #1e2832 0%, #0a0f14 100%) !important;
    border: 2px solid rgba(255, 215, 0, 0.6) !important;
    border-radius: 15px !important;
    color: #FFD700 !important;
    font-size: 28px !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    box-shadow: 0 4px 0 #8B0000, 0 6px 12px rgba(0, 0, 0, 0.5) !important;
    cursor: pointer !important;
    touch-action: manipulation !important;
    -webkit-tap-highlight-color: transparent !important;
    transition: transform 0.1s !important;
}

.dpad-btn:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 #8B0000, 0 2px 5px rgba(0, 0, 0, 0.6);
    background: #FFD700;
    color: #000;
}

/* Eliminado el bloqueo de XS para permitir la 'baraja' de trofeos */

/* --- DEBUG CONTROLS (Small but Visible) --- */
.debug-controls {
    position: fixed;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 10px;
    z-index: 10000;
    opacity: 0.5;
    /* MÃ¡s visibles ahora */
    transition: all 0.2s;
}

.debug-controls:hover {
    opacity: 1;
    transform: scale(1.1);
}

.btn-debug {
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-family: 'Oswald', sans-serif;
    font-size: 11px;
    cursor: pointer;
    text-transform: uppercase;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.btn-debug.next {
    background: rgba(40, 167, 69, 0.4);
}

.btn-debug.reset {
    background: rgba(220, 53, 69, 0.4);
}


/* Ocultar controles en desktop */
.mobile-controls {
    display: none;
}

/* Mostrar controles en móviles y TABLETS */
@media (max-width: 1180px) {
    .mobile-controls {
        display: flex !important;
        justify-content: center;
    }
}

/* CSS updates for clearer recipe buttons and locked state */

/* Global Recipe Button Style */
.recipe-btn {
    display: inline-block;
    width: 90%;
    margin-top: auto;
    margin-bottom: 2px;
    padding: 3px 2px;
    background: linear-gradient(to bottom, #FFD700, #B8860B);
    color: #000;
    font-family: 'Orbitron', sans-serif;
    font-size: 9px;
    font-weight: 700;
    text-decoration: none;
    text-align: center;
    border-radius: 4px;
    border: 1px solid #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    z-index: 100 !important;
    /* Ensure it stays on top */
    filter: none !important;
    /* Prevent any inherited blur */
    opacity: 1 !important;
    white-space: nowrap;
    /* Default for single line */
    cursor: pointer;
    text-shadow: none;
}

/* Locked Button Style - Multi-line and Warning Color */
.recipe-btn.locked-btn {
    background: linear-gradient(to bottom, #444, #222);
    /* Dark background */
    color: #ff9;
    /* Pale yellow text */
    border: 1px solid #666;
    font-size: 7px !important;
    /* Smaller font to fit text */
    line-height: 1.1;
    white-space: normal;
    /* Allow branding */
    padding: 2px 1px;
    height: auto;
    min-height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    /* Non-clickable */
    box-shadow: none;
}

/* Ensure controls are visible in Mobile/XS */
@media (max-width: 480px) {
    .recipe-btn {
        font-size: 8px !important;
        width: 95% !important;
    }

    .recipe-btn.locked-btn {
        font-size: 6px !important;
        /* Even smaller for XS */
        padding: 1px !important;
        background: #333 !important;
        color: #ddd !important;
        border-color: #555 !important;
    }
}