/* 基础重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* 主容器布局 */
.container {
    display: flex;
    gap: 20px;
    background-color: #1a1a2e;
    border: 3px solid #16213e;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.game-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.game-area h1 {
    color: #fff;
    font-size: 56px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    margin-bottom: 20px;
}

#tetris-canvas {
    background-color: #111;
    border: 2px solid #333;
    border-radius: 5px;
    display: block;
    
    /* --- 核心优化：确保画布始终适应屏幕 --- */
    max-width: 90vw;      /* 最大宽度为屏幕宽度的 90% */
    max-height: 60vh;     /* 稍微调低高度比例（从70vh降到60vh），确保按钮在屏幕内 */
    width: auto;
    height: auto;
    margin: 0 auto;       /* 居中显示 */
    
    /* 移除之前的 transform，改用上面的自适应布局 */
    transform: none !important; 
}

/* 侧边栏样式 */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 25px;
    min-width: 320px;
}

.score-panel, .stats-panel, .info-panel, .next-panel {
    background-color: #16213e;
    border: 2px solid #0f3460;
    border-radius: 8px;
    padding: 15px;
}

.score-panel h2, .info-panel h3, .next-panel h3 {
    color: #e94560;
    font-size: 18px;
    margin-bottom: 15px;
    text-align: center;
    text-transform: uppercase;
}

.score-value {
    color: #fff;
    font-size: 72px;
    font-weight: bold;
    text-align: center;
    text-shadow: 0 0 10px rgba(233, 69, 96, 0.5);
}

.stat-item {
    display: flex;
    justify-content: space-between;
    color: #fff;
    padding: 8px 0;
    border-bottom: 1px solid #0f3460;
}

.info-panel ul {
    list-style: none;
    color: #fff;
    font-size: 14px;
    line-height: 1.8;
}

/* 按钮基础样式 */
.controls, .audio-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.audio-controls {
    flex-direction: row;
}

button {
    padding: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 5px;
    color: white;
    border: none;
}

#start-btn, #pause-btn, #reset-btn {
    background-color: #e94560;
    border: 2px solid #c73650;
}

.audio-btn {
    flex: 1;
    background-color: #16a085;
}

/* --- 手机端控制区样式 (默认在电脑端隐藏) --- */
.mobile-input-area {
    display: none;
    width: 100%;
    max-width: 400px;
    margin-top: 20px;
}

.direction-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 15px;
    margin: 15px 0;
}

.ctrl-btn {
    background-color: #34495e;
    font-size: 20px;
    box-shadow: 0 5px 0 #2c3e50;
    touch-action: manipulation; /* 消除点击延迟 */
    padding: 20px;
}

.ctrl-btn:active {
    transform: translateY(3px);
    box-shadow: 0 2px 0 #2c3e50;
}

.large { background-color: #e94560; box-shadow: 0 5px 0 #c73650; height: 80px; }
.full { width: 100%; background-color: #2a5298; box-shadow: 0 5px 0 #1e3c72; }

/* --- 响应式设计 --- */
@media (max-width: 768px) {
    body { padding: 10px; }
    
    .container {
        flex-direction: column;
        padding: 10px;
        border: none;
    }

    .game-area h1 { font-size: 28px; }

    /* 手机端显示控制按钮 */
    .mobile-input-area {
        display: flex;
        flex-direction: column;
    }

    /* 手机端调整侧边栏布局 */
    .sidebar {
        min-width: 100%;
        gap: 15px;
    }

    /* 隐藏对手机无用的说明面板 */
    .info-panel {
        display: none;
    }

    .score-value { font-size: 48px; }
    
    /* 让侧边栏的控制按钮排成一排 */
    .controls {
        flex-direction: row;
    }
    .controls button { flex: 1; font-size: 14px; }
}
