/* ─── CV GAME STYLES ─── */

/* Root variables for consistent theming */
:root {
    --game-primary: rgba(10,147,150,1);
    --game-primary-glow: rgba(10,147,150,0.5);
    --game-secondary: rgba(99,102,241,1);
    --game-danger: rgba(239,71,111,1);
    --game-warning: rgba(251,191,36,1);
    --game-dark-bg: rgba(20,25,35,0.92);
    --game-darker-bg: rgba(10,15,25,0.95);
}

#game-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    z-index: 2000;
    color: white;
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

#loading-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, #1f2937 0%, #0f1419 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
    font-family: 'Poppins', sans-serif;
}

#loading-screen .spinner {
    border: 5px solid rgba(255, 255, 255, 0.08);
    border-left-color: #0a9396;
    border-top-color: #0a9396;
    border-radius: 50%;
    width: 70px;
    height: 70px;
    animation: spin 0.9s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    margin-bottom: 32px;
    box-shadow: 0 0 30px rgba(10,147,150,0.4), inset 0 0 20px rgba(10,147,150,0.1);
    position: relative;
}

#loading-screen .spinner::after {
    content: '';
    position: absolute;
    inset: 8px;
    border: 3px solid rgba(255, 255, 255, 0.05);
    border-right-color: #0fc5c9;
    border-bottom-color: #0fc5c9;
    border-radius: 50%;
    animation: spin 1.2s cubic-bezier(0.4, 0, 0.2, 1) infinite reverse;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#loading-screen p {
    font-size: 1.3rem;
    color: #e5e7eb;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-shadow: 0 2px 8px rgba(0,0,0,0.5);
    animation: textPulse 2s ease-in-out infinite;
}

@keyframes textPulse {
    0%, 100% { opacity: 0.9; }
    50% { opacity: 1; }
}

#loading-progress {
    font-size: 1.1rem;
    margin-top: 16px;
    color: #0a9396;
    font-weight: 600;
    letter-spacing: 2px;
    text-shadow: 0 0 20px rgba(10,147,150,0.5);
    min-width: 80px;
    text-align: center;
}


#game-ui {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Allows clicks to go through to the canvas */
}

#game-ui button, #game-ui .music-toggle, #game-ui .exhaust-toggle, #game-ui .engine-sound-toggle, #game-ui .sound-toggle, #game-ui .credits, #game-ui .npc-dialogue, #game-ui .placement-hint, #game-ui #compass, #game-ui #minimap-canvas {
    pointer-events: all; /* Re-enable on interactive elements */
}

/* Overlay for dynamic chat bubbles */
#chat-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 15;
}

.speech-bubble {
    position: absolute;
    max-width: 320px;
    color: #fff;
    font-size: 14px;
    line-height: 1.5;
    padding: 12px 16px;
    border-radius: 16px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.35), 0 4px 12px rgba(0,0,0,0.2), inset 0 1px 2px rgba(255,255,255,0.15);
    backdrop-filter: blur(8px);
    transform: translate(-50%, -100%);
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-weight: 500;
    letter-spacing: 0.3px;
}
.speech-bubble.typing { 
    opacity: 0.92;
    animation: typingPulse 1.5s ease-in-out infinite;
}
@keyframes typingPulse {
    0%, 100% { box-shadow: 0 12px 32px rgba(0,0,0,0.35), 0 4px 12px rgba(0,0,0,0.2), inset 0 1px 2px rgba(255,255,255,0.15); }
    50% { box-shadow: 0 12px 32px rgba(0,0,0,0.35), 0 4px 12px rgba(0,0,0,0.2), inset 0 1px 2px rgba(255,255,255,0.15), 0 0 20px rgba(10,147,150,0.3); }
}
.bubble-enter { 
    animation: bubbleIn 400ms cubic-bezier(0.34, 1.56, 0.64, 1);
    opacity: 0.98;
}
.bubble-fade { animation: bubbleOut 500ms ease-in forwards; }
@keyframes bubbleIn { 
    from { 
        transform: translate(-50%, -85%) scale(0.85); 
        opacity: 0; 
    } 
    to { 
        transform: translate(-50%, -100%) scale(1); 
        opacity: 0.98; 
    } 
}
@keyframes bubbleOut { 
    to { 
        opacity: 0; 
        transform: translate(-50%, -105%) scale(0.95); 
    } 
}

