/* ========================================================
   Nine Men's Morris — 样式表
   分区：Variables → Reset → Layout → Board → Pieces →
         Status Panel → Danmaku & Bubble → Modal → Responsive
   ======================================================== */

/* ==================== Variables ==================== */

:root {
    /* 主题色 */
    --color-bg: #1a1a2e;
    --color-surface: #16213e;
    --color-text: #e0e0e0;
    --color-text-dim: #888;
    --color-accent: #4fc3f7;
    --color-border: #444;
    --color-border-dark: #333;
    --color-hover: rgba(255, 255, 255, 0.08);
    --color-active: rgba(255, 255, 255, 0.15);
    --color-overlay: rgba(0, 0, 0, 0.6);

    /* 棋盘色 */
    --color-board-face: #e6cb9a;
    --color-board-stroke: #b8860b;
    --color-board-line: #8B7355;
    --color-board-hover: #e6cb9a;
    --color-board-highlight: #e6cb9a;

    /* 棋子色 */
    --color-white: #f0f0f0;
    --color-white-stroke: #e0e0e0;
    --color-black: #2d2d2d;
    --color-black-stroke: #222;
    --color-capture: #ff8a80;
    --color-capture-glow: #f44336;
    --color-thinking: #81d4fa;

    /* 圆点色 */
    --color-dot-white-hand: #f0f0f0;
    --color-dot-black: #555;
    --color-dot-black-board: #888;
    --color-dot-lost: #555;

    /* 气泡 / 弹幕色 */
    --color-bubble: #2a2a4a;
    --color-danmaku: #fff;

    /* 棋子阴影色板 */
    --shadow-warm: rgba(40, 30, 20, 0.3);
    --shadow-black: rgba(0, 0, 0, 0.45);
    --highlight-white: rgba(255, 255, 255, 0.9);
    --highlight-soft: rgba(255, 255, 255, 0.35);
    --shadow-ambient: rgba(0, 0, 0, 0.15);
    --shadow-board: rgba(0, 0, 0, 0.4);
    --shadow-danmaku: rgba(0, 0, 0, 0.7);
    --shadow-modal: rgba(0, 0, 0, 0.5);

    /* 尺寸 */
    --radius: 8px;
}

/* ==================== Variables (Macaron Premium) ==================== */

[data-theme="macaron"] {
    /* 主题色：干净的奶油白与轻熟粉蓝 */
    --color-bg: #f2f5f8;
    --color-surface: #ffffff;
    --color-text: #2c3e50;
    --color-text-dim: #7f8c8d;
    --color-accent: #ff7597;
    --color-border: #e9ecef;
    --color-border-dark: #dee2e6;
    --color-hover: rgba(255, 117, 151, 0.1);
    --color-active: rgba(255, 117, 151, 0.2);
    --color-overlay: rgba(44, 62, 80, 0.3);

    /* 棋盘色：薄荷冰沙 */
    --color-board-face: #eaf7f4;
    --color-board-stroke: #bfe3db;
    --color-board-line: #8ccfcf;
    --color-board-hover: #d2f0ea;
    --color-board-highlight: #ffe3d1;

    /* 棋子色：香草奶霜 vs 蓝莓慕斯 */
    --color-white: #ffffff;
    --color-white-stroke: #d0d7de;
    --color-black: #5dade2;
    --color-black-stroke: #3498db;
    --color-capture: #ff2a6d;
    --color-capture-glow: rgba(255, 42, 109, 0.4);
    --color-thinking: #ff7597;

    /* 圆点色 */
    --color-dot-white-hand: #ffffff;
    --color-dot-black: #5dade2;
    --color-dot-black-board: #3498db;
    --color-dot-lost: #bdc3c7;

    /* 气泡 / 弹幕色 */
    --color-bubble: #f4eff7;
    --color-danmaku: #6c5ce7;

    /* 阴影色板：同色系微弱阴影与强高光 */
    --shadow-warm: rgba(165, 175, 185, 0.2);
    --shadow-black: rgba(52, 152, 219, 0.25);
    --highlight-white: rgba(255, 255, 255, 1);
    --highlight-soft: rgba(255, 255, 255, 0.6);
    --shadow-ambient: rgba(0, 0, 0, 0.04);
    --shadow-board: rgba(165, 175, 185, 0.15);
    --shadow-danmaku: rgba(255, 255, 255, 0.9);
    --shadow-modal: rgba(44, 62, 80, 0.1);

    /* 尺寸 */
    --radius: 12px;
}

