/* ============================================================
   Xiangqi — layout & chrome synced with Fastdo's design tokens:
   Inter font (global default), --shadow-1/2/3 (app.css), 12px card
   radius, 768px/780px breakpoints (the app's two conventional cutovers).
   The board itself keeps its own wood-toned identity per request —
   only the surrounding chrome (header, cards, player bars) matches Fastdo.
   Board proportions must stay in sync with CellSize/Margin in
   XiangqiBoardComponent.razor (SVG viewBox 400 x 444).
   ============================================================ */

.xiangqi-app {
    --xiangqi-wood-light: #f0d9a8;
    --xiangqi-wood-dark: #c99b5c;
    --xiangqi-wood-frame: #7a5230;
    --xiangqi-ink: #6b4a26;
    --xiangqi-red: #c0392b;
    --xiangqi-red-deep: #8e2417;
    --xiangqi-black: #22252b;
    --xiangqi-accent: hsl(228deg, 85%, 58%);

    max-width: 760px;
    margin: 0 auto;
    padding: 1rem;
}

/* Board is the visual centerpiece — let it (and the player bars/status banner that share its
   width) grow further once there's real desktop width to spend, instead of staying capped at a
   phone-sized column in the middle of the page. */
@media (min-width: 860px) {
    .xiangqi-app {
        max-width: 920px;
        padding: 1.5rem;
    }
}

.xiangqi-card {
    background: #fff;
    border: 1px solid #ebebec;
    border-radius: 14px;
    box-shadow: var(--shadow-2, 0 0 4px rgba(0, 0, 0, .1));
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.xiangqi-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.xiangqi-title {
    margin: 0 !important;
}

/* --- Segmented "pill" tab control, used for mode switch + setup pickers --- */
.xiangqi-mode-switch {
    display: inline-flex;
    flex-wrap: wrap;
    background: #f5f5f7;
    border-radius: 999px;
    padding: 3px;
    gap: 2px;
}

.xiangqi-mode-tab {
    border: none;
    background: transparent;
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #6b7280;
    cursor: pointer;
    transition: background-color .2s ease, color .2s ease, box-shadow .2s ease;
}

.xiangqi-mode-tab:hover {
    color: #111827;
}

.xiangqi-mode-tab.is-active {
    background: #fff;
    color: var(--xiangqi-accent);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .15);
}

.xiangqi-setup-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 420px;
    margin: 0 auto;
    width: 100%;
}

/* This is a bare <button>, not a Bulma .button — it needs its own full visual treatment rather
   than relying on a class that was never applied to it. */
.xiangqi-start-button {
    align-self: stretch;
    font: inherit;
    font-weight: 700;
    font-size: 1rem;
    padding: .85rem 1.25rem;
    border: none;
    border-radius: 12px;
    background: var(--xiangqi-accent);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 6px 18px hsl(228deg 85% 58% / 30%);
    transition: transform .15s ease, filter .15s ease, box-shadow .15s ease;
}

.xiangqi-start-button:hover:not(:disabled) {
    filter: brightness(1.08);
    transform: translateY(-1px);
}

.xiangqi-start-button:active:not(:disabled) {
    transform: translateY(0);
}

.xiangqi-start-button:disabled {
    opacity: .5;
    cursor: not-allowed;
    box-shadow: none;
}

.xiangqi-join-field {
    margin-top: 0.25rem;
}

.xiangqi-error {
    color: var(--xiangqi-red-deep);
    text-align: center;
    font-size: 0.875rem;
}

.xiangqi-waiting {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.xiangqi-room-code-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* --- Stage: opponent bar / board / your bar / controls, board is always the visual center --- */
.xiangqi-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
}

.xiangqi-player-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: min(100%, 640px);
    padding: 0.75rem 1.1rem;
    border-radius: 14px;
    background: #f7f7f8;
    border: 1px solid transparent;
    box-shadow: var(--shadow-1, 0 1px 3px rgba(0, 0, 0, .08));
    transition: background-color .25s ease, border-color .25s ease, box-shadow .25s ease;
}

/* Prefixed with .xiangqi-app (always true) to outrank the unconditional .xiangqi-board-wrap /
   .xiangqi-status-banner width rules that are declared further down this file — those have equal
   specificity and would otherwise win on source order alone, silently cancelling this override at
   every viewport width regardless of the media query. */