.bubble-player { 
    background: linear-gradient(135deg, rgba(15,160,165,0.96), rgba(7,125,130,0.92)); 
    border: 1px solid rgba(255,255,255,0.25);
}
.bubble-npc { 
    background: linear-gradient(135deg, rgba(48,71,94,0.96), rgba(30,50,70,0.92)); 
    border: 1px solid rgba(255,255,255,0.18);
}

.speech-bubble .bubble-inner {
    transform-origin: 50% 100%;
    animation: bubblePopInner 300ms ease-out, bubbleFloat 4s ease-in-out 500ms infinite;
}
@keyframes bubblePopInner { 
    from { transform: scale(0.95); opacity: 0.7; } 
    to { transform: scale(1); opacity: 1; } 
}
@keyframes bubbleFloat { 
    0%,100% { transform: translateY(0) scale(1); } 
    50% { transform: translateY(-2px) scale(1.01); } 
}

/* Modern speech bubble tails with glow */
.bubble-player::before, .bubble-player::after,
.bubble-npc::before, .bubble-npc::after {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
}
.bubble-player::before, .bubble-npc::before {
    bottom: -12px;
    border-width: 10px 10px 0 10px;
    border-style: solid;
    border-color: rgba(0,0,0,0.3) transparent transparent transparent;
    filter: blur(2px);
}
.bubble-player::after {
    bottom: -9px;
    border-width: 10px 10px 0 10px;
    border-style: solid;
    border-color: rgba(7,125,130,0.92) transparent transparent transparent;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}
.bubble-npc::after {
    bottom: -9px;
    border-width: 10px 10px 0 10px;
    border-style: solid;
    border-color: rgba(30,50,70,0.92) transparent transparent transparent;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

/* Enhanced central chat input */
#center-chat {
    position: absolute;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(20,25,35,0.92), rgba(10,15,25,0.94));
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4), 0 2px 8px rgba(0,0,0,0.3), inset 0 1px 2px rgba(255,255,255,0.1);
    backdrop-filter: blur(12px);
    z-index: 20;
    pointer-events: all;
    animation: slideUpFade 400ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes slideUpFade {
    from { transform: translateX(-50%) translateY(20px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}
.center-chat-close {
    background: linear-gradient(135deg, rgba(239,71,111,0.85), rgba(220,53,95,0.9));
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    cursor: pointer;
    opacity: 0.95;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-size: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(239,71,111,0.3);
}
.center-chat-close:hover {
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 4px 16px rgba(239,71,111,0.5);
    opacity: 1;
}
.center-chat-input {
    width: 42vw;
    min-width: 240px;
    max-width: 600px;
    background: rgba(255,255,255,0.08);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 12px;
    padding: 10px 16px;
    outline: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    letter-spacing: 0.3px;
}
.center-chat-input:focus {
    background: rgba(255,255,255,0.12);
    border-color: rgba(10,147,150,0.6);
    box-shadow: 0 0 0 3px rgba(10,147,150,0.15), inset 0 2px 4px rgba(0,0,0,0.1);
}
.center-chat-input::placeholder {
    color: rgba(255,255,255,0.5);
}
.center-chat-send {
    background: linear-gradient(135deg, rgba(10,147,150,0.95), rgba(6,120,123,0.98));
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 10px 20px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 4px 12px rgba(10,147,150,0.3);
    letter-spacing: 0.5px;
}
.center-chat-send:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 20px rgba(10,147,150,0.45);
    background: linear-gradient(135deg, rgba(13,170,173,1), rgba(8,140,143,1));
}
.center-chat-send:active {
    transform: translateY(0) scale(0.98);
}

#close-game-btn {
    position: absolute;
    top: 24px;
    right: 24px;
    background: linear-gradient(135deg, rgba(239,71,111,0.85), rgba(220,53,95,0.9));
    color: white;
    border: 2px solid rgba(255,255,255,0.25);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    font-size: 28px;
    line-height: 44px;
    text-align: center;
    cursor: pointer;
    pointer-events: all;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 4px 16px rgba(239,71,111,0.4), inset 0 1px 2px rgba(255,255,255,0.2);
    backdrop-filter: blur(8px);
    font-weight: 700;
}

