/* Avatar-inspired cosmic styling */
@import url('https://fonts.googleapis.com/css2?family=Uncial+Antiqua&family=Cinzel:wght@400;500;600&family=Poppins:wght@400;500;600&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Poppins', sans-serif;
    background: #0a0a1a;
    color: #e8e8e8;
    overflow: hidden;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -ms-user-select: none;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

#gameCanvas {
    display: block;
    background: linear-gradient(to bottom, #0a0a1a, #2d1b69);
    touch-action: none;
}

/* HUD Styling */
.hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    pointer-events: none;
}

.hud-top {
    display: flex;
    justify-content: space-between;
    padding: 20px;
    align-items: flex-start;
}

.score-display {
    background: rgba(45, 61, 42, 0.8);
    backdrop-filter: blur(10px);
    padding: 10px 20px;
    border-radius: 25px;
    border: 2px solid #6ab04c;
    font-family: 'Cinzel', serif;
    font-weight: 600;
    font-size: 18px;
    color: #6ab04c;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 0 20px rgba(106, 176, 76, 0.3);
}

.cabbage-icon {
    font-size: 24px;
    animation: spin 3s linear infinite;
}

.health-display {
    background: rgba(45, 61, 42, 0.8);
    backdrop-filter: blur(10px);
    padding: 10px 15px;
    border-radius: 20px;
    border: 2px solid #ff6b6b;
    font-size: 18px;
    box-shadow: 0 0 15px rgba(255, 107, 107, 0.3);
}

.distance-display {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(45, 61, 42, 0.7);
    backdrop-filter: blur(10px);
    padding: 8px 20px;
    border-radius: 20px;
    border: 1px solid #4a90e2;
    font-family: 'Cinzel', serif;
    font-size: 14px;
    color: #4a90e2;
}

/* Touch Controls */
.touch-zone {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 50%;
    z-index: 5;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: auto;
}

.touch-left {
    left: 0;
    background: linear-gradient(to right, rgba(100, 255, 218, 0.1), transparent);
}

.touch-right {
    right: 0;
    background: linear-gradient(to left, rgba(100, 255, 218, 0.1), transparent);
}

.touch-zone.active {
    opacity: 1;
}

/* Power-up Indicator */
.powerup-indicator {
    position: absolute;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    font-size: 40px;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    text-shadow: 0 0 20px #ffff00;
    animation: powerup-pulse 1s ease-in-out infinite;
}

.powerup-indicator.active {
    opacity: 1;
}

/* Menu Overlays */
.menu-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 10, 26, 0.95);
    backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: opacity 0.5s;
}

.menu-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.menu-content {
    text-align: center;
    max-width: 90vw;
    padding: 20px;
}

