/* 对局页面样式（自原 style.css 拆分） */
/* 游戏单屏 */

#game {
    min-height: 0;
    padding: 0;
    align-items: stretch;
    background-color: var(--ink-950);
    background-image: url("/static/assets/land.webp");
    background-size: 46rem;
    background-blend-mode: soft-light;
}

.game-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 18.5rem;
    grid-template-rows: 3.75rem minmax(0, 1fr);
    gap: 0.65rem;
    width: min(100%, 96rem);
    height: 100dvh;
    min-height: 0;
    margin: 0 auto;
    padding: max(0.65rem, env(safe-area-inset-top)) max(0.65rem, env(safe-area-inset-right)) max(0.65rem, env(safe-area-inset-bottom)) max(0.65rem, env(safe-area-inset-left));
    background: rgba(6, 23, 25, 0.94);
}

.game-header {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    min-width: 0;
    padding: 0 0.75rem;
    border-bottom: 1px solid var(--line);
}

.game-brand,
.mobile-brand {
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

.brand-mark {
    display: block;
    width: 2.15rem;
    height: 2.15rem;
    flex: none;
    border: 1px solid rgba(243, 236, 220, 0.32);
    border-radius: 50%;
    background-image: url("/static/assets/victory-seal.png");
    background-size: 115%;
    background-position: center;
}

.game-brand div,
.mobile-brand div {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.game-brand strong,
.mobile-brand strong {
    color: var(--paper);
    font-family: "Songti SC", "STSong", serif;
    font-size: 1rem;
}

.game-brand span:not(.brand-mark),
.mobile-brand span {
    color: #78908e;
    font-size: 0.61rem;
}

.turn-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    min-width: 9rem;
    padding: 0.55rem 1rem;
    border: 1px solid var(--turn-color, var(--line));
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--paper);
    font-size: 0.8rem;
    font-weight: 700;
    text-align: center;
    transition: border-color 220ms ease, background-color 220ms ease;
}

.turn-dot {
    width: 0.5rem;
    height: 0.5rem;
    flex: none;
    border-radius: 50%;
    background: var(--turn-color, var(--paper-dim));
    animation: turn-pulse 1.6s ease-in-out infinite;
}

@keyframes turn-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0.25rem color-mix(in srgb, var(--turn-color, var(--paper-dim)) 18%, transparent);
    }
    50% {
        box-shadow: 0 0 0 0.45rem color-mix(in srgb, var(--turn-color, var(--paper-dim)) 32%, transparent);
    }
}

.game-legend {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.85rem;
    color: #879997;
    font-size: 0.7rem;
}

.game-header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
}

.forfeit-btn {
    display: grid;
    width: 2.25rem;
    height: 2.25rem;
    flex: none;
    place-items: center;
    padding: 0;
    border: 1px solid rgba(184, 69, 53, 0.42);
    color: #d97060;
}

.forfeit-btn svg {
    width: 1.1rem;
    height: 1.1rem;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.7;
}

.forfeit-btn:hover {
    background: rgba(184, 69, 53, 0.14);
}

.forfeit-btn:disabled {
    cursor: not-allowed;
    opacity: 0.3;
}

