@charset "UTF-8";
/*
 * Chinese Chess (中國象棋) styling.
 *
 * Mirrors gomoku.css / junglechess.css structure. Two view states
 * (.mg-xq__lobby / .mg-xq__match) toggled via [hidden]. Inherits theme
 * tokens from the surrounding .mg-frame.
 *
 * Key differences from junglechess:
 *   - Red/black piece color tokens instead of red/blue
 *   - 9-col × 10-row aspect ratio (still portrait but wider)
 *   - Hint line below board explains the 2-step click flow
 */

.mg-xq {
    font-family: var(--mg-body);
    color: var(--mg-ink);
    /* v0.22.62: dedicated font stack for chess piece characters and
     * the 楚河漢界 river label. Independent of --mg-display so the
     * arcade pixel font (Cubic 11) no longer applies to pieces — the
     * pixel aesthetic clashed with the "carved wooden coin" piece
     * design. Kai-script (楷書) is the traditional choice carved on
     * real xiangqi pieces, falling back through any available CJK
     * serif before landing on system serif as the last resort.
     *
     * Font names cover macOS (STKaiti, Kaiti TC, Kaiti SC), Windows
     * (DFKai-SB / 標楷體 in Traditional, KaiTi / 楷體 in Simplified,
     * also BiauKai), Linux (AR PL UKai / AR PL KaitiM via fontconfig).
     * Final fallback to Songti/Source Han Serif gives a respectable
     * formal look when no kai is installed. */
    --mg-xq-piece-font:
        "STKaiti", "Kaiti TC", "Kaiti SC", "Kaiti", "KaiTi",
        "DFKai-SB", "標楷體", "BiauKai", "楷體",
        "AR PL UKai TW", "AR PL UKai HK", "AR PL UKai CN",
        "Source Han Serif TC", "Source Han Serif SC", "Noto Serif CJK TC",
        "STSong", "Songti TC", serif;
}

/* ---------------------------------------------------------------------
 * Lobby
 * ------------------------------------------------------------------ */
.mg-xq__gate-msg {
    color: var(--mg-ink-muted);
    margin: 12px 0 0;
}
.mg-xq__section {
    margin-top: 24px;
}
.mg-xq__section-title {
    margin: 0 0 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--mg-ink-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    /* Explicit font-family overrides aggressive site-theme rules
       like `h1,h2,h3 { font-family: ... }` that would otherwise win
       on specificity against inherited frame fonts. */
    font-family: var(--mg-display);
}

.mg-xq__match-list {
    list-style: none;
    margin: 0;
    /* Belt-and-suspenders: physical + logical padding reset, since
       some site themes set padding-inline-start explicitly which
       would defeat plain padding:0. */
    padding: 0;
    padding-inline-start: 0;
    padding-inline-end: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.mg-xq__match-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    padding-inline-start: 16px;
    margin: 0;
    background: var(--mg-bg-2);
    border: 1px solid var(--mg-line);
    border-radius: var(--mg-radius-sm);
    flex-wrap: wrap;
    list-style: none;
    transition: border-color .12s, background .12s;
}
.mg-xq__match-row:hover {
    border-color: var(--mg-line-strong);
}
.mg-xq__match-label {
    flex: 1 1 auto;
    font-size: 14px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}
.mg-xq__match-meta {
    color: var(--mg-ink-subtle);
    font-size: 12px;
    margin-left: 8px;
}
.mg-xq__match-row .mg-btn {
    flex: 0 0 auto;
}
.mg-xq__empty {
    padding: 18px 14px;
    padding-inline-start: 14px;
    margin: 0;
    color: var(--mg-ink-subtle);
    font-size: 13px;
    text-align: center;
    background: var(--mg-bg-2);
    border: 1px dashed var(--mg-line);
    border-radius: var(--mg-radius-sm);
    list-style: none;
}

/* ---------------------------------------------------------------------
 * Create-match modal
 * ------------------------------------------------------------------ */
.mg-xq__create-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
    z-index: 9000;
    padding: 16px;
}
.mg-xq__create-modal[hidden] {
    display: none;
}
.mg-xq__create-card {
    background: var(--mg-bg-2);
    border: 1px solid var(--mg-line-strong);
    border-radius: var(--mg-radius);
    padding: 20px 22px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
    width: 100%;
    max-width: 420px;
}
.mg-xq__create-title {
    margin: 0 0 14px;
    font-size: 16px;
    font-weight: 600;
    color: var(--mg-ink);
    font-family: var(--mg-display);
}
.mg-xq__create-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    background: var(--mg-bg);
    border: 1px solid var(--mg-line);
    border-radius: var(--mg-radius-sm);
    cursor: pointer;
    font-size: 14px;
    transition: border-color .12s;
}
.mg-xq__create-row:hover {
    border-color: var(--mg-line-strong);
}
.mg-xq__create-row input[type="checkbox"] {
    accent-color: var(--mg-accent);
    margin-top: 2px;
    flex: 0 0 auto;
}
.mg-xq__create-hint {
    display: block;
    font-size: 12px;
    color: var(--mg-ink-muted);
    margin-top: 4px;
    line-height: 1.4;
}
.mg-xq__create-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

