/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: Arial, sans-serif;
}

/* 页面主体样式 */
body {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    background-color: #f0f0f0;
    padding: 10px;
    overflow-x: hidden;
}

/* 标题样式 */
h1 {
    margin-bottom: 15px;
    color: #333;
    font-size: clamp(18px, 5vw, 24px);
}

/* 整合后的单个面板容器 - 桌面端样式 */
.game-panel {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    max-width: 500px;
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 0 15px rgba(0,0,0,0.2);
}

/* 游戏容器 - 桌面端+通用样式 */
.game-container {
    text-align: center;
    max-height: 600px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* 游戏画布 - 通用样式 */
#game-board {
    border: 1px solid #E3E3E3;
    background-color: #f8f8f8;
    width: 100%;
    max-width: 300px;
    max-height: 500px;
    height: auto;
    aspect-ratio: 10/20;
}

/* 右侧功能区 - 桌面端样式 */
.right-panel {
    width: 220px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* 下一个方块预览画布 - 通用样式 */
#next-piece-preview {
    width: 80%;
    height: auto;
    aspect-ratio: 1/1;
    margin: 0 auto 15px;
    background-color: #f8f8f8;
    border: 1px solid #ccc;
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 分数面板样式 - 通用 */
.score-title {
    font-weight: bold;
    color: #4CAF50;
    margin-bottom: 8px;
    font-size: 15px;
}

.score-item {
    margin: 5px 0;
    display: flex;
    justify-content: space-between;
    font-size: 13px;
}

.score-label {
    color: #666;
}

.score-value {
    font-weight: bold;
    color: #333;
}

/* 开始/暂停按钮 - 通用 */
.game-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
}

.game-btn {
    flex: 1;
    padding: 12px 0;
    font-size: 13px;
    cursor: pointer;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    transition: background-color 0.3s;
}

.game-btn:hover {
    background-color: #45a049;
}

.game-btn:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

/* 方向键控制区 - 通用 */
.direction-controls {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 10px;
}

.dir-btn {
    aspect-ratio: 1;
    font-size: 24px;
    min-height: 50px;
    background-color: #2196F3;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.dir-btn.up {
    grid-column: 2;
    grid-row: 1;
}

.dir-btn.left {
    grid-column: 1;
    grid-row: 2;
}

.dir-btn.down {
    grid-column: 2;
    grid-row: 2;
}

.dir-btn.right {
    grid-column: 3;
    grid-row: 2;
}

/* 快速下落按钮 - 通用 */
.drop-btn {
    width: 100%;
    padding: 12px 0;
    font-size: 16px;
    background-color: #ff9800;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    margin-top: 5px;
}

/* 得分显示 - 通用 */
#score {
    font-size: clamp(16px, 4vw, 20px);
    margin: 10px 0;
    font-weight: bold;
}

/* 操作说明 - 通用 */
.instructions {
    margin-top: 10px;
    font-size: 13px;
    color: #666;
    line-height: 1.4;
}

/* ===================== 核心修改：移动端适配（7:3比例） ===================== */
@media (max-width: 768px) {
    /* 1. 整个游戏面板最宽300px，横向排列（7:3） */
    .game-panel {
        flex-direction: row !important; /* 强制横向排列 */
        align-items: flex-start;
        padding: 10px;
        max-width: 350px !important; /* 面板最宽300px */
        width: 100%;
        gap: 5px !important; /* 减小间距，适配窄面板 */
    }

    /* 2. 游戏区占70%宽度 */
    .game-container {
        width: 70% !important;
        max-width: none !important;
        max-height: 600px;
        padding: 0;
    }

    /* 3. 功能区占30%宽度 */
    .right-panel {
        width: 30% !important;
        max-width: none !important;
        padding: 0 5px !important;
        gap: 8px !important; /* 减小内部间距 */
    }

    /* 4. 游戏画布适配70%宽度 */
    #game-board {
        max-width: none !important;
        width: 100%;
        max-height: 500px; /* 移动端适当降低高度，适配窄面板 */
    }

    /* 5. 功能区元素适配 */
    .score-title {
        font-size: 12px !important; /* 缩小标题字体 */
        margin-bottom: 4px !important;
    }

    .score-item {
        font-size: 11px !important; /* 缩小分数文字 */
    }

    /* 6. 按钮适配窄面板 */
    .game-btn {
        padding: 6px 0 !important; /* 缩小开始/暂停按钮 */
        font-size: 11px !important;
    }

    .dir-btn {
        min-height: 30px !important; /* 缩小方向键 */
        font-size: 16px !important;
    }

    .drop-btn {
        padding: 6px 0 !important; /* 缩小快速下落按钮 */
        font-size: 11px !important;
    }

    /* 7. 预览区适配 */
    #next-piece-preview {
        width: 100% !important;
        max-width: 60px !important; /* 缩小预览画布 */
        margin: 0 auto 5px !important;
    }

    /* 8. 其他优化 */
    h1 {
        font-size: 18px !important; /* 缩小标题 */
    }

    .instructions {
        display: none !important; /* 隐藏说明文字 */
    }

    .game-controls {
        gap: 4px !important; /* 减小按钮间距 */
        margin-bottom: 8px !important;
    }

    .direction-controls {
        gap: 4px !important; /* 减小方向键间距 */
        margin-bottom: 5px !important;
    }

    #score {
        font-size: 14px !important; /* 缩小得分文字 */
        margin: 5px 0 !important;
    }
}

/* 小屏手机额外适配（保证按钮可点击） */
@media (max-width: 320px) {
    .game-panel {
        max-width: 280px !important; /* 更小屏面板宽度 */
    }

    .dir-btn {
        min-height: 25px !important;
        font-size: 14px !important;
    }
}