/* --- START OF FILE ui-controls.css --- */

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

/* --- MONEY DISPLAY --- */
#money-display {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.6);
    padding: 10px 15px;
    border: 3px solid #fbbf24;
    border-radius: 8px;
    color: #fbbf24;
    font-family: 'Press Start 2P', cursive;
    font-size: 14px;
    text-shadow: 2px 2px 0 #000;
    z-index: 90;
    box-shadow: 4px 4px 0 rgba(0,0,0,0.5);
}

.coin-icon {
    width: 20px;
    height: 20px;
}

/* --- LEVEL DISPLAY (NEW) --- */
#level-container {
    position: absolute;
    top: 70px;
    left: 20px;
    z-index: 90;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-family: 'Press Start 2P', cursive;
}

#level-badge {
    font-size: 10px;
    color: #fff;
    text-shadow: 2px 2px 0 #000;
    background: rgba(0,0,0,0.5);
    padding: 4px 8px;
    border: 2px solid #000;
    width: fit-content;
}

#level-value {
    color: #fbbf24;
}

#xp-bar-container {
    width: 120px;
    height: 8px;
    background: #000;
    border: 2px solid #fff;
    box-shadow: 2px 2px 0 rgba(0,0,0,0.5);
    position: relative;
}

#xp-bar-fill {
    width: 0%;
    height: 100%;
    background: #3b82f6;
    transition: width 0.3s ease-out;
}


/* --- BOTÓN DE INVENTARIO (BAÚL) --- */
#inventory-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 64px; 
    height: 64px;
    background: #8b5e34;
    border: 4px solid #000;
    box-shadow: 
        inset 4px 4px 0 rgba(255,255,255,0.3), 
        inset -4px -4px 0 rgba(0,0,0,0.2),    
        6px 6px 0px rgba(0,0,0,0.5);          
    padding: 0;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 90;
    transition: transform 0.1s;
}

#inventory-toggle:active {
    transform: translateY(4px);
    box-shadow: 
        inset 4px 4px 0 rgba(255,255,255,0.3),
        inset -4px -4px 0 rgba(0,0,0,0.2),
        0px 0px 0px rgba(0,0,0,0.5);
}

#inventory-toggle svg {
    width: 40px;
    height: 40px;
    filter: drop-shadow(2px 2px 0 rgba(0,0,0,0.3));
    image-rendering: pixelated;
}

/* --- BOTÓN DE MEJORAS --- */
#upgrades-toggle {
    position: absolute;
    top: 20px;
    right: 180px;
    width: 64px; 
    height: 64px;
    background: #475569;
    border: 4px solid #000;
    box-shadow: 
        inset 4px 4px 0 rgba(255,255,255,0.3), 
        inset -4px -4px 0 rgba(0,0,0,0.2),    
        6px 6px 0px rgba(0,0,0,0.5);          
    padding: 0;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 90;
    transition: transform 0.1s;
}

#upgrades-toggle:active {
    transform: translateY(4px);
    box-shadow: 
        inset 4px 4px 0 rgba(255,255,255,0.3),
        inset -4px -4px 0 rgba(0,0,0,0.2),
        0px 0px 0px rgba(0,0,0,0.5);
}

#upgrades-toggle svg {
    width: 40px;
    height: 40px;
    filter: drop-shadow(2px 2px 0 rgba(0,0,0,0.3));
    image-rendering: pixelated;
}

/* --- BOTÓN DE LEADERBOARD --- */
#leaderboard-toggle {
    position: absolute;
    top: 20px;
    right: 260px;
    width: 64px; 
    height: 64px;
    background: #111827;
    border: 4px solid #000;
    box-shadow: 
        inset 4px 4px 0 rgba(255,255,255,0.3), 
        inset -4px -4px 0 rgba(0,0,0,0.2),    
        6px 6px 0px rgba(0,0,0,0.5);          
    padding: 0;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 90;
    transition: transform 0.1s;
}

#leaderboard-toggle:active {
    transform: translateY(4px);
    box-shadow: 
        inset 4px 4px 0 rgba(255,255,255,0.3),
        inset -4px -4px 0 rgba(0,0,0,0.2),
        0px 0px 0px rgba(0,0,0,0.5);
}

