#game-root {
    --xq-accent: #10B981;
    --xq-accent-dark: #0e9c6f;
    --xq-accent-light: #e3f9ef;
    --xq-accent-border: #a7f3d0;
    border-radius: var(--kw-radius, 16px);
}

#game-root button {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.kwg-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 14px;
}

.xq-wrap {
    max-width: 480px;
    margin: 0 auto;
}

.xq-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 10px;
}

.xq-header-icon {
    display: flex;
    font-size: 18px;
    line-height: 1;
}

.xq-header-title {
    font-size: 22px;
    font-weight: 800;
    color: var(--xq-accent);
}

/* ---- Setup screen ---- */

.xq-setup-card {
    background: #fff;
    border-radius: var(--kw-radius, 16px);
    padding: 20px;
    box-shadow: 0 3px 12px rgba(0, 0, 0, .07);
}

.xq-setup-section {
    margin-bottom: 20px;
}

.xq-setup-section-last {
    margin-bottom: 0;
}

.xq-setup-label {
    font-size: 13px;
    font-weight: 800;
    color: #888;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: 10px;
}

.xq-opponent-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.xq-difficulty-grid,
.xq-side-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.xq-time-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.xq-option-card,
.xq-difficulty-card,
.xq-side-card,
.xq-time-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 4px;
    border: 2px solid var(--xq-accent-border);
    border-radius: var(--kw-radius, 14px);
    background: #fff;
    padding: 12px 8px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .06);
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}

.xq-option-card:hover,
.xq-difficulty-card:hover,
.xq-side-card:hover,
.xq-time-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 14px rgba(0, 0, 0, .1);
}

.xq-option-card.xq-option-selected,
.xq-difficulty-card.xq-option-selected,
.xq-side-card.xq-option-selected,
.xq-time-card.xq-option-selected {
    border-color: var(--xq-accent);
    background: var(--xq-accent-light);
}

.xq-option-selected::after {
    content: '✓';
    position: absolute;
    top: 6px;
    right: 6px;
    width: 16px;
    height: 16px;
    background: var(--xq-accent);
    color: #fff;
    border-radius: 50%;
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.xq-option-emoji {
    font-size: 22px;
    line-height: 1;
}

.xq-option-label {
    font-size: 13px;
    font-weight: 800;
    color: var(--kw-text, #2D2A32);
}

.xq-option-sub {
    font-size: 11px;
    color: #888;
    font-weight: 600;
}

.xq-difficulty-bullets {
    list-style: none;
    margin: 4px 0 0;
    padding: 0;
    font-size: 11px;
    color: #777;
    font-weight: 600;
    line-height: 1.5;
}

.xq-difficulty-bullets li::before {
    content: '• ';
    color: var(--xq-accent);
}

.xq-start-btn {
    display: block;
    width: 100%;
    text-align: center;
    font-size: 16px;
    padding: 14px;
    margin-top: 20px;
}

/* ---- Piece tokens - shared by the "Play As" setup preview, the player
   chips, and the board itself, so all three read as the exact same
   Xiangqi-style disc with an authentic Chinese character. ---- */

.xq-token {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: radial-gradient(circle at 32% 28%, #fbf1d8, #ecd9ab 72%);
    font-family: "Songti SC", "STSong", "SimSun", "PingFang SC", serif;
    font-weight: 700;
    line-height: 1;
    user-select: none;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06), 0 2px 3px rgba(0, 0, 0, .25);
}

.xq-piece-r {
    color: #b91c1c;
    border: 2px solid #b91c1c;
}

.xq-piece-b {
    color: #1f2937;
    border: 2px solid #1f2937;
}

.xq-side-preview {
    width: 32px;
    height: 32px;
    font-size: 16px;
}

/* ---- Match screen ---- */

.xq-mode-row {
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.xq-mode-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--xq-accent-light);
    color: var(--xq-accent-dark);
    border-radius: 999px;
    padding: 5px 12px;
    font-weight: 700;
    font-size: 12px;
}

.xq-mode-pill-icon {
    display: inline-flex;
    line-height: 1;
}

.xq-change-setup-btn {
    border: none;
    background: none;
    color: var(--xq-accent-dark);
    font-weight: 700;
    font-size: 12px;
    cursor: pointer;
    padding: 4px;
}

.xq-change-setup-btn:hover {
    color: var(--xq-accent);
}

.xq-players-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-bottom: 20px;
}