/* ==================== Variables (Cyber-Macaron) ==================== */

[data-theme="cyber"] {
    /* 基础背景与面板：深邃暗夜 */
    --color-bg: #0b0c10;
    --color-surface: #1f2833;
    --color-text: #c5a3ff;
    --color-text-dim: #66fcf1;
    --color-accent: #ff4081;
    --color-border: #3a4f5c;
    --color-border-dark: #2a3a44;
    --color-hover: rgba(102, 252, 241, 0.1);
    --color-active: rgba(102, 252, 241, 0.2);
    --color-overlay: rgba(11, 12, 16, 0.85);

    /* 棋盘色：极光霓虹线 */
    --color-board-face: #121c24;
    --color-board-stroke: #1f2833;
    --color-board-line: #00ffcc;
    --color-board-hover: #424b55;
    --color-board-highlight: #424b55;

    /* 棋子色：量子奶白 vs 霓虹电蓝 */
    --color-white: #ffffff;
    --color-white-stroke: #00ffcc;
    --color-black: #00e5ff;
    --color-black-stroke: #0086b3;
    --color-capture: #ff0055;
    --color-capture-glow: #ff0055;
    --color-thinking: #66fcf1;

    /* 圆点色 */
    --color-dot-white-hand: #ffffff;
    --color-dot-black: #00e5ff;
    --color-dot-black-board: #0086b3;
    --color-dot-lost: #414a4c;

    /* 气泡 / 弹幕色 */
    --color-bubble: #1a1528;
    --color-danmaku: #ffff00;

    /* 霓虹发光核心 */
    --shadow-warm: rgba(255, 255, 255, 0.4);
    --shadow-black: rgba(0, 229, 255, 0.5);
    --highlight-white: rgba(255, 255, 255, 0.8);
    --highlight-soft: rgba(0, 255, 204, 0.4);
    --shadow-ambient: rgba(0, 0, 0, 0.5);
    --shadow-board: rgba(0, 255, 204, 0.15);
    --shadow-danmaku: rgba(0, 0, 0, 0.9);
    --shadow-modal: rgba(0, 0, 0, 0.8);

    --radius: 12px;
}

/* 赛博主题专属发光效果 */
[data-theme="cyber"] #board-lines {
    filter: drop-shadow(0 0 4px rgba(0, 255, 204, 0.6));
}

[data-theme="cyber"] .board-dot {
    filter: drop-shadow(0 0 6px var(--color-board-line));
}

[data-theme="cyber"] .piece-white {
    filter:
        drop-shadow(0 0 8px rgba(0, 255, 204, 0.5))
        drop-shadow(2px 3px 4px rgba(0,0,0,0.7));
}

[data-theme="cyber"] .piece-black {
    filter:
        drop-shadow(0 0 10px rgba(0, 229, 255, 0.6))
        drop-shadow(2px 3px 4px rgba(0,0,0,0.7));
}

[data-theme="cyber"] .dot-white.hand {
    box-shadow: 0 0 8px rgba(255,255,255,0.6);
}

[data-theme="cyber"] .dot-black.hand {
    box-shadow: 0 0 8px rgba(0, 229, 255, 0.6);
}

/* ==================== Reset ==================== */

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

html, body {
    height: 100dvh;
    overflow: hidden;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

/* ==================== Layout ==================== */

#app {
    display: flex;
    flex-direction: column;
    height: 100dvh;
}

#board-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    min-height: 0;
    padding: 8px;
}

#board {
    width: 100%;
    height: 100%;
    max-width: min(100% - 16px, 100dvh - 200px);
    max-height: min(100% - 16px, 100dvh - 200px);
    aspect-ratio: 1;
    display: block;
}

