@charset "UTF-8";
/*
 * Jungle Chess (鬥獸棋) styling.
 *
 * Mirrors gomoku.css structure. Two view states (.mg-jc__lobby /
 * .mg-jc__match) toggled via [hidden]. Inherits theme tokens from the
 * surrounding .mg-frame.
 *
 * Key differences from gomoku:
 *   - Red/blue piece color tokens instead of black/white
 *   - 7-col × 9-row aspect ratio (board is portrait, not square)
 *   - Hint line below board explains the 2-step click flow
 */

.mg-jc {
    font-family: var(--mg-body);
    color: var(--mg-ink);
}

/* ---------------------------------------------------------------------
 * Lobby
 * ------------------------------------------------------------------ */
.mg-jc__gate-msg {
    color: var(--mg-ink-muted);
    margin: 12px 0 0;
}
.mg-jc__section {
    margin-top: 24px;
}
.mg-jc__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-jc__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-jc__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-jc__match-row:hover {
    border-color: var(--mg-line-strong);
}
.mg-jc__match-label {
    flex: 1 1 auto;
    font-size: 14px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}
.mg-jc__match-meta {
    color: var(--mg-ink-subtle);
    font-size: 12px;
    margin-left: 8px;
}
.mg-jc__match-row .mg-btn {
    flex: 0 0 auto;
}
.mg-jc__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-jc__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-jc__create-modal[hidden] {
    display: none;
}
.mg-jc__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-jc__create-title {
    margin: 0 0 14px;
    font-size: 16px;
    font-weight: 600;
    color: var(--mg-ink);
    font-family: var(--mg-display);
}
.mg-jc__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-jc__create-row:hover {
    border-color: var(--mg-line-strong);
}
.mg-jc__create-row input[type="checkbox"] {
    accent-color: var(--mg-accent);
    margin-top: 2px;
    flex: 0 0 auto;
}
.mg-jc__create-hint {
    display: block;
    font-size: 12px;
    color: var(--mg-ink-muted);
    margin-top: 4px;
    line-height: 1.4;
}
.mg-jc__create-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

/* ---------------------------------------------------------------------
 * Match view
 * ------------------------------------------------------------------ */
.mg-jc__header-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.mg-jc__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-jc__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-jc[data-practice-active="1"] .mg-jc__practice-badge {
    display: inline-flex;
}
.mg-jc__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-jc__status.is-your-turn {
    color: var(--mg-accent);
    text-shadow: 0 0 8px var(--mg-accent-glow);
}

.mg-jc__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-jc__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-jc__player[data-player="2"] {
    justify-content: flex-end;
}
.mg-jc__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 chip showing which player is which color.
   Matches the canvas piece palette: deep wine for player 1,
   slate-charcoal for player 2 (NOT pure black — emoji'd be invisible). */
.mg-jc__color {
    display: inline-block;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    flex: 0 0 auto;
    box-shadow:
        inset -1px -2px 3px rgba(0,0,0,0.4),
        inset 1px 1px 2px rgba(255,255,255,0.08);
}
.mg-jc__color--red {
    background: radial-gradient(circle at 30% 30%, #a32230, #7a1521 55%, #3d0a10);
    border: 1px solid rgba(255,200,200,0.18);
}
.mg-jc__color--blue {
    background: radial-gradient(circle at 30% 30%, #3a414c, #252a32 55%, #15181d);
    border: 1px solid rgba(255,255,255,0.10);
}

.mg-jc__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-jc__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-jc__clock.is-low {
    color: #ff5252;
    font-weight: 700;
}
.mg-jc__vs {
    font-size: 11px;
    font-weight: 700;
    color: var(--mg-ink-subtle);
    letter-spacing: 0.12em;
}

/* ---------------------------------------------------------------------
 * Board canvas — 7×9 portrait aspect.
 *
 * Canvas internal resolution is 700×900 (set in template). We let
 * CSS scale it to fit, capping at a sensible max so it doesn't take
 * over a wide-screen page.
 * ------------------------------------------------------------------ */
.mg-jc__board-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 12px;
}
.mg-jc__board {
    display: block;
    width: 100%;
    max-width: 440px;
    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-jc__board:focus,
.mg-jc__board:focus-visible {
    outline: none;
}

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

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

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

    .mg-jc__players { padding: 10px 12px; gap: 6px; }
    .mg-jc__vs { font-size: 10px; }
    .mg-jc__player { padding: 4px 6px; font-size: 13px; gap: 6px; }
    .mg-jc__player-name { font-size: 12px; }
    .mg-jc__clock { font-size: 12px; min-width: 38px; }
    .mg-jc__color { width: 14px; height: 14px; }

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

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

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