:root {
    /* 背景颜色 */
    --bg-main: #faf8ef;
    --bg-board: burlywood;
    --bg-game-container: #bbada0;
    --bg-message: rgba(238, 228, 218, 0.73);
    
    /* 文本颜色 */
    --text-main: #776e65;
    --text-light: white;
    --theme-toggle-color: #ffa500;
    
    /* 按钮颜色 */
    --btn-bg: #8f7a66;
    --btn-hover: #9f8b77;
    
    /* 棋盘颜色 */
    --board-line: #000000;
    --stone-black: #000000;
    --stone-white: #ffffff;

    --mode-image: url("../../assets/images/gomoku.png");
}

/* 深色模式颜色变量 */
[data-theme="dark"] {
    /* 背景颜色 */
    --bg-main: #1a1a1a;
    --bg-board: #8B4513;
    --bg-game-container: #2c2c2c;
    --bg-message: rgba(50, 50, 50, 0.73);
    
    /* 文本颜色 */
    --text-main: #e0e0e0;
    --text-light: #ffffff;
    --theme-toggle-color: #f1c40f;
    
    /* 按钮颜色 */
    --btn-bg: #4a4a4a;
    --btn-hover: #5a5a5a;
    
    /* 棋盘颜色 */
    --board-line: #888888;
    --stone-black: #222222;
    --stone-white: #dddddd;

    --mode-image: url("../../assets/images/gomoku-dark.png");
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: "Clear Sans", "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    touch-action: none;
}

/* 控制按钮共用样式 */
.control-button {
    position: fixed;
    top: 20px;
    background: var(--btn-bg);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 20px;
    z-index: 1000;
    transition: background-color 0.3s ease;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

.control-button:hover {
    background: var(--btn-hover);
}

/* 返回按钮 */
#back-button {
    left: 20px;
    color: var(--text-light);
}

/* 主题切换按钮 */
#theme-button {
    right: 20px;
    color: var(--theme-toggle-color);
}

/* 模式选择页面样式 */
.mode-select {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    gap: 2rem;
}

#mode-image {
    width: 200px;
    height: 200px;
    margin-bottom: 1rem;
    object-fit: contain;
    background-image: var(--mode-image);
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.mode-select .title {
    font-size: 3rem;
    margin-bottom: 2rem;
}

.mode-buttons {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
    max-width: 300px;
}

.mode-select-button {
    padding: 1rem 2rem;
    font-size: 1.2rem;
    background-color: var(--btn-bg);
    color: var(--text-light);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    text-align: center;
}

.mode-select-button:hover {
    background-color: var(--btn-hover);
    transform: translateY(-2px);
}

.container {
    width: 474px;
    margin: 0 auto;
}

/* 标题和分数区域 */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 10px 0px;
}

.title {
    font-size: 50px;
    font-weight: bold;
    margin: 0;
    display: block;
}

.mode-display {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--text-main);
}

.scores-container {
    display: flex;
    align-items: center;
    gap: 5px;
}

.score-box {
    position: relative;
    display: inline-block;
    background: var(--bg-game-container);
    padding: 10px 15px;
    border-radius: 3px;
    color: var(--text-light);
    text-align: center;
    min-width: 70px;
}

.score-box span {
    font-size: 15px;
    display: block;
    margin-bottom: 3px;
}

.score-box div {
    font-size: 20px;
    font-weight: bold;
}

/* 游戏介绍和控制区域 */
.game-intro-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.game-intro {
    line-height: 1.5;
}

.game-info {
    font-weight: bold;
    font-size: 16px;
}

.game-controls {
    display: flex;
    gap: 8px;
}

.restart-button, .undo-button {
    background: var(--btn-bg);
    border-radius: 3px;
    padding: 0 15px;
    line-height: 36px;
    color: var(--text-light);
    border: none;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
}

.restart-button:hover, .undo-button:hover {
    background: var(--btn-hover);
}

/* 游戏容器 */
.game-container {
    position: relative;
    background: var(--bg-game-container);
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 15px;
}

.board-container {
    position: relative;
    width: 450px;
    height: 450px;
    background: var(--bg-board);
    border-radius: 3px;
    overflow: hidden;
    margin: 0 auto;
}

#gomoku-board {
    display: block;
    cursor: pointer;
    width: 100%;
    height: 100%;
    touch-action: none;
}

/* 棋子虚影 */
#ghost-piece {
    display: none;
    position: absolute;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    opacity: 0.5;
    pointer-events: none;
    z-index: 5;
    transform: translate(-50%, -50%);
}

#ghost-piece.black {
    background-color: var(--stone-black);
    display: block;
}

#ghost-piece.white {
    background-color: var(--stone-white);
    display: block;
}

/* 游戏消息 */
.game-message {
    display: none;
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: var(--bg-message);
    z-index: 100;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.game-message.game-over {
    display: flex;
}

.game-message p {
    font-size: 30px;
    font-weight: bold;
    margin: 0 0 20px;
}

.game-message .lower {
    margin-top: 30px;
}

.game-message a {
    display: inline-block;
    background: var(--btn-bg);
    border-radius: 3px;
    padding: 0 20px;
    line-height: 42px;
    color: var(--text-light);
    text-decoration: none;
    cursor: pointer;
}

.game-message a:hover {
    background: var(--btn-hover);
}

/* 游戏说明 */
.game-explanation {
    margin-top: 20px;
    font-size: 16px;
    line-height: 1.5;
}

/* 响应式设计 */
@media screen and (max-width: 768px) {
    .container {
        width: 100%;
        margin: 0 auto;
        padding: 0 10px;
        box-sizing: border-box;
    }

    .title {
        font-size: 28px;
        margin-bottom: 5px;
    }

    .board-container {
        width: 100%;
        height: 100%;
        margin: 0 auto;
    }

    .game-explanation {
        font-size: 13px;
        line-height: 1.4;
        padding: 0 5px;
    }
}