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

body {
    font-family: 'Courier New', monospace;
    background: #1a1a1a;
    color: white;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

#canvas {
    display: block;
    border: 4px solid #48BB78;
    box-shadow: 0 0 20px rgba(72, 187, 120, 0.5);
    max-width: 100%;
    max-height: calc(100vh - 200px);
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

#ui-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#ui-overlay > * {
    pointer-events: auto;
}

/* Top Bar */
#top-bar {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    background: rgba(45, 55, 72, 0.95);
    padding: 10px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.top-btn {
    background: #2D3748;
    color: white;
    border: 2px solid #4A5568;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-family: 'Courier New', monospace;
    transition: all 0.2s;
}

.top-btn:hover {
    background: #4A5568;
    transform: translateY(-2px);
}

.top-btn:active {
    transform: translateY(0);
}

.play-btn {
    background: #48BB78;
    border-color: #48BB78;
    font-weight: bold;
}

.play-btn:hover {
    background: #38A169;
}

/* HUD */
#hud {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: none;
    justify-content: space-between;
    align-items: center;
}

#coin-counter, #death-counter {
    background: rgba(45, 55, 72, 0.95);
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 18px;
    font-weight: bold;
}

.edit-btn {
    background: #4299E1;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-family: 'Courier New', monospace;
    font-weight: bold;
}

.edit-btn:hover {
    background: #3182CE;
}

/* Tool Palette */
#tool-palette {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    background: rgba(45, 55, 72, 0.95);
    padding: 10px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.tool-btn {
    width: 50px;
    height: 50px;
    background: #2D3748;
    border: 3px solid #4A5568;
    border-radius: 8px;
    cursor: pointer;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.tool-btn:hover {
    transform: scale(1.1);
}

.tool-btn.active {
    border-color: #48BB78;
    background: #2F855A;
    box-shadow: 0 0 12px rgba(72, 187, 120, 0.6);
}

/* Background Button */
.bg-btn {
    position: absolute;
    bottom: 80px;
    left: 20px;
    width: 60px;
    height: 60px;
    background: rgba(45, 55, 72, 0.95);
    border: 3px solid #4A5568;
    border-radius: 12px;
    cursor: pointer;
    font-size: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.bg-btn:hover {
    transform: scale(1.1);
    border-color: #48BB78;
}

/* Mobile Controls */
#mobile-controls {
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    display: none;
    justify-content: space-between;
    padding: 0 20px;
    pointer-events: none;
}

#mobile-controls > * {
    pointer-events: auto;
}

#joystick-zone {
    position: relative;
    width: 150px;
    height: 150px;
}

#joystick-base, #joystick-stick {
    position: absolute;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s;
}

#joystick-base {
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.2);
    border: 3px solid rgba(255, 255, 255, 0.4);
    transform: translate(-50%, -50%);
}

#joystick-stick {
    width: 40px;
    height: 40px;
    background: rgba(72, 187, 120, 0.8);
    border: 3px solid #48BB78;
    transform: translate(-50%, -50%);
}

.jump-btn {
    width: 100px;
    height: 100px;
    background: #48BB78;
    border: 4px solid #38A169;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    color: white;
    font-family: 'Courier New', monospace;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    user-select: none;
}

.jump-btn:active {
    transform: scale(0.95);
    background: #38A169;
}

/* Tutorial */
.tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.tutorial-content {
    background: #2D3748;
    padding: 30px;
    border-radius: 16px;
    max-width: 500px;
    text-align: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.tutorial-content h2 {
    color: #48BB78;
    margin-bottom: 20px;
}

.tutorial-step {
    margin: 20px 0;
}

.tutorial-step p {
    margin: 10px 0;
    line-height: 1.6;
}

.tutorial-btn {
    background: #48BB78;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    margin-top: 20px;
}

.tutorial-btn:hover {
    background: #38A169;
}

/* Footer */
footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    text-align: center;
    padding: 10px;
    background: rgba(26, 26, 26, 0.9);
    font-size: 12px;
    pointer-events: none;
}

footer a {
    color: #48BB78;
    text-decoration: none;
    pointer-events: auto;
}

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

/* Mobile Responsive */
@media (max-width: 768px) {
    #canvas {
        max-height: calc(100vh - 280px);
    }
    
    .tool-btn {
        width: 44px;
        height: 44px;
        font-size: 20px;
    }
    
    #tool-palette {
        bottom: 140px;
    }
    
    .bg-btn {
        bottom: 140px;
    }
    
    .top-btn {
        padding: 6px 12px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .tool-btn {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
    
    #tool-palette {
        gap: 4px;
        padding: 8px;
    }
}