* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Courier New', monospace;
    background: linear-gradient(45deg, #0a0a0a, #1a1a2e, #16213e);
    color: #00ff00;
    overflow: hidden;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    max-width: 1200px;
    max-height: 800px;
    border: 3px solid #00ff00;
    border-radius: 10px;
    box-shadow: 0 0 30px rgba(0, 255, 0, 0.3), inset 0 0 20px rgba(0, 255, 0, 0.1);
    background: #000;
    overflow: hidden;
}

canvas {
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    border-radius: 7px;
}

.loading-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, #000428, #004e92, #8e2de2);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.8s ease-out;
}

.loading-text {
    font-size: 2.5rem;
    margin-bottom: 2rem;
    text-align: center;
    color: #00ff00;
    text-shadow: 0 0 20px rgba(0, 255, 0, 0.8);
    animation: pulse 2s infinite, glow 3s ease-in-out infinite alternate;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.05); }
}

@keyframes glow {
    from { text-shadow: 0 0 20px rgba(0, 255, 0, 0.8), 0 0 30px rgba(0, 255, 0, 0.4); }
    to { text-shadow: 0 0 20px rgba(0, 255, 0, 0.8), 0 0 40px rgba(0, 255, 0, 0.8), 0 0 50px rgba(0, 255, 0, 0.6); }
}

.loading-bar {
    width: 350px;
    height: 25px;
    border: 3px solid #00ff00;
    border-radius: 15px;
    overflow: hidden;
    background: #000;
    position: relative;
}

.loading-progress {
    height: 100%;
    background: linear-gradient(90deg, #00ff00, #00dd00, #ffff00, #00ff00);
    background-size: 200% 100%;
    width: 0%;
    transition: width 0.3s ease;
    box-shadow: 0 0 15px rgba(0, 255, 0, 0.8);
    animation: shimmer 2s linear infinite;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.controls-info {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    padding: 15px 20px;
    border: 2px solid #00ff00;
    border-radius: 15px;
    font-size: 14px;
    text-align: center;
    color: #00ff00;
    z-index: 500;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.3);
    backdrop-filter: blur(5px);
}

.ui-overlay {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.98);
    padding: 20px;
    border: 3px solid #00ff00;
    border-radius: 15px;
    min-width: 220px;
    z-index: 500;
    box-shadow: 0 0 25px rgba(0, 255, 0, 0.4), inset 0 0 15px rgba(0, 255, 0, 0.1);
    backdrop-filter: blur(12px);
    font-size: 14px;
    font-weight: 600;
}

.ui-overlay div {
    margin: 8px 0;
    color: #00ff00;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9), 0 0 6px rgba(0, 255, 0, 0.3);
}

.health-bar {
    width: 180px;
    height: 12px;
    background: #333;
    border: 2px solid #00ff00;
    margin: 8px 0;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

.health-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff0000, #ffaa00, #ffff00, #00ff00);
    width: 100%;
    transition: width 0.5s ease;
    box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.3);
}

.dialog-box {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    width: 85%;
    max-width: 700px;
    background: rgba(0, 0, 0, 0.98); /* More opaque for better text visibility */
    border: 4px solid #00ff00; /* Thicker border */
    border-radius: 20px;
    padding: 25px;
    display: none;
    z-index: 1000;
    animation: slideUp 0.4s ease-out;
    box-shadow: 0 0 40px rgba(0, 255, 0, 0.6), inset 0 0 20px rgba(0, 255, 0, 0.1);
    backdrop-filter: blur(15px);
}

@keyframes slideUp {
    from { 
        transform: translateX(-50%) translateY(100px); 
        opacity: 0; 
        scale: 0.9;
    }
    to { 
        transform: translateX(-50%) translateY(0); 
        opacity: 1; 
        scale: 1;
    }
}

.dialog-text {
    font-size: 18px;
    line-height: 1.7;
    color: #ffffff;
    margin-bottom: 15px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 1), 0 0 8px rgba(0, 255, 0, 0.3);
    font-weight: 600;
    letter-spacing: 0.5px;
}

.dialog-continue {
    text-align: right;
    font-size: 12px;
    color: #888;
    animation: blink 1.5s infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.3; }
}

.achievement-popup {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #ffd700, #ffb347);
    color: #000;
    padding: 20px 30px;
    border-radius: 15px;
    border: 3px solid #fff;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.8);
    font-weight: bold;
    font-size: 18px;
    z-index: 2000;
    animation: achievementBounce 0.6s ease-out;
    display: none;
}

@keyframes achievementBounce {
    0% { 
        transform: translate(-50%, -50%) scale(0.5); 
        opacity: 0; 
    }
    50% { 
        transform: translate(-50%, -50%) scale(1.1); 
        opacity: 1; 
    }
    100% { 
        transform: translate(-50%, -50%) scale(1); 
        opacity: 1; 
    }
}

.mini-map {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 150px;
    height: 120px;
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid #00ff00;
    border-radius: 10px;
    z-index: 500;
}

/* Touch Controls for Mobile */
.touch-controls {
    display: none;
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
}

.touch-btn {
    background: rgba(0, 255, 0, 0.8);
    border: 2px solid #00ff00;
    color: #000;
    padding: 15px;
    margin: 5px;
    border-radius: 50%;
    font-weight: bold;
    font-size: 18px;
    width: 60px;
    height: 60px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    touch-action: manipulation;
    cursor: pointer;
    transition: all 0.2s ease;
}

.touch-btn:active {
    background: rgba(0, 255, 0, 1);
    transform: scale(0.95);
}

.touch-grid {
    display: grid;
    grid-template-columns: 60px 60px 60px;
    grid-template-rows: 60px 60px;
    gap: 10px;
    align-items: center;
    justify-items: center;
}

.interact-btn {
    background: rgba(255, 255, 0, 0.8);
    border-color: #ffff00;
    grid-column: 2;
    grid-row: 2;
}

/* Performance Optimizations */
.game-container * {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .game-container {
        border-radius: 0;
        border: none;
        max-width: 100vw;
        max-height: 100vh;
    }
    
    .loading-text {
        font-size: 1.8rem;
        padding: 0 20px;
    }
    
    .loading-bar {
        width: 280px;
        height: 20px;
    }
    
    .controls-info {
        font-size: 12px;
        padding: 12px 16px;
        bottom: 120px; /* Moved up to make room for touch controls */
        width: 90%;
    }
    
    .ui-overlay {
        top: 10px;
        left: 10px;
        padding: 15px;
        min-width: 180px;
        font-size: 12px;
    }
    
    .dialog-box {
        width: 95%;
        padding: 20px;
        bottom: 140px; /* Moved up to avoid touch controls */
    }
    
    .dialog-text {
        font-size: 16px;
    }
    
    .mini-map {
        width: 120px;
        height: 90px;
        top: 10px;
        right: 10px;
    }
    
    /* Show touch controls on mobile */
    .touch-controls {
        display: block !important;
    }
    
    /* Improve touch targets */
    .touch-btn {
        width: 50px;
        height: 50px;
        font-size: 16px;
    }
    
    .touch-grid {
        grid-template-columns: 50px 50px 50px;
        grid-template-rows: 50px 50px;
        gap: 8px;
    }
}

@media (max-width: 480px) {
    .loading-text {
        font-size: 1.4rem;
    }
    
    .ui-overlay {
        font-size: 11px;
        min-width: 160px;
    }
    
    .health-bar {
        width: 140px;
        height: 10px;
    }
}