#close-game-btn:hover {
    background: linear-gradient(135deg, rgba(255,71,111,1), rgba(240,53,95,1));
    transform: scale(1.15) rotate(90deg);
    box-shadow: 0 6px 24px rgba(239,71,111,0.6), inset 0 1px 2px rgba(255,255,255,0.3);
    border-color: rgba(255,255,255,0.4);
}

#close-game-btn:active {
    transform: scale(1.05) rotate(90deg);
}

#interaction-prompt {
    position: absolute;
    bottom: 22%;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, rgba(10,147,150,0.92), rgba(6,120,123,0.95));
    padding: 14px 28px;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.8px;
    animation: interactPulse 2s ease-in-out infinite;
    box-shadow: 0 8px 32px rgba(10,147,150,0.4), 0 0 40px rgba(10,147,150,0.2), inset 0 1px 2px rgba(255,255,255,0.2);
    border: 2px solid rgba(255,255,255,0.3);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    gap: 10px;
}

#interaction-prompt::before {
    content: '🎮';
    font-size: 1.2rem;
    animation: iconBounce 2s ease-in-out infinite;
}

/* Mobile-friendly interaction button */
.mobile-interact-btn {
    position: absolute;
    bottom: 240px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, rgba(10,147,150,0.95), rgba(6,120,123,0.98));
    color: #fff;
    border: 3px solid rgba(255,255,255,0.4);
    border-radius: 50%;
    width: 80px;
    height: 80px;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    pointer-events: all;
    font-weight: 700;
    box-shadow: 0 8px 32px rgba(10,147,150,0.5), 0 0 40px rgba(10,147,150,0.3), inset 0 2px 4px rgba(255,255,255,0.2);
    backdrop-filter: blur(12px);
    animation: mobileBtnPulse 2s ease-in-out infinite;
    transition: all 0.3s ease;
    z-index: 100;
}

.mobile-interact-btn:active {
    transform: translateX(-50%) scale(0.95);
}

.mobile-interact-btn .interact-icon {
    font-size: 2rem;
    animation: iconBounce 2s ease-in-out infinite;
}

.mobile-interact-btn .interact-text {
    font-size: 0.75rem;
    letter-spacing: 1px;
    text-transform: uppercase;
}

@keyframes mobileBtnPulse {
    0%, 100% { 
        box-shadow: 0 8px 32px rgba(10,147,150,0.5), 0 0 40px rgba(10,147,150,0.3), inset 0 2px 4px rgba(255,255,255,0.2);
    }
    50% { 
        box-shadow: 0 12px 48px rgba(10,147,150,0.7), 0 0 60px rgba(10,147,150,0.5), inset 0 2px 4px rgba(255,255,255,0.3);
    }
}

@keyframes interactPulse {
    0%, 100% { 
        transform: translateX(-50%) scale(1); 
        opacity: 0.95;
        box-shadow: 0 8px 32px rgba(10,147,150,0.4), 0 0 40px rgba(10,147,150,0.2), inset 0 1px 2px rgba(255,255,255,0.2);
    }
    50% { 
        transform: translateX(-50%) scale(1.08); 
        opacity: 1;
        box-shadow: 0 12px 48px rgba(10,147,150,0.6), 0 0 60px rgba(10,147,150,0.35), inset 0 1px 2px rgba(255,255,255,0.3);
    }
}

@keyframes iconBounce {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-3px) rotate(-5deg); }
    75% { transform: translateY(-3px) rotate(5deg); }
}