#leaderboard-toggle svg {
    width: 40px;
    height: 40px;
    filter: drop-shadow(2px 2px 0 rgba(0,0,0,0.3));
    image-rendering: pixelated;
}

/* --- CHAT TOGGLE BUTTON --- */
#chat-toggle {
    position: absolute;
    top: 20px;
    right: 100px;
    width: 64px; 
    height: 64px;
    background: #3b82f6;
    border: 4px solid #000;
    box-shadow: 
        inset 4px 4px 0 rgba(255,255,255,0.3), 
        inset -4px -4px 0 rgba(0,0,0,0.2),    
        6px 6px 0px rgba(0,0,0,0.5);          
    padding: 0;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 90;
    transition: transform 0.1s;
}

#chat-toggle:active {
    transform: translateY(4px);
    box-shadow: inset 4px 4px 0 rgba(255,255,255,0.3), inset -4px -4px 0 rgba(0,0,0,0.2), 0px 0px 0px rgba(0,0,0,0.5);
}

#chat-toggle svg {
    width: 40px;
    height: 40px;
    filter: drop-shadow(2px 2px 0 rgba(0,0,0,0.3));
}

/* --- IDLE SOUND TOGGLE (NEW) --- */
#idle-sound-toggle {
    position: absolute;
    top: 100px;
    right: 20px;
    width: 48px; 
    height: 48px;
    background: #10b981; /* Default Green (On) */
    border: 4px solid #000;
    box-shadow: 
        inset 4px 4px 0 rgba(255,255,255,0.3), 
        inset -4px -4px 0 rgba(0,0,0,0.2),    
        6px 6px 0px rgba(0,0,0,0.5);          
    padding: 0;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 90;
    transition: transform 0.1s, background-color 0.2s;
}

#idle-sound-toggle.muted {
    background: #64748b; /* Gray when muted idle */
}

#idle-sound-toggle:active {
    transform: translateY(4px);
    box-shadow: inset 4px 4px 0 rgba(255,255,255,0.3), inset -4px -4px 0 rgba(0,0,0,0.2), 0px 0px 0px rgba(0,0,0,0.5);
}

#idle-sound-toggle svg {
    width: 32px;
    height: 32px;
    filter: drop-shadow(2px 2px 0 rgba(0,0,0,0.3));
}

/* --- TUTORIAL TOGGLE BUTTON --- */
#tutorial-toggle {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 48px; 
    height: 48px;
    background: #e2e8f0;
    border: 4px solid #000;
    box-shadow: 
        inset 4px 4px 0 rgba(255,255,255,0.6), 
        inset -4px -4px 0 rgba(0,0,0,0.2),    
        4px 4px 0px rgba(0,0,0,0.5);          
    padding: 0;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 95;
    transition: transform 0.1s;
}

#tutorial-toggle:active {
    transform: translateY(4px);
    box-shadow: 
        inset 4px 4px 0 rgba(255,255,255,0.6),
        inset -4px -4px 0 rgba(0,0,0,0.2),
        0px 0px 0px rgba(0,0,0,0.5);
}

.pixel-font {
    font-family: 'Press Start 2P', cursive;
    font-size: 20px;
    color: #000;
}

/* --- CHAT LOG --- */
#global-chat-log {
    position: absolute;
    bottom: 180px;
    left: 20px;
    width: 250px;
    max-height: 150px;
    overflow-y: hidden;
    pointer-events: none;
    z-index: 50;
    display: flex;
    flex-direction: column-reverse;
    align-items: flex-start; 
    gap: 6px;
}

.chat-log-entry {
    background: #202028;
    color: #fff;
    font-family: 'Press Start 2P', cursive;
    font-size: 8px; 
    padding: 5px 8px; 
    border: 2px solid #000; 
    box-shadow: 2px 2px 0 rgba(0,0,0,0.5); 
    border-radius: 0; 
    animation: chatFadeIn 0.3s ease-out, chatFadeOut 1s forwards 6s;
    word-break: break-word;
    max-width: 90%; 
    line-height: 1.4;
}

@keyframes chatFadeIn { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: translateX(0); } }
@keyframes chatFadeOut { from { opacity: 1; } to { opacity: 0; } }

