@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

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

body {
    font-family: 'Press Start 2P', monospace;
    background: #0a0a0f;
    color: #fff;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}

/* CRT scanline effect */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.15),
        rgba(0, 0, 0, 0.15) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
    z-index: 100;
}

/* Game container */
#game-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Canvas */
#game-canvas {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    border: 3px solid #555;
    border-radius: 4px;
    background: #000;
    box-shadow: 0 0 30px rgba(0, 240, 255, 0.15);
}

/* Gesture zone overlay on canvas */
#gesture-zone {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    touch-action: none;
    display: none;
}

/* Mobile controls */
#mobile-controls {
    display: none;
    width: 100%;
    max-width: 360px;
    margin-top: 8px;
    padding: 0 10px;
}

.mobile-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    gap: 8px;
}

.mobile-btn {
    width: 72px;
    height: 72px;
    font-family: 'Press Start 2P', monospace;
    font-size: 18px;
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 14px;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.05s, border-color 0.05s, transform 0.05s;
}

.mobile-btn:active, .mobile-btn.pressed {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(0.92);
}

.mobile-btn.rotate {
    width: 72px;
    height: 72px;
    font-size: 24px;
    background: rgba(0, 240, 255, 0.12);
    border-color: rgba(0, 240, 255, 0.3);
}

.mobile-btn.rotate:active, .mobile-btn.rotate.pressed {
    background: rgba(0, 240, 255, 0.3);
    border-color: rgba(0, 240, 255, 0.6);
}

.mobile-btn.drop {
    width: 72px;
    height: 56px;
    font-size: 12px;
    background: rgba(255, 200, 0, 0.1);
    border-color: rgba(255, 200, 0, 0.25);
}

.mobile-btn.drop:active, .mobile-btn.drop.pressed {
    background: rgba(255, 200, 0, 0.25);
    border-color: rgba(255, 200, 0, 0.5);
}

.mobile-btn.harddrop {
    width: 100%;
    max-width: 200px;
    height: 56px;
    font-size: 12px;
    background: rgba(240, 50, 50, 0.12);
    border-color: rgba(240, 50, 50, 0.3);
}

.mobile-btn.harddrop:active, .mobile-btn.harddrop.pressed {
    background: rgba(240, 50, 50, 0.3);
    border-color: rgba(240, 50, 50, 0.6);
}

/* Instructions */
#instructions {
    margin-top: 12px;
    font-size: 8px;
    color: #666;
    text-align: center;
    line-height: 1.8;
}

/* Mobile gesture hints */
#gesture-hint {
    display: none;
    margin-top: 6px;
    font-size: 7px;
    color: #444;
    text-align: center;
}

/* Responsive */
@media (max-width: 520px) {
    body {
        justify-content: flex-start;
        padding-top: 8px;
    }

    #game-container {
        width: 100%;
    }

    #game-canvas {
        width: 95vw;
        max-width: 360px;
        height: auto;
    }

    #gesture-zone {
        display: block;
    }

    #mobile-controls {
        display: block;
    }

    #instructions {
        display: none;
    }

    #gesture-hint {
        display: block;
    }
}

@media (max-height: 750px) and (max-width: 520px) {
    .mobile-btn {
        width: 64px;
        height: 64px;
        font-size: 16px;
    }

    .mobile-btn.rotate {
        width: 64px;
        height: 64px;
        font-size: 20px;
    }

    .mobile-btn.drop, .mobile-btn.harddrop {
        height: 48px;
    }
}

@media (max-height: 700px) and (min-width: 521px) {
    #game-canvas {
        transform: scale(0.85);
        transform-origin: top center;
    }
}