#game-controls-info {
    position: absolute;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, rgba(25,30,40,0.85), rgba(15,20,30,0.9));
    padding: 12px 24px;
    border-radius: 24px;
    font-size: 0.9rem;
    border: 1px solid rgba(255,255,255,0.2);
    backdrop-filter: blur(16px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.3), inset 0 1px 2px rgba(255,255,255,0.1);
    color: rgba(255, 255, 255, 0.95);
    font-weight: 600;
    letter-spacing: 0.6px;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideDownFade 500ms ease-out;
}

#game-controls-info::before {
    content: '⌨️';
    font-size: 1.1rem;
}

/* Show/hide controls based on device */
.mobile-controls {
    display: none;
}

@media (pointer: coarse) and (hover: none) {
    #game-controls-info::before {
        content: '🎮';
    }
    .desktop-controls {
        display: none;
    }
    .mobile-controls {
        display: inline;
    }
}

@keyframes slideDownFade {
    from { transform: translateX(-50%) translateY(-20px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

.compass {
    position: absolute;
    top: 24px;
    left: 24px;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(145deg, rgba(20,25,35,0.85), rgba(10,15,25,0.9));
    border: 2px solid rgba(255,255,255,0.25);
    box-shadow: 0 4px 16px rgba(0,0,0,0.4), inset 0 2px 4px rgba(0,0,0,0.3), inset 0 -1px 2px rgba(255,255,255,0.1);
    backdrop-filter: blur(8px);
    pointer-events: all;
    transition: all 0.3s ease;
    animation: compassGlow 3s ease-in-out infinite;
}

.compass:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(0,0,0,0.5), inset 0 2px 4px rgba(0,0,0,0.3), inset 0 -1px 2px rgba(255,255,255,0.15);
}

@keyframes compassGlow {
    0%, 100% { border-color: rgba(255,255,255,0.25); }
    50% { border-color: rgba(10,147,150,0.5); }
}

.compass::after {
    content: 'N';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    font-weight: 700;
    color: rgba(255,255,255,0.9);
    letter-spacing: 1.5px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.compass-arrow {
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 26px solid #ff6b6b;
    filter: drop-shadow(0 2px 6px rgba(255,107,107,0.6)) drop-shadow(0 0 8px rgba(255,107,107,0.3));
    transform-origin: bottom center;
    transition: filter 0.3s ease;
}

.compass:hover .compass-arrow {
    filter: drop-shadow(0 2px 8px rgba(255,107,107,0.8)) drop-shadow(0 0 12px rgba(255,107,107,0.5));
}

#minimap-canvas {
    position: absolute;
    top: 120px;
    left: 24px;
    background: linear-gradient(145deg, rgba(15,20,30,0.85), rgba(5,10,20,0.9));
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    pointer-events: all;
    box-shadow: 0 6px 20px rgba(0,0,0,0.5), inset 0 2px 4px rgba(0,0,0,0.3), inset 0 -1px 2px rgba(255,255,255,0.1);
    transition: all 0.3s ease;
}

#minimap-canvas:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 28px rgba(0,0,0,0.6), inset 0 2px 4px rgba(0,0,0,0.3), inset 0 -1px 2px rgba(255,255,255,0.15);
    border-color: rgba(10,147,150,0.5);
}

/* Placement hint for development mode */
.placement-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, rgba(251,191,36,0.92), rgba(245,158,11,0.94));
    color: #000;
    padding: 12px 20px;
    border-radius: 16px;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    border: 2px solid rgba(255,255,255,0.4);
    box-shadow: 0 8px 24px rgba(251,191,36,0.4), inset 0 1px 2px rgba(255,255,255,0.3);
    animation: hintPulse 2s ease-in-out infinite;
}

@keyframes hintPulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.95; }
    50% { transform: translate(-50%, -50%) scale(1.05); opacity: 1; }
}

/* Modern control strip */
#control-strip {
    position: absolute;
    bottom: 80px;
    left: 24px;
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 24px;
    background: linear-gradient(135deg, rgba(25,30,40,0.85), rgba(15,20,30,0.9));
    border: 1px solid rgba(255,255,255,0.15);
    backdrop-filter: blur(16px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.35), inset 0 1px 2px rgba(255,255,255,0.08);
    animation: slideInLeft 500ms ease-out;
}

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