.xq-player-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 92px;
    padding: 8px 14px;
    border-radius: 14px;
    background: #fff;
    border: 2px solid var(--xq-accent-border);
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.xq-player-piece {
    width: 30px;
    height: 30px;
    font-size: 15px;
}

.xq-player-name {
    font-size: 11px;
    font-weight: 800;
    color: #999;
}

.xq-clock {
    font-size: 12px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: #999;
    margin-top: 2px;
}

.xq-clock-active {
    color: var(--xq-accent-dark);
}

.xq-clock-low {
    color: #ef4444;
}

.xq-player-chip.xq-player-active {
    border-color: var(--xq-accent);
    box-shadow: 0 0 0 2px var(--xq-accent-light) inset, 0 4px 10px rgba(16, 185, 129, .25);
    transform: translateY(-2px);
}

.xq-player-chip.xq-player-active .xq-player-name {
    color: var(--xq-accent-dark);
}

.xq-players-vs {
    font-size: 12px;
    font-weight: 800;
    color: #bbb;
}

.xq-toolbar {
    justify-content: center;
    margin-top: 30px;
    margin-bottom: 0;
}

.xq-tool-btn {
    border: none;
    background: var(--xq-accent-light);
    color: var(--xq-accent-dark);
    border-radius: 999px;
    padding: 8px 16px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    transition: transform .1s ease, background .15s ease;
}

.xq-tool-btn:hover:not(:disabled) {
    background: var(--xq-accent-border);
    transform: translateY(-1px);
}

.xq-tool-btn:disabled {
    opacity: .45;
    cursor: default;
}

/* ---- Board - a point-based Xiangqi grid (pieces sit ON intersections,
   not inside squares), unlike mind-chess's CSS-grid-of-squares board. The
   grid/palace/river lines are one static SVG (buildBoardLinesSvg() in
   game.js) sized to a viewBox that exactly matches the percentage math
   used to place each point button on top of it - see visualPos(). ---- */

.xq-board-wrap {
    margin: 0 auto;
    padding: 30px;
    box-sizing: border-box;
    background: #e8cf9d;
    border: 6px solid #5c3a21;
    border-radius: 10px;
    box-shadow: 0 12px 26px -10px rgba(0, 0, 0, .32), 0 2px 0 rgba(0, 0, 0, .12);
}

.xq-board-surface {
    position: relative;
    width: 100%;
    aspect-ratio: 8 / 9;
}

.xq-lines {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.xq-grid-lines line {
    stroke: #6b4423;
    stroke-width: 3;
}

.xq-river-text {
    fill: #8a5a3a;
    font-family: "Songti SC", "STSong", "SimSun", "PingFang SC", serif;
    font-size: 64px;
    font-weight: 700;
    letter-spacing: 6px;
}

.xq-board {
    position: absolute;
    inset: 0;
}

.xq-point {
    position: absolute;
    width: clamp(28px, 8.6vw, 44px);
    height: clamp(28px, 8.6vw, 44px);
    transform: translate(-50%, -50%);
    border: none;
    background: transparent;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.xq-point .xq-token {
    width: 100%;
    height: 100%;
    font-size: clamp(15px, 4.6vw, 23px);
}

.xq-point.xq-selected .xq-token {
    transform: scale(1.14);
    box-shadow: 0 0 0 3px var(--xq-accent), 0 3px 6px rgba(0, 0, 0, .3);
}

.xq-point.xq-selected {
    z-index: 3;
}

.xq-point.xq-last-move .xq-token {
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06), 0 0 0 3px rgba(250, 204, 21, .75), 0 2px 3px rgba(0, 0, 0, .25);
}

.xq-point.xq-check .xq-token {
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06), 0 0 0 3px #ef4444, 0 2px 3px rgba(0, 0, 0, .25);
    animation: xq-check-pulse .8s ease infinite alternate;
}

