/* orbit_match.css
----------------------------------------
Orbit 对局界面（frontend/orbit_game.html）的样式。

叠加在 orbit.css 之上：颜色变量、.piece-slot / .arrived-slot（未落子
棋子）、.lobby-sidebar（左侧站点栏）、.banner（终局横幅）都沿用那边的，
这里只管这个页面自己的布局。

没有覆盖 orbit_game.css——那个文件现在只给复盘页 orbit_replay.html
用（它依赖那边的 #match-shell / .rack-corner 这些类），改它会把复盘页
一起改坏，所以对局页单独用这一份新文件。

PC：左侧站点栏 | 左栏（对手 / 棋谱 / 按钮 / 自己）| 棋盘 | 右栏（信息 / 聊天）
手机（≤ 760px）：顶栏 → 对手 → 对手棋子 → 棋盘 → 自己棋子 → 自己 → 按钮
                 → 对局信息 → 聊天；不显示棋谱窗口。
---------------------------------------- */

:root {
    --om-panel: #d9d4ce;
    --om-panel-dark: #cdc7c0;
    --om-clock-bg: #5c4330;
    --om-clock-idle: #8d7b6c;
    --om-green: #2c9e45;
    --om-red: #c0392b;
    --om-serif: Georgia, "Times New Roman", "Songti SC", "SimSun", serif;
}

body.om-body { margin: 0; }

#om-root {
    display: grid;
    grid-template-columns: 130px minmax(0, 1fr);
    min-height: 100vh;
}

/* 连接状态提示（orbit_game.js 的连接层）：断线时屏幕上方一条小提示，恢复后消失 */
.om-conn {
    position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 200;
    max-width: 92vw; padding: 7px 14px; border-radius: 0; font-size: 13px; line-height: 1.4;
    background: #5c4330; color: #fff;
}
.om-conn[hidden] { display: none; }
.om-conn[data-kind="connLost"] { background: #b8651b; }
.om-conn[data-kind="takenOver"], .om-conn[data-kind="connClosed"] { background: #c0392b; }

#om-sidebar { min-height: 100vh; }

/* 侧栏固定在屏幕上（2026-09-28）：不随页面滚动，玩家名钉在屏幕左下角。
   （手机版 ≤760px 侧栏是顶栏，不适用，见下面 @media） */
@media (min-width: 761px) {
    #om-sidebar {
        position: sticky;
        top: 0;
        align-self: start;
        height: 100vh;
        height: 100dvh;
        min-height: 0;
        overflow-y: auto;
    }
}
#om-sidebar .om-brand { text-decoration: none; }
#om-sidebar .site-switch-btn { text-decoration: none; }
#om-sidebar .lobby-account-btn { text-decoration: none; }

/* ---------- 对局主体：PC 网格 ---------- */

#om-match {
    display: grid;
    grid-template-columns: 200px minmax(0, 1fr) 220px;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    grid-template-areas:
        "opp      board info"
        "moves    board chat"
        "controls board chat"
        "self     board chat";
    column-gap: 18px;
    row-gap: 0;
    height: 100vh;
    padding: 16px 16px 16px 4px;
    box-sizing: border-box;
}

#om-opp      { grid-area: opp; }
#om-moves    { grid-area: moves; }
#om-controls { grid-area: controls; }
#om-self     { grid-area: self; }
#om-board-area { grid-area: board; }
#om-info     { grid-area: info; }
#om-chat     { grid-area: chat; margin-top: 10px; }

.om-card {
    background: var(--om-panel);
    padding: 8px 10px;
}

/* ---------- 棋手卡片 + 时钟 ---------- */