.game-legend > span {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.legend-swatch {
    display: block;
    width: 0.6rem;
    height: 0.6rem;
    border: 1px solid rgba(243, 236, 220, 0.25);
}

.legend-swatch.river { background: #17676b; }
.legend-swatch.trap { background: #cabf9e; }
.legend-swatch.den { background: #8f483c; }

.board-stage {
    position: relative;
    display: grid;
    min-width: 0;
    min-height: 0;
    place-items: center;
    overflow: hidden;
}

/* 限定 #game：布局编辑器复用 .board-container，避免对局尺寸规则泄漏过去 */
#game .board-container {
    position: relative;
    display: flex;
    align-items: stretch;
    width: min(100%, calc((100dvh - 6.5rem) * 8 / 7));
    max-height: 100%;
    aspect-ratio: 8 / 7;
    margin: 0;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: 4px;
    background: #081d1f;
    box-shadow: 0 1.8rem 4rem rgba(0, 6, 7, 0.35), inset 0 0 0 1px rgba(243, 236, 220, 0.12);
}

#game #board-canvas {
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
    height: 100%;
    border-radius: 4px;
    cursor: pointer;
    touch-action: manipulation;
}

.board-loading {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    background: #081d1f;
    color: var(--paper-dim);
    font-size: 0.75rem;
    transition: opacity 220ms ease, visibility 220ms ease;
}

.board-loading.is-hidden {
    visibility: hidden;
    opacity: 0;
}

.board-hint {
    position: absolute;
    bottom: 0.75rem;
    left: 50%;
    z-index: 2;
    padding: 0.38rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: 3px;
    background: rgba(6, 23, 25, 0.86);
    color: #aab7b4;
    font-size: 0.72rem;
    transform: translateX(-50%);
    white-space: nowrap;
    pointer-events: none;
    transition: opacity 600ms ease, visibility 600ms ease;
}

.board-hint.is-hidden {
    opacity: 0;
    visibility: hidden;
}

/* 复盘控制条：停靠在棋盘左侧的垂直栏，画布让出该宽度，不遮挡棋盘 */
.replay-bar {
    position: relative;
    z-index: 4;
    order: -1;                  /* 排到画布左侧 */
    flex: 0 0 3.4rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    padding: 0.6rem 0.28rem;
    border: 0;
    border-right: 1px solid var(--line);
    border-radius: 4px 0 0 4px;
    background: rgba(6, 23, 25, 0.94);
    box-shadow: inset -0.7rem 0 1rem -0.9rem rgba(0, 6, 7, 0.8);
}

.replay-steps {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}

.replay-steps .btn-icon {
    width: 2.2rem;
    height: 2.2rem;
}

.replay-progress {
    margin: 0.2rem 0;
    writing-mode: vertical-rl;  /* 竖排：沿控制栏自上而下阅读 */
    text-orientation: mixed;
    color: var(--gold);
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 0.68rem;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.12em;
    white-space: nowrap;
    max-height: 10rem;
    overflow: hidden;
}

.replay-exit-btn {
    margin-top: 0;
}

.replay-exit-btn span {
    display: none;              /* 竖栏内只保留关闭图标 */
}

.replay-play-btn {
    padding: 0.32rem 0.34rem;
    font-size: 0.72rem;
}

@media (max-width: 800px) {
    .replay-bar {
        flex-basis: 2.9rem;
        gap: 0.4rem;
        padding: 0.45rem 0.2rem;
    }

    .replay-steps .btn-icon {
        width: 1.9rem;
        height: 1.9rem;
    }

    .replay-progress {
        font-size: 0.6rem;
        max-height: 8rem;
    }
}

.game-sidebar {
    display: grid;
    grid-template-rows: auto minmax(7rem, 1fr) auto;
    min-height: 0;
    overflow: hidden;
    border-left: 1px solid var(--line);
    background: rgba(4, 18, 19, 0.34);
}

.seal-board {
    margin-top: 0.65rem;
}

/* 九宫格的三个列头：三方状态（名字 / 剩子 / 持印 / 状态）与同列格位对齐 */
.seal-board-head {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.3rem;
    margin-bottom: 0.3rem;
}

.player-status {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.18rem;
    min-width: 0;
    padding: 0.44rem 0.2rem 0.32rem;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.24);
    transition: background-color 220ms ease, opacity 220ms ease;
}

.player-status.active {
    background: rgba(243, 236, 220, 0.075);
    box-shadow: inset 0 2px 0 var(--player-color, var(--paper));
    transform: none;
    animation: active-row-breath 2.2s ease-in-out infinite;
}

@keyframes active-row-breath {
    0%, 100% { background: rgba(243, 236, 220, 0.075); }
    50% { background: rgba(243, 236, 220, 0.14); }
}

.player-status.you {
    border-color: rgba(243, 236, 220, 0.28);
}

.player-status.you .pname::after {
    content: "你";
    margin-left: 0.3rem;
    padding: 0.04rem 0.22rem;
    border: 1px solid rgba(243, 236, 220, 0.24);
    color: var(--paper-dim);
    font-family: "Avenir Next", "PingFang SC", sans-serif;
    font-size: 0.52rem;
    font-weight: 500;
}

.player-status.eliminated {
    opacity: 0.35;
    text-decoration: none;
}

.ps-head {
    display: inline-flex;
    align-items: center;
    gap: 0.26rem;
    min-width: 0;
}

.player-dot {
    width: 0.6rem;
    height: 0.6rem;
    box-shadow: 0 0 0 0.18rem rgba(255, 255, 255, 0.06);
}

#player-status-0 { --player-color: var(--ember); }
#player-status-1 { --player-color: var(--violet); }
#player-status-2 { --player-color: var(--gold); }

.pname {
    color: var(--paper);
    font-size: 0.76rem;
    font-weight: 700;
    white-space: nowrap;
}

.pcount {
    color: #81918f;
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 0.68rem;
    font-variant-numeric: tabular-nums;
}

/* 列头第二行：棋子数 + 兽印格 */
.player-meta {
    display: flex;
    align-items: center;
    gap: 0.26rem;
    min-width: 0;
}

.seal-pips {
    display: inline-flex;
    align-items: center;
    gap: 0.24rem;
    padding: 0.14rem 0.3rem;
    border: 1px solid rgba(243, 236, 220, 0.1);
    border-radius: 3px;
    background: rgba(0, 0, 0, 0.24);
}

.seal-pips.has-seals {
    border-color: rgba(210, 169, 59, 0.42);
    background: rgba(210, 169, 59, 0.09);
}

.seal-pip {
    width: 0.5rem;
    height: 0.5rem;
    border: 1px solid rgba(243, 236, 220, 0.22);
    border-radius: 1.5px;
    background: rgba(243, 236, 220, 0.07);
}

.seal-pip.is-filled {
    border-color: var(--gold);
    background: linear-gradient(150deg, #eed173 0%, var(--gold) 55%, #a8842a 100%);
    box-shadow: 0 0 0.34rem rgba(210, 169, 59, 0.55);
}

/* 兽印到期：格位转红脉冲，提示本回合须打出 */
.seal-pip.is-expiring {
    border-color: #d86a4a;
    background: linear-gradient(150deg, #f0a184 0%, #c9563a 60%, #9c3c26 100%);
    box-shadow: 0 0 0.34rem rgba(216, 106, 74, 0.65);
    animation: seal-due-pulse 1.1s ease-in-out infinite;
}

@keyframes seal-due-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.28); }
}