.xq-point.xq-legal-target::after {
    content: '';
    position: absolute;
    width: 32%;
    height: 32%;
    border-radius: 50%;
    background: rgba(16, 185, 129, .55);
    pointer-events: none;
}

.xq-point.xq-legal-capture::after {
    content: '';
    position: absolute;
    inset: -4%;
    border-radius: 50%;
    box-shadow: inset 0 0 0 3px rgba(239, 68, 68, .75);
    pointer-events: none;
}

.xq-point.xq-hint-from .xq-token,
.xq-point.xq-hint-to .xq-token {
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06), 0 0 0 3px #3b82f6, 0 2px 3px rgba(0, 0, 0, .25);
}

.xq-point.xq-hint-from:not(.xq-has-piece)::after,
.xq-point.xq-hint-to:not(.xq-has-piece)::after {
    content: '';
    position: absolute;
    inset: 6%;
    border-radius: 50%;
    box-shadow: inset 0 0 0 3px #3b82f6;
    pointer-events: none;
}

/* ---- Done screen ---- */

.xq-done-card {
    text-align: center;
    background: #fff;
    border-radius: var(--kw-radius, 16px);
    padding: 32px 20px;
    box-shadow: 0 3px 12px rgba(0, 0, 0, .07);
    animation: xq-pop .3s ease;
    border: 2px solid transparent;
}

.xq-done-card.xq-done-win {
    border-color: var(--xq-accent-border);
    box-shadow: 0 3px 16px rgba(16, 185, 129, .22);
}

.xq-done-card.xq-done-draw {
    border-color: #fde68a;
}

.xq-done-card.xq-done-loss {
    border-color: #fecaca;
}

.xq-done-emoji {
    font-size: 56px;
    margin-bottom: 8px;
}

.xq-done-title {
    font-size: 20px;
    font-weight: 800;
    color: var(--xq-accent-dark);
    margin-bottom: 8px;
}

.xq-done-score {
    font-size: 16px;
    font-weight: 600;
    color: #555;
    margin-bottom: 10px;
}

.xq-done-stars {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    font-size: 24px;
}

.xq-done-share {
    justify-content: center;
    margin-top: 16px;
}

.xq-done-actions {
    justify-content: center;
    margin-top: 20px;
}

.xq-btn-primary,
.xq-btn-secondary {
    border: none;
    padding: 12px 22px;
    border-radius: 999px;
    font-weight: 800;
    font-size: 14px;
    cursor: pointer;
    transition: transform .1s ease;
}

.xq-btn-primary {
    background: var(--xq-accent);
    color: #fff;
    box-shadow: 0 3px 0 var(--xq-accent-dark);
}

.xq-btn-primary:hover {
    transform: translateY(-1px);
}

.xq-btn-secondary {
    background: var(--xq-accent-light);
    color: var(--xq-accent-dark);
}

.xq-btn-secondary:hover {
    background: var(--xq-accent-border);
}

@keyframes xq-pop {
    0% { transform: scale(.7); }
    100% { transform: scale(1); }
}

@keyframes xq-check-pulse {
    0% { opacity: .7; }
    100% { opacity: 1; }
}

@media (max-width: 420px) {
    .xq-opponent-grid {
        grid-template-columns: 1fr;
    }

    .xq-difficulty-grid,
    .xq-side-grid,
    .xq-time-grid {
        grid-template-columns: 1fr;
    }

    .xq-board-wrap {
        padding: 14px;
    }

    .xq-river-text {
        font-size: 54px;
        letter-spacing: 4px;
    }
}