#control-strip .control-btn,
#control-strip .music-toggle,
#control-strip .engine-sound-toggle,
#control-strip .exhaust-toggle {
    position: static;
    background: linear-gradient(135deg, rgba(10,147,150,0.85), rgba(6,120,123,0.9));
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    cursor: pointer;
    opacity: 0.95;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(10,147,150,0.3), inset 0 1px 2px rgba(255,255,255,0.15);
    position: relative;
    overflow: hidden;
}

#control-strip .control-btn::before,
#control-strip .music-toggle::before,
#control-strip .engine-sound-toggle::before,
#control-strip .exhaust-toggle::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    transform: translate(-50%, -50%);
    transition: width 0.4s ease, height 0.4s ease;
}

#control-strip .control-btn:hover,
#control-strip .music-toggle:hover,
#control-strip .engine-sound-toggle:hover,
#control-strip .exhaust-toggle:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 6px 20px rgba(10,147,150,0.5), inset 0 1px 2px rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.35);
}

#control-strip .control-btn:hover::before,
#control-strip .music-toggle:hover::before,
#control-strip .engine-sound-toggle:hover::before,
#control-strip .exhaust-toggle:hover::before {
    width: 100%;
    height: 100%;
}

#control-strip .off { 
    opacity: 0.5; 
    filter: grayscale(60%);
    background: linear-gradient(135deg, rgba(60,60,70,0.7), rgba(50,50,60,0.8));
}

#control-strip .off:hover {
    opacity: 0.7;
    filter: grayscale(40%);
}

/* Enhanced Credits Button and Panel */
.credits {
    position: absolute;
    bottom: 24px;
    left: 24px;
    background: linear-gradient(135deg, rgba(99,102,241,0.85), rgba(79,82,221,0.9));
    color: #fff;
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid rgba(255,255,255,0.25);
    box-shadow: 0 4px 16px rgba(99,102,241,0.35), inset 0 1px 2px rgba(255,255,255,0.15);
    backdrop-filter: blur(8px);
    pointer-events: all;
    z-index: 10;
    animation: slideInLeft 600ms ease-out 200ms both;
}

/* Virtual Joystick for Mobile */
.joystick-base {
    position: absolute;
    bottom: 100px;
    right: 32px;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: linear-gradient(145deg, rgba(20,25,35,0.75), rgba(10,15,25,0.85));
    border: 3px solid rgba(255,255,255,0.2);
    box-shadow: 0 8px 32px rgba(0,0,0,0.5), inset 0 2px 8px rgba(0,0,0,0.4), inset 0 -2px 4px rgba(255,255,255,0.1);
    backdrop-filter: blur(12px);
    display: none; /* Hidden by default, shown on touch devices */
    justify-content: center;
    align-items: center;
    pointer-events: all;
    z-index: 50;
    animation: joystickFadeIn 500ms ease-out;
    touch-action: none;
}

@keyframes joystickFadeIn {
    from { opacity: 0; transform: scale(0.8); }\n    to { opacity: 1; transform: scale(1); }
}

.joystick-base::before {
    content: '';
    position: absolute;
    inset: 12px;
    border-radius: 50%;
    border: 2px dashed rgba(10,147,150,0.3);
    animation: joystickRotate 20s linear infinite;
}

@keyframes joystickRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.joystick-stick {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(10,147,150,0.9), rgba(6,120,123,0.95));
    border: 3px solid rgba(255,255,255,0.3);
    box-shadow: 0 4px 16px rgba(10,147,150,0.4), inset 0 2px 4px rgba(255,255,255,0.2), inset 0 -2px 4px rgba(0,0,0,0.3);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: box-shadow 0.2s ease;
    pointer-events: none;
    z-index: 51;
}

.joystick-stick::after {
    content: '';
    position: absolute;
    inset: 8px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(255,255,255,0.3), transparent);
}