.om-player-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.om-name {
    font-family: var(--om-serif);
    font-size: 18px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.om-rating { font-size: 12px; color: #8a8077; }

.om-clock-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.om-clock {
    font-family: var(--om-serif);
    font-weight: 700;
    font-size: 22px;
    color: #fff;
    background: var(--om-clock-idle);
    padding: 1px 8px;
    min-width: 64px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.om-clock.is-active { background: var(--om-clock-bg); }
.om-clock.is-low    { background: var(--om-red); }

.om-inc { font-size: 14px; color: #6f655c; }

/* ---------- 棋谱面板 ---------- */

.om-moves {
    display: flex;
    flex-direction: column;
    margin-top: 6px;
    min-height: 0;
    background: var(--om-panel-dark);
}

.om-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
}

.om-nav-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #7c7066;
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 0;
}

.om-nav-btn:hover:not(:disabled) { background: rgba(0,0,0,.06); color: var(--text-dark); }
.om-nav-btn:disabled { opacity: .35; cursor: default; }

.om-ply { font-size: 11px; color: #8a8077; font-variant-numeric: tabular-nums; }

.om-move-list { flex: 1; min-height: 60px; overflow-y: auto; }

/* ---------- 通知 + 按钮 ---------- */

.om-controls {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: var(--om-panel-dark);
    border-top: 1px solid rgba(0,0,0,.08);
    padding-top: 6px;
    padding-bottom: 0;
}

#om-offers   { order: 1; display: flex; flex-direction: column; gap: 3px; }
#om-yourturn { order: 2; }
#om-flash    { order: 3; }
.om-actions  { order: 4; }
#om-firstmove { order: 5; }

.om-notice, .om-offer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    font-size: 12px;
    line-height: 1.3;
}

.om-notice[hidden], .om-flash[hidden], .om-firstmove[hidden] { display: none; }

.om-offer-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.om-offer-btns { display: flex; gap: 4px; flex-shrink: 0; }

.om-mini {
    border: none;
    border-radius: 0;
    color: #fff;
    font-size: 11px;
    padding: 2px 8px;
    cursor: pointer;
    line-height: 1.4;
}

.om-agree, .om-go { background: var(--om-green); }
.om-deny { background: var(--om-red); }
.om-go { font-size: 13px; padding: 0 10px; }

.om-flash { font-size: 12px; color: #a0522d; }

.om-actions {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 2px 0 4px;
}

.om-act-wrap { position: relative; }

.om-act {
    width: 42px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: 0;
    color: #4a3a2e;
    cursor: pointer;
}

.om-act:hover { background: rgba(0,0,0,.05); }
.om-eq { font-size: 26px; font-weight: 700; line-height: 1; }

/* 单击一次 = 高亮 + 右侧出现 ×；再点一次图标才生效 */
.om-act-wrap.armed .om-act { background: rgba(107,74,52,.2); }
.om-act-wrap.armed #om-act-resign { color: var(--om-red); background: rgba(192,57,43,.14); }

/* 悔棋在计分对局里不可用：透明度 40% */
.om-act.is-off { opacity: .4; cursor: not-allowed; }
.om-act.is-off:hover { background: none; }

.om-cancel {
    display: none;
    position: absolute;
    right: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    border-radius: 0;
    border: none;
    background: #fff;
    color: var(--om-red);
    font-size: 14px;
    line-height: 18px;
    padding: 0;
    cursor: pointer;
    z-index: 2;
}

.om-act-wrap.armed .om-cancel { display: block; }

/* 首步倒计时条 */
.om-firstmove {
    margin: 0 -10px;
    padding: 3px 10px;
    font-family: var(--om-serif);
    font-weight: 700;
    font-size: 13px;
    color: #fff;
    background: var(--om-green);
}

.om-firstmove.is-waiting { background: #9b9189; font-weight: 400; }

/* ---------- 棋盘区 ---------- */

#om-board-area {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-rows: minmax(0, 1fr) auto;
    min-height: 0;
    min-width: 0;
}

.om-board-box {
    grid-column: 2;
    grid-row: 1;
    width: min(100%, calc(100vh - 70px));
    aspect-ratio: 1 / 1;
    justify-self: center;
    align-self: center;
}

#board-svg { width: 100%; height: 100%; display: block; }

/* 黑方视角：整个棋盘转 180°，棋子图片再各自转回来（不然是倒着的）。
   用 CSS 而不是改 orbit_board.js：走子动画是改图片的 x/y 属性，
   transform-box: fill-box 让每张图绕自己的中心转，跟动画互不干扰。 */
#board-svg.om-flipped { transform: rotate(180deg); }
#board-svg.om-flipped .piece-icon {
    transform-box: fill-box;
    transform-origin: center;
    transform: rotate(180deg);
}

#om-hint-bar {
    grid-column: 1 / -1;
    grid-row: 2;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    min-height: 26px;
    font-size: 13px;
}

/* 未落子棋子：PC 上是竖排，对手贴棋盘左上、自己贴右下 */
.om-rack {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 4px;
    grid-row: 1;
    z-index: 3;
}

.om-rack-opp  { grid-column: 1; align-self: start; }
.om-rack-self { grid-column: 3; align-self: end; }

.om-rack .piece-slot { width: 62px; height: 62px; }
.om-rack .piece-slot img { width: 52px; height: 52px; }

/* 抵达区（两个虚线圈）：绝对定位，不撑宽这一列，
   伸进棋盘方框的角落——圆形棋盘的四个角本来就是空的 */
.om-rack .arrived-row { position: absolute; margin: 0; }
.om-rack-opp  .arrived-row { left: 100%; top: 14px; margin-left: 8px; }
.om-rack-self .arrived-row { right: 100%; bottom: 14px; margin-right: 8px; }

/* 棋盘上一步的起点/终点高亮在 orbit_game.js 里画（SVG 图层），
   这里只放往回翻看时棋子架不可点的视觉提示 */
.om-viewing .om-rack { opacity: .75; }

/* ---------- 右栏：对局信息 + 聊天 ---------- */

.om-info { background: none; padding: 4px 0 0; font-size: 13px; }
.om-info-tc { margin-bottom: 8px; color: #5d534b; }

.om-info-row {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 5px;
}

.om-dot {
    width: 13px;
    height: 13px;
    border-radius: 50%;
    border: 1.5px solid #6f655c;
    flex-shrink: 0;
}

.om-dot-white { background: #f4f2ee; }
.om-dot-black { background: #6f655c; }

.om-chat {
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 0;
    border: 1px solid rgba(0,0,0,.06);
}

.om-chat-head {
    font-family: var(--om-serif);
    font-size: 17px;
    padding: 4px 8px;
    border-bottom: 1px solid rgba(255,255,255,.6);
}

.om-chat-log {
    flex: 1;
    min-height: 120px;
    overflow-y: auto;
    padding: 6px 8px;
    font-size: 12px;
    line-height: 1.5;
    background: var(--om-panel-dark);
}

.om-chat-line { margin-bottom: 3px; overflow-wrap: anywhere; }
.om-chat-who { font-weight: 700; color: var(--btn-brown); }
.om-chat-sys { color: #8a8077; font-style: italic; }

.om-chat-input {
    border: none;
    border-top: 1px solid rgba(0,0,0,.08);
    padding: 7px 8px;
    font-size: 13px;
    background: #ebe7e2;
    color: var(--text-dark);
    outline: none;
}

.om-chat-input:disabled { color: #a39a8f; }

/* ---------- 观战者 ----------
   不显示悔棋/提和/认输、首步倒计时、聊天输入框；
   也不显示任何"你是观众，不能操作"之类的提示。 */

body.om-spectator #om-controls,
body.om-spectator .om-chat-input { display: none; }

/* ---------- 错误提示 ---------- */

#om-error {
    grid-column: 2;
    max-width: 480px;
    margin: 80px auto;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
}

#om-error[hidden] { display: none; }

/* ================= 手机 ================= */

@media (max-width: 760px) {

    #om-root { display: block; }

    .om-pc-only { display: none !important; }

    /* 左侧栏变成顶栏：Orbit ……… 账号，下面一行导航 */
    #om-sidebar {
        width: auto;
        min-height: 0;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        gap: 8px 14px;
        padding: 12px 14px 6px;
    }

    #om-sidebar .om-brand { order: 1; }
    #om-sidebar .lobby-account-btn { order: 2; width: auto; margin: 0; }
    #om-sidebar .lobby-nav {
        order: 3;
        width: 100%;
        flex-direction: row;
        gap: 16px;
    }

    #om-match {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: none;
        grid-template-areas:
            "opp"
            "board"
            "self"
            "controls"
            "info"
            "chat";
        height: auto;
        padding: 0 8px 20px;
    }

    #om-moves { display: none; }      /* 手机版不做棋谱窗口 */

    .om-player { background: none; padding: 6px 4px; }
    .om-player-head { justify-content: flex-start; }
    .om-name { font-size: 22px; }
    .om-clock { font-size: 26px; }

    #om-board-area {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto auto auto auto;
    }

    .om-board-box { grid-column: 1; grid-row: 2; width: 100%; }

    /* 未落子棋子改成横排：对手在棋盘上方，自己在下方 */
    .om-rack {
        flex-direction: row;
        justify-content: center;
        align-items: center;
        align-self: center;
        grid-column: 1;
    }

    .om-rack-opp  { grid-row: 1; }
    .om-rack-self { grid-row: 3; }
    #om-hint-bar  { grid-row: 4; }

    .om-rack .piece-slot[data-piece="pawn"]    { order: 1; }
    .om-rack .piece-slot[data-piece="hussar"]  { order: 2; }
    .om-rack .piece-slot[data-piece="phoenix"] { order: 3; }
    .om-rack .piece-slot[data-piece="chariot"] { order: 4; }
    .om-rack .arrived-row { order: 5; position: static; margin: 0 0 0 8px; }

    .om-rack .piece-slot { width: 52px; height: 52px; }
    .om-rack .piece-slot img { width: 44px; height: 44px; }

    /* 手机上：首步倒计时条紧跟在自己的时钟下面，按钮在它下面 */
    .om-controls { background: none; border: none; padding: 0 4px; }
    #om-firstmove { order: 0; margin: 0; }
    .om-actions { justify-content: flex-start; gap: 22px; padding-left: 4px; }

    #om-info { margin-top: 14px; }
    #om-chat { margin-top: 8px; }
    .om-chat-log { min-height: 160px; max-height: 260px; }
}

/* ---------- 棋谱窗口（orbit_notation.js 生成的记录） ---------- */

.om-mv-row {
    display: grid;
    grid-template-columns: 26px 1fr 1fr;
    gap: 2px;
    font-size: 12px;
    line-height: 1.45;
    padding: 1px 0;
}

.om-mv-num { color: #8a8077; text-align: right; padding-right: 4px; }

.om-mv {
    font-family: Consolas, "SFMono-Regular", Menlo, monospace;
    padding: 0 4px;
    border-radius: 0;
    cursor: pointer;
    overflow-wrap: anywhere;
}

.om-mv:hover { background: rgba(0, 0, 0, 0.07); }
.om-mv.is-current { background: var(--btn-brown); color: #fff; }
.om-mv-empty { cursor: default; }
.om-mv-empty:hover { background: none; }
