* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --board-size: 14;
    --unit: min(1vw, 1vh);
}

html {
    font-size: 16px;
}

@media (max-width: 480px) {
    html {
        font-size: 14px;
    }
}

@media (max-width: 320px) {
    html {
        font-size: 12px;
    }
}

body {
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #4a3425 0%, #6b4e3a 100%);
    min-height: 100vh;
    width: 100vw;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #e8d5b7;
    position: relative;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

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: 98vw;
    height: 98vh;
    max-width: 100vw;
    max-height: 100vh;
    background: linear-gradient(to bottom, rgba(232, 213, 183, 0.9), rgba(212, 185, 140, 0.8));
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: 
        0 1rem 2.5rem rgba(0, 0, 0, 0.35), 
        0 0.5rem 1rem rgba(0, 0, 0, 0.25),
        inset 0 0 0.8rem rgba(255, 255, 255, 0.2);
    position: relative;
    border: 0.8rem 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: 1rem;
    transition: transform 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55), opacity 0.5s;
    opacity: 0;
    pointer-events: none;
    transform: translateY(1.5rem);
    z-index: 2;
    overflow: auto;
}

.page.active {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0);
}

.page-title {
    text-align: center;
    font-size: clamp(1.6rem, 5vw, 2.2rem);
    font-weight: 700;
    margin: 1rem 0 1.5rem;
    text-shadow: 0.1rem 0.1rem 0.3rem rgba(0,0,0,0.2);
    color: #5D4037;
    letter-spacing: 0.1rem;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 3.5rem;
}

.page-title::after {
    content: "";
    position: absolute;
    bottom: -0.8rem;
    left: 50%;
    transform: translateX(-50%);
    width: 8rem;
    height: 0.3rem;
    background: linear-gradient(90deg, transparent, #8B6E4E, transparent);
    border-radius: 0.1rem;
}

.title-icon {
    display: inline-block;
    width: clamp(1.8rem, 8vw, 2.2rem);
    height: clamp(1.8rem, 8vw, 2.2rem);
    border-radius: 50%;
    margin: 0 1rem;
    vertical-align: middle;
    position: relative;
    top: -0.3rem;
    box-shadow: 0 0.2rem 0.5rem rgba(0,0,0,0.16);
    animation: float 3s ease-in-out infinite;
}

.title-icon.black {
    background: radial-gradient(circle at 30% 30%, #3e2d20, #1a130e);
}

.title-icon.white {
    background: radial-gradient(circle at 30% 30%, #f5f0e6, #e0d7c5);
    border: 0.1rem solid #8B6E4E;
}

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-0.8rem); }
    100% { transform: translateY(0px); }
}

.button-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.2rem;
    flex: 1;
    justify-content: center;
    position: relative;
    z-index: 2;
}

