:root {
    --bg-color: #2c3e50;
    --container-bg: #34495e;
    --grid-cell-bg: #ecf0f1;
    --hidden-cell-bg: #34495e;
    --highlight-color: #f1c40f;
    --success-color: #2ecc71;
    --error-color: #e74c3c;
    --text-color: #ecf0f1;
    --shadow-color: rgba(0, 0, 0, 0.4);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    margin: 0;
}

/* 核心修正 1: 缩小游戏容器最大宽度，以便在屏幕上留出更大的边距来确保居中 */
.game-container {
    background: var(--container-bg);
    padding: 20px; 
    border-radius: 15px;
    box-shadow: 0 0 20px var(--shadow-color);
    text-align: center;
    width: 95%; 
    max-width: 350px; /* 进一步缩小到 350px，这是关键调整 */
}

h1 {
    color: var(--highlight-color); 
    margin-bottom: 10px;
}

.info-panel {
    display: flex;
    justify-content: space-around;
    padding: 10px 0;
    margin-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

#level-select {
    padding: 5px;
    border-radius: 4px;
}

.message {
    font-weight: bold;
    min-height: 25px;
    color: var(--success-color);
}

/* 游戏网格 - 核心修正 2: 保持网格相对于新父容器的百分比，并确保 margin: auto 居中 */
.grid-container {
    display: grid;
    gap: 3px; 
    margin: 15px auto; /* 确保使用 auto 来水平居中 */
    width: 90%; /* 稍微缩小网格的相对宽度，从 95% 调整到 90% */
    aspect-ratio: 1 / 1;
    padding: 5px; /* 进一步缩小内边距 */
    border: 3px solid var(--highlight-color);
    border-radius: 10px;
}

.grid-cell {
    background-color: var(--grid-cell-bg);
    color: var(--bg-color);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.6em; /* 进一步缩小字体大小 */
    font-weight: bold;
    border-radius: 4px;
    transition: background-color 0.3s, color 0.3s, transform 0.2s;
    user-select: none;
    cursor: default;
    box-shadow: 0 2px 3px var(--shadow-color);
    line-height: 1; 
}

/* 状态变化 */
.hidden-content {
    /* 隐藏状态的背景 */
    background-color: var(--hidden-cell-bg);
    color: var(--hidden-cell-bg); 
    cursor: default !important;
}

/* 测试高亮时，背景高亮，但数字内容在 JS 中已清除 */
.test-cell {
    background-color: var(--highlight-color);
    transform: scale(1.05);
}

.correct {
    background-color: var(--success-color) !important;
    color: white !important;
}

.incorrect {
    background-color: var(--error-color) !important;
    color: white !important;
}

/* 答案输入区样式 */
.input-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px; 
    margin: 15px auto;
    width: 80%; 
    max-width: 250px; 
}

/* 控制按钮样式 (不变) */
.controls { margin-top: 20px; }
.hidden { display: none !important; }
.controls button { padding: 12px 25px; font-size: 1.1rem; }
.input-pad button { background-color: #e67e22; padding: 15px 0; font-size: 1.3rem; }
.skip-btn { background-color: #7f8c8d !important; margin-top: 10px; }