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

body {
    background: linear-gradient(135deg, #0d0d0d 0%, #1a1a2e 50%, #0d0d0d 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Press Start 2P', monospace;
    color: #55FF55;
    overflow: hidden;
}

#game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    max-width: 100vw;
}

#header {
    text-align: center;
    margin-bottom: 10px;
}

#header h1 {
    font-size: clamp(1.5rem, 5vw, 2.5rem);
    color: #7CFC00;
    text-shadow: 
        0 0 10px #7CFC00,
        0 0 20px #228B22,
        4px 4px 0 #2d2d44;
    letter-spacing: 4px;
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from { text-shadow: 0 0 10px #7CFC00, 0 0 20px #228B22, 4px 4px 0 #2d2d44; }
    to { text-shadow: 0 0 20px #7CFC00, 0 0 40px #228B22, 4px 4px 0 #2d2d44; }
}

.subtitle {
    font-size: clamp(0.5rem, 2vw, 0.7rem);
    color: #888;
    margin-top: 5px;
}

#scoreboard {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    margin-bottom: 10px;
    background: rgba(45, 45, 68, 0.8);
    padding: 10px 20px;
    border-radius: 5px;
    border: 2px solid #4a4a6a;
}

.score-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: clamp(0.5rem, 2vw, 0.7rem);
    color: #FFD700;
}

.score-item img {
    width: 16px;
    height: 16px;
    image-rendering: pixelated;
}

.heart-icon {
    width: 14px !important;
    height: 14px !important;
    image-rendering: pixelated;
}

#game-area {
    position: relative;
    border: 4px solid #4a4a6a;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 
        0 0 20px rgba(85, 205, 252, 0.3),
        inset 0 0 50px rgba(0, 0, 0, 0.5);
}

#canvas {
    display: block;
    image-rendering: pixelated;
    background: #1a1a1a;
}

#loading-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(26, 26, 26, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.loading-content {
    text-align: center;
    padding: 20px;
}

.loading-content h2 {
    font-size: clamp(0.8rem, 3vw, 1.2rem);
    color: #FFD700;
    margin-bottom: 20px;
}

.progress-bar {
    width: 200px;
    height: 20px;
    background: #2d2d44;
    border: 2px solid #4a4a6a;
    border-radius: 4px;
    overflow: hidden;
    margin: 0 auto;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #7CFC00, #55FF55);
    transition: width 0.3s ease;
}

#loading-text {
    font-size: 0.6rem;
    color: #888;
    margin-top: 10px;
}

#overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 5;
}

#overlay.hidden {
    display: none;
}

.overlay-content {
    text-align: center;
    padding: 30px;
}

#overlay-title {
    font-size: clamp(1.2rem, 4vw, 2rem);
    color: #7CFC00;
    margin-bottom: 20px;
    text-shadow: 0 0 10px #7CFC00;
}

#overlay-text {
    font-size: clamp(0.6rem, 2vw, 0.9rem);
    color: #FFD700;
    animation: blink 1s infinite;
}

#overlay-score {
    font-size: clamp(0.5rem, 1.5vw, 0.7rem);
    color: #55CDFC;
    margin-top: 15px;
}

@keyframes blink {
    50% { opacity: 0.5; }
}

#controls {
    margin-top: 15px;
    text-align: center;
}

.desktop-controls {
    font-size: clamp(0.4rem, 1.5vw, 0.6rem);
    color: #888;
    background: rgba(45, 45, 68, 0.6);
    padding: 8px 15px;
    border-radius: 4px;
    border: 1px solid #4a4a6a;
}

.mobile-controls {
    display: none;
}

.dpad {
    display: grid;
    grid-template-areas: 
        ". up ."
        "left . right"
        ". down .";
    gap: 5px;
    width: 150px;
    margin: 0 auto;
}

.dpad-btn {
    width: 45px;
    height: 45px;
    background: rgba(45, 45, 68, 0.9);
    border: 2px solid #7CFC00;
    border-radius: 8px;
    color: #7CFC00;
    font-size: 1.2rem;
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.dpad-btn:active {
    background: #7CFC00;
    color: #1a1a1a;
}

.dpad-btn.up { grid-area: up; }
.dpad-btn.down { grid-area: down; }
.dpad-btn.left { grid-area: left; }
.dpad-btn.right { grid-area: right; }

footer {
    margin-top: 15px;
}

.minecraft-sign {
    display: inline-block;
    background: linear-gradient(180deg, #8B4513 0%, #654321 100%);
    color: #FFD700;
    padding: 8px 16px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.6rem;
    border: 2px solid #4a3520;
    box-shadow: 0 4px 0 #3d2914;
    transition: transform 0.1s;
}

.minecraft-sign:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #3d2914;
}

@media (max-width: 600px) {
    .desktop-controls {
        display: none;
    }
    
    .mobile-controls {
        display: block;
    }
    
    #scoreboard {
        gap: 8px;
        padding: 8px 12px;
    }
    
    .score-item {
        font-size: 0.5rem;
    }
}

@media (max-height: 700px) {
    #header {
        margin-bottom: 5px;
    }
    
    #header h1 {
        font-size: 1.2rem;
    }
    
    .subtitle {
        display: none;
    }
}