/* ============================================================
   水墨宣纸视觉层 · 仅改变表现，不参与规则计算
   ============================================================ */

body {
    min-width: 1024px;
    font-size: 12px;
    background: var(--ink);
}

.backdrop {
    background:
        radial-gradient(ellipse 70% 52% at 50% 10%, rgba(79, 150, 137, 0.13), transparent 62%),
        radial-gradient(ellipse 50% 40% at 90% 90%, rgba(102, 80, 111, 0.11), transparent 70%),
        repeating-linear-gradient(0deg, rgba(232, 223, 201, 0.012) 0 1px, transparent 1px 5px),
        linear-gradient(180deg, #17211c 0%, var(--ink) 62%, #0b100d 100%);
}

.backdrop__grain { opacity: 0.055; }

.topbar,
.page-game .game-top,
.page-game .game-bottom {
    border-color: rgba(198, 161, 91, 0.28);
    background: rgba(16, 23, 19, 0.94);
}

.btn { border-radius: 2px; }

.btn--primary {
    color: #15140f;
    background: linear-gradient(180deg, #ead39d, var(--gilt) 62%, #8e713b);
}

.btn--ghost {
    border-color: rgba(198, 161, 91, 0.42);
    background: rgba(16, 23, 19, 0.64);
}

/* 卷轴弹窗：内容承载用宣纸，外围仍保持深墨环境。 */
.modal,
.game-overlay__box {
    position: relative;
    overflow: visible;
    border: 1px solid #967743;
    border-radius: 2px;
    color: #28251d;
    background:
        repeating-linear-gradient(0deg, rgba(70, 55, 34, 0.025) 0 1px, transparent 1px 4px),
        linear-gradient(90deg, #c7b88f, var(--paper) 4% 96%, #c7b88f);
    box-shadow: 0 28px 78px rgba(0, 0, 0, 0.68), inset 0 0 38px rgba(91, 67, 34, 0.14);
}

.modal::before,
.modal::after,
.game-overlay__box::before,
.game-overlay__box::after {
    content: "";
    position: absolute;
    z-index: 2;
    left: -10px;
    right: -10px;
    height: 10px;
    border: 1px solid #8d6e3d;
    border-radius: 8px;
    background: linear-gradient(180deg, #dbc99e, #927344);
    box-shadow: 0 3px 7px rgba(0, 0, 0, 0.28);
}

.modal::before,
.game-overlay__box::before { top: -7px; }
.modal::after,
.game-overlay__box::after { bottom: -7px; }

.modal__head,
.modal__foot { border-color: rgba(63, 50, 31, 0.18); }
.modal__title,
.game-overlay__title { color: #211e17; }
.modal__close,
.confirm__text,
.rules dd,
.game-overlay__text { color: #544c3a; }
.game-overlay__eyebrow { color: #80642f; }

/* 选宗：宗主卡以完整 3:4 卡图为主体。 */
.leaders { gap: 12px; }

.faction.is-active .faction__leaders {
    max-height: min(62vh, 520px);
    overflow-y: auto;
}

.leader {
    display: grid;
    grid-template-rows: auto 1fr;
    align-items: start;
    gap: 9px;
    padding: 8px;
    justify-items: center;
    border-radius: 2px;
    background: rgba(16, 23, 19, 0.62);
}

.leader__portrait {
    width: min(100%, 180px);
    height: auto;
    aspect-ratio: 3 / 4;
    object-fit: contain;
    border-radius: 2px;
    border-color: rgba(198, 161, 91, 0.42);
    background: #0d1410;
}

.leader__body { width: 100%; padding: 2px 3px 4px; }
.leader__name { font-family: var(--font-display); font-size: 15px; }
.leader__skill { min-height: 3.2em; font-size: 12px; }
.leader.is-selected { border-color: var(--jade); box-shadow: 0 0 0 1px rgba(79, 150, 137, 0.42); }

/* 构筑筛选和卡组数据。 */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 42px;
    padding: 6px 12px;
    border-bottom: 1px solid rgba(198, 161, 91, 0.16);
    background: rgba(8, 14, 11, 0.28);
}

.filter-bar label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-dim);
    font-size: 12px;
}

.filter-bar select {
    min-width: 88px;
    height: 28px;
    padding: 0 24px 0 8px;
    border: 1px solid rgba(198, 161, 91, 0.3);
    border-radius: 2px;
    color: var(--text);
    background: var(--ink-soft);
}

.count__value,
.ccard__power,
.gcard__power,
.lane__total,
.score-strip__side b,
.score-strip__diff { font-family: var(--number-font); font-variant-numeric: tabular-nums; }

/* 卡面只显示原画；所有信息都落在允许的框、印章和角标层。 */
.ccard,
.gcard {
    isolation: isolate;
    overflow: visible;
    padding: 0;
    border: 1px solid rgba(198, 161, 91, 0.76);
    border-radius: 2px;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    box-shadow: inset 0 0 0 1px rgba(16, 23, 19, 0.62), 0 4px 12px rgba(0, 0, 0, 0.32);
    filter: none;
}

.ccard::before,
.gcard::before {
    content: "";
    position: absolute;
    z-index: 4;
    inset: -3px;
    pointer-events: none;
    background:
        linear-gradient(var(--gilt), var(--gilt)) left top / 12px 1px no-repeat,
        linear-gradient(var(--gilt), var(--gilt)) left top / 1px 12px no-repeat,
        linear-gradient(var(--gilt), var(--gilt)) right top / 12px 1px no-repeat,
        linear-gradient(var(--gilt), var(--gilt)) right top / 1px 12px no-repeat,
        linear-gradient(var(--gilt), var(--gilt)) left bottom / 12px 1px no-repeat,
        linear-gradient(var(--gilt), var(--gilt)) left bottom / 1px 12px no-repeat,
        linear-gradient(var(--gilt), var(--gilt)) right bottom / 12px 1px no-repeat,
        linear-gradient(var(--gilt), var(--gilt)) right bottom / 1px 12px no-repeat;
    opacity: 0.72;
}

.ccard--north,
.gcard--north { background-color: #1a2924; }
.ccard--monster,
.gcard--monster { background-color: #241c28; }
.ccard--neutral,
.gcard--neutral { background-color: #282116; }

.ccard__name,
.ccard__meta,
.gcard__name { display: none !important; }

.ccard__power,
.gcard__power {
    display: grid;
    place-items: center;
    top: 4px;
    left: 4px;
    z-index: 6;
    min-width: 27px;
    width: 27px;
    height: 27px;
    padding: 0;
    border: 1px solid rgba(232, 223, 201, 0.72);
    border-radius: 50%;
    color: #f4f0e6;
    background: rgba(16, 23, 19, 0.9);
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    text-shadow: 0 1px 2px #000;
    box-shadow: 0 0 0 2px rgba(16, 23, 19, 0.72);
}

.gcard--hand .gcard__power,
.deck .ccard__power { width: 32px; height: 32px; font-size: 17px; }
.gcard__power.is-buffed { color: #d8d28a; border-color: var(--jade); }
.gcard__power.is-weakened { color: #ffb0a5; border-color: var(--cinnabar); }

.ccard__ability,
.gcard__ability {
    position: absolute;
    z-index: 6;
    right: 4px;
    bottom: 4px;
    display: grid;
    place-items: center;
    width: 20px;
    height: 20px;
    border: 1px solid currentColor;
    border-radius: 50%;
    color: var(--paper);
    background: rgba(16, 23, 19, 0.86);
    pointer-events: none;
}

.ccard__ability svg,
.gcard__ability svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.ccard__badge { z-index: 7; top: 4px; right: 4px; }
.ccard__hero,
.gcard__hero {
    z-index: 6;
    top: auto;
    right: auto;
    left: 4px;
    bottom: 4px;
    min-width: 25px;
    padding: 2px 4px;
    border: 1px solid var(--gold-bright);
    border-radius: 50%;
    color: var(--gold-bright);
    background: rgba(16, 23, 19, 0.84);
    font-size: 9px;
    text-align: center;
    box-shadow: 0 0 0 2px rgba(198, 161, 91, 0.3);
}

.ccard--hero,
.gcard--hero {
    border-color: var(--gold-bright);
    box-shadow: 0 0 0 2px rgba(198, 161, 91, 0.3), 0 5px 16px rgba(0, 0, 0, 0.36);
    animation: hero-gilt 4.8s ease-in-out infinite;
}

.ccard--hero::after,
.gcard--hero::after {
    display: none;
}

@keyframes hero-gilt {
    0%, 65%, 100% { box-shadow: 0 0 0 2px rgba(198, 161, 91, 0.28), 0 5px 16px rgba(0, 0, 0, 0.36); }
    82% { box-shadow: 0 0 0 2px rgba(234, 211, 157, 0.72), 0 0 18px rgba(198, 161, 91, 0.46); }
}

.ccard.is-full { opacity: 1; border-color: rgba(160, 158, 146, 0.34); }
.ccard.is-full::before,
.ccard.is-full .ccard__ability { opacity: 0.34; }
.ccard.is-full:hover { opacity: 1; }

.gcard--hand.is-playable::before { opacity: 1; }
.gcard--hand.is-playable { border-color: var(--jade); }
.gcard--hand.is-unplayable { border-color: rgba(160, 158, 146, 0.34); }
.gcard--hand.is-unplayable::before,
.gcard--hand.is-unplayable .gcard__ability,
.gcard--hand.is-unplayable .gcard__power { opacity: 0.38; }

.gcard--hand.is-selected {
    border-color: #d87567;
    box-shadow: 0 0 0 2px rgba(161, 63, 53, 0.72), 0 0 22px rgba(161, 63, 53, 0.58);
}

/* 战场：横向阵位、墨池总分、天象粒子。 */
.page-game .board {
    gap: 3px;
    padding: 5px 18px 5px 114px;
    background:
        linear-gradient(90deg, rgba(232, 223, 201, 0.018) 1px, transparent 1px),
        linear-gradient(rgba(232, 223, 201, 0.014) 1px, transparent 1px);
    background-size: 64px 64px;
}

.half { gap: 3px; }

.lane {
    isolation: isolate;
    gap: 8px;
    min-height: 52px;
    border: 1px solid rgba(232, 223, 201, 0.07);
    border-radius: 2px;
    background: rgba(20, 31, 26, 0.7);
}

.lane > * { position: relative; z-index: 2; }

.lane__label {
    display: flex;
    align-items: center;
    gap: 5px;
    width: 62px;
    writing-mode: horizontal-tb;
    letter-spacing: 0.06em;
    font-size: 12px;
    color: #c2c0b5;
}

.lane__label::before {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border: 1px solid currentColor;
    border-radius: 50%;
    color: var(--gold);
    font-family: var(--font-display);
    font-size: 13px;
}

.lane--melee .lane__label::before { content: "剑"; }
.lane--ranged .lane__label::before { content: "弓"; }
.lane--siege .lane__label::before { content: "阵"; }

.lane__total {
    position: relative;
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border: 1px solid rgba(198, 161, 91, 0.5);
    border-radius: 50%;
    color: #ead39d;
    background: radial-gradient(circle, rgba(25, 35, 30, 0.96) 48%, rgba(6, 10, 8, 0.9) 100%);
    font-size: 18px;
    text-align: center;
    box-shadow: inset 0 0 9px rgba(0, 0, 0, 0.65);
}

.lane__total::before {
    content: "";
    position: absolute;
    inset: -3px;
    border: 1px solid rgba(198, 161, 91, 0.16);
    border-radius: 44% 56% 52% 48%;
    transform: rotate(-8deg);
}

.score-strip__side.is-updated b { animation: score-flash 0.5s ease; }
@keyframes score-flash { 45% { color: #fff4c9; text-shadow: 0 0 15px var(--gilt); } }

.lane.is-weathered {
    border-color: rgba(126, 183, 205, 0.52);
    box-shadow: inset 3px 0 0 #7eb7cd, inset 0 0 24px rgba(96, 154, 180, 0.13);
}

.lane.is-weathered::before {
    content: "";
    position: absolute;
    z-index: 1;
    inset: 0;
    pointer-events: none;
    opacity: 0.42;
}

.lane[data-weather="melee"]::before {
    background:
        radial-gradient(circle, rgba(235, 249, 255, 0.9) 0 1px, transparent 1.5px) 0 0 / 24px 20px,
        linear-gradient(180deg, rgba(125, 187, 213, 0.16), transparent);
    animation: weather-drift 5s linear infinite;
}

.lane[data-weather="ranged"]::before {
    background: linear-gradient(95deg, transparent, rgba(205, 220, 225, 0.2), transparent 70%);
    animation: weather-fog 4s ease-in-out infinite alternate;
}

.lane[data-weather="siege"]::before {
    background: repeating-linear-gradient(112deg, transparent 0 15px, rgba(146, 202, 224, 0.25) 16px, transparent 17px 30px);
    animation: weather-drift 3s linear infinite;
}

.lane.is-weathered .lane__total::after {
    position: absolute;
    right: -5px;
    top: -8px;
    display: grid;
    place-items: center;
    width: 18px;
    height: 18px;
    border: 1px solid rgba(148, 205, 228, 0.58);
    border-radius: 50%;
    color: #c9ecfa;
    background: #17272c;
    font-size: 11px;
}

.lane[data-weather="melee"] .lane__total::after { content: "霜"; }
.lane[data-weather="ranged"] .lane__total::after { content: "雾"; }
.lane[data-weather="siege"] .lane__total::after { content: "雨"; }

@keyframes weather-drift { to { background-position: 80px 60px, 0 0; } }
@keyframes weather-fog { to { background-position: 120px 0; } }

/* 中轴比分。 */
.score-strip {
    gap: 22px;
    height: 48px;
    border-top: 1px solid rgba(198, 161, 91, 0.16);
    border-bottom: 1px solid rgba(198, 161, 91, 0.16);
    background: linear-gradient(90deg, rgba(79, 150, 137, 0.05), rgba(9, 15, 12, 0.86), rgba(102, 80, 111, 0.05));
}

.score-strip__side {
    min-width: 130px;
    justify-content: center;
    padding: 5px 14px;
    border: 1px solid transparent;
    font-size: 12px;
    transition: border-color 0.25s ease, background 0.25s ease;
}

.score-strip__side b { font-size: 28px; }
.score-strip__center { display: grid; gap: 2px; min-width: 92px; text-align: center; }
.score-strip__vs { font-family: var(--font-display); font-size: 12px; letter-spacing: 0.12em; }
.score-strip__diff { font-size: 10px; color: var(--text-dim); }
.score-strip.is-mine-leading .score-strip__side--mine,
.score-strip.is-opp-leading .score-strip__side--opp {
    border-color: rgba(198, 161, 91, 0.5);
    background: rgba(198, 161, 91, 0.1);
    box-shadow: inset 0 0 16px rgba(198, 161, 91, 0.08);
}

/* 宗主卡、灵珠和回合状态。 */
.leader-face {
    width: 66px;
    height: 88px;
    aspect-ratio: 3 / 4;
    object-fit: contain;
    border-radius: 2px;
    background: #0b110e;
}

.leader-rail.is-ready .leader-face,
.leader-chip--btn.is-ready { animation: leader-ready 2s ease-in-out infinite; }

.leader-rail.is-used::after {
    content: "已用";
    position: absolute;
    left: 50%;
    top: 50%;
    z-index: 4;
    padding: 2px 5px;
    border: 2px solid var(--cinnabar);
    color: #d76e60;
    background: rgba(16, 23, 19, 0.74);
    font-family: var(--font-display);
    font-size: 13px;
    transform: translate(-50%, -50%) rotate(-9deg);
}

@keyframes leader-ready {
    50% { border-color: var(--gold-bright); box-shadow: 0 0 18px rgba(198, 161, 91, 0.46); }
}

.lives { gap: 7px; }
.life-orb {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 17px;
    height: 17px;
    border: 1px solid rgba(234, 211, 157, 0.76);
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #fff5cd 0 8%, #c6a15b 24%, #5a4324 72%);
    box-shadow: 0 0 9px rgba(198, 161, 91, 0.42), inset -2px -2px 4px rgba(0,0,0,0.45);
}

.life-orb i {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: rgba(255,255,255,0.56);
}

.life-orb.is-lost {
    opacity: 0.24;
    background: transparent;
    box-shadow: none;
}

.fx-heart-burst { border-color: var(--gilt); }
.fx-life-banner::first-letter { color: var(--gilt); }

.hand-wrap {
    height: clamp(108px, 16vh, 178px);
    border-bottom: 2px solid transparent;
    transition: border-color 0.22s ease, box-shadow 0.22s ease;
}

.hand-wrap.is-current {
    border-bottom-color: var(--jade);
    box-shadow: inset 0 -12px 24px rgba(79, 150, 137, 0.1);
}

.page-game .hand .gcard { height: clamp(94px, 14vh, 156px); }

.turn-banner {
    position: fixed;
    z-index: 70;
    left: 50%;
    bottom: clamp(116px, 18vh, 190px);
    padding: 7px 28px;
    border-top: 1px solid var(--jade);
    border-bottom: 1px solid var(--jade);
    color: #d5eee8;
    background: rgba(14, 35, 29, 0.94);
    font-family: var(--font-display);
    font-size: 15px;
    letter-spacing: 0.24em;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 10px);
}

.turn-banner.is-visible { animation: turn-notice 0.8s ease both; }
@keyframes turn-notice {
    0% { opacity: 0; transform: translate(-50%, 10px); }
    20%, 72% { opacity: 1; transform: translate(-50%, 0); }
    100% { opacity: 0; transform: translate(-50%, -5px); }
}

.side-info--opp.is-thinking::after {
    content: "●  ●  ●";
    margin-left: 8px;
    color: var(--mystic-purple);
    letter-spacing: 0.16em;
    animation: thinking-dots 1.1s ease-in-out infinite;
}
@keyframes thinking-dots { 50% { color: var(--gold-bright); opacity: 0.48; } }

/* 三局比分。 */
.round-scores {
    display: grid;
    gap: 6px;
    width: min(320px, 100%);
    margin: 16px auto 4px;
    list-style: none;
}

.round-scores:empty { display: none; }
.round-scores li {
    display: flex;
    justify-content: space-between;
    padding: 7px 12px;
    border-top: 1px solid rgba(77, 62, 37, 0.2);
    color: #5b513d;
}
.round-scores li.is-win b { color: #356a5e; }
.round-scores li.is-loss b { color: #983c33; }
.round-scores b { font-family: var(--number-font); color: #59441f; }

@media (max-height: 820px) {
    .page-game .game-top,
    .page-game .game-bottom { height: 38px; }
    .page-game .weather-bar { height: 26px; }
    .page-game .board { padding-top: 3px; padding-bottom: 3px; }
    .score-strip { height: 38px; }
    .score-strip__side b { font-size: 23px; }
    .leader-face { width: 54px; height: 72px; }
    .leader-rail--p2 { top: calc(25% - 42px); }
    .leader-rail--p1 { bottom: calc(25% - 42px); }
    .hand-wrap { height: clamp(96px, 15vh, 124px); padding-top: 4px; }
    .page-game .hand .gcard { height: clamp(86px, 13.5vh, 112px); }
    .lane__total { width: 38px; height: 38px; font-size: 16px; }
    .mulligan-bar { bottom: 116px; }
}

@media (min-height: 1050px) {
    .page-game .board { padding-top: 10px; padding-bottom: 10px; }
    .lane { padding-block: 6px; }
    .leader-face { width: 78px; height: 104px; }
}

@media (prefers-reduced-motion: reduce) {
    .ccard--hero::after,
    .gcard--hero::after,
    .ccard--hero,
    .gcard--hero,
    .leader-rail.is-ready .leader-face,
    .leader-chip--btn.is-ready,
    .lane.is-weathered::before,
    .side-info--opp.is-thinking::after { animation: none; }
}