/* 得印瞬间：格子依次弹跳 */
.seal-pips.is-gained .seal-pip.is-filled {
    animation: seal-pop 480ms ease both;
}

.seal-pips.is-gained .seal-pip.is-filled:nth-child(2) { animation-delay: 90ms; }
.seal-pips.is-gained .seal-pip.is-filled:nth-child(3) { animation-delay: 180ms; }

@keyframes seal-pop {
    0% { transform: scale(1); }
    45% { transform: scale(1.55); box-shadow: 0 0 0.8rem rgba(210, 169, 59, 0.95); }
    100% { transform: scale(1); }
}

/* 得印瞬间：整行玩家卡随阵营色呼吸 */
.player-status.seal-flash {
    animation: seal-row-flash 1.3s ease;
}

@keyframes seal-row-flash {
    0%, 100% { background: transparent; }
    25% { background: color-mix(in srgb, var(--player-color, #d2a93b) 26%, transparent); }
    65% { background: color-mix(in srgb, var(--player-color, #d2a93b) 12%, transparent); }
}

.pstatus {
    color: var(--player-color, var(--paper));
    font-size: 0.68rem;
    font-weight: 700;
}

.victory-panel {
    padding: 0.8rem 0.9rem 0.85rem;
    border-bottom: 1px solid var(--line);
    background: rgba(243, 236, 220, 0.035);
}

.victory-panel-head,
.victory-scoreline {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.victory-panel-head {
    color: var(--paper);
    font-size: 0.72rem;
    font-weight: 700;
    justify-content: space-between;
}

#victory-center-status {
    color: var(--gold);
    font-size: 0.74rem;
    font-weight: 700;
}

.victory-track {
    display: grid;
    grid-template-columns: repeat(10, minmax(0, 1fr));
    gap: 0.22rem;
    margin-top: 0.65rem;
}

.victory-track-step {
    position: relative;
    height: 0.5rem;
    border: 1px solid rgba(243, 236, 220, 0.18);
    border-radius: 2px;
    background: rgba(243, 236, 220, 0.08);
}

.victory-track-step.is-filled {
    border-color: var(--gold);
    background: var(--gold);
    color: #071b1d;
    box-shadow: 0 0 0.42rem rgba(210, 169, 59, 0.3);
}

.victory-track-step.is-end {
    border-color: rgba(210, 169, 59, 0.62);
}

/* 九宫格聚印：三列对应三方颜色，按行棋顺序在行棋者那列自上而下填充 */
.seal-grid {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.3rem;
}

.seal-grid-cell {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 0.92;      /* 随列宽自适应的近正方格 */
    align-self: start;
    border: 1px solid color-mix(in srgb, var(--player-color) 40%, transparent);
    border-radius: 3px;
    background: rgba(243, 236, 220, 0.05);
    transition: background-color 200ms ease, box-shadow 200ms ease;
}

.seal-grid-cell.is-filled {
    border-color: var(--player-color);
    background: linear-gradient(150deg,
        color-mix(in srgb, var(--player-color) 72%, #fff 28%) 0%,
        var(--player-color) 55%,
        color-mix(in srgb, var(--player-color) 62%, #000 38%) 100%);
    box-shadow: 0 0 0.32rem color-mix(in srgb, var(--player-color) 55%, transparent);
}

.seal-grid-cell.is-latest {
    animation: seal-grid-pop 480ms ease both;
}

@keyframes seal-grid-pop {
    0% { transform: scale(0.55); }
    55% { transform: scale(1.22); box-shadow: 0 0 0.6rem var(--player-color); }
    100% { transform: scale(1); }
}

.victory-track-center.is-sealed {
    border-color: rgba(109, 127, 124, 0.5);
    color: #8fa09c;
}

.victory-track-center {
    grid-column: 1 / -1;
    padding: 0.28rem 0;
    border: 1px solid rgba(210, 169, 59, 0.5);
    color: var(--gold);
    font-size: 0.6rem;
    text-align: center;
}

.victory-track-center.is-error {
    border-color: rgba(184, 69, 53, 0.65);
    color: #e77462;
}

.victory-scoreline {
    margin-top: 0.62rem;
    color: #95a4a0;
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 0.68rem;
    font-variant-numeric: tabular-nums;
}

.victory-score {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.22rem 0.5rem 0.22rem 0.38rem;
    border: 1px solid rgba(243, 236, 220, 0.12);
    border-radius: 3px;
    background: rgba(243, 236, 220, 0.05);
}

.victory-score b {
    color: var(--paper);
    font-size: 0.82rem;
    font-weight: 700;
}

.victory-score-target {
    color: #6d7f7c;
    font-style: normal;
}

.victory-score.is-leading {
    border-color: var(--player-color);
    background: color-mix(in srgb, var(--player-color) 22%, transparent);
    box-shadow: 0 0 0.55rem color-mix(in srgb, var(--player-color) 38%, transparent);
}

.victory-score.is-leading b {
    color: #fff8ea;
}

/* 持有者的兽印已到期：描边转警示色 */
.victory-score.is-expiring {
    border-color: rgba(216, 106, 74, 0.75);
    box-shadow: 0 0 0.55rem rgba(216, 106, 74, 0.38);
}

.victory-score-dot {
    width: 0.48rem;
    height: 0.48rem;
    border-radius: 50%;
    background: var(--player-color);
    box-shadow: 0 0 0 1px rgba(243, 236, 220, 0.24);
}

/* 兽印抉择改用必答弹窗（token-choice-modal），复用 .modal 体系 */

.log-panel {
    display: flex;
    flex-direction: column;
    width: auto;
    min-height: 0;
    max-height: none;
    padding: 0.9rem;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    background: transparent;
    overflow: hidden;
}

.log-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.65rem;
    color: var(--paper);
    font-size: 0.78rem;
    font-weight: 700;
}

.log-title i {
    color: #71908d;
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 0.62rem;
    font-style: normal;
    letter-spacing: 0.12em;
}

.log-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: none;
    color: #81918f;
    font-size: 0.74rem;
    line-height: 1.55;
}

.log-content::-webkit-scrollbar {
    display: none;
}

.log-content .log-entry {
    padding: 0.42rem 0;
    border-bottom: 1px solid rgba(243, 236, 220, 0.07);
    animation: log-slide-in 260ms ease both;
}

@keyframes log-slide-in {
    from {
        opacity: 0;
        transform: translateY(0.4rem);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.log-content .log-entry:last-child {
    color: var(--paper);
    font-weight: 550;
}

.rules-panel {
    padding: 0.85rem 0.9rem 1rem;
}

.rules-title {
    color: #81918f;
    font-size: 0.68rem;
}

.rank-line {
    margin-top: 0.4rem;
    color: var(--paper);
    font-family: "Songti SC", "STSong", serif;
    font-size: 0.84rem;
    white-space: nowrap;
}

.rank-line b {
    color: var(--gold);
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 0.72rem;
}

.rules-panel p {
    margin-top: 0.55rem;
    color: #778987;
    font-size: 0.72rem;
    line-height: 1.55;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    /* 兼容 JS 内联 display:flex/grid 两种打开方式，均保持内容居中 */
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100dvh;
    padding: 1rem;
    background: rgba(2, 12, 13, 0.84);
    backdrop-filter: blur(8px);
}

.modal-content {
    width: min(24rem, 100%);
    padding: 2.2rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--ink-900);
    box-shadow: 0 2rem 5rem rgba(0, 0, 0, 0.44), inset 0 1px rgba(255, 255, 255, 0.05);
    text-align: center;
    animation: modal-in 340ms cubic-bezier(0.2, 0.9, 0.3, 1.15) both;
}

@keyframes modal-in {
    from {
        opacity: 0;
        transform: translateY(1rem) scale(0.94);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.modal-kicker {
    color: var(--gold);
}

.modal-content h2 {
    margin: 0.65rem 0 0.5rem;
    color: var(--paper);
    font-family: "Songti SC", "STSong", serif;
    font-size: 2rem;
}

.modal-content p {
    margin-bottom: 1.3rem;
    color: var(--paper-dim);
    font-size: 0.85rem;
}

#rematch-btn {
    padding: 0.65rem 1.25rem;
    border-radius: 4px;
    background: var(--ember);
    color: #fff8ea;
    font-size: 0.82rem;
    transition: background-color 200ms ease, transform 180ms ease, box-shadow 180ms ease;
}

#rematch-btn:hover {
    background: #cf5845;
}

#rematch-btn:disabled {
    background: #48605e;
}

#rematch-status {
    color: #839492;
    font-size: 0.7rem;
}

