/* ============================================================
   手机适配：全部页面按横屏使用
   竖屏时显示旋转提示，横屏给紧凑布局。
   桌面（宽 >= 1024 且横屏）完全不受影响。
   ============================================================ */

/* ---------- 竖屏提示 ---------- */

.rotate-hint {
    display: none;
}

@media (max-width: 1023px) and (orientation: portrait) {
    .rotate-hint {
        position: fixed;
        inset: 0;
        z-index: 500;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 18px;
        padding: 32px;
        background: rgba(8, 12, 10, 0.97);
        color: var(--gold);
        text-align: center;
    }

    .rotate-hint__icon {
        font-size: 46px;
        line-height: 1;
        animation: rotate-tip 2.2s ease-in-out infinite;
    }

    .rotate-hint__title {
        font-family: var(--font-display);
        font-size: 19px;
        letter-spacing: 0.16em;
    }

    .rotate-hint__text {
        font-size: 12.5px;
        line-height: 1.9;
        color: var(--text-dim);
        max-width: 300px;
    }

    .rotate-hint__continue {
        margin-top: 6px;
        padding: 7px 18px;
        border: 1px solid rgba(198, 161, 91, 0.42);
        border-radius: 3px;
        background: transparent;
        color: var(--gold-dim);
        font-size: 11.5px;
        letter-spacing: 0.12em;
        cursor: pointer;
    }

    body.rotate-dismissed .rotate-hint { display: none; }
}

@keyframes rotate-tip {
    0%, 55%, 100% { transform: rotate(0deg); }
    75%, 90% { transform: rotate(-90deg); }
}

/* ---------- 横屏手机 ---------- */

