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

body {
    background: linear-gradient(180deg, #0a0a14 0%, #1a1a2e 50%, #0d0d1a 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Press Start 2P', cursive;
    overflow: hidden;
}

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

#hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 12px 16px;
    background: linear-gradient(180deg, #2d2d44 0%, #1a1a2e 100%);
    border: 3px solid #4a4a6a;
    border-radius: 8px;
    margin-bottom: 10px;
    box-shadow: 
        0 4px 0 #0d0d1a,
        inset 0 2px 0 rgba(255,255,255,0.1);
}

#hud > div {
    font-size: 10px;
    color: #ffd700;
    text-shadow: 2px 2px 0 #000;
}

#level-display {
    color: #ff6b6b;
}

#gem-display {
    color: #00ff88;
}

#score-display {
    color: #88ccff;
}

#canvas {
    border: 4px solid #4a4a6a;
    border-radius: 8px;
    box-shadow: 
        0 0 20px rgba(0, 255, 136, 0.2),
        0 8px 0 #0d0d1a,
        inset 0 0 60px rgba(0,0,0,0.5);
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

#controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 15px 10px;
    margin-top: 10px;
}

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

#dpad-middle {
    display: flex;
    gap: 4px;
}

.dpad-btn {
    width: 50px;
    height: 50px;
    background: linear-gradient(180deg, #3d3d5c 0%, #2d2d44 100%);
    border: 3px solid #5a5a7a;
    border-radius: 8px;
    color: #ffd700;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 
        0 4px 0 #1a1a2e,
        inset 0 2px 0 rgba(255,255,255,0.1);
    transition: transform 0.1s, box-shadow 0.1s;
    user-select: none;
}

.dpad-btn:active {
    transform: translateY(4px);
    box-shadow: 
        0 0 0 #1a1a2e,
        inset 0 2px 0 rgba(255,255,255,0.1);
}

#btn-center {
    background: #1a1a2e;
    border-color: #2d2d44;
    cursor: default;
    box-shadow: none;
}

#action-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.action-btn {
    width: 60px;
    height: 50px;
    background: linear-gradient(180deg, #5a3d3d 0%, #442d2d 100%);
    border: 3px solid #7a5a5a;
    border-radius: 8px;
    color: #ffcccc;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 
        0 4px 0 #2e1a1a,
        inset 0 2px 0 rgba(255,255,255,0.1);
    transition: transform 0.1s, box-shadow 0.1s;
    user-select: none;
}

.action-btn:active {
    transform: translateY(4px);
    box-shadow: 
        0 0 0 #2e1a1a,
        inset 0 2px 0 rgba(255,255,255,0.1);
}

#btn-undo {
    background: linear-gradient(180deg, #3d5a3d 0%, #2d442d 100%);
    border-color: #5a7a5a;
}

#message-overlay {
    position: fixed;
    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: 100;
}

#message-overlay.hidden {
    display: none;
}

#message-box {
    background: linear-gradient(180deg, #2d2d44 0%, #1a1a2e 100%);
    border: 4px solid #ffd700;
    border-radius: 12px;
    padding: 30px 40px;
    text-align: center;
    box-shadow: 
        0 0 40px rgba(255, 215, 0, 0.3),
        0 8px 0 #0d0d1a;
}

#message-title {
    font-size: 18px;
    color: #ffd700;
    margin-bottom: 15px;
    text-shadow: 2px 2px 0 #000;
}

#message-text {
    font-size: 10px;
    color: #aaa;
    margin-bottom: 25px;
}

#message-btn {
    font-family: 'Press Start 2P', cursive;
    font-size: 12px;
    padding: 12px 24px;
    background: linear-gradient(180deg, #00aa66 0%, #008844 100%);
    border: 3px solid #00cc88;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    box-shadow: 
        0 4px 0 #005522,
        inset 0 2px 0 rgba(255,255,255,0.2);
    transition: transform 0.1s, box-shadow 0.1s;
}

#message-btn:hover {
    background: linear-gradient(180deg, #00cc88 0%, #00aa66 100%);
}

#message-btn:active {
    transform: translateY(4px);
    box-shadow: 
        0 0 0 #005522,
        inset 0 2px 0 rgba(255,255,255,0.2);
}

footer {
    margin-top: auto;
    padding: 10px;
}

footer a {
    font-size: 8px;
    color: #666;
    text-decoration: none;
    transition: color 0.3s;
}

footer a:hover {
    color: #ff6b9d;
}

@media (max-width: 400px) {
    .dpad-btn {
        width: 44px;
        height: 44px;
        font-size: 16px;
    }
    
    .action-btn {
        width: 50px;
        height: 44px;
        font-size: 18px;
    }
    
    #hud > div {
        font-size: 8px;
    }
}

@media (min-height: 800px) {
    .dpad-btn {
        width: 60px;
        height: 60px;
        font-size: 22px;
    }
    
    .action-btn {
        width: 70px;
        height: 60px;
        font-size: 24px;
    }
}