/* Difficulty grid + buttons — three-up grid in the practice modal,
   each button = one difficulty level + start-practice action. Same
   visual pattern as gomoku's difficulty selector for consistency
   across the plugin. */
.mg-xq__difficulty-grid {
    display: grid;
    /* minmax(0, 1fr) instead of 1fr — without it, long uppercase
       subtitles like "EXPECT TO LOSE" force the column wider than the
       modal and clip the text. */
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 8px;
}
@media (max-width: 480px) {
    .mg-xq__difficulty-grid {
        grid-template-columns: 1fr;
    }
}
/* Specificity 0,2,1 to match (and override) `.mg-frame button.mg-btn`
   global rule that imposes uppercase + wide letter-spacing — without
   matching specificity, those styles bleed onto our two-line button. */
.mg-xq button.mg-xq__difficulty-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 6px;
    text-align: center;
    line-height: 1.3;
    height: auto;
    text-transform: none;
    letter-spacing: 0;
    font-weight: 400;
    min-width: 0;
    box-sizing: border-box;
}
.mg-xq button.mg-xq__difficulty-btn strong {
    font-size: 15px;
    font-weight: 700;
    color: var(--mg-ink);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    min-width: 0;
}
.mg-xq button.mg-xq__difficulty-btn span {
    font-size: 11px;
    color: var(--mg-ink-muted);
    font-weight: 400;
    line-height: 1.25;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    max-width: 100%;
    min-width: 0;
}
@media (max-width: 380px) {
    .mg-xq button.mg-xq__difficulty-btn span { font-size: 10px; }
}
.mg-xq__difficulty-btn:hover strong {
    color: var(--mg-accent);
}

/* ---------------------------------------------------------------------
 * Match view
 * ------------------------------------------------------------------ */
.mg-xq__header-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.mg-xq__match-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

/* Practice-mode badge — visually echoes the gomoku version. CSS gates
 * visibility on the data-practice-active attribute on the host root
 * (set by JS in enterPracticeMode). The element-level [hidden] flag
 * is also set by JS but the CSS gate is the source of truth — defends
 * against any state drift where the flag gets out of sync. */
.mg-xq__practice-badge {
    display: none;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
    white-space: nowrap;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--mg-accent);
    background: var(--mg-accent-soft, rgba(255,82,82,0.08));
    border: 1px solid var(--mg-accent);
    border-radius: 999px;
    padding: 4px 12px;
    margin: 0;
    font-weight: 600;
    line-height: 1.4;
    flex: 0 0 auto;
    align-self: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
}
.mg-xq[data-practice-active="1"] .mg-xq__practice-badge {
    display: inline-flex;
}
.mg-xq__practice-badge-sep {
    opacity: 0.45;
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
}
.mg-xq__practice-badge-detail {
    font-weight: 500;
    /* Slightly muted — secondary to the main "Practice Mode" label.
       Don't apply the badge's uppercase since difficulty labels read
       better in native casing (e.g. "簡單", "Easy"). */
    opacity: 0.85;
    text-transform: none;
    letter-spacing: 0;
}
.mg-xq__status {
    flex: 1 1 auto;
    text-align: right;
    font-size: 14px;
    color: var(--mg-ink-muted);
    min-height: 1.2em;
    word-break: break-all;
    font-weight: 500;
}
.mg-xq__status.is-your-turn {
    color: var(--mg-accent);
    text-shadow: 0 0 8px var(--mg-accent-glow);
}

.mg-xq__players {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding: 14px 16px;
    background: var(--mg-bg-2);
    border: 1px solid var(--mg-line);
    border-radius: var(--mg-radius-sm);
}
.mg-xq__player {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    padding: 6px 10px;
    border-radius: var(--mg-radius-xs);
    transition: background .15s, box-shadow .15s;
    min-width: 0;
}
.mg-xq__player[data-player="2"] {
    justify-content: flex-end;
}
.mg-xq__player.is-active {
    background: var(--mg-bg-3);
    box-shadow: 0 0 0 1px var(--mg-accent), 0 0 12px var(--mg-accent-glow);
}