/* --- CHAT INPUT --- */
#chat-input-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6); 
    backdrop-filter: blur(2px);   
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
}

#chat-input-overlay.hidden { display: none; }

#chat-input-container {
    background: #3b82f6; 
    border: 4px solid #000;
    box-shadow: 
        inset 4px 4px 0 rgba(255,255,255,0.3),
        inset -4px -4px 0 rgba(0,0,0,0.2),
        6px 6px 0 rgba(0,0,0,0.5);
    padding: 10px;
    display: flex;
    gap: 8px;
    width: 400px;
    max-width: 90%;
}

#chat-input {
    flex: 1;
    background: #1e293b;
    border: 2px solid #000;
    color: #fff;
    padding: 12px;
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
    outline: none;
    box-shadow: inset 2px 2px 0 rgba(0,0,0,0.5);
}

#chat-input::placeholder {
    color: #94a3b8;
}

#chat-send {
    background: #fbbf24; 
    color: #000;
    border: 2px solid #000;
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
    padding: 0 15px;
    cursor: pointer;
    box-shadow: 2px 2px 0 rgba(0,0,0,0.5);
    text-transform: uppercase;
}

#chat-send:active {
    transform: translate(2px, 2px);
    box-shadow: none;
}

/* --- JOYSTICK CONTAINERS --- */

#joystick-container-left,
#joystick-container-right {
    position: absolute;
    bottom: 40px;
    width: 120px;
    height: 120px;
    z-index: 10;
}

#joystick-container-left { left: 40px; }
#joystick-container-right { right: 40px; }

/* --- NIPPLEJS PIXEL ART OVERRIDES --- */

#joystick-container-left .back {
    border-radius: 4px !important;
    background: #2d3748 !important;
    border: 4px solid #000 !important;
    box-shadow: inset 4px 4px 0 rgba(255,255,255,0.1) !important;
    width: 100px !important;
    height: 100px !important;
    margin-left: -50px !important;
    margin-top: -50px !important;
}

#joystick-container-left .back::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 80%; height: 30%;
    background: #1a202c;
    box-shadow: 0 0 0 4px #000;
}
#joystick-container-left .back::before {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 30%; height: 80%;
    background: #1a202c;
    box-shadow: 0 0 0 4px #000;
}

#joystick-container-left .front {
    border-radius: 2px !important;
    background: #94a3b8 !important;
    border: 4px solid #000 !important;
    box-shadow: 
        inset 4px 4px 0 rgba(255,255,255,0.8),
        inset -4px -4px 0 rgba(0,0,0,0.2),
        4px 4px 0 rgba(0,0,0,0.5) !important;
    opacity: 1 !important;
    width: 50px !important;
    height: 50px !important;
    margin-left: -25px !important;
    margin-top: -25px !important;
}

#joystick-container-right .back {
    border-radius: 50% !important;
    background: #451a03 !important;
    border: 4px solid #000 !important;
    width: 100px !important;
    height: 100px !important;
    margin-left: -50px !important;
    margin-top: -50px !important;
    background-image: repeating-radial-gradient(
      #451a03 0px, 
      #451a03 10px, 
      #78350f 10px, 
      #78350f 12px
    ) !important;
}

#joystick-container-right .front {
    border-radius: 4px !important;
    background: #ef4444 !important;
    border: 4px solid #000 !important;
    box-shadow: 
        inset 6px 6px 0 rgba(255,255,255,0.4),
        inset -6px -6px 0 rgba(0,0,0,0.2),
        6px 6px 0 rgba(0,0,0,0.6) !important;
    opacity: 1 !important;
    width: 60px !important;
    height: 60px !important;
    margin-left: -30px !important;
    margin-top: -30px !important;
    display: flex !important;
    justify-content: center;
    align-items: center;
}

#joystick-container-right .front::after {
    content: "A";
    font-family: 'Press Start 2P', cursive;
    color: rgba(0,0,0,0.3);
    font-size: 20px;
}

@media (pointer: coarse) {
    canvas { cursor: none; }
}