@media (max-width: 1023px) and (orientation: landscape) {
    body {
        min-width: 0;
        overflow-x: hidden;
    }

    .rotate-hint { display: none; }

    .backdrop { background-attachment: scroll !important; }

    button, .btn, .gcard, .ccard {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }

    /* ---------- 首页 ---------- */

    .page-home .home {
        min-height: 100svh;
        padding: 44px 32px 48px;
    }

    .home__eyebrow { font-size: 10.5px; letter-spacing: 0.34em; margin-bottom: 12px; }
    .home__title-cn { font-size: clamp(38px, 7vw, 64px); letter-spacing: 0.12em; }
    .home__title-en { font-size: 9.5px; letter-spacing: 0.42em; }
    .home__subtitle { font-size: 12.5px; margin-top: 14px; }
    .home__divider { margin: 18px 0 20px; }
    .home__actions { flex-direction: row; gap: 12px; max-width: none; width: auto; }
    .home__actions .btn { width: auto; min-width: 132px; height: 40px; font-size: 13px; }
    .home__hint { font-size: 10.5px; margin-top: 14px; }

    .page-home .footer {
        padding: 6px 16px;
        font-size: 9.5px;
        gap: 7px;
    }

    .page-home .topbar {
        position: fixed;
        padding: 10px 18px;
        font-size: 10.5px;
    }

    .rule-tip {
        top: 8px;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        font-size: 10.5px;
        padding: 6px 12px;
    }

    /* ---------- 选人页 ---------- */

    .setup {
        max-width: none;
        padding: 40px 16px 62px;
    }

    .page-setup .topbar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 30px;
        padding: 0 16px;
        align-items: center;
        background: rgba(16, 23, 19, 0.9);
    }

    .setup__head {
        text-align: left;
        display: flex;
        align-items: baseline;
        gap: 12px;
        flex-wrap: wrap;
    }
    .setup__eyebrow { display: none; }
    .setup__title { font-size: 20px; letter-spacing: 0.1em; }
    .setup__lead { margin: 0; font-size: 10.5px; }

    .factions {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        margin-top: 10px;
        align-items: start;
    }

    .faction { border-radius: 5px; }
    .faction:hover { transform: none; }

    .faction__face {
        flex-direction: row;
        justify-content: flex-start;
        gap: 10px;
        padding: 8px 12px;
        text-align: left;
    }

    .faction__crest { width: 30px; height: 30px; font-size: 14px; flex: none; }
    .faction__name { font-size: 15px; letter-spacing: 0.08em; }
    .faction__passive { font-size: 9.5px; line-height: 1.5; }
    .faction__cta { display: none; }

    .faction.is-active .faction__leaders {
        max-height: 42svh;
        overflow-y: auto;
    }

    .faction__leaders-title { font-size: 9.5px; padding: 6px 12px 0; }

    .leaders {
        grid-template-columns: 1fr;
        gap: 6px;
        padding: 6px 10px 10px;
        align-items: stretch;
        justify-items: stretch;
    }

    .leader {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 8px;
        padding: 5px 8px;
        width: 100%;
    }

    .leader__portrait {
        width: 26px;
        height: 34px;
        min-width: 26px;
        aspect-ratio: auto;
        flex: none;
    }

    .leader__body { width: auto; flex: 1; padding: 0; }
    .leader__name { font-size: 11.5px; }
    .leader__skill { font-size: 9px; line-height: 1.45; min-height: 0; }

    .setup__bar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 40;
        flex-direction: row;
        align-items: center;
        padding: 7px 16px calc(7px + env(safe-area-inset-bottom));
        gap: 12px;
    }

    .setup__summary { font-size: 11px; flex: 1; }
    .setup__bar .btn { width: auto; min-width: 150px; height: 34px; font-size: 12px; }

    .page-setup .topbar { padding: 8px 16px; font-size: 10.5px; }
    .page-setup .steps { display: none; }

    /* ---------- 构筑页 ---------- */

    body.page-builder { overflow-y: auto; }

    .page-builder .topbar { padding: 8px 16px; font-size: 10.5px; }
    .page-builder .steps { font-size: 9.5px; }
    .page-builder .topbar__note { display: none; }

    .builder {
        padding: 8px 12px 14px;
        gap: 6px;
        max-width: none;
    }

    .builder__head {
        flex-direction: row;
        align-items: flex-end;
        gap: 12px;
    }

    .builder__eyebrow { display: none; }
    .builder__title { font-size: 17px; margin: 0; letter-spacing: 0.1em; }
    .builder__meta { font-size: 10px; margin-top: 3px; gap: 6px; }
    .builder__hint { font-size: 9.5px; }

    .counts { gap: 8px; width: auto; justify-content: flex-end; flex-wrap: nowrap; }
    .count { min-width: 30px; }
    .count__value { font-size: 15px; }
    .count__label { font-size: 8.5px; letter-spacing: 0.06em; }
    .status { font-size: 9.5px; padding: 3px 8px; }

    .builder__cols {
        grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
        gap: 8px;
    }

    .panel__head { padding: 6px 8px; font-size: 10px; }
    .pool__grid { grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 5px; padding: 7px; }
    .deck__grid { grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 5px; padding: 7px; }
    .pool__grid, .deck__grid { max-height: none; }

    .ccard__name { font-size: 8px; }
    .ccard__meta { display: none; }
    .ccard__power { font-size: 10px; padding: 0 3px; }

    .deck__foot { padding: 6px 10px calc(6px + env(safe-area-inset-bottom)); }
    .deck__foot .btn { height: 34px; font-size: 12px; }
    .deck__foot-note { font-size: 9px; }

    /* ---------- 对局页 ---------- */

    body.page-game {
        height: 100svh;
        overflow: hidden;
    }

    .page-game .game-top {
        height: 34px;
        padding: 0 8px;
        gap: 8px;
        flex-wrap: nowrap;
    }

    .page-game .side-info {
        gap: 7px;
        padding: 0 4px;
        font-size: 9.5px;
        flex-wrap: nowrap;
        overflow: hidden;
    }

    .leader-chip { font-size: 9.5px; white-space: nowrap; }
    .stat { font-size: 9.5px; }
    .stat b { font-size: 10.5px; }
    .faction-tag { font-size: 9px; padding: 1px 5px; }
    .round-chip { font-size: 11px; letter-spacing: 0.1em; }
    .thinking-toggle { padding: 2px 6px; font-size: 9.5px; }
    .lives { transform: scale(0.78); transform-origin: left center; }

    .page-game .weather-bar {
        height: 20px;
        padding: 0 10px;
        font-size: 9.5px;
    }

    .page-game .board {
        min-height: 0;
        padding: 3px 6px 3px 44px;
        gap: 2px;
    }

    .page-game .leader-rail,
    body.page-game.log-open .leader-rail,
    body.page-game.panel-open .leader-rail {
        left: 2px;
        width: 38px;
        height: 50px;
    }

    .leader-rail--p2 { top: calc(25% - 25px); }
    .leader-rail--p1 { bottom: calc(25% - 25px); }
    .leader-face { width: 38px; height: 50px; border-radius: 3px; }

    .half { gap: 2px; }

    .lane {
        padding: 1px 4px;
        gap: 4px;
        min-height: 0;
    }

    .lane__label { width: 11px; font-size: 8px; letter-spacing: 0; }
    .lane__cards { gap: 3px; }
    .lane__total { width: 22px; font-size: 12px; }
    .lane .gcard { height: 38px; }
    .lane .gcard__power { font-size: 8.5px; padding: 0 2px; top: 1px; left: 1px; }
    .lane .gcard__ability { width: 9px; height: 9px; }

    .score-strip { height: 26px; gap: 12px; }
    .score-strip__side { font-size: 9.5px; gap: 4px; }
    .score-strip__side b { font-size: 15px; }
    .score-strip__vs, .score-strip__diff, .score-strip__center { font-size: 8px; }
    .score-strip__center { min-width: 66px; }

    .page-game .game-bottom {
        height: 30px;
        padding: 0 8px;
        font-size: 9.5px;
        gap: 6px;
    }

    .btn--pass { min-width: 58px; height: 24px; padding: 0 10px; font-size: 10.5px; }

    .hand-wrap {
        height: 74px;
        padding: 3px 4px 4px;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
    }

    .page-game .hand {
        justify-content: flex-start;
        gap: 3px;
        padding: 0 2px;
        width: max-content;
        min-width: 100%;
    }

    .page-game .hand .gcard { height: 64px; }

    /* 侧栏改为左右抽屉，横屏不挤占棋盘 */
    .page-game .side-panels {
        position: fixed;
        top: 34px;
        bottom: 0;
        right: 0;
        left: auto;
        width: min(300px, 46vw);
        max-height: none;
        margin: 0;
        padding: 0 8px calc(8px + env(safe-area-inset-bottom));
        overflow-y: auto;
        background: rgba(12, 18, 15, 0.96);
        border-left: 1px solid rgba(198, 161, 91, 0.3);
        box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
    }

    .page-game .side-panels .thinking-panel {
        max-height: none;
        margin-top: 6px;
    }

    .page-game .side-panels .thinking-panel__body { max-height: 26svh; }

    body.page-game.log-open .board,
    body.page-game.panel-open .board,
    body.page-game .board {
        min-height: 0;
        padding-left: 44px;
    }

    body.page-game.log-open .board,
    body.page-game.panel-open .board {
        padding-left: 44px;
        padding-right: calc(min(300px, 46vw) + 8px);
    }

    .thinking-panel__head { padding: 6px 9px; font-size: 10px; }
    .thinking-line, .thinking-empty { font-size: 9.5px; line-height: 1.55; }
    .log-entry { font-size: 9.5px; }
    .log-round { font-size: 9px; }

    .game-overlay__box {
        width: min(420px, calc(100vw - 60px));
        max-height: calc(100svh - 30px);
        overflow-y: auto;
        padding: 16px 20px 14px;
    }

    .game-overlay__title { font-size: 19px; }
    .game-overlay__text { font-size: 11px; }
    .round-scores { font-size: 9.5px; }

    .mulligan-bar {
        left: 50%;
        right: auto;
        bottom: 76px;
        transform: translateX(-50%);
        padding: 5px 12px;
        font-size: 9.5px;
        gap: 8px;
        flex-wrap: nowrap;
        white-space: nowrap;
    }

    .mulligan-bar .btn { height: 24px; padding: 0 12px; font-size: 10.5px; }

    .card-preview {
        width: min(320px, calc(100vw - 60px));
        max-height: 76svh;
        overflow-y: auto;
    }

    .sfx-toggle {
        right: 8px;
        bottom: calc(6px + env(safe-area-inset-bottom));
        width: 28px;
        height: 28px;
        font-size: 12px;
    }

    /* ---------- 开场 ---------- */

    .opening__video { object-fit: contain; }

    .opening__skip {
        right: 10px;
        bottom: calc(8px + env(safe-area-inset-bottom));
        padding: 4px 12px;
        font-size: 10px;
    }

    .opening__sound {
        bottom: calc(38px + env(safe-area-inset-bottom));
        font-size: 10.5px;
        padding: 6px 14px;
    }
}

/* 超矮横屏（如 iPhone 横屏 375 高）再收一档 */
@media (max-width: 1023px) and (orientation: landscape) and (max-height: 430px) {
    .page-game .game-top { height: 30px; }
    .page-game .weather-bar { height: 18px; }
    .page-game .leader-rail { width: 34px; height: 44px; }
    .leader-rail--p2 { top: calc(25% - 22px); }
    .leader-rail--p1 { bottom: calc(25% - 22px); }
    .leader-face { width: 34px; height: 44px; }
    .page-game .board { padding-left: 40px; }
    .lane .gcard { height: 32px; }
    .hand-wrap { height: 62px; }
    .page-game .hand .gcard { height: 54px; }
    .home__title-cn { font-size: clamp(30px, 6vw, 44px); }
    .home { padding: 36px 24px 40px; }
    .home__divider { margin: 12px 0 14px; }
}