/* Side-color marker — small disc showing which player is which color.
   Matches the canvas piece palette: cream/bone gradient body with a
   colored accent border (vermilion for red, ink-black for black) — same
   convention as the canvas pieces, where side is told by character
   color on a shared cream disc. */
.mg-xq__color {
    display: inline-block;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    flex: 0 0 auto;
    background: radial-gradient(circle at 30% 30%, #fdf6e3, #ecdfbf 55%, #bf9f6b);
    box-shadow:
        inset -1px -2px 3px rgba(120,80,36,0.30),
        inset 1px 1px 2px rgba(255,255,255,0.40);
    box-sizing: border-box;
}
.mg-xq__color--red {
    border: 2px solid #a91d20;
}
.mg-xq__color--black {
    border: 2px solid #1a1a1a;
}

.mg-xq__player-name {
    font-weight: 600;
    color: var(--mg-ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1 1 auto;
}
.mg-xq__clock {
    font-family: var(--mg-mono);
    font-size: 13px;
    color: var(--mg-ink-muted);
    min-width: 44px;
    text-align: center;
    flex: 0 0 auto;
    font-variant-numeric: tabular-nums;
}
.mg-xq__clock.is-low {
    color: #ff5252;
    font-weight: 700;
}
.mg-xq__vs {
    font-size: 11px;
    font-weight: 700;
    color: var(--mg-ink-subtle);
    letter-spacing: 0.12em;
}

/* ---------------------------------------------------------------------
 * Board canvas — 9×10 aspect.
 *
 * Canvas internal resolution is 900×1000 (set in template). Slightly
 * wider than junglechess's 7×9, so we bump the max-width a bit to keep
 * intersections legible at typical desktop sizes.
 * ------------------------------------------------------------------ */
.mg-xq__board-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 12px;
}
.mg-xq__board {
    display: block;
    width: 100%;
    max-width: 480px;
    height: auto;
    /* Soft inset highlight + outer shadow for "lifted off the page"
       feel — luxury depth without flashiness. */
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.06);
    box-shadow:
        0 1px 0 rgba(255,255,255,0.04) inset,
        0 0 0 1px rgba(0,0,0,0.4),
        0 12px 32px rgba(0, 0, 0, 0.45),
        0 2px 8px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    /* Belt-and-suspenders: core.css already wipes tap-highlight for
       .mg-frame *, but on some Android Chrome builds the inheritance
       to <canvas> is flaky. Set it directly on the canvas so the
       browser's translucent blue tap overlay never appears — selection
       feedback is rendered by the canvas itself (gold rings + green
       move dots). */
    -webkit-tap-highlight-color: transparent;
    outline: none;
}
.mg-xq__board:focus,
.mg-xq__board:focus-visible {
    outline: none;
}

.mg-xq__hint {
    margin: 0 0 14px;
    text-align: center;
    color: var(--mg-ink-muted);
    font-size: 12px;
}

.mg-xq__actions {
    display: flex;
    justify-content: center;
    gap: 12px;
}

/* ---------------------------------------------------------------------
 * Mobile
 * ------------------------------------------------------------------ */
@media (max-width: 540px) {
    .mg-xq__match-header { flex-direction: column; align-items: stretch; }
    .mg-xq__match-header .mg-btn { align-self: flex-start; }
    .mg-xq__practice-badge { align-self: flex-start; margin: 0; }
    .mg-xq__status { font-size: 13px; text-align: left; }

    .mg-xq__players { padding: 10px 12px; gap: 6px; }
    .mg-xq__vs { font-size: 10px; }
    .mg-xq__player { padding: 4px 6px; font-size: 13px; gap: 6px; }
    .mg-xq__player-name { font-size: 12px; }
    .mg-xq__clock { font-size: 12px; min-width: 38px; }
    .mg-xq__color { width: 14px; height: 14px; }

    .mg-xq__board { max-width: 100%; }

    .mg-xq__match-row { padding: 12px 14px; gap: 10px; }
    .mg-xq__match-row .mg-btn { width: 100%; }
    .mg-xq__match-label { width: 100%; }
}

/* ---------------------------------------------------------------------
 * Arcade theme tweaks
 * ------------------------------------------------------------------ */
.mg-theme-arcade .mg-xq__match-row {
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.02);
}
.mg-theme-arcade .mg-xq__board {
    box-shadow:
        0 0 16px var(--mg-accent-glow),
        0 4px 12px rgba(0, 0, 0, 0.4);
}
.mg-theme-arcade .mg-xq__vs {
    color: var(--mg-accent);
    text-shadow: 0 0 6px var(--mg-accent-glow);
}