@media (min-width: 860px) {
    .xiangqi-app .xiangqi-player-bar,
    .xiangqi-app .xiangqi-board-wrap,
    .xiangqi-app .xiangqi-status-banner {
        width: min(100%, 720px);
    }
}

.xiangqi-player-bar.is-active-turn {
    background: #fff;
    border-color: var(--xiangqi-accent);
    box-shadow: 0 0 0 3px hsl(228deg 85% 58% / 12%);
}

.xiangqi-player-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.05rem;
    color: #fff;
    flex-shrink: 0;
    box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .15), 0 2px 6px rgba(0, 0, 0, .15);
}

.xiangqi-player-bar.is-red .xiangqi-player-avatar {
    background: var(--xiangqi-red);
}

.xiangqi-player-bar.is-black .xiangqi-player-avatar {
    background: var(--xiangqi-black);
}

.xiangqi-player-captured {
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
    max-width: 160px;
    flex-shrink: 0;
}

/* Captured pieces are shown as small versions of the actual board piece token (same wood-disc
   look) rather than plain chips, so a glance at the tray reads as "pieces", not abstract dots. */
.xiangqi-captured-chip {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .78rem;
    font-weight: 700;
    background: radial-gradient(circle at 35% 30%, #fffdf5, #f0e2c4);
    border: 1.5px solid var(--xiangqi-ink);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .25), inset 0 1px 1px rgba(255, 255, 255, .6);
    flex-shrink: 0;
    animation: xiangqi-fade-in .2s ease-out;
}

/* A bar's captured tray always shows the OPPONENT's color of piece (what this side has captured). */
.xiangqi-player-bar.is-red .xiangqi-captured-chip {
    color: var(--xiangqi-black);
}

.xiangqi-player-bar.is-black .xiangqi-captured-chip {
    color: var(--xiangqi-red-deep);
}

.xiangqi-player-name {
    font-weight: 700;
    font-size: 1.05rem;
    color: #1f2430;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.xiangqi-player-offline {
    color: var(--xiangqi-red-deep);
    font-size: 0.8rem;
    flex-shrink: 0;
}

.xiangqi-player-thinking {
    font-size: 0.75rem;
    color: var(--xiangqi-accent);
    font-style: italic;
    flex-shrink: 0;
}

.xiangqi-player-timer {
    font-variant-numeric: tabular-nums;
    font-weight: 800;
    font-size: 1.15rem;
    color: #1f2430;
    background: #eceef3;
    padding: 0.3rem 0.8rem;
    border-radius: 8px;
    flex-shrink: 0;
    transition: background-color .25s ease, color .25s ease;
}

.xiangqi-player-bar.is-active-turn .xiangqi-player-timer {
    background: var(--xiangqi-accent);
    color: #fff;
}

.xiangqi-player-timer.is-warning,
.xiangqi-player-bar.is-active-turn .xiangqi-player-timer.is-warning {
    background: var(--xiangqi-red-deep);
    color: #fff;
    animation: xiangqi-timer-warning-pulse 1s ease-in-out infinite;
}

@keyframes xiangqi-timer-warning-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(142, 36, 23, .4); }
    50% { box-shadow: 0 0 0 5px rgba(142, 36, 23, 0); }
}

/* Default (desktop) DOM/visual order inside .xiangqi-stage; overridden on mobile below so "you" reads
   first without changing markup order (keeps DOM/accessibility order = opponent, board, you). */
.xiangqi-stage > .is-opponent-bar { order: 1; }
.xiangqi-stage > .xiangqi-draw-offer-banner { order: 2; }
.xiangqi-stage > .xiangqi-board-wrap { order: 3; }
.xiangqi-stage > .is-self-bar { order: 4; }
.xiangqi-stage > .xiangqi-controls { order: 5; }

/* --- Status banners --- */
.xiangqi-status-banner {
    text-align: center;
    font-weight: 700;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    width: min(100%, 640px);
    margin: 0 auto;
}

.xiangqi-status-banner.is-check {
    background: #fff3cd;
    color: #7a5c00;
    animation: xiangqi-check-pulse 1.1s ease-in-out infinite;
}

.xiangqi-status-banner.is-checkmate,
.xiangqi-status-banner.is-stalemate {
    background: #f0e6d2;
    color: #5c4a1e;
}

