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

body {
    background: #0a0a0a;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Press Start 2P', monospace;
    overflow: hidden;
}

#game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    background: linear-gradient(180deg, #1a1a2e 0%, #0f0f1a 100%);
    border: 4px solid #2121DE;
    border-radius: 12px;
    box-shadow: 
        0 0 20px rgba(33, 33, 222, 0.5),
        inset 0 0 30px rgba(0, 0, 0, 0.5);
    max-width: 100vw;
}

#header {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 448px;
    padding: 8px 4px;
    margin-bottom: 5px;
}

.score-section {
    text-align: center;
    flex: 1;
}

.score-label {
    font-size: 8px;
    color: #FFFFFF;
    margin-bottom: 4px;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
}

#score, #high-score, #level {
    font-size: 12px;
    color: #FFFF00;
    text-shadow: 0 0 10px rgba(255, 255, 0, 0.7);
}

#canvas-wrapper {
    position: relative;
    border: 3px solid #2121DE;
    border-radius: 4px;
    box-shadow: 
        0 0 15px rgba(33, 33, 222, 0.6),
        inset 0 0 10px rgba(0, 0, 0, 0.8);
    overflow: hidden;
}

#canvas-wrapper::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.1) 0px,
        rgba(0, 0, 0, 0.1) 1px,
        transparent 1px,
        transparent 3px
    );
    pointer-events: none;
}

#canvas {
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

#overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 20px;
    z-index: 10;
}

.title {
    font-size: 32px;
    color: #FFFF00;
    text-shadow: 
        3px 3px 0 #FF8800,
        0 0 20px rgba(255, 255, 0, 0.8);
    animation: titlePulse 1s ease-in-out infinite;
}

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

.blink {
    font-size: 14px;
    color: #FFFFFF;
    animation: blink 1s step-start infinite;
}

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

.instructions {
    font-size: 8px;
    color: #00FFFF;
    text-align: center;
    line-height: 1.8;
    text-shadow: 0 0 5px rgba(0, 255, 255, 0.5);
}

.ready-text, .paused-text, .level-text {
    font-size: 20px;
    color: #FFFF00;
    text-shadow: 0 0 15px rgba(255, 255, 0, 0.8);
    animation: bounce 0.5s ease-in-out infinite alternate;
}

@keyframes bounce {
    from { transform: translateY(-5px); }
    to { transform: translateY(5px); }
}

.gameover-text {
    font-size: 24px;
    color: #FF0000;
    text-shadow: 0 0 20px rgba(255, 0, 0, 0.8);
}

.final-score {
    font-size: 14px;
    color: #FFFFFF;
}

.play-again-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 12px;
    padding: 12px 24px;
    background: #2121DE;
    color: #FFFFFF;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 0 10px rgba(33, 33, 222, 0.6);
}

.play-again-btn:hover {
    background: #4444FF;
    transform: scale(1.05);
}

#lives-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 448px;
    padding: 8px 4px;
}

#lives {
    display: flex;
    gap: 5px;
}

.life-icon {
    font-size: 14px;
}

#controls-hint {
    font-size: 6px;
    color: #888888;
}

.mobile-hint {
    display: none;
}

#control-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 448px;
    padding: 10px;
    gap: 20px;
}

#dpad {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.dpad-middle {
    display: flex;
    gap: 2px;
}

.dpad-btn {
    width: 44px;
    height: 44px;
    background: #333;
    border: 2px solid #555;
    border-radius: 8px;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s;
    user-select: none;
}

.dpad-btn:active {
    background: #2121DE;
    border-color: #4444FF;
    transform: scale(0.95);
}

.dpad-center {
    width: 44px;
    height: 44px;
    background: #222;
    border-radius: 8px;
}

#action-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
}

#start-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    padding: 10px 20px;
    background: linear-gradient(180deg, #FF4444 0%, #CC0000 100%);
    color: #FFFFFF;
    border: 2px solid #FF6666;
    border-radius: 6px;
    cursor: pointer;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    box-shadow: 
        0 4px 0 #880000,
        0 0 10px rgba(255, 0, 0, 0.4);
    transition: all 0.1s;
}

#start-btn:active {
    transform: translateY(2px);
    box-shadow: 
        0 2px 0 #880000,
        0 0 10px rgba(255, 0, 0, 0.4);
}

.icon-btn {
    width: 40px;
    height: 40px;
    background: #333;
    border: 2px solid #555;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: #444;
}

.icon-btn.muted {
    opacity: 0.5;
    background: #222;
}

footer {
    margin-top: 10px;
    font-size: 8px;
    color: #666;
    text-align: center;
}

footer a {
    color: #FF6B9D;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Mobile styles */
@media (max-width: 500px) {
    #game-container {
        border-width: 2px;
        border-radius: 8px;
    }
    
    #canvas-wrapper {
        transform: scale(0.85);
        transform-origin: center;
    }
    
    #dpad {
        display: flex;
    }
    
    .desktop-hint {
        display: none;
    }
    
    .mobile-hint {
        display: inline;
    }
    
    #header {
        padding: 4px 2px;
    }
    
    .score-label {
        font-size: 6px;
    }
    
    #score, #high-score, #level {
        font-size: 10px;
    }
    
    .title {
        font-size: 24px;
    }
    
    .blink {
        font-size: 10px;
    }
    
    .instructions {
        font-size: 6px;
        padding: 0 10px;
    }
}

@media (max-width: 380px) {
    #canvas-wrapper {
        transform: scale(0.7);
    }
    
    .dpad-btn {
        width: 38px;
        height: 38px;
    }
    
    .dpad-center {
        width: 38px;
        height: 38px;
    }
}

/* Prevent text selection on game elements */
#game-container, #canvas, #dpad, .dpad-btn {
    user-select: none;
    -webkit-user-select: none;
}