:root {
    --bg: #F5F2EB;            /* 米白素纸 */
    --card-bg: #EAE4D5;       /* 灰陶浅灰 */
    --grid-line: #CFC8B8;     /* 浅墨线 */
    --text: #32302E;          /* 浓墨 */
    --text-muted: #888277;    /* 墨灰 */
    
    --accent: #888277;        
    --accent-soft: #F6DFCA;

    /* 橙与蓝配色 */
    --piece-white: #E07A3A;   /* 柿色 / 橙方 */
    --piece-black: #3D6EB8;   /* 群青 / 蓝方 */

    --hint: rgba(128, 128, 128, 0.4); 

    --hard-shadow: rgba(45, 38, 30, 0.28);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font);
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* ==========================================
   顶部状态栏：得分与手指示合并行
   ========================================== */
.top-status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background: var(--bg);
    flex-shrink: 0;
    gap: 8px;
}

.player-score {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
}

.score-orange .player-label {
    color: var(--piece-white);
}

.score-blue .player-label {
    color: var(--piece-black);
}

.ring-slots {
    display: flex;
    gap: 4px;
}

.ring-slot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--card-bg);
    display: inline-block;
}

.ring-slot.filled-white {
    background: var(--piece-white);
    border: 3px solid var(--piece-white);
}

.ring-slot.filled-black {
    background: var(--piece-black);
    border: 3px solid var(--piece-black);
}

.turn-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 16px;
    background: var(--card-bg);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.turn-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.turn-white { 
    background: var(--piece-white); 
}

.turn-black { 
    background: var(--piece-black); 
}

/* ==========================================
   棋盘容器与 SVG 适配
   ========================================== */
.board-container {
    flex: 1;
    position: relative;
    width: 100%;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: var(--bg);
    padding: 4px;
}

svg#gameBoard {
    width: 100%;
    height: 100%;
    max-width: 100vw;
    max-height: 100%;
    touch-action: none;
}

/* ==========================================
   底部操作栏：选游戏、联机、重开
   ========================================== */
.bottom-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--bg);
    flex-shrink: 0;
}

.bottom-btn {
    flex: 1;
    max-width: 120px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--card-bg);
    border: none;
    border-radius: 19px;
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}

.bottom-btn:active {
    opacity: 0.8;
}

/* ==========================================
   弹窗及组件样式
   ========================================== */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(35, 34, 32, 0.45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-card {
    width: 100%;
    max-width: 320px;
    background: var(--bg);
    border-radius: 20px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-title {
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    color: var(--text);
}

.game-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.game-item {
    background: var(--card-bg);
    padding: 14px 10px;
    border-radius: 14px;
    text-align: center;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.game-item.active {
    background: var(--accent);
    color: #fff;
}

.game-item.active .game-sub {
    color: rgba(255, 255, 255, 0.8);
}

.game-item.disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.game-name {
    font-size: 14px;
    font-weight: 600;
}

.game-sub {
    font-size: 11px;
    color: var(--text-muted);
}

.code-box {
    background: var(--card-bg);
    border-radius: 14px;
    padding: 12px;
    text-align: center;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.code-display {
    font-size: 30px;
    font-weight: 700;
    letter-spacing: 6px;
    color: var(--accent);
}

.input-field {
    width: 100%;
    padding: 12px;
    background: var(--card-bg);
    border: none;
    border-radius: 12px;
    font-size: 18px;
    text-align: center;
    letter-spacing: 4px;
    color: var(--text);
    outline: none;
}

.btn {
    width: 100%;
    padding: 12px;
    border-radius: 14px;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    background: var(--card-bg);
    color: var(--text);
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--piece-black);
    color: #fff;
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 13px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 200;
}

.toast.show { 
    opacity: 0.95; 
}