/* --- AJUSTES PARA MÓVILES --- */
@media (max-width: 600px) {
    #inventory-toggle,
    #chat-toggle,
    #upgrades-toggle,
    #leaderboard-toggle {
        top: 15px;
        width: 52px;
        height: 52px;
    }
    #inventory-toggle { right: 15px; }
    #chat-toggle { right: 80px; }
    #upgrades-toggle { right: 145px; }
    #leaderboard-toggle { right: 210px; }
    
    #idle-sound-toggle {
        top: 80px;
        right: 15px;
        width: 40px;
        height: 40px;
    }

    #inventory-toggle svg, 
    #chat-toggle svg, 
    #upgrades-toggle svg,
    #leaderboard-toggle svg {
        width: 30px;
        height: 30px;
    }
    
    #idle-sound-toggle svg {
        width: 24px;
        height: 24px;
    }

    /* Adaptación del Chat Input para Móvil */
    #chat-input-overlay {
        align-items: flex-start;
        padding-top: 60px; /* Espacio arriba para no tapar los botones UI */
    }

    #chat-input-container {
        width: 95%;
        flex-direction: row; /* Mantener en fila */
        padding: 8px;
    }

    #chat-input {
        font-size: 12px; /* Letra un poco más grande en móvil */
        padding: 10px;
    }

    #chat-send {
        padding: 0 10px;
        font-size: 10px;
    }

    #global-chat-log {
        width: 200px;
        left: 10px;
        bottom: 160px;
    }
    
    .chat-log-entry {
        font-size: 7px; /* Aún más pequeño en móvil si se desea */
    }

    #joystick-container-left { bottom: 30px; left: 30px; }
    #joystick-container-right { bottom: 30px; right: 30px; }
    #money-display { top: 15px; left: 15px; font-size: 10px; padding: 8px; }
    
    #level-container { top: 60px; left: 15px; }
    #level-badge { font-size: 8px; padding: 3px 6px; }
    #xp-bar-container { width: 90px; height: 6px; }
    
    #tutorial-toggle {
        bottom: auto;
        top: 130px; /* Debajo de niveles y botones */
        right: 15px;
        width: 40px; height: 40px;
    }
    .pixel-font { font-size: 14px; }
}

/* --- UniFish DeFi Theme Overlay --- */
#money-display {
    border-color: #00f5ff;
    color: #00f5ff;
    background: linear-gradient(135deg, rgba(2, 6, 23, 0.82), rgba(15, 23, 42, 0.72));
    box-shadow: 0 0 0 3px #000, 0 0 18px rgba(0, 245, 255, 0.45), 4px 4px 0 rgba(0,0,0,0.55);
}

#money-display::before {
    content: "ETH / $UNIFISH";
    position: absolute;
    top: -12px;
    left: 8px;
    padding: 2px 5px;
    background: #020617;
    border: 2px solid #00f5ff;
    color: #d946ef;
    font-size: 6px;
    line-height: 1;
    text-shadow: none;
}

.token-symbol {
    color: #d946ef;
    font-size: 8px;
    letter-spacing: 0.5px;
}

.coin-icon rect:first-child {
    fill: #00f5ff;
}

#inventory-toggle,
#upgrades-toggle,
#leaderboard-toggle {
    position: absolute;
}

#inventory-toggle::after,
#upgrades-toggle::after,
#leaderboard-toggle::after {
    position: absolute;
    left: 50%;
    bottom: -17px;
    transform: translateX(-50%);
    padding: 2px 4px;
    background: rgba(2, 6, 23, 0.88);
    border: 2px solid #000;
    color: #e0f2fe;
    font-family: 'Press Start 2P', cursive;
    font-size: 6px;
    white-space: nowrap;
    text-shadow: 1px 1px 0 #000;
}

#inventory-toggle::after { content: "FISH HOLD"; color: #d8b4fe; }
#upgrades-toggle::after { content: "OPTIMIZE"; color: #86efac; }
#leaderboard-toggle::after { content: "POOL RANK"; color: #fef08a; }

#level-badge {
    border-color: #7c3aed;
    background: rgba(15, 23, 42, 0.78);
}

#level-badge::before {
    content: "POOL ";
    color: #00f5ff;
}

#xp-bar-container {
    border-color: #7c3aed;
}

#xp-bar-fill {
    background: linear-gradient(90deg, #00f5ff, #d946ef);
}
