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

body {
    font-family: 'Arial', sans-serif;
    background: #0a0a0a;
    color: #666;
    min-height: 100vh;
    overflow: hidden;
}

#gameCanvas {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 2px solid #333;
    background: #0a0a0a;
}

.title {
    position: absolute;
    top: 20px;
    left: 20px;
    color: #4ecca3;
    font-size: 1.5rem;
    font-weight: bold;
}

.score-board {
    position: absolute;
    top: 20px;
    right: 20px;
    color: #666;
    font-size: 0.9rem;
    white-space: nowrap;
}

.score-board span {
    display: inline;
    margin-left: 15px;
}

.controls {
    position: absolute;
    bottom: 20px;
    left: 20px;
    color: #444;
    font-size: 0.8rem;
}

button {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: transparent;
    color: #444;
    border: 1px solid #333;
    padding: 8px 16px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

button:hover:not(:disabled) {
    color: #4ecca3;
    border-color: #4ecca3;
}

button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Mobile controls - 9 宫格十字布局 */
.mobile-controls {
    display: none;
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    grid-template-rows: repeat(3, 60px);
    grid-template-columns: repeat(3, 60px);
    gap: 8px;
}

/* 方向键在 grid 中的位置 */
#btnUp { grid-row: 1; grid-column: 2; }
#btnLeft { grid-row: 2; grid-column: 1; }
#btnAction { grid-row: 2; grid-column: 2; }
#btnRight { grid-row: 2; grid-column: 3; }
#btnDown { grid-row: 3; grid-column: 2; }

.dpad-btn {
    position: static;
    width: 60px;
    height: 60px;
    background: rgba(78, 204, 163, 0.1);
    border: 1px solid #4ecca3;
    border-radius: 0;
    color: #4ecca3;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.dpad-btn:active {
    background: rgba(78, 204, 163, 0.3);
}

/* Show mobile controls on touch devices */
@media (max-width: 768px) {
    .mobile-controls {
        display: grid;
    }

    .controls {
        display: none;
    }

    button#actionBtn {
        display: none;
    }

    .title {
        position: static;
        text-align: center;
        font-size: 1.2rem;
        margin-top: 20px;
        margin-bottom: 10px;
    }

    .score-board {
        position: static;
        text-align: center;
        font-size: 0.8rem;
        display: flex;
        justify-content: center;
        gap: 20px;
    }

    .score-board span {
        margin-left: 0;
    }

    #gameCanvas {
        position: static;
        transform: none;
        max-width: 360px;
        width: 90vw;
        height: auto;
        margin: 80px auto;
        display: block;
    }
}
