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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #0a0f0d;
    font-family: 'Press Start 2P', monospace;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

#game-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    height: calc(100vh - 40px);
    padding: 10px;
    gap: 10px;
}

#canvas {
    background: #0d1912;
    border: 4px solid #2d4a3e;
    border-radius: 4px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    box-shadow: 
        0 0 20px rgba(45, 74, 62, 0.5),
        inset 0 0 30px rgba(0, 0, 0, 0.3);
}

#touch-controls {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 640px;
    padding: 10px;
    gap: 20px;
}

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

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

.dpad-btn {
    width: 50px;
    height: 50px;
    background: linear-gradient(145deg, #2d4a3e, #1a2f26);
    border: 3px solid #4ade80;
    border-radius: 8px;
    color: #4ade80;
    font-size: 20px;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s;
    box-shadow: 
        0 4px 0 #1a2f26,
        0 0 10px rgba(74, 222, 128, 0.3);
}

.dpad-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #1a2f26;
    background: #4ade80;
    color: #0a0f0d;
}

#action-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
}

.action-btn {
    width: 55px;
    height: 55px;
    border-radius: 50%;
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    font-weight: bold;
    cursor: pointer;
    border: 3px solid;
    transition: all 0.1s;
}

.action-btn.attack {
    background: linear-gradient(145deg, #ef4444, #b91c1c);
    border-color: #fca5a5;
    color: #ffffff;
    box-shadow: 0 4px 0 #991b1b, 0 0 15px rgba(239, 68, 68, 0.4);
}

.action-btn.grab {
    background: linear-gradient(145deg, #a855f7, #7c3aed);
    border-color: #d8b4fe;
    color: #ffffff;
    box-shadow: 0 4px 0 #6b21a8, 0 0 15px rgba(168, 85, 247, 0.4);
}

.action-btn.throw {
    background: linear-gradient(145deg, #3b82f6, #1d4ed8);
    border-color: #93c5fd;
    color: #ffffff;
    box-shadow: 0 4px 0 #1e40af, 0 0 15px rgba(59, 130, 246, 0.4);
}

.action-btn.special {
    background: linear-gradient(145deg, #fbbf24, #d97706);
    border-color: #fde68a;
    color: #1a1a1a;
    box-shadow: 0 4px 0 #b45309, 0 0 15px rgba(251, 191, 36, 0.4);
}

.action-btn:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 currentColor;
}

#footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    padding: 8px;
    background: #0a0f0d;
    color: #4ade80;
    font-size: 10px;
    border-top: 2px solid #2d4a3e;
}

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

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

/* Desktop: hide touch controls if mouse is primary */
@media (hover: hover) and (pointer: fine) {
    #touch-controls {
        opacity: 0.6;
    }
    
    #touch-controls:hover {
        opacity: 1;
    }
}

/* Small screens */
@media (max-width: 480px) {
    .dpad-btn {
        width: 44px;
        height: 44px;
        font-size: 16px;
    }
    
    .action-btn {
        width: 48px;
        height: 48px;
        font-size: 7px;
    }
    
    #touch-controls {
        padding: 5px;
        gap: 10px;
    }
}

/* Landscape orientation */
@media (orientation: landscape) and (max-height: 500px) {
    #game-wrapper {
        flex-direction: row;
        padding: 5px;
    }
    
    #touch-controls {
        flex-direction: column;
        width: auto;
        max-width: none;
        height: 100%;
        justify-content: center;
    }
    
    .dpad-btn, .action-btn {
        width: 40px;
        height: 40px;
        font-size: 14px;
    }
    
    .action-btn {
        font-size: 6px;
    }
}