@keyframes xiangqi-check-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(122, 92, 0, .25); }
    50% { box-shadow: 0 0 0 6px rgba(122, 92, 0, 0); }
}

.xiangqi-controls {
    display: flex;
    gap: 0.5rem;
}

/* --- Chat (online mode) — base list styling, reused inside the floating widget panel below --- */
.xiangqi-chat-messages {
    max-height: 140px;
    overflow-y: auto;
    border: 1px solid #ebebec;
    border-radius: 8px;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    background: #fafafb;
}

.xiangqi-chat-message {
    margin: 0 0 0.25rem;
    word-break: break-word;
    font-size: 0.85rem;
}

/* --- Board wrap: also hosts the centered status overlay, so it shares the board's exact footprint --- */
.xiangqi-board-wrap {
    position: relative;
    width: min(100%, 640px);
    margin: 0 auto;
}

/* --- Board: keeps its own wood-toned identity, just polished (richer gradient/depth/radius) --- */
.xiangqi-board {
    position: relative;
    width: 100%;
    aspect-ratio: 400 / 444;
    background: linear-gradient(160deg, var(--xiangqi-wood-light), var(--xiangqi-wood-dark));
    border: 3px solid var(--xiangqi-wood-frame);
    border-radius: 12px;
    box-shadow: var(--shadow-3, 0 4px 32px rgba(0, 0, 0, .14)), inset 0 0 24px rgba(122, 82, 48, .25);
}