.menu-decoration {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.menu-piece {
    position: absolute;
    border-radius: 50%;
    opacity: 0.15;
    animation: float 6s ease-in-out infinite;
    animation-delay: calc(var(--delay) * 1s);
}

.menu-piece.black {
    background: radial-gradient(circle at 30% 30%, #3e2d20, #1a130e);
}

.menu-piece.white {
    background: radial-gradient(circle at 30% 30%, #f5f0e6, #e0d7c5);
}

.btn {
    min-width: 16rem;
    width: 80%;
    max-width: 20rem;
    height: 4rem;
    background: linear-gradient(to bottom, #D4B98C, #C9A87A);
    border: none;
    border-radius: 0.8rem;
    color: #5D4037;
    font-size: clamp(1rem, 3vw, 1.2rem);
    font-weight: 600;
    box-shadow: 
        0 0.5rem 1rem rgba(0,0,0,0.15), 
        inset 0 0.1rem 0 rgba(255,255,255,0.4),
        0 0 0 0.2rem #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 1.5rem;
    text-align: center;
    letter-spacing: 0.05rem;
    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(-0.3rem);
    box-shadow: 
        0 0.8rem 1.5rem rgba(0,0,0,0.2), 
        inset 0 0.1rem 0 rgba(255,255,255,0.4),
        0 0 0 0.2rem #8B6E4E;
}

.btn:active {
    transform: translateY(0);
}

.btn i {
    margin-right: 0.8rem;
    font-size: clamp(1.1rem, 3.5vw, 1.3rem);
}

.btn-difficulty {
    min-width: 14rem;
    height: 4.5rem;
    font-size: clamp(0.9rem, 2.8vw, 1.1rem);
}

.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: 10rem;
    height: 3.5rem;
    font-size: clamp(0.8rem, 2.5vw, 1rem);
    border-radius: 0.7rem;
}

.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;
}

/* 游戏区域 - 响应式布局 */
.game-area {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: row;
    padding: 0.5rem;
}

/* 棋盘区域 */
.board-section {
    flex: 3;
    display: flex;
    flex-direction: column;
    padding-right: 0.5rem;
    min-width: 0;
    position: relative;
}

.board-container {
    flex: 1;
    display: flex;
    position: relative;
    background: rgba(212, 185, 140, 0.6);
    border-radius: 0.8rem;
    border: 0.15rem solid #8B6E4E;
    box-shadow: inset 0 0.3rem 1rem rgba(0,0,0,0.1);
    padding: 0.8rem;
    overflow: hidden;
    justify-content: center;
    align-items: center;
    min-height: 0;
}

/* 关键修改：确保棋盘在任何屏幕比例下都保持正方形 */
.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: 0.2rem solid #8B6E4E;
    box-shadow: 0 0.8rem 2rem rgba(0,0,0,0.2);
}

#board {
    display: grid;
    width: 100%;
    height: 100%;
    position: relative;
}

.cell {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    border-right: 0.05rem solid #8B6E4E;
    border-bottom: 0.05rem solid #8B6E4E;
    cursor: pointer;
    transition: background-color 0.2s;
    touch-action: manipulation;
}

.cell::after {
    content: '';
    position: absolute;
    top: -0.8rem;
    left: -0.8rem;
    right: -0.8rem;
    bottom: -0.8rem;
    z-index: 1;
}

.cell:hover {
    background-color: rgba(139, 110, 78, 0.1);
}

.row:first-child .cell {
    border-top: 0.05rem solid #8B6E4E;
}

.cell:first-child {
    border-left: 0.05rem solid #8B6E4E;
}

/* 特殊点位 */
.star-point {
    position: absolute;
    width: 0.6rem;
    height: 0.6rem;
    background-color: #5D4037;
    border-radius: 50%;
    z-index: 1;
}

/* 控制面板区域 */
.control-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding-left: 0.5rem;
    max-width: 16rem;
    min-width: 12rem;
}

.timer-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
    padding: 1rem;
    background: rgba(212, 185, 140, 0.9);
    border-radius: 0.8rem;
    margin-bottom: 0.8rem;
    box-shadow: 0 0.3rem 0.8rem rgba(0,0,0,0.1);
    border: 0.15rem solid #8B6E4E;
    position: relative;
    z-index: 2;
    height: 30%;
}

.timer {
    background: rgba(245, 239, 224, 0.9);
    color: #5D4037;
    padding: 0.8rem 1.5rem;
    border-radius: 0.5rem;
    font-size: clamp(1.3rem, 4vw, 1.6rem);
    font-weight: bold;
    min-width: 8rem;
    text-align: center;
    box-shadow: inset 0 0.1rem 0.3rem rgba(0,0,0,0.1);
    font-family: 'Courier New', monospace;
    border: 0.15rem solid #8B6E4E;
}

.current-turn {
    font-size: clamp(1rem, 2.8vw, 1.2rem);
    font-weight: bold;
    padding: 0.7rem 1rem;
    border-radius: 1.5rem;
    background: rgba(139, 110, 78, 0.2);
    color: #5D4037;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 100%;
    line-height: 1.5;
}

/* 优化：游戏底部按钮区域自适应放大缩小 */
.game-footer {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    padding: 1rem;
    background: rgba(212, 185, 140, 0.9);
    border-radius: 0.8rem;
    box-shadow: 0 0.3rem 0.8rem rgba(0,0,0,0.1);
    border: 0.15rem solid #8B6E4E;
    flex: 1;
    justify-content: space-between;
    height: 70%;
}

