* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    touch-action: manipulation;
}

body {
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #4a3425 0%, #6b4e3a 100%);
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #e8d5b7;
    position: relative;
}

body::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 10% 20%, rgba(107, 78, 58, 0.2) 0%, rgba(107, 78, 58, 0) 20%),
        radial-gradient(circle at 90% 80%, rgba(140, 109, 79, 0.2) 0%, rgba(140, 109, 79, 0) 20%),
        linear-gradient(135deg, #4a3425 0%, #6b4e3a 100%);
    background-image: url("data:image/svg+xml,%3Csvg width='200' height='200' viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M20 30c7.732 0 14-6.268 14-14s-6.268-14-14-14-14 6.268-14 14 6.268 14 14 14zm96 50c7.732 0 14-6.268 14-14s-6.268-14-14-14-14 6.268-14 14 6.268 14 14 14zm-86-14c3.314 0 6-2.686 6-6s-2.686-6-6-6-6 2.686-6 6 2.686 6 6 6zm126 62c3.314 0 6-2.686 6-6s-2.686-6-6-6-6 2.686-6 6 2.686 6 6 6zM68 180c3.314 0 6-2.686 6-6s-2.686-6-6-6-6 2.686-6 6 2.686 6 6 6zm112-152c3.314 0 6-2.686 6-6s-2.686-6-6-6-6 2.686-6 6 2.686 6 6 6zM24 172c4.42 0 8-3.58 8-8s-3.58-8-8-8-8 3.58-8 8 3.58 8 8 8zm56-130c4.42 0 8-3.58 8-8s-3.58-8-8-8-8 3.58-8 8 3.58 8 8 8zm46-22c5.52 0 10-4.48 10-10s-4.48-10-10-10-10 4.48-10 10 4.48 10 10 10zm-12 120c4.42 0 8-3.58 8-8s-3.58-8-8-8-8 3.58-8 8 3.58 8 8 8zm58 44c5.52 0 10-4.48 10-10s-4.48-10-10-10-10 4.48-10 10 4.48 10 10 10zM64 126c5.52 0 10-4.48 10-10s-4.48-10-10-10-10 4.48-10 10 4.48 10 10 10zm114-26c5.52 0 10-4.48 10-10s-4.48-10-10-10-10 4.48-10 10 4.48 10 10 10zm-18-42c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zM120 182c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zM70 82c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zM24 120c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4z' fill='%23e8d5b7' fill-opacity='0.1' fill-rule='evenodd'/%3E%3C/svg%3E");
    opacity: 0.6;
    z-index: -1;
}

.game-container {
    width: 95%;
    height: 95vh;
    background: linear-gradient(to bottom, rgba(232, 213, 183, 0.9), rgba(212, 185, 140, 0.8));
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 
        0 15px 35px rgba(0, 0, 0, 0.35), 
        0 5px 15px rgba(0, 0, 0, 0.25),
        inset 0 0 10px rgba(255, 255, 255, 0.2);
    position: relative;
    border: 10px solid #8B6E4E;
    display: flex;
    flex-direction: column;
}

.wood-frame {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0 L100 0 L100 100 L0 100 Z' fill='none' stroke='%238B6E4E' stroke-width='1' stroke-opacity='0.15'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 0;
}

.page {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 30px;
    transition: transform 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55), opacity 0.5s;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
    z-index: 2;
}

.page.active {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0);
}

.page-title {
    text-align: center;
    font-size: 2.8rem;
    font-weight: 700;
    margin: 20px 0 40px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
    color: #5D4037;
    letter-spacing: 2px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.page-title::after {
    content: "";
    position: absolute;
    bottom: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: 4px;
    background: linear-gradient(90deg, transparent, #8B6E4E, transparent);
    border-radius: 2px;
}

.title-icon {
    display: inline-block;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    margin: 0 20px;
    vertical-align: middle;
    position: relative;
    top: -5px;
    box-shadow: 0 3px 6px rgba(0,0,0,0.16);
    animation: float 3s ease-in-out infinite;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.8rem;
    color: #8B6E4E;
    background: radial-gradient(circle at 30% 30%, #f5f0e6, #e0d7c5);
    border: 2px solid #8B6E4E;
}

.title-icon.left {
    background: radial-gradient(circle at 30% 30%, #3e2d20, #1a130e);
    color: #D4B98C;
}

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0px); }
}

.button-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 25px;
    flex: 1;
    justify-content: center;
    position: relative;
    z-index: 2;
}