/* ==================== Board ==================== */

#board-face {
    fill: var(--color-board-face);
    stroke: var(--color-board-stroke);
    stroke-width: 6;
    filter: drop-shadow(3px 5px 6px var(--shadow-board));
}

.board-dot {
    fill: var(--color-board-line);
    stroke: none;
    pointer-events: none;
}

#board-lines {
    stroke: var(--color-board-line);
    stroke-width: 3;
    fill: none;
}

.board-position {
    fill: transparent;
    cursor: pointer;
    r: 22;
    transition: fill 0.2s ease;
}

.board-position:hover {
    fill: var(--color-board-hover);
    filter: url(#inset-shadow);
}

.highlight-move {
    fill: var(--color-board-highlight);
    r: 14;
    pointer-events: none;
    filter: url(#inset-shadow);
}

/* ==================== Pieces ==================== */

.piece {
    r: 22;
    stroke-width: 2;
    pointer-events: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.piece-white {
    fill: var(--color-white);
    stroke: var(--color-white-stroke);
    filter: drop-shadow(0 4px 6px var(--shadow-warm));
}

.piece-black {
    fill: var(--color-black);
    stroke: var(--color-black-stroke);
    filter: drop-shadow(0 4px 6px var(--shadow-black));
}

.piece.selected {
    stroke: var(--color-accent);
    stroke-width: 3.5;
    filter: drop-shadow(0 0 12px var(--color-accent));
}

.piece.capture {
    stroke: var(--color-capture);
    stroke-width: 3.5;
    filter: drop-shadow(0 0 12px var(--color-capture));
}

.piece.captured {
    animation: capture-flash 0.6s ease-in forwards;
}

@keyframes capture-flash {
    0%, 20%, 40%, 60% { opacity: 1; }
    10%, 30%, 50%      { opacity: 0.2; }
    70%                 { opacity: 1; r: 22; }
    100%                { opacity: 0; r: 0; }
}

/* ==================== Status Panel ==================== */

#status-panel {
    flex-shrink: 0;
    background: var(--color-surface);
    padding: 10px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#panel-header h1 {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 1px;
}

/* 棋子圆点 */

#player-status {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.player-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

#player-status.ai-first #status-opponent { order: 1; }
#player-status.ai-first #status-ai { order: 0; }

.player-label {
    font-size: 14px;
    font-weight: 600;
    min-width: 32px;
    color: var(--color-text);
}

.piece-dots {
    display: flex;
    gap: 6px;
}

.dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    transition: all 0.2s;
}

.dot.board { background: transparent !important; }
.dot.lost  { background: transparent !important; border: 2px dashed var(--color-dot-lost); }

.dot-white.hand  {
    background: var(--color-dot-white-hand);
    border: 2px solid var(--color-white-stroke);
}
.dot-white.board { border: 2px solid var(--color-white-stroke); }
.dot-black.hand  {
    background: var(--color-dot-black);
    border: 2px solid var(--color-dot-black-board);
}
.dot-black.board { border: 2px solid var(--color-dot-black-board); }

/* AI 思考走马灯 */

.piece-dots.thinking .dot {
    animation: dot-think 1.2s ease-in-out infinite;
}

.piece-dots.thinking .dot:nth-child(1) { animation-delay: 0s; }
.piece-dots.thinking .dot:nth-child(2) { animation-delay: 0.1s; }
.piece-dots.thinking .dot:nth-child(3) { animation-delay: 0.2s; }
.piece-dots.thinking .dot:nth-child(4) { animation-delay: 0.3s; }
.piece-dots.thinking .dot:nth-child(5) { animation-delay: 0.4s; }
.piece-dots.thinking .dot:nth-child(6) { animation-delay: 0.5s; }
.piece-dots.thinking .dot:nth-child(7) { animation-delay: 0.6s; }
.piece-dots.thinking .dot:nth-child(8) { animation-delay: 0.7s; }
.piece-dots.thinking .dot:nth-child(9) { animation-delay: 0.8s; }

@keyframes dot-think {
    0%, 100% { border-color: var(--color-accent); box-shadow: none; }
    50%      { border-color: var(--color-thinking); box-shadow: 0 0 6px var(--color-accent); }
}

/* 游戏信息 */

#game-info {
    font-size: 13px;
    color: var(--color-text-dim);
    min-height: 20px;
}

#phase-display {
    font-weight: 500;
    color: var(--color-accent);
}

#message-display {
    color: var(--color-text-dim);
}

/* 设置 & 控制按钮 */

#settings-row {
    display: flex;
    gap: 8px;
}

.setting-btn {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--color-text);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s;
}

.setting-btn:hover  { background: var(--color-hover); }
.setting-btn:active { background: var(--color-active); }

#controls {
    display: flex;
    gap: 8px;
}

#controls button {
    flex: 1;
    padding: 8px 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--color-text);
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s;
}

#controls button:hover  { background: var(--color-hover); }
#controls button:active { background: var(--color-active); }

/* ==================== Danmaku & Bubble ==================== */

#danmaku-layer {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 10;
}

.danmaku-item {
    position: absolute;
    white-space: nowrap;
    font-size: 16px;
    font-weight: 600;
    color: var(--color-danmaku);
    text-shadow: 1px 1px 3px var(--shadow-danmaku);
    animation: danmaku-scroll linear forwards;
    pointer-events: none;
}

@keyframes danmaku-scroll {
    from { transform: translateX(0); }
    to   { transform: translateX(calc(-100% - 100vw)); }
}

#bubble-area {
    display: none;
}

.bubble {
    position: relative;
    background: var(--color-bubble);
    color: var(--color-text);
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 14px;
    line-height: 1.5;
    max-width: 90%;
    animation: bubble-in 0.3s ease;
}

.bubble::before {
    content: "";
    position: absolute;
    left: -8px;
    top: 12px;
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-right: 8px solid var(--color-bubble);
}

@keyframes bubble-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ==================== Modal ==================== */

.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-overlay);
    z-index: 100;
    animation: modal-in 0.3s ease;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 24px 32px;
    text-align: center;
    min-width: 260px;
    max-width: 90%;
    box-shadow: 0 8px 32px var(--shadow-modal);
}

.modal-content h2 {
    font-size: 20px;
    margin-bottom: 16px;
    color: var(--color-text);
}

#result-stats {
    font-size: 14px;
    color: var(--color-text-dim);
    line-height: 1.8;
    margin-bottom: 20px;
}

#result-stats .stat-label {
    color: var(--color-text);
    font-weight: 500;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.modal-buttons button {
    padding: 10px 24px;
    border: 1px solid var(--color-accent);
    border-radius: var(--radius);
    background: transparent;
    color: var(--color-accent);
    font-size: 15px;
    cursor: pointer;
    transition: background 0.15s;
}

.modal-buttons button:hover {
    background: var(--color-hover);
}

.modal-buttons .hidden {
    display: none;
}

@keyframes modal-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ==================== Responsive ==================== */

@media (orientation: landscape) and (min-width: 769px) {
    #app {
        flex-direction: row;
    }

    #status-panel {
        width: 22%;
        max-width: 280px;
        height: 100dvh;
        flex-direction: column;
        justify-content: center;
        gap: 16px;
        padding: 20px 16px;
        order: -1;
    }

    #board-area {
        flex: 1;
        order: 0;
    }

    #board {
        max-width: min(100% - 16px, 100dvh - 40px);
        max-height: min(100% - 16px, 100dvh - 40px);
    }

    #bubble-area {
        display: flex;
        flex-direction: column;
        width: 28%;
        max-width: 320px;
        height: 100dvh;
        padding: 16px;
        background: var(--color-surface);
        border-left: 1px solid var(--color-border-dark);
    }

    #bubble-list {
        flex: 1;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
        gap: 10px;
        padding-bottom: 8px;
    }

    #danmaku-layer {
        display: none;
    }
}

@media (max-width: 360px) {
    #panel-header h1 {
        font-size: 14px;
    }

    .dot {
        width: 13px;
        height: 13px;
    }

    #controls button {
        font-size: 13px;
        padding: 6px 0;
    }
}