.game-footer .btn-game {
    flex: 1;
    min-height: 3.5rem;
    width: 100%;
    font-size: clamp(0.9rem, 2.8vw, 1.1rem);
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-container {
    max-width: 40rem;
    width: 90%;
    margin: 0 auto;
    background: rgba(245, 239, 224, 0.9);
    border-radius: 1.2rem;
    padding: 1.5rem;
    box-shadow: 0 0.6rem 1.5rem rgba(0,0,0,0.08);
    border: 0.2rem solid #8B6E4E;
    position: relative;
    z-index: 2;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0.8rem;
    border-bottom: 0.15rem dashed #D4B98C;
}

.setting-label {
    font-size: clamp(1rem, 3vw, 1.2rem);
    font-weight: 600;
    color: #5D4037;
}

.setting-options {
    display: flex;
    gap: 1.2rem;
}

.option {
    width: 3.2rem;
    height: 3.2rem;
    border-radius: 0.5rem;
    cursor: pointer;
    border: 0.15rem solid transparent;
    box-shadow: 0 0.2rem 0.6rem rgba(0,0,0,0.15);
    transition: all 0.3s;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 0.9rem;
    color: #5D4037;
    touch-action: manipulation;
}

.option:hover {
    transform: scale(1.05);
}

.option.selected {
    border: 0.15rem solid #8B6E4E;
    box-shadow: 0 0 0 0.2rem #D4B98C;
}

.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;
    padding: 1.5rem;
    box-sizing: border-box;
}

.modal.active {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background: radial-gradient(ellipse at center, #A67C52 0%, #8B6E4E 100%);
    border-radius: 1.5rem;
    padding: 2rem;
    width: 85%;
    max-width: 35rem;
    text-align: center;
    color: white;
    box-shadow: 0 1rem 2.5rem rgba(0,0,0,0.4);
    border: 0.3rem solid #D4B98C;
    position: relative;
    transform: scale(0.9);
    animation: modalAppear 0.5s forwards;
}

@keyframes modalAppear {
    to {
        transform: scale(1);
    }
}

.modal-title {
    font-size: clamp(1.6rem, 5vw, 2rem);
    margin-bottom: 2rem;
    text-shadow: 0 0.1rem 0.3rem rgba(0,0,0,0.3);
    letter-spacing: 0.05rem;
}

.modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.5rem;
}

.modal-btn {
    flex: 1;
    height: 4rem;
    border-radius: 0.8rem;
    font-size: clamp(1rem, 2.8vw, 1.1rem);
    font-weight: bold;
    cursor: pointer;
    border: none;
    box-shadow: 0 0.4rem 1rem rgba(0,0,0,0.2);
    transition: all 0.3s;
    display: flex;
    justify-content: center;
    align-items: center;
    touch-action: manipulation;
}

.modal-btn:hover {
    transform: translateY(-0.2rem);
    box-shadow: 0 0.5rem 1.2rem 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;
}