.joystick-base:active .joystick-stick {
    box-shadow: 0 6px 24px rgba(10,147,150,0.6), inset 0 2px 4px rgba(255,255,255,0.3), inset 0 -2px 4px rgba(0,0,0,0.4);
}

.credits:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 6px 24px rgba(99,102,241,0.5), inset 0 1px 2px rgba(255,255,255,0.2);
    background: linear-gradient(135deg, rgba(109,112,251,1), rgba(89,92,231,1));
}

.credits-panel {
    position: absolute;
    bottom: 80px;
    left: 24px;
    background: linear-gradient(135deg, rgba(20,25,35,0.96), rgba(10,15,25,0.98));
    color: #fff;
    padding: 24px;
    border-radius: 20px;
    max-width: 500px;
    box-shadow: 0 12px 48px rgba(0,0,0,0.5), 0 4px 16px rgba(0,0,0,0.3), inset 0 1px 3px rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    backdrop-filter: blur(20px);
    z-index: 30;
    font-size: 0.85rem;
    line-height: 1.6;
    pointer-events: all;
    animation: panelSlideIn 400ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes panelSlideIn {
    from { transform: translateY(20px) scale(0.95); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

.credits-panel .credits-content {
    max-height: 400px;
    overflow-y: auto;
    padding-right: 8px;
}

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

.credits-panel .credits-content::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.05);
    border-radius: 3px;
}

.credits-panel .credits-content::-webkit-scrollbar-thumb {
    background: rgba(10,147,150,0.6);
    border-radius: 3px;
}

.credits-panel .credits-content::-webkit-scrollbar-thumb:hover {
    background: rgba(10,147,150,0.8);
}

.credits-panel a {
    color: #0fc5c9;
    text-decoration: none;
    transition: color 0.2s ease;
    font-weight: 500;
}

.credits-panel a:hover {
    color: #13dfdf;
    text-decoration: underline;
}

.credits-panel hr {
    border: none;
    border-top: 1px solid rgba(255,255,255,0.15);
    margin: 16px 0;
}

.credits-panel strong {
    color: rgba(255,255,255,0.95);
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* Enhanced In-game NPC Dialogue */
.npc-dialogue {
    position: absolute;
    bottom: 24px;
    right: 24px;
    width: 380px;
    max-height: 55vh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, rgba(20,25,35,0.96), rgba(10,15,25,0.98));
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 24px;
    box-shadow: 0 12px 48px rgba(0,0,0,0.5), inset 0 1px 3px rgba(255,255,255,0.1);
    backdrop-filter: blur(20px);
    overflow: hidden;
    pointer-events: all;
    animation: dialogueSlideIn 500ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes dialogueSlideIn {
    from { transform: translateX(100px) scale(0.95); opacity: 0; }
    to { transform: translateX(0) scale(1); opacity: 1; }
}

.npc-dialogue-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    background: linear-gradient(135deg, rgba(10,147,150,0.25), rgba(6,120,123,0.2));
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    border-radius: 24px 24px 0 0;
}

.npc-dialogue-header .npc-name {
    font-weight: 700;
    font-size: 1.15rem;
    color: #0fc5c9;
    letter-spacing: 0.5px;
    text-shadow: 0 2px 8px rgba(15,197,201,0.3);
}

.npc-close-btn {
    background: linear-gradient(135deg, rgba(239,71,111,0.8), rgba(220,53,95,0.85));
    color: #fff;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 10px;
    width: 36px;
    height: 36px;
    cursor: pointer;
    font-size: 22px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 2px 8px rgba(239,71,111,0.3);
}

.npc-close-btn:hover {
    transform: scale(1.15) rotate(90deg);
    box-shadow: 0 4px 16px rgba(239,71,111,0.5);
    background: linear-gradient(135deg, rgba(255,81,121,1), rgba(240,63,105,1));
}

.npc-messages {
    padding: 20px 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 40vh;
}

.npc-messages::-webkit-scrollbar {
    width: 8px;
}

.npc-messages::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.05);
    border-radius: 4px;
}