.xiangqi-board-lines {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.xiangqi-board-lines .board-line {
    stroke: var(--xiangqi-ink);
    stroke-width: 1.5;
    opacity: 0.8;
}

.xiangqi-board-lines .river-text {
    fill: var(--xiangqi-ink);
    font-size: 22px;
    dominant-baseline: middle;
    opacity: 0.85;
}

.xiangqi-board-cells {
    position: absolute;
    inset: 0;
}

.xiangqi-cell {
    position: absolute;
    transform: translate(-50%, -50%);
    width: 9.5%;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    border: none;
    background: transparent;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: default;
    /* Animates a flip (orientation change) smoothly; ordinary moves don't move the cell itself,
       only the piece glyph inside it, so this never fights the piece-pop animation below. */
    transition: left .3s cubic-bezier(.4, 0, .2, 1), top .3s cubic-bezier(.4, 0, .2, 1);
}

.xiangqi-board.is-playable .xiangqi-cell:not(:disabled) {
    cursor: pointer;
}

.xiangqi-cell.is-legal-destination::after {
    content: "";
    position: absolute;
    width: 32%;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    background: rgba(46, 125, 50, .6);
    animation: xiangqi-fade-in .18s ease-out;
}

.xiangqi-cell.has-piece.is-legal-destination::after {
    width: 95%;
    background: transparent;
    border: 3px solid rgba(211, 47, 47, .75);
    animation: xiangqi-ring-in .18s ease-out;
}

.xiangqi-cell.is-last-move {
    box-shadow: inset 0 0 0 2px hsl(228deg 85% 58% / 65%);
    border-radius: 6px;
}

.xiangqi-cell.is-selected .xiangqi-piece-glyph {
    box-shadow: 0 0 0 3px #2e7d32, 0 2px 6px rgba(0, 0, 0, .25);
    transform: scale(1.08);
}

.xiangqi-piece-glyph {
    width: 90%;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(0.75rem, 4.5vw, 1.6rem);
    font-weight: 700;
    background: radial-gradient(circle at 35% 30%, #fffdf5, #f0e2c4);
    border: 1.5px solid var(--xiangqi-ink);
    box-shadow: 0 2px 3px rgba(0, 0, 0, .25), inset 0 1px 1px rgba(255, 255, 255, .6);
    transition: transform .15s ease, box-shadow .15s ease;
    animation: xiangqi-piece-pop .18s ease-out;
}

.xiangqi-cell.is-red .xiangqi-piece-glyph {
    color: var(--xiangqi-red-deep);
}

.xiangqi-cell.is-black .xiangqi-piece-glyph {
    color: var(--xiangqi-black);
}

@keyframes xiangqi-piece-pop {
    from { transform: scale(.4); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes xiangqi-fade-in {
    from { opacity: 0; transform: scale(.5); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes xiangqi-ring-in {
    from { opacity: 0; transform: scale(.7); }
    to { opacity: 1; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    .xiangqi-piece-glyph,
    .xiangqi-cell.is-legal-destination::after,
    .xiangqi-cell.has-piece.is-legal-destination::after,
    .xiangqi-status-banner.is-check,
    .xiangqi-player-timer.is-warning,
    .xiangqi-home,
    .xiangqi-setup-form,
    .xiangqi-stage,
    .xiangqi-waiting,
    .xiangqi-seat,
    .xiangqi-captured-chip,
    .xiangqi-overlay-card,
    .xiangqi-chat-panel,
    .xiangqi-chat-badge {
        animation: none;
    }

    .xiangqi-cell,
    .xiangqi-app .button,
    .xiangqi-home-action {
        transition: none;
    }
}

@media (max-width: 768px) {
    .xiangqi-app {
        padding: 0.5rem;
    }

    .xiangqi-card {
        padding: 0.85rem;
        border-radius: 10px;
    }

    .xiangqi-header {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }

    .xiangqi-mode-switch {
        justify-content: center;
    }

    /* Mobile content priority per spec: Header → you → board → opponent → controls → chat (floating,
       unaffected by document order). DOM order stays opponent/board/you for a11y; only the visual
       order changes. */
    .xiangqi-stage > .is-self-bar { order: 1; }
    .xiangqi-stage > .xiangqi-draw-offer-banner { order: 2; }
    .xiangqi-stage > .xiangqi-board-wrap { order: 3; }
    .xiangqi-stage > .is-opponent-bar { order: 4; }
    .xiangqi-stage > .xiangqi-controls { order: 5; }
}

@media (max-width: 480px) {
    .xiangqi-player-avatar {
        width: 36px;
        height: 36px;
        font-size: .9rem;
    }

    .xiangqi-player-name {
        font-size: 0.92rem;
    }

    .xiangqi-player-timer {
        font-size: 0.95rem;
        padding: 0.2rem 0.6rem;
    }

    .xiangqi-waiting-seats {
        flex-direction: column;
    }

    .xiangqi-chat-panel {
        width: min(280px, 78vw);
    }
}

/* ============================================================
   Home (landing) — the only place that intentionally breaks from
   the plain white Fastdo card look, since it's the game's own
   marquee moment. Still lives inside .xiangqi-app's 640px column
   (no full-bleed) to avoid any risk of introducing horizontal scroll.
   ============================================================ */
.xiangqi-home {
    position: relative;
    overflow: hidden;
    border-radius: 16px;
    padding: 2.5rem 1.5rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    text-align: center;
    color: #fff;
    background:
        radial-gradient(circle at 15% 15%, hsl(228deg 85% 58% / 35%), transparent 55%),
        radial-gradient(circle at 85% 85%, rgba(192, 57, 43, .35), transparent 55%),
        linear-gradient(160deg, #1c1f2b, #2a2f42);
    box-shadow: var(--shadow-3, 0 4px 32px rgba(0, 0, 0, .14));
}

.xiangqi-home::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        repeating-linear-gradient(0deg, rgba(255, 255, 255, .05) 0 1px, transparent 1px 34px),
        repeating-linear-gradient(90deg, rgba(255, 255, 255, .05) 0 1px, transparent 1px 34px);
    opacity: .6;
    pointer-events: none;
}

.xiangqi-home-hero {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: .35rem;
}

.xiangqi-home-eyebrow {
    margin: 0;
    font-size: 2.25rem;
    line-height: 1;
    opacity: .85;
    letter-spacing: .1em;
}

.xiangqi-home-title {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -.01em;
}

.xiangqi-home-tagline {
    margin: 0;
    color: rgba(255, 255, 255, .75);
    font-size: .95rem;
    max-width: 320px;
}

.xiangqi-home-actions {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: .6rem;
    width: 100%;
    max-width: 320px;
}

.xiangqi-home-action {
    display: flex;
    align-items: center;
    gap: .6rem;
    justify-content: center;
    font: inherit;
    font-weight: 700;
    font-size: .95rem;
    padding: .85rem 1rem;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, .18);
    background: rgba(255, 255, 255, .08);
    color: #fff;
    cursor: pointer;
    transition: transform .15s ease, background-color .15s ease, box-shadow .15s ease;
}

.xiangqi-home-action:hover {
    background: rgba(255, 255, 255, .16);
    transform: translateY(-1px);
}

.xiangqi-home-action:active {
    transform: translateY(0);
}

.xiangqi-home-action.is-primary {
    background: var(--xiangqi-accent);
    border-color: transparent;
    box-shadow: 0 6px 18px hsl(228deg 85% 58% / 35%);
}

.xiangqi-home-action.is-primary:hover {
    filter: brightness(1.08);
}

.xiangqi-home-action-icon {
    font-size: 1.1rem;
    line-height: 1;
}

.xiangqi-home-secondary {
    position: relative;
    z-index: 1;
    background: none;
    border: none;
    color: rgba(255, 255, 255, .7);
    font: inherit;
    font-size: .85rem;
    text-decoration: underline;
    cursor: pointer;
    padding: .25rem;
}

.xiangqi-home-secondary:hover {
    color: #fff;
}

/* --- Back link (setup forms / in-game header) --- */
.xiangqi-back-link {
    background: none;
    border: none;
    cursor: pointer;
    font: inherit;
    font-size: .85rem;
    font-weight: 600;
    color: #6b7280;
    padding: .25rem .1rem;
    transition: color .15s ease;
}

.xiangqi-back-link:hover {
    color: var(--xiangqi-accent);
}

/* --- Waiting room seats --- */
.xiangqi-waiting-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
}

.xiangqi-waiting-meta,
.xiangqi-waiting-hint {
    margin: 0;
    color: #6b7280;
    font-size: .85rem;
}

.xiangqi-waiting-seats {
    display: flex;
    gap: .75rem;
    width: 100%;
    max-width: 420px;
    margin: .5rem auto 0;
}

.xiangqi-seat {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .3rem;
    padding: .85rem .5rem;
    border-radius: 10px;
    background: #f7f7f8;
    border: 1px solid #ebebec;
    border-top-width: 3px;
    animation: xiangqi-fade-in .25s ease-out;
}

.xiangqi-seat.is-red {
    border-top-color: var(--xiangqi-red);
}

.xiangqi-seat.is-black {
    border-top-color: var(--xiangqi-black);
}

.xiangqi-seat-label {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #9aa0b4;
}

.xiangqi-seat-name {
    font-weight: 700;
    font-size: .9rem;
}

.xiangqi-seat-name.is-empty {
    color: #9aa0b4;
    font-weight: 500;
    font-style: italic;
}

.xiangqi-seat-status {
    font-size: .75rem;
    padding: .1rem .5rem;
    border-radius: 999px;
    background: #eceef3;
    color: #6b7280;
}

.xiangqi-seat-status.is-ready {
    background: #e6f4ea;
    color: #2e7d32;
}

/* --- Status overlay: centered over the board only, not the whole page --- */
.xiangqi-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    pointer-events: none;
    z-index: 5;
}

.xiangqi-overlay-card {
    pointer-events: auto;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(6px);
    border-radius: 14px;
    padding: 1rem 1.25rem;
    box-shadow: 0 8px 28px rgba(0, 0, 0, .28);
    text-align: center;
    max-width: 90%;
    border-top: 4px solid var(--xiangqi-accent);
    animation: xiangqi-overlay-in .22s cubic-bezier(.34, 1.56, .64, 1);
}

.xiangqi-overlay-warning .xiangqi-overlay-card { border-top-color: #b8860b; }
.xiangqi-overlay-danger .xiangqi-overlay-card { border-top-color: var(--xiangqi-red-deep); }
.xiangqi-overlay-success .xiangqi-overlay-card { border-top-color: #2e7d32; }

.xiangqi-overlay-title {
    margin: 0;
    font-weight: 800;
    font-size: 1.1rem;
    letter-spacing: .02em;
}

.xiangqi-overlay.is-toast .xiangqi-overlay-title {
    text-transform: uppercase;
    font-size: 1rem;
}

.xiangqi-overlay-detail {
    margin: .25rem 0 0;
    font-size: .85rem;
    color: #4b5165;
}

.xiangqi-overlay-actions {
    display: flex;
    gap: .5rem;
    justify-content: center;
    margin-top: .75rem;
}

@keyframes xiangqi-overlay-in {
    from { opacity: 0; transform: scale(.85) translateY(6px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* --- Floating chat widget --- */
.xiangqi-chat-widget {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 40;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: .6rem;
}

.xiangqi-chat-fab {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    background: var(--xiangqi-accent);
    color: #fff;
    font-size: 1.4rem;
    cursor: pointer;
    position: relative;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
    transition: transform .15s ease;
}

.xiangqi-chat-fab:hover {
    transform: scale(1.06);
}

.xiangqi-chat-fab:active {
    transform: scale(.96);
}

.xiangqi-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--xiangqi-red-deep);
    color: #fff;
    font-size: .65rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    animation: xiangqi-fade-in .2s ease-out;
}

.xiangqi-chat-panel {
    width: min(300px, 80vw);
    max-height: 360px;
    background: #fff;
    border-radius: 14px;
    border: 1px solid #ebebec;
    box-shadow: var(--shadow-3, 0 4px 32px rgba(0, 0, 0, .14));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    animation: xiangqi-chat-panel-in .18s ease-out;
}

@keyframes xiangqi-chat-panel-in {
    from { opacity: 0; transform: scale(.9) translateY(8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.xiangqi-chat-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .6rem .85rem;
    font-weight: 700;
    font-size: .85rem;
    background: #f7f7f8;
    border-bottom: 1px solid #ebebec;
}

.xiangqi-chat-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: .9rem;
    color: #6b7280;
}

.xiangqi-chat-close:hover {
    color: #1f2430;
}

.xiangqi-chat-panel .xiangqi-chat-messages {
    flex: 1;
    margin: 0;
    border: none;
    border-radius: 0;
    max-height: 220px;
}

.xiangqi-chat-row {
    display: flex;
    gap: .4rem;
    padding: .5rem;
    border-top: 1px solid #ebebec;
}

.xiangqi-chat-row input {
    flex: 1;
    font: inherit;
    padding: .4rem .6rem;
    border-radius: 8px;
    border: 1px solid #dcdfe6;
    font-size: .85rem;
}

.xiangqi-chat-row button {
    font: inherit;
    font-weight: 700;
    font-size: .8rem;
    padding: .4rem .7rem;
    border-radius: 8px;
    border: none;
    background: var(--xiangqi-accent);
    color: #fff;
    cursor: pointer;
}

/* --- Generic polish: page-transition fade for each stage, gentle button hover, scoped to this feature --- */
.xiangqi-home,
.xiangqi-setup-form,
.xiangqi-stage,
.xiangqi-waiting {
    animation: xiangqi-fade-in-page .25s ease-out;
}

@keyframes xiangqi-fade-in-page {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Bulma's base .button is intentionally plain (thin border, tight padding) — give every button in
   this feature a bit more presence (size, radius, lift) so it reads as "game UI", not a form control. */
.xiangqi-app .button {
    padding: .65em 1.2em;
    border-radius: 10px;
    font-weight: 600;
    box-shadow: var(--shadow-1, 0 1px 3px rgba(0, 0, 0, .08));
    transition: transform .15s ease, background-color .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.xiangqi-app .button.is-small {
    padding: .5em .95em;
    border-radius: 8px;
}

.xiangqi-app .button.is-primary {
    box-shadow: 0 4px 14px hsl(228deg 85% 58% / 30%);
}

.xiangqi-app .button:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-2, 0 4px 10px rgba(0, 0, 0, .12));
}

.xiangqi-app .button.is-primary:hover {
    box-shadow: 0 6px 18px hsl(228deg 85% 58% / 40%);
}

.xiangqi-app .button:active {
    transform: translateY(0);
}

/* ============================================================
   Page background — every Xiangqi stage (not just the dark Home
   hero) sits on a soft ambient wash instead of the bare white page
   background, so the white .xiangqi-card doesn't float in a void.
   Scoped via :has() to this route only; no global/layout file touched.
   ============================================================ */
body:has(.xiangqi-app) {
    min-height: 100vh;
    background:
        radial-gradient(1100px 560px at 12% -8%, hsl(228deg 85% 58% / 10%), transparent 60%),
        radial-gradient(800px 480px at 100% 100%, rgba(192, 57, 43, .07), transparent 55%),
        linear-gradient(180deg, #f8f8fb, #eef0f5);
}
