:root {
    --primary-color: #1890ff;
    --success-color: #52c41a;
    --board-bg: #f3d7ac;
    --line-color: #5c3a1e;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: #f4f6f9;
    margin: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    user-select: none;
    color: #333;
    overflow-x: hidden;
}

/* 标题行绝对居中，左侧下拉框绝对靠左 */
.header-container {
    position: relative;
    width: 100%;
    max-width: 600px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 16px;
}

.simple-left-select {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid #d9d9d9;
    background: white;
    cursor: pointer;
    color: #555;
    font-weight: 500;
}

h1 { 
    margin: 0;
    color: #1a1a1a; 
    font-size: 22px; 
    font-weight: 700;
    text-align: center;
}

.main-layout {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    width: 100%;
    max-width: 900px;
}

.board-center-panel {
    position: relative;
    background: white;
    padding: 18px;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.06);
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 580px;
    box-sizing: border-box;
    overflow: visible;
}

.top-settings-bar {
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 12px;
    background: #f8f9fa;
    padding: 6px 8px;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    box-sizing: border-box;
    overflow: hidden;
}

.setting-item {
    display: flex;
    align-items: center;
    gap: 2px;
    font-size: clamp(10px, 2.1vw, 12px);
    color: #555;
    white-space: nowrap;
    flex-shrink: 0;
}