.btn {
    min-width: 260px;
    height: 70px;
    background: linear-gradient(to bottom, #D4B98C, #C9A87A);
    border: none;
    border-radius: 12px;
    color: #5D4037;
    font-size: 1.4rem;
    font-weight: 600;
    box-shadow: 
        0 6px 12px rgba(0,0,0,0.15), 
        inset 0 2px 0 rgba(255,255,255,0.4),
        0 0 0 2px #8B6E4E;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 30px;
    text-align: center;
    letter-spacing: 1px;
    z-index: 1;
}

.btn::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, rgba(255,255,255,0.3), rgba(255,255,255,0.1));
    z-index: -1;
    transition: opacity 0.3s;
}

.btn:hover {
    transform: translateY(-5px);
    box-shadow: 
        0 10px 20px rgba(0,0,0,0.2), 
        inset 0 2px 0 rgba(255,255,255,0.4),
        0 0 0 2px #8B6E4E;
}

.btn:active {
    transform: translateY(0);
}

.btn i {
    margin-right: 12px;
    font-size: 1.6rem;
}

.btn-exit {
    background: linear-gradient(to bottom, #A67C52, #8B6E4E);
    color: #f5f0e6;
}

.btn-difficulty {
    min-width: 240px;
    height: 80px;
    font-size: 1.3rem;
}

.btn-difficulty.primary {
    background: linear-gradient(to bottom, #E8D5B7, #D4B98C);
}

.btn-difficulty.medium {
    background: linear-gradient(to bottom, #C9A87A, #B8966A);
    color: #3e2d20;
}

.btn-difficulty.hard {
    background: linear-gradient(to bottom, #8B6E4E, #6b4e3a);
    color: #f5f0e6;
}

.btn-game {
    min-width: 160px;
    height: 60px;
    font-size: 1.2rem;
    border-radius: 10px;
}

.btn-restart {
    background: linear-gradient(to bottom, #70A859, #5c8a48);
    color: white;
}

.btn-undo {
    background: linear-gradient(to bottom, #E6C251, #d9b347);
}

.btn-menu {
    background: linear-gradient(to bottom, #C75A4A, #a94436);
    color: white;
}

.btn-save {
    background: linear-gradient(to bottom, #8B6E4E, #6b4e3a);
    color: white;
}

.btn-hint {
    background: linear-gradient(to bottom, #6A5ACD, #483D8B);
    color: white;
}

.btn-check {
    background: linear-gradient(to bottom, #E6C251, #d9b347);
    color: #5D4037;
}

.btn-submit {
    background: linear-gradient(to bottom, #70A859, #5c8a48);
    color: white;
}

/* 游戏区域 - 左右结构布局 - 关键修改 */
.game-area {
    width: 100%;
    height: 100%;
    display: flex;
    padding: 10px;
    flex-direction: row;
}

/* 棋盘区域 - 占据左侧大部分空间 */
.board-section {
    flex: 3;
    display: flex;
    flex-direction: column;
    padding-right: 10px;
    align-items: center;
    justify-content: center;
    min-width: 0;
}

.board-container {
    flex: 1;
    display: flex;
    position: relative;
    background: rgba(212, 185, 140, 0.6);
    border-radius: 12px;
    border: 2px solid #8B6E4E;
    box-shadow: inset 0 4px 12px rgba(0,0,0,0.1);
    padding: 15px;
    overflow: hidden;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 100%;
    max-height: 100%;
    min-height: 300px;
}

/* 关键修改：确保数独棋盘在任何屏幕比例下都保持正方形，并与右侧等高 */
.board-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 1/1;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #E8D5B7;
    border: 3px solid #8B6E4E;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    min-width: 280px;
    min-height: 280px;
}

#sudoku-board {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(9, 1fr);
    width: 100%;
    height: 100%;
    position: relative;
    background: #E8D5B7;
}

.sudoku-cell {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid #8B6E4E;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 1.8rem;
    font-weight: bold;
    font-family: 'Courier New', monospace;
    color: #5D4037;
    font-size: min(1.8rem, 4vw);
}

.sudoku-cell.fixed {
    background-color: rgba(139, 110, 78, 0.1);
    color: #3e2d20;
    font-weight: bold;
}

.sudoku-cell.selected {
    background-color: rgba(212, 185, 140, 0.5);
    box-shadow: inset 0 0 0 2px #8B6E4E;
}

.sudoku-cell.error {
    background-color: rgba(199, 90, 74, 0.3);
    color: #a94436;
}

.sudoku-cell.correct {
    background-color: rgba(112, 168, 89, 0.3);
}

.sudoku-cell.hint {
    color: rgba(93, 64, 55, 0.5);
    font-style: italic;
}

/* 区块边框加粗 */
.sudoku-cell:nth-child(3n) {
    border-right: 2px solid #8B6E4E;
}

.sudoku-cell:nth-child(n+19):nth-child(-n+27),
.sudoku-cell:nth-child(n+46):nth-child(-n+54) {
    border-bottom: 2px solid #8B6E4E;
}

/* 控制面板区域 - 右侧窄边栏 - 关键修改 */
.control-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding-left: 10px;
    max-width: 280px;
    height: 100%;
    min-width: 0;
    min-width: 200px;
}

.game-header {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 15px;
    background: rgba(212, 185, 140, 0.9);
    border-radius: 12px;
    margin-bottom: 10px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    border: 2px solid #8B6E4E;
    position: relative;
    z-index: 2;
    height: auto;
    flex-shrink: 0;
}

.timer-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.timer {
    background: rgba(245, 239, 224, 0.9);
    color: #5D4037;
    padding: 8px 15px;
    border-radius: 8px;
    font-size: 1.5rem;
    font-weight: bold;
    min-width: 100px;
    text-align: center;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
    font-family: 'Courier New', monospace;
    border: 2px solid #8B6E4E;
    font-size: min(1.5rem, 4vw);
}

/* 关键修改：游戏底部区域 */
.game-footer {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 15px;
    background: rgba(212, 185, 140, 0.9);
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    border: 2px solid #8B6E4E;
    flex: 1;
    justify-content: space-between;
    min-height: 0;
}

/* 关键修改：数字键盘两列布局 */
.number-pad {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin: 0;
    flex: 1;
    min-height: 0;
}

.num-btn {
    height: 100%;
    min-height: 45px;
    background: linear-gradient(to bottom, #E8D5B7, #D4B98C);
    border: 2px solid #8B6E4E;
    border-radius: 8px;
    font-size: 1.5rem;
    font-weight: bold;
    color: #5D4037;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s;
    font-size: min(1.5rem, 4vw);
}

.num-btn:active {
    transform: scale(0.95);
    background: linear-gradient(to bottom, #D4B98C, #C9A87A);
}

/* 关键修改：游戏功能按钮区域横向排列 - 检查/提交、提示、返回 */
.game-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.game-actions .btn-game {
    flex: 1;
    min-width: 0;
    height: 45px;
    font-size: 1rem;
}

.settings-container {
    max-width: 600px;
    margin: 0 auto;
    background: rgba(245, 239, 224, 0.9);
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.08);
    border: 3px solid #8B6E4E;
    position: relative;
    z-index: 2;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 15px;
    border-bottom: 2px dashed #D4B98C;
}

.setting-label {
    font-size: 1.3rem;
    font-weight: 600;
    color: #5D4037;
}

.rules-container {
    max-width: 700px;
    margin: 0 auto;
    background: rgba(245, 239, 224, 0.95);
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.08);
    border: 3px solid #D4B98C;
    max-height: 60vh;
    overflow-y: auto;
    position: relative;
    z-index: 2;
}

.rules-content {
    line-height: 1.8;
    font-size: 1.1rem;
    padding: 15px;
    color: #5D4037;
}

.rules-content p {
    margin-bottom: 20px;
    text-align: justify;
}

.rules-content h3 {
    margin: 25px 0 15px;
    color: #8B6E4E;
    border-bottom: 2px solid #D4B98C;
    padding-bottom: 8px;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s;
}

.modal.active {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background: radial-gradient(ellipse at center, #A67C52 0%, #8B6E4E 100%);
    border-radius: 20px;
    padding: 40px;
    width: 85%;
    max-width: 450px;
    text-align: center;
    color: white;
    box-shadow: 0 15px 35px rgba(0,0,0,0.4);
    border: 4px solid #D4B98C;
    position: relative;
    transform: scale(0.9);
    animation: modalAppear 0.5s forwards;
}

@keyframes modalAppear {
    to {
        transform: scale(1);
    }
}

.modal-title {
    font-size: 2.2rem;
    margin-bottom: 35px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    letter-spacing: 1px;
}

.modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
}

.modal-btn {
    flex: 1;
    height: 60px;
    border-radius: 12px;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    border: none;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    transition: all 0.3s;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 7px 18px rgba(0,0,0,0.3);
}

.modal-btn:active {
    transform: translateY(0);
}

.modal-btn.primary {
    background: linear-gradient(to bottom, #70A859, #5c8a48);
    color: white;
}

.modal-btn.secondary {
    background: linear-gradient(to bottom, #C9A87A, #B8966A);
    color: #3e2d20;
}

/* 胜利提示条 */
.win-banner {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(90deg, #8B6E4E, #A67C52);
    color: white;
    padding: 12px 30px;
    border-radius: 30px;
    font-size: 1.5rem;
    font-weight: bold;
    z-index: 100;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    gap: 12px;
    opacity: 0;
    transition: opacity 0.5s;
}

.win-banner.show {
    opacity: 1;
}

/* 难度选择页面 */
.difficulty-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.difficulty-title {
    font-size: 2.5rem;
    margin-bottom: 40px;
    text-align: center;
    color: #5D4037;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.difficulty-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 25px;
    width: 100%;
    max-width: 300px;
    margin-bottom: 30px;
}

.difficulty-btn-large {
    min-width: 260px;
    height: 80px;
    font-size: 1.5rem;
    border-radius: 15px;
    border: 3px solid #8B6E4E;
    background: linear-gradient(to bottom, #E8D5B7, #D4B98C);
    color: #5D4037;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s;
    font-weight: bold;
    box-shadow: 
        0 6px 12px rgba(0,0,0,0.15), 
        inset 0 2px 0 rgba(255,255,255,0.4);
    position: relative;
    overflow: hidden;
}

.difficulty-btn-large::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, rgba(255,255,255,0.3), rgba(255,255,255,0.1));
    z-index: 1;
    transition: opacity 0.3s;
}

.difficulty-btn-large:hover {
    transform: translateY(-5px);
    box-shadow: 
        0 10px 20px rgba(0,0,0,0.2), 
        inset 0 2px 0 rgba(255,255,255,0.4);
}

.difficulty-btn-large.easy {
    background: linear-gradient(to bottom, #70A859, #5c8a48);
    color: white;
}

.difficulty-btn-large.medium {
    background: linear-gradient(to bottom, #E6C251, #d9b347);
    color: #5D4037;
}

.difficulty-btn-large.hard {
    background: linear-gradient(to bottom, #C75A4A, #a94436);
    color: white;
}

.back-button {
    margin-top: 30px;
    background: linear-gradient(to bottom, #8B6E4E, #6b4e3a);
    color: white;
}

/* 响应式调整 - 重点优化小屏幕 */
@media (max-width: 1024px) {
    .game-area {
        flex-direction: row;
    }
    
    .board-section {
        padding-right: 10px;
        padding-bottom: 0;
        flex: 3;
    }
    
    .control-panel {
        flex-direction: column;
        max-width: 280px;
        padding-left: 10px;
        padding-top: 0;
        flex: 1;
    }
    
    .game-header {
        flex: 0;
        margin-bottom: 10px;
        margin-right: 0;
    }
    
    .game-footer {
        flex: 1;
        margin-left: 0;
    }
    
    /* 字体大小调整 */
    .sudoku-cell {
        font-size: min(1.6rem, 3.5vw);
    }
    
    .timer {
        font-size: min(1.6rem, 3.5vw);
    }
    
    .num-btn {
        font-size: min(1.6rem, 3.5vw);
    }
    
    .game-actions .btn-game {
        font-size: min(0.9rem, 2.2vw);
    }
}

@media (max-width: 768px) {
    .btn {
        min-width: 220px;
        height: 60px;
        font-size: 1.2rem;
    }
    
    .page-title {
        font-size: 2.2rem;
        margin: 15px 0 30px;
    }
    
    .game-header {
        padding: 15px;
        flex-direction: column;
        gap: 8px;
    }
    
    .timer {
        font-size: min(1.4rem, 3.2vw);
        min-width: 100px;
        padding: 5px 10px;
    }
    
    .control-panel {
        flex-direction: column;
        max-width: 220px;
    }
    
    .game-header, .game-footer {
        margin: 5px 0;
    }
    
    .btn-game {
        width: 100%;
        min-width: auto;
        font-size: min(1.1rem, 2.5vw);
    }
    
    .win-banner {
        font-size: 1.2rem;
        padding: 8px 20px;
        top: 10px;
    }
    
    .title-icon {
        width: 40px;
        height: 40px;
        margin: 0 10px;
        font-size: 1.5rem;
    }
    
    .modal-buttons {
        flex-direction: column;
        gap: 15px;
    }
    
    .modal-btn {
        width: 100%;
    }
    
    .sudoku-cell {
        font-size: min(1.4rem, 3vw);
    }
    
    .difficulty-btn-large {
        min-width: 220px;
        height: 70px;
        font-size: 1.3rem;
    }
    
    /* 关键：进一步缩小棋盘最小尺寸 */
    .board-wrapper {
        min-width: 220px;
        min-height: 220px;
    }
    
    .control-panel {
        min-width: 160px;
    }
    
    .game-actions .btn-game {
        height: 45px;
        font-size: min(0.8rem, 2vw);
    }
}

/* 横屏优化 */
@media (max-height: 600px) and (orientation: landscape) {
    .game-container {
        height: 98vh;
        width: 98%;
    }
    
    .board-wrapper {
        width: 70vmin;
        height: 70vmin;
        max-width: 70vmin;
        max-height: 70vmin;
    }
    
    .game-area {
        padding: 5px;
    }
    
    .game-header {
        padding: 8px 15px;
        margin-bottom: 5px;
        height: auto;
    }
    
    .timer {
        font-size: min(1.3rem, 3vw);
        min-width: 90px;
        padding: 4px 8px;
    }
    
    .game-footer {
        padding: 10px 0;
        margin-top: 5px;
        height: auto;
    }
    
    .btn-game {
        height: 50px;
        font-size: min(1rem, 2.2vw);
    }
    
    /* 关键：横屏时适当调整布局比例 */
    .board-section {
        flex: 2.5;
    }
    
    .control-panel {
        flex: 1;
    }
    
    .game-actions .btn-game {
        height: 40px;
        font-size: min(0.8rem, 1.8vw);
    }
}

/* 小度智能屏幕设备优化 */
@media (max-width: 480px) and (max-height: 480px) {
    .game-container {
        width: 98%;
        height: 98%;
    }
    
    .page {
        padding: 10px;
    }
    
    .page-title {
        font-size: 1.8rem;
        margin: 10px 0 20px;
    }
    
    .title-icon {
        width: 35px;
        height: 35px;
        margin: 0 8px;
        font-size: 1.2rem;
    }
    
    .btn {
        min-width: 200px;
        height: 50px;
        font-size: 1.1rem;
    }
    
    .board-container {
        padding: 8px;
    }
    
    .sudoku-cell {
        font-size: min(1.2rem, 2.8vw);
    }
    
    .control-panel {
        max-width: 100%;
        min-width: 140px;
    }
    
    .game-header, .game-footer {
        padding: 10px;
    }
    
    .timer {
        font-size: min(1.2rem, 2.8vw);
        min-width: 80px;
        padding: 4px 8px;
    }
    
    .num-btn {
        height: 45px;
        font-size: min(1.5rem, 3.2vw);
    }
    
    .btn-game {
        height: 45px;
        font-size: min(1rem, 2.2vw);
    }
    
    /* 关键：小屏幕时进一步缩小棋盘最小尺寸 */
    .board-wrapper {
        min-width: 180px;
        min-height: 180px;
    }
    
    .game-actions .btn-game {
        height: 35px;
        font-size: min(0.7rem, 1.8vw);
    }
}

.wood-grain {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0 L100 0 L100 100 L0 100 Z' fill='none' stroke='%238B6E4E' stroke-width='1' stroke-opacity='0.1'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 1;
}

.corner-decoration {
    position: absolute;
    width: 80px;
    height: 80px;
    z-index: 2;
}

.corner-tl {
    top: 15px;
    left: 15px;
    border-top: 4px solid #8B6E4E;
    border-left: 4px solid #8B6E4E;
}

.corner-tr {
    top: 15px;
    right: 15px;
    border-top: 4px solid #8B6E4E;
    border-right: 4px solid #8B6E4E;
}

.corner-bl {
    bottom: 15px;
    left: 15px;
    border-bottom: 4px solid #8B6E4E;
    border-left: 4px solid #8B6E4E;
}

.corner-br {
    bottom: 15px;
    right: 15px;
    border-bottom: 4px solid #8B6E4E;
    border-right: 4px solid #8B6E4E;
}

.board-wood {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        linear-gradient(90deg, rgba(139, 110, 78, 0.1) 1px, transparent 1px),
        linear-gradient(rgba(139, 110, 78, 0.1) 1px, transparent 1px);
    background-size: 30px 30px;
    pointer-events: none;
    z-index: 1;
}

/* 顶部装饰 */
.header-decoration {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 15px;
    background: linear-gradient(to bottom, #8B6E4E, #6b4e3a);
    z-index: 3;
}

/* 底部装饰 */
.footer-decoration {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 15px;
    background: linear-gradient(to top, #8B6E4E, #6b4e3a);
    z-index: 3;
}

/* 按钮光泽效果 */
.btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    transition: 0.5s;
    z-index: 1;
}

.btn:hover::after {
    left: 100%;
}

/* 点击效果 */
.sudoku-cell:active {
    background-color: rgba(139, 110, 78, 0.2);
}

/* 数字输入动画 */
@keyframes numberPop {
    0% { transform: scale(0); opacity: 0; }
    70% { transform: scale(1.1); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

.number-pop {
    animation: numberPop 0.3s ease-out;
}

/* 错误动画 */
@keyframes errorShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.error-shake {
    animation: errorShake 0.3s ease-in-out;
}

/* 音效开关 - 移到左上角 */
.sound-toggle {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(to bottom, #D4B98C, #C9A87A);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 3px 6px rgba(0,0,0,0.16);
    z-index: 10;
    transition: all 0.3s;
}

.sound-toggle:hover {
    transform: scale(1.1);
}

.sound-toggle i {
    font-size: 1.5rem;
    color: #5D4037;
}

.sound-toggle.muted {
    background: linear-gradient(to bottom, #C75A4A, #a94436);
}

.sound-toggle.muted i {
    color: white;
}

/* 棋盘尺寸自适应计算 - 关键修改 */
@media (orientation: portrait) {
    .board-wrapper {
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
    }
}

@media (orientation: landscape) {
    .board-wrapper {
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
    }
    
    /* 横屏时适当调整布局比例 */
    .board-section {
        flex: 2.5;
    }
    
    .control-panel {
        flex: 1;
    }
}

/* 棋盘尺寸自适应 - 小屏幕 */
@media (max-width: 768px) and (orientation: portrait) {
    .board-wrapper {
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
    }
}

@media (max-height: 600px) and (orientation: landscape) {
    .board-wrapper {
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
    }
}

/* 新增：超小屏幕设备优化 */
@media (max-width: 360px) {
    .game-container {
        width: 98%;
        height: 98%;
        border-width: 5px;
    }
    
    .page {
        padding: 5px;
    }
    
    .page-title {
        font-size: 1.6rem;
        margin: 10px 0 20px;
    }
    
    .title-icon {
        width: 30px;
        height: 30px;
        margin: 0 5px;
        font-size: 1rem;
    }
    
    .btn {
        min-width: 180px;
        height: 45px;
        font-size: 1rem;
        padding: 0 20px;
    }
    
    .board-wrapper {
        min-width: 160px;
        min-height: 160px;
    }
    
    .control-panel {
        min-width: 120px;
    }
    
    .game-header, .game-footer {
        padding: 8px;
    }
    
    .timer {
        font-size: min(1rem, 2.5vw);
        min-width: 70px;
        padding: 3px 6px;
    }
    
    .num-btn {
        height: 40px;
        font-size: min(1.2rem, 2.8vw);
    }
    
    .btn-game {
        height: 40px;
        font-size: min(0.9rem, 2vw);
    }
    
    .game-actions .btn-game {
        height: 30px;
        font-size: min(0.6rem, 1.6vw);
    }
    
    /* 缩小难度选择按钮 */
    .difficulty-btn-large {
        min-width: 180px;
        height: 60px;
        font-size: 1.1rem;
    }
}

/* 小度最小屏幕特殊优化 */
@media (max-width: 360px) and (max-height: 640px) {
    .game-container {
        width: 99%;
        height: 99%;
        border-width: 3px;
    }
    
    .page {
        padding: 5px;
    }
    
    .page-title {
        font-size: 1.4rem;
        margin: 5px 0 15px;
    }
    
    .title-icon {
        width: 25px;
        height: 25px;
        margin: 0 3px;
        font-size: 0.9rem;
    }
    
    .btn {
        min-width: 160px;
        height: 40px;
        font-size: 0.9rem;
        padding: 0 15px;
    }
    
    .board-wrapper {
        min-width: 140px;
        min-height: 140px;
    }
    
    .control-panel {
        min-width: 100px;
    }
    
    .game-header, .game-footer {
        padding: 5px;
    }
    
    .timer {
        font-size: min(0.9rem, 2.2vw);
        min-width: 60px;
        padding: 2px 4px;
    }
    
    .num-btn {
        height: 35px;
        font-size: min(1rem, 2.2vw);
    }
    
    .btn-game {
        height: 35px;
        font-size: min(0.8rem, 1.6vw);
    }
    
    .game-actions .btn-game {
        height: 25px;
        font-size: min(0.5rem, 1.2vw);
    }
    
    /* 进一步缩小难度选择按钮 */
    .difficulty-btn-large {
        min-width: 160px;
        height: 50px;
        font-size: 1rem;
    }
    
    .sound-toggle {
        width: 40px;
        height: 40px;
    }
    
    .sound-toggle i {
        font-size: 1.2rem;
    }
    
    /* 关键修改：完全解除难度选择按钮的最小宽度限制 */
    .difficulty-btn-large {
        min-width: unset;
        width: 90%;
        max-width: 200px;
    }
    
    /* 确保返回按钮在小屏幕上可见 */
    .back-button {
        margin-top: 15px;
        width: 90%;
        max-width: 200px;
    }
}

/* 新增：检查结果弹窗 */
.check-result-modal {
    background: radial-gradient(ellipse at center, #A67C52 0%, #8B6E4E 100%);
    border-radius: 20px;
    padding: 40px;
    width: 85%;
    max-width: 500px;
    text-align: center;
    color: white;
    box-shadow: 0 15px 35px rgba(0,0,0,0.4);
    border: 4px solid #D4B98C;
    position: relative;
    transform: scale(0.9);
    animation: modalAppear 0.5s forwards;
}

.check-result {
    margin-bottom: 25px;
    font-size: 1.3rem;
    line-height: 1.6;
}

.check-result.success {
    color: #a8e6a3;
}

.check-result.warning {
    color: #ffcc80;
}

.check-result.error {
    color: #ff8a80;
}

.check-stats {
    display: flex;
    justify-content: space-around;
    margin: 20px 0;
    padding: 15px;
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.9rem;
    opacity: 0.8;
}

/* 小度设备适配 - 根据文档添加 */
/* 7英寸小度屏适配 */
@media (device-width: 1024px) and (device-height: 600px) {
    .game-container { 
        width: calc(100% - 40px);
        height: calc(100vh - 40px);
    }
    
    .page {
        padding: 20px;
    }
    
    .game-btn { 
        font-size: 14px !important; 
        min-width: 48px !important;
        min-height: 48px !important;
    }
    
    .game-title { 
        font-size: 24px !important; 
    }
}

/* 10英寸小度屏适配 */
@media (device-width: 1280px) and (device-height: 800px) {
    .game-container { 
        width: calc(100% - 40px);
        height: calc(100vh - 40px);
    }
    
    .page {
        padding: 24px;
    }
    
    .game-btn { 
        font-size: 16px !important; 
        min-width: 48px !important;
        min-height: 48px !important;
    }
    
    .game-title { 
        font-size: 28px !important; 
    }
}

/* 遥控器焦点适配 */
.btn:focus, .num-btn:focus, .difficulty-btn-large:focus {
    outline: 2px solid #d4af37 !important;
    outline-offset: 2px !important;
}

/* 遥控器设备禁用hover */
@media (pointer: coarse) {
    .btn:hover, .num-btn:hover, .difficulty-btn-large:hover {
        background-color: inherit !important;
        transform: none !important;
    }
}

/* 为小度系统退出按钮预留位置 */
.dueros-exit-area {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    z-index: 10;
    /* 小度系统会在这里放置退出按钮 */
}