.npc-messages::-webkit-scrollbar-thumb {
    background: rgba(10,147,150,0.6);
    border-radius: 4px;
}

.npc-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(10,147,150,0.8);
}

.npc-msg, .player-msg {
    max-width: 90%;
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 0.9rem;
    line-height: 1.5;
    white-space: pre-wrap;
    animation: messageFadeIn 300ms ease-out;
}

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

.npc-msg {
    align-self: flex-start;
    background: linear-gradient(135deg, rgba(48,71,94,0.5), rgba(30,50,70,0.55));
    border: 1px solid rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.95);
}

.player-msg {
    align-self: flex-end;
    background: linear-gradient(135deg, rgba(10,147,150,0.4), rgba(6,120,123,0.45));
    border: 1px solid rgba(10,147,150,0.3);
    color: rgba(255,255,255,0.95);
}

.npc-input-row {
    display: flex;
    gap: 12px;
    padding: 16px 24px;
    background: rgba(0,0,0,0.2);
    border-top: 1px solid rgba(255,255,255,0.1);
    border-radius: 0 0 24px 24px;
}

.npc-input-row input {
    flex: 1;
    background: rgba(255,255,255,0.08);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 0.9rem;
    outline: none;
    transition: all 0.3s ease;
}

.npc-input-row input:focus {
    background: rgba(255,255,255,0.12);
    border-color: rgba(10,147,150,0.6);
    box-shadow: 0 0 0 3px rgba(10,147,150,0.15);
}

.npc-input-row .btn {
    background: linear-gradient(135deg, rgba(10,147,150,0.9), rgba(6,120,123,0.95));
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 12px 20px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 4px 12px rgba(10,147,150,0.3);
}

.npc-input-row .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(10,147,150,0.45);
    background: linear-gradient(135deg, rgba(13,170,173,1), rgba(8,140,143,1));
}

@media (max-width: 768px) {
    #game-controls-info {
        font-size: 0.8rem;
        padding: 10px 16px;
        top: 16px;
    }
    
    .compass {
        width: 64px;
        height: 64px;
        top: 16px;
        left: 16px;
    }
    
    #minimap-canvas {
        width: 100px !important;
        height: 100px !important;
        top: 95px;
        left: 16px;
    }
    
    #control-strip {
        bottom: 70px;
        left: 16px;
        padding: 10px 12px;
        gap: 10px;
    }
    
    #control-strip .control-btn,
    #control-strip .music-toggle,
    #control-strip .engine-sound-toggle,
    #control-strip .exhaust-toggle {
        width: 38px;
        height: 38px;
        font-size: 16px;
    }
    
    .credits {
        bottom: 16px;
        left: 16px;
        padding: 8px 16px;
        font-size: 0.8rem;
    }
    
    .credits-panel {
        max-width: calc(100vw - 32px);
        left: 16px;
        bottom: 70px;
    }
    
    #center-chat {
        bottom: 20px;
        padding: 10px 12px;
        gap: 8px;
    }
    
    .center-chat-input {
        width: 50vw;
        min-width: 180px;
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .speech-bubble {
        max-width: 260px;
        font-size: 13px;
        padding: 10px 14px;
    }
    
    #close-game-btn {
        width: 42px;
        height: 42px;
        font-size: 24px;
        top: 16px;
        right: 16px;
    }
    
    .npc-dialogue {
        width: calc(100% - 32px);
        right: 16px;
        left: 16px;
        bottom: 16px;
        max-width: none;
    }
    
    /* Mobile joystick adjustments */
    .joystick-base {
        bottom: 80px;
        right: 24px;
        width: 110px;
        height: 110px;
    }
    
    .joystick-stick {
        width: 45px;
        height: 45px;
    }
    
    /* Adjust mobile interaction button position to avoid joystick */
    .mobile-interact-btn {
        bottom: 220px;
        width: 70px;
        height: 70px;
    }
    
    .mobile-interact-btn .interact-icon {
        font-size: 1.8rem;
    }
    
    .mobile-interact-btn .interact-text {
        font-size: 0.7rem;
    }
}