.game-title {
    font-family: 'Uncial Antiqua', serif;
    font-size: clamp(28px, 8vw, 48px);
    background: linear-gradient(45deg, #64ffda, #6ab04c);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 10px;
    text-shadow: 0 0 30px rgba(100, 255, 218, 0.5);
}

.game-subtitle {
    font-family: 'Cinzel', serif;
    font-size: 16px;
    color: #e8e8e8;
    margin-bottom: 30px;
    opacity: 0.9;
}

.ship-selector {
    margin: 30px 0;
}

.ship-selector h3 {
    font-family: 'Cinzel', serif;
    color: #64ffda;
    margin-bottom: 20px;
    font-size: 18px;
}

.ships {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.ship-btn {
    background: rgba(45, 61, 42, 0.6);
    border: 2px solid #6ab04c;
    color: #e8e8e8;
    padding: 12px 16px;
    border-radius: 15px;
    font-family: 'Cinzel', serif;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

.ship-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(106, 176, 76, 0.4);
}

.ship-btn.active {
    background: rgba(106, 176, 76, 0.3);
    border-color: #64ffda;
    color: #64ffda;
    box-shadow: 0 0 25px rgba(100, 255, 218, 0.5);
    animation: ship-glow 2s ease-in-out infinite;
}

.start-btn {
    background: linear-gradient(45deg, #4a90e2, #6ab04c);
    border: none;
    color: #0a0a1a;
    padding: 16px 40px;
    border-radius: 25px;
    font-family: 'Cinzel', serif;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 10px 30px rgba(74, 144, 226, 0.4);
    margin: 20px 10px 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.start-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 15px 40px rgba(74, 144, 226, 0.6);
}

.share-btn {
    background: linear-gradient(45deg, #9c88ff, #64ffda);
    border: none;
    color: #0a0a1a;
    padding: 12px 30px;
    border-radius: 20px;
    font-family: 'Cinzel', serif;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    margin: 10px;
}

.share-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(156, 136, 255, 0.5);
}

.wisdom {
    margin-top: 20px;
    font-style: italic;
    font-size: 14px;
    color: #9c88ff;
    opacity: 0.8;
}

.final-stats {
    background: rgba(45, 61, 42, 0.4);
    border: 1px solid #6ab04c;
    border-radius: 20px;
    padding: 20px;
    margin: 20px 0;
    backdrop-filter: blur(10px);
}

.final-stats p {
    margin: 8px 0;
    font-family: 'Cinzel', serif;
    font-size: 16px;
}

.final-stats span {
    color: #6ab04c;
    font-weight: 600;
}

/* Instructions */
.instructions {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(45, 61, 42, 0.9);
    backdrop-filter: blur(15px);
    padding: 12px 25px;
    border-radius: 25px;
    border: 2px solid #64ffda;
    font-size: 14px;
    color: #64ffda;
    text-align: center;
    transition: opacity 0.5s;
    box-shadow: 0 0 20px rgba(100, 255, 218, 0.3);
    z-index: 20;
}

/* Animations */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes powerup-pulse {
    0%, 100% { transform: translateY(-50%) scale(1); }
    50% { transform: translateY(-50%) scale(1.2); }
}

@keyframes ship-glow {
    0%, 100% { box-shadow: 0 0 25px rgba(100, 255, 218, 0.5); }
    50% { box-shadow: 0 0 35px rgba(100, 255, 218, 0.8); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.shake {
    animation: shake 0.3s ease-in-out;
}

/* Responsive Design */
@media (max-width: 768px) {
    .hud-top {
        padding: 15px;
    }
    
    .score-display {
        padding: 8px 16px;
        font-size: 16px;
    }
    
    .health-display {
        padding: 8px 12px;
        font-size: 16px;
    }
    
    .ships {
        grid-template-columns: 1fr 1fr;
    }
    
    .ship-btn {
        font-size: 12px;
        padding: 10px 12px;
    }
    
    .instructions {
        font-size: 12px;
        padding: 10px 20px;
    }
}

@media (max-width: 480px) {
    .ships {
        grid-template-columns: 1fr;
    }
    
    .final-stats {
        padding: 15px;
    }
    
    .final-stats p {
        font-size: 14px;
    }
}

/* Landscape orientation tweaks */
@media (orientation: landscape) and (max-height: 500px) {
    .menu-content {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 20px;
        align-items: center;
        max-width: 95vw;
    }
    
    .game-title {
        font-size: clamp(20px, 4vw, 32px);
        margin-bottom: 5px;
    }
    
    .ship-selector {
        margin: 15px 0;
    }
    
    .ships {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    
    .ship-btn {
        padding: 8px 12px;
        font-size: 12px;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    canvas {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Dark mode system preference */
@media (prefers-color-scheme: dark) {
    /* Already optimized for dark theme */
}

/* Reduce motion preference */
@media (prefers-reduced-motion: reduce) {
    .animate-float-cabbage,
    .animate-twinkle,
    .animate-cart-drift,
    .avatar-glow,
    .powerup-pulse,
    .ship-glow {
        animation: none;
    }
    
    .start-btn:hover,
    .ship-btn:hover,
    .share-btn:hover {
        transform: none;
    }
}