select, button, input {
    padding: 4px 6px;
    font-size: clamp(10px, 2.1vw, 12px);
    border: 1px solid #d9d9d9;
    border-radius: 5px;
    box-sizing: border-box;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

button:hover { border-color: var(--primary-color); color: var(--primary-color); }
button.primary { background: var(--primary-color); color: white; border-color: var(--primary-color); }
button.primary:hover { background: #40a9ff; }

select.highlight-select {
    font-weight: bold;
    color: var(--primary-color);
    border-color: #91d5ff;
    background: #e6f7ff;
}

.xiangqi-board {
    width: 100%;
    max-width: 600px;
    aspect-ratio: 560 / 620;
    height: auto;
    background: var(--board-bg);
    border: 3px solid var(--line-color);
    position: relative;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.15);
    border-radius: 4px;
    box-sizing: border-box;
}

.board-svg {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
}

/* 象棋棋子 */
.piece {
    position: absolute;
    width: 10%; height: 9.03%;
    max-width: 56px; max-height: 56px;
    border-radius: 50%;
    display: flex; justify-content: center; align-items: center;
    font-size: clamp(18px, 5.2vw, 30px);
    font-weight: bold;
    box-shadow: 0 3px 6px rgba(0,0,0,0.3);
    border: 2px solid;
    background: #fffdfa;
    cursor: pointer;
    z-index: 10;
    transform: translate(-50%, -50%);
    box-sizing: border-box;
}

.piece.red { color: #d32f2f; border-color: #d32f2f; }
.piece.black { color: #111; border-color: #111; }
.piece.selected { background: #ffe7ba; transform: translate(-50%, -50%) scale(1.12); z-index: 20; }

/* 围棋石子 */
.go-stone {
    position: absolute;
    width: 5%; height: 5%;
    max-width: 28px; max-height: 28px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
    transform: translate(-50%, -50%);
    box-shadow: 0 2px 5px rgba(0,0,0,0.4);
}
.go-stone.black-stone {
    background: radial-gradient(circle at 30% 30%, #555, #000);
}
.go-stone.white-stone {
    background: radial-gradient(circle at 30% 30%, #ffffff, #e0e0e0);
    border: 1px solid #ccc;
}

.move-marker {
    position: absolute;
    width: 16px; height: 16px;
    border-radius: 50%;
    background: rgba(82, 196, 26, 0.75);
    transform: translate(-50%, -50%);
    z-index: 15;
    pointer-events: none;
}

.copy-badge {
    position: absolute;
    background: #52c41a;
    color: white;
    font-size: 11px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
    z-index: 100;
    pointer-events: none;
    white-space: nowrap;
    animation: popFade 1.8s ease-out forwards;
}

@keyframes popFade {
    0% { opacity: 0; transform: translate(10px, -25px) scale(0.6); }
    20% { opacity: 1; transform: translate(10px, -30px) scale(1); }
    70% { opacity: 1; transform: translate(10px, -33px) scale(1); }
    100% { opacity: 0; transform: translate(10px, -40px) scale(0.8); }
}

.status-badge {
    padding: 6px 12px;
    background: #e6f7ff;
    border: 1px solid #91d5ff;
    color: #1890ff;
    border-radius: 6px;
    font-weight: bold;
    font-size: 13px;
    margin-bottom: 10px;
    text-align: center;
    width: 100%;
    box-sizing: border-box;
    transition: all 0.3s;
}
.status-badge.in-check {
    background: #fff1f0 !important;
    border-color: #ffa39e !important;
    color: #cf1322 !important;
    animation: blinkCheck 1s infinite alternate;
}

@keyframes blinkCheck {
    0% { box-shadow: 0 0 2px rgba(207, 19, 34, 0.2); }
    100% { box-shadow: 0 0 10px rgba(207, 19, 34, 0.6); }
}

.toggle-expand-btn {
    position: absolute;
    right: -8px; top: 18px;
    transform: translateX(100%);
    padding: 2px 8px;
    font-size: 11px;
    background: white;
    border: 1px solid #d9d9d9;
    border-radius: 10px;
    color: #555;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.08);
    transition: all 0.2s;
    white-space: nowrap;
    z-index: 30;
}
.toggle-expand-btn:hover { border-color: var(--primary-color); color: var(--primary-color); background: #e6f7ff; }

.dynamic-bridge-panel {
    position: absolute;
    right: -8px; top: 60px; bottom: 50px;
    transform: translateX(100%);
    box-sizing: border-box;
    z-index: 25;
    width: auto;
}

.combined-block {
    display: flex;
    flex-direction: column;
    transition: transform 0.55s cubic-bezier(0.34, 1.25, 0.64, 1), width 0.3s ease;
    will-change: transform;
}

.action-square-btn {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    cursor: pointer; text-align: center; box-shadow: 0 3px 8px rgba(0,0,0,0.08);
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1); box-sizing: border-box; border-radius: 6px;
}

.combined-block.mini-mode { width: 68px; gap: 6px; }
.combined-block.mini-mode .action-square-btn { height: 36px; padding: 2px 4px; }
.combined-block.mini-mode .btn-sub { display: none; }

.combined-block.expanded-mode { width: 140px; gap: 10px; }
.combined-block.expanded-mode .action-square-btn { height: 75px; padding: 8px 6px; border-radius: 10px; }
.combined-block.expanded-mode .btn-sub { display: block; }

.action-square-btn:hover { transform: scale(1.04); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.action-square-btn:active { transform: scale(0.97); }

.btn-copy-style { background: #ffffff; border: 2px solid var(--primary-color); color: var(--primary-color); }
.btn-copy-style:hover { background: #e6f7ff; }

.btn-paste-style { background: var(--success-color); border: none; color: white; }
.btn-paste-style:hover { background: #73d13d; }

.btn-title { font-weight: 700; font-size: 13px; line-height: 1.2; }
.btn-sub { font-size: 10px; opacity: 0.85; margin-top: 3px; font-weight: normal; }

.bottom-tools-bar {
    margin-top: 10px; display: flex; justify-content: space-between; width: 100%; align-items: center;
}

.log-toggle-btn {
    padding: 5px 12px; font-size: 12px; background: #f5f5f5; border: 1px solid #d9d9d9; border-radius: 20px; color: #555; cursor: pointer; transition: all 0.2s;
}
.log-toggle-btn:hover { background: #e6f7ff; color: var(--primary-color); border-color: var(--primary-color); }

/* Modal 弹窗 */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(3px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }

.modal-card {
    background: white; width: 90%; max-width: 480px; border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2); padding: 18px; display: flex; flex-direction: column; gap: 12px;
    transform: scale(0.9); transition: transform 0.25s cubic-bezier(0.25, 1, 0.5, 1);
}
.modal-overlay.active .modal-card { transform: scale(1); }

.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    font-weight: 700; font-size: 15px; border-bottom: 1px solid #f0f0f0; padding-bottom: 8px;
}
.close-btn { background: none; border: none; font-size: 20px; cursor: pointer; color: #999; padding: 0; line-height: 1; }
.close-btn:hover { color: #333; }

.log-box-modal {
    height: 240px; overflow-y: auto; background: #fafafa; border: 1px solid #f0f0f0; padding: 10px; font-size: 12px; font-family: monospace; border-radius: 6px; line-height: 1.6;
}

.api-form { display: flex; flex-direction: column; gap: 10px; font-size: 13px; }
.api-form input[type="text"], .api-form input[type="password"] {
    width: 100%; padding: 8px; border: 1px solid #d9d9d9; border-radius: 6px; box-sizing: border-box; font-family: monospace; font-size: 12px;
}
.preset-btn-group { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.preset-btn { font-size: 11px; padding: 4px 8px; background: #f0f0f0; border: 1px solid #d9d9d9; border-radius: 4px; }
.preset-btn.active-provider { background: #e6f7ff; color: var(--primary-color); border-color: #91d5ff; font-weight: bold; }

@media (max-width: 750px) {
    .board-center-panel { margin-bottom: 80px; }
    .toggle-expand-btn { display: none; }
    .dynamic-bridge-panel {
        position: absolute; left: 0; right: 0; top: auto; bottom: -70px; transform: translateX(0) !important; width: 100%; max-width: 100%;
    }
    .combined-block { flex-direction: row !important; width: 100% !important; transform: translateY(0px) !important; gap: 10px; }
    .action-square-btn { flex: 1; height: 46px !important; }
}