.modal-btn.view-btn {
    background: linear-gradient(to bottom, #8B6E4E, #6b4e3a);
    color: white;
}

.piece {
    width: 85%;
    height: 85%;
    border-radius: 50%;
    position: relative;
    z-index: 2;
    animation: placePiece 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes placePiece {
    0% { transform: scale(0); opacity: 0; }
    70% { transform: scale(1.1); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

/* 胜利棋子跳动效果 */
.win-piece {
    animation: winPulse 0.6s infinite alternate;
}

@keyframes winPulse {
    0% { transform: scale(1); }
    100% { transform: scale(1.15); box-shadow: 0 0 1rem rgba(255, 215, 0, 0.8); }
}

/* 胜利提示条 */
.win-banner {
    position: absolute;
    top: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(90deg, #8B6E4E, #A67C52);
    color: white;
    padding: 0.8rem 2rem;
    border-radius: 2rem;
    font-size: clamp(1.2rem, 3.5vw, 1.4rem);
    font-weight: bold;
    z-index: 100;
    box-shadow: 0 0.4rem 1rem rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    gap: 0.8rem;
    opacity: 0;
    transition: opacity 0.5s;
}

.win-banner.show {
    opacity: 1;
}

/* AI思考指示器 */
.thinking-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 1rem 1.8rem;
    border-radius: 1.5rem;
    font-size: clamp(1rem, 2.8vw, 1.1rem);
    z-index: 10;
    display: none;
}

.thinking-indicator.show {
    display: block;
    animation: thinkingPulse 1.5s infinite;
}

@keyframes thinkingPulse {
    0% { opacity: 0.7; }
    50% { opacity: 1; }
    100% { opacity: 0.7; }
}

/* 顶部控制栏 */
.top-controls {
    position: absolute;
    top: 1rem;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 10;
}

.control-btn {
    width: 3.2rem;
    height: 3.2rem;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(139, 110, 78, 0.8);
    color: white;
    font-size: clamp(1.2rem, 3.5vw, 1.4rem);
    border: 0.15rem solid #8B6E4E;
    box-shadow: 0 0.3rem 0.6rem rgba(0,0,0,0.2);
    cursor: pointer;
    transition: all 0.3s;
    touch-action: manipulation;
}

.control-btn:hover {
    transform: scale(1.05);
    background: rgba(139, 110, 78, 1);
}

/* 右上角预留退出按钮区域 */
.exit-button-space {
    width: 3.2rem;
    height: 3.2rem;
    visibility: hidden;
}

/* 模式选择页面新布局 */
.mode-selection {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 40rem;
    margin: 0 auto;
    gap: 1.5rem;
}

.mode-row {
    display: flex;
    justify-content: space-between;
    gap: 1.2rem;
}

.mode-option {
    flex: 1;
    min-height: 6rem;
    background: rgba(245, 239, 224, 0.9);
    border-radius: 1rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    border: 0.2rem solid transparent;
    transition: all 0.3s;
    padding: 1rem;
    box-shadow: 0 0.4rem 1rem rgba(0,0,0,0.1);
    position: relative;
}

.mode-option::after {
    content: '';
    position: absolute;
    top: -0.8rem;
    left: -0.8rem;
    right: -0.8rem;
    bottom: -0.8rem;
    z-index: 1;
}

.mode-option:hover {
    transform: translateY(-0.3rem);
    box-shadow: 0 0.8rem 1.5rem rgba(0,0,0,0.15);
}

.mode-option.selected {
    border-color: #8B6E4E;
    background: rgba(212, 185, 140, 0.9);
}

.mode-icon {
    font-size: clamp(1.6rem, 6vw, 2rem);
    margin-bottom: 0.8rem;
    color: #5D4037;
}

.mode-title {
    font-size: clamp(1.1rem, 3.5vw, 1.3rem);
    font-weight: bold;
    color: #5D4037;
    text-align: center;
}

/* 设置行布局优化 - 标题在左侧，选项在右侧 */
.settings-row {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: rgba(245, 239, 224, 0.9);
    border-radius: 1rem;
    padding: 1.2rem;
    box-shadow: 0 0.4rem 1rem rgba(0,0,0,0.1);
}

.setting-row-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
}

.setting-row-title {
    font-size: clamp(1rem, 3.2vw, 1.2rem);
    font-weight: bold;
    color: #5D4037;
    flex: 1;
}

.options-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: flex-end;
    flex: 2;
}

.option-btn {
    min-width: 6rem;
    height: 3.2rem;
    background: linear-gradient(to bottom, #D4B98C, #C9A87A);
    border: none;
    border-radius: 0.7rem;
    color: #5D4037;
    font-size: clamp(0.8rem, 2.5vw, 0.9rem);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 0.8rem;
    box-shadow: 0 0.3rem 0.6rem rgba(0,0,0,0.1);
    border: 0.15rem solid transparent;
}

.option-btn:hover {
    transform: translateY(-0.2rem);
    box-shadow: 0 0.5rem 1rem rgba(0,0,0,0.15);
}

.option-btn.selected {
    border-color: #8B6E4E;
    background: linear-gradient(to bottom, #E8D5B7, #D4B98C);
    box-shadow: 0 0 0 0.2rem rgba(139, 110, 78, 0.3);
}

.start-game-btn {
    min-width: 16rem;
    height: 4.5rem;
    background: linear-gradient(to bottom, #70A859, #5c8a48);
    border: none;
    border-radius: 1rem;
    color: white;
    font-size: clamp(1.2rem, 4vw, 1.4rem);
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 1.2rem auto;
    box-shadow: 0 0.6rem 1.2rem rgba(0,0,0,0.2);
    border: 0.2rem solid #5c8a48;
}

.start-game-btn:hover {
    transform: translateY(-0.3rem);
    box-shadow: 0 1rem 1.5rem rgba(0,0,0,0.25);
}

.start-game-btn:active {
    transform: translateY(0);
}

.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: 4rem;
    height: 4rem;
    z-index: 2;
}

.corner-tl {
    top: 1rem;
    left: 1rem;
    border-top: 0.3rem solid #8B6E4E;
    border-left: 0.3rem solid #8B6E4E;
}

.corner-tr {
    top: 1rem;
    right: 1rem;
    border-top: 0.3rem solid #8B6E4E;
    border-right: 0.3rem solid #8B6E4E;
}

.corner-bl {
    bottom: 1rem;
    left: 1rem;
    border-bottom: 0.3rem solid #8B6E4E;
    border-left: 0.3rem solid #8B6E4E;
}

.corner-br {
    bottom: 1rem;
    right: 1rem;
    border-bottom: 0.3rem solid #8B6E4E;
    border-right: 0.3rem solid #8B6E4E;
}

.board-frame {
    border: 0.8rem solid transparent;
    border-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="75" height="75"><rect x="0" y="0" width="75" height="75" fill="none" stroke="%238B6E4E" stroke-width="4" stroke-dasharray="10,5"/></svg>') 30 stretch;
    border-radius: 0.3rem;
    box-shadow: 0 0.6rem 1.5rem rgba(0,0,0,0.15);
}

/* 主菜单背景装饰 */
.menu-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 30%, rgba(212, 185, 140, 0.2) 0%, transparent 25%),
        radial-gradient(circle at 80% 70%, rgba(166, 124, 82, 0.2) 0%, transparent 25%);
    pointer-events: none;
    z-index: 0;
}

.menu-title {
    position: relative;
    z-index: 2;
}

/* 棋盘自适应 */
.board-wood {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        linear-gradient(90deg, rgba(139, 110, 78, 0.1) 0.05rem, transparent 0.05rem),
        linear-gradient(rgba(139, 110, 78, 0.1) 0.05rem, transparent 0.05rem);
    background-size: 2rem 2rem;
    pointer-events: none;
    z-index: 1;
}

/* 顶部装饰 */
.header-decoration {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 1rem;
    background: linear-gradient(to bottom, #8B6E4E, #6b4e3a);
    z-index: 3;
}

/* 底部装饰 */
.footer-decoration {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1rem;
    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%;
}

/* 点击效果 */
.cell:active {
    background-color: rgba(139, 110, 78, 0.2);
}

/* 触摸优化 */
.touch-optimized {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* 预览棋子样式 */
.preview-piece {
    width: 85%;
    height: 85%;
    border-radius: 50%;
    position: relative;
    z-index: 1;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.preview-piece.black {
    background: radial-gradient(circle at 30% 30%, #3e2d20, #1a130e);
}

.preview-piece.white {
    background: radial-gradient(circle at 30% 30%, #f5f0e6, #e0d7c5);
    border: 0.05rem solid #CCCCCC;
}

/* 添加点击提示 */
.click-hint {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 1rem;
    font-size: 0.9rem;
    z-index: 10;
    display: none;
}

.click-hint.show {
    display: block;
    animation: fadeInOut 2s infinite;
}

@keyframes fadeInOut {
    0% { opacity: 0.7; }
    50% { opacity: 1; }
    100% { opacity: 0.7; }
}

/* 响应式调整 - 精细化断点 */
/* 超小屏设备（<375px） */
@media (max-width: 374px) {
    .game-container {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
        border: 0.4rem solid #8B6E4E;
    }
    
    .page {
        padding: 0.8rem;
    }
    
    .page-title {
        margin: 0.5rem 0 1rem;
        height: auto;
        flex-wrap: wrap;
    }
    
    .title-icon {
        margin: 0 0.5rem;
    }
    
    .btn {
        min-width: 12rem;
        height: 3.5rem;
        font-size: 0.9rem;
        padding: 0 1rem;
    }
    
    .game-area {
        padding: 0.4rem;
        flex-direction: column;
        height: calc(100% - 1rem);
    }
    
    .board-section {
        padding-right: 0;
        padding-bottom: 0.4rem;
        flex: 2;
    }
    
    .control-panel {
        padding-left: 0;
        max-width: 100%;
        min-width: auto;
        flex: 1;
    }
    
    .timer-container {
        padding: 0.8rem;
        gap: 0.5rem;
        height: auto;
    }
    
    .timer {
        font-size: 1.1rem;
        padding: 0.5rem 0.8rem;
        min-width: 6rem;
    }
    
    .current-turn {
        font-size: 0.85rem;
        padding: 0.5rem 0.7rem;
    }
    
    /* 优化：游戏底部按钮区域在小屏幕上使用紧凑布局 */
    .game-footer {
        padding: 0.8rem;
        gap: 0.5rem;
        height: auto;
        flex-direction: row;
        justify-content: space-around;
        flex-wrap: wrap;
    }
    
    .game-footer .btn-game {
        flex: 1 1 30%;
        min-height: 3rem;
        font-size: 0.8rem;
        min-width: 6rem;
    }
    
    .control-btn {
        width: 2.8rem;
        height: 2.8rem;
        font-size: 1rem;
    }
    
    .top-controls {
        padding: 0 0.8rem;
    }
    
    .mode-option {
        min-height: 5rem;
        padding: 0.8rem;
    }
    
    .mode-icon {
        font-size: 1.3rem;
        margin-bottom: 0.5rem;
    }
    
    .mode-title {
        font-size: 0.9rem;
    }
    
    .option-btn {
        min-width: 5rem;
        height: 2.8rem;
        font-size: 0.8rem;
    }
    
    .start-game-btn {
        min-width: 12rem;
        height: 4rem;
        font-size: 1.1rem;
    }
    
    .modal-content {
        padding: 1.5rem;
    }
    
    .settings-container {
        padding: 1rem;
    }
    
    .setting-item {
        padding: 0.8rem 0.4rem;
    }
    
    .option {
        width: 2.8rem;
        height: 2.8rem;
    }
    
    .setting-row-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .options-row {
        justify-content: flex-start;
        width: 100%;
    }
}

/* 小屏幕手机（375px-480px） */
@media (min-width: 375px) and (max-width: 480px) {
    .game-container {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
    }
    
    .page-title {
        font-size: 1.6rem;
        height: auto;
    }
    
    .btn {
        min-width: 14rem;
        height: 3.8rem;
    }
    
    .control-panel {
        min-width: 10rem;
    }
    
    .timer-container {
        height: auto;
    }
    
    .game-footer {
        height: auto;
    }
    
    .modal-content {
        padding: 1.8rem;
    }
}

/* 平板竖屏（600px-768px） */
@media (min-width: 600px) and (max-width: 768px) and (orientation: portrait) {
    .game-area {
        flex-direction: column;
    }
    
    .board-section {
        padding-right: 0;
        padding-bottom: 0.5rem;
        flex: 2;
    }
    
    .control-panel {
        padding-left: 0;
        max-width: 100%;
        min-width: auto;
        flex: 1;
    }
    
    .timer-container {
        height: auto;
    }
    
    .game-footer {
        flex-direction: row;
        justify-content: space-around;
        height: auto;
    }
    
    .btn-game {
        min-width: 8rem;
    }
}

/* 平板横屏（768px-1024px） */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
    .game-container {
        width: 98vw;
        height: 98vh;
    }
    
    .control-panel {
        min-width: 14rem;
    }
    
    .board-wrapper {
        width: 95%;
        height: 95%;
    }
}

/* 大屏桌面（>1600px） */
@media (min-width: 1600px) {
    .game-container {
        max-width: 100vw;
        max-height: 100vh;
    }
}

/* 横屏优化 - 确保在横屏模式下保持左右布局 */
@media (orientation: landscape) and (max-height: 600px) {
    .game-area {
        flex-direction: row !important;
    }
    
    .board-section {
        flex: 3;
        padding-right: 0.5rem;
    }
    
    .control-panel {
        flex: 1;
        padding-left: 0.5rem;
        max-width: 14rem;
        min-width: 10rem;
    }
    
    .board-wrapper {
        width: 100%;
        height: 100%;
    }
    
    .timer-container {
        height: auto;
    }
    
    .game-footer {
        height: auto;
    }
}

/* 竖屏优化 - 手机竖屏 */
@media (orientation: portrait) and (max-width: 480px) {
    .game-area {
        flex-direction: column;
    }
    
    .board-section {
        padding-right: 0;
        padding-bottom: 0.4rem;
        flex: 2;
    }
    
    .control-panel {
        padding-left: 0;
        max-width: 100%;
        min-width: auto;
        flex: 1;
    }
    
    .timer-container {
        height: auto;
    }
    
    .game-footer {
        flex-direction: row;
        justify-content: space-around;
        height: auto;
    }
    
    .btn-game {
        min-width: 7rem;
    }
}

/* 小屏设备棋子优化 */
@media (max-width: 480px) {
    .piece {
        width: 80%;
        height: 80%;
    }
    
    .star-point {
        width: 0.5rem;
        height: 0.5rem;
    }
}

/* 按钮组在小屏设备上的优化 */
@media (max-width: 374px) {
    .button-group {
        gap: 0.8rem;
    }
    
    .options-row {
        gap: 0.6rem;
    }
    
    .option-btn {
        min-width: 4.5rem;
        height: 2.5rem;
        font-size: 0.75rem;
    }
    
    .mode-row {
        gap: 0.8rem;
    }
}

/* 特别针对小度智能屏幕的优化 */
@media (max-width: 320px) and (max-height: 480px) {
    .game-container {
        min-width: 100vw;
        min-height: 100vh;
        border: 0.2rem solid #8B6E4E;
    }
    
    .page {
        padding: 0.5rem;
    }
    
    .page-title {
        font-size: 1.4rem;
        margin: 0.5rem 0 0.8rem;
    }
    
    .title-icon {
        width: 1.6rem;
        height: 1.6rem;
    }
    
    .btn {
        min-width: 10rem;
        height: 3.2rem;
        font-size: 0.9rem;
    }
    
    .timer {
        font-size: 1rem;
        padding: 0.3rem 0.6rem;
        min-width: 5rem;
    }
    
    .current-turn {
        font-size: 0.8rem;
        padding: 0.3rem 0.5rem;
    }
    
    .btn-game {
        height: 2.8rem;
        font-size: 0.75rem;
        min-width: 5rem;
    }
    
    .mode-option {
        min-height: 4.5rem;
        padding: 0.6rem;
    }
    
    .mode-icon {
        font-size: 1.1rem;
    }
    
    .mode-title {
        font-size: 0.85rem;
    }
    
    .option-btn {
        min-width: 4rem;
        height: 2.5rem;
        font-size: 0.75rem;
    }
    
    .start-game-btn {
        min-width: 10rem;
        height: 3.5rem;
        font-size: 1rem;
    }
}

/* 安全区域适配（刘海屏设备） */
@supports(padding: max(0px)) {
    .page {
        padding-left: max(0.8rem, env(safe-area-inset-left));
        padding-right: max(0.8rem, env(safe-area-inset-right));
        padding-top: max(0.8rem, env(safe-area-inset-top));
        padding-bottom: max(0.8rem, env(safe-area-inset-bottom));
    }
    
    .top-controls {
        padding-left: max(0.8rem, env(safe-area-inset-left));
        padding-right: max(0.8rem, env(safe-area-inset-right));
    }
    
    .modal {
        padding-left: max(0.8rem, env(safe-area-inset-left));
        padding-right: max(0.8rem, env(safe-area-inset-right));
        padding-top: max(0.8rem, env(safe-area-inset-top));
        padding-bottom: max(0.8rem, env(safe-area-inset-bottom));
    }
}

/* 设置页面选项样式 */
#sound-on, #bgm-on {
    background: #70A859;
    display: flex;
    justify-content: center;
    align-items: center;
}

#sound-on i, #bgm-on i {
    color: white;
    font-size: 1.1rem;
}

#sound-off, #bgm-off {
    background: #C75A4A;
    display: flex;
    justify-content: center;
    align-items: center;
}

#sound-off i, #bgm-off i {
    color: white;
    font-size: 1.1rem;
}