/* Compact Battle V3 presentation. Desktop arena styles stay in battlev3.css. */
.v3-compact-battle { display: none; }

@media (max-width: 1599px), (max-height: 899px) {
    body.v3-body > :is(.ability-tooltip-floating, .item-tooltip-floating, .v3-floating-tooltip, .v3-native-tooltip) {
        box-sizing: border-box;
        max-width: min(320px, calc(100vw - 24px)) !important;
        max-height: min(56dvh, 420px) !important;
        overflow: auto !important;
    }
    body.v3-body > :is(.ability-tooltip-floating, .item-tooltip-floating, .v3-floating-tooltip) > * {
        box-sizing: border-box; min-width: 0 !important; max-width: 100%;
    }
}

@media all {
    body.v3-compact-mode { overflow: hidden; }
    body.v3-compact-mode .v3-page { visibility: hidden; pointer-events: none; }
    body.v3-compact-mode .v3-compact-battle {
        --compact-gold: #e8cb89;
        --compact-muted: #91a5b8;
        position: fixed; inset: 0; z-index: 100;
        display: flex; flex-direction: column; gap: clamp(10px, 1.5vh, 18px);
        box-sizing: border-box;
        padding: max(16px, env(safe-area-inset-top)) clamp(12px, 3vw, 34px) max(22px, env(safe-area-inset-bottom));
        overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
        color: #edf2f6; font: 500 14px/1.35 Outfit, sans-serif;
        background:
            radial-gradient(ellipse at 50% 26%, #4b251b35, transparent 56%),
            linear-gradient(180deg, #040b16c9, #050b13b0 35%, #050b13f5 84%),
            url('../image/backgrounds/battlev3_vs.webp') center 34% / cover fixed;
        isolation: isolate;
    }
    .v3-compact-battle::before {
        position: fixed; inset: 8px; z-index: -1; content: ""; pointer-events: none;
        border: 1px solid #cfb47718; border-radius: 3px;
        box-shadow: inset 0 0 90px #02050bc4;
    }
    .v3-compact-battle *, .v3-compact-battle *::before, .v3-compact-battle *::after { box-sizing: border-box; }
    .v3-compact-battle[hidden], .v3-compact-battle [hidden] { display: none !important; }
    .v3-compact-battle button { font: inherit; color: inherit; touch-action: manipulation; cursor: pointer; -webkit-tap-highlight-color: transparent; }
    .v3-compact-battle button:focus-visible { outline: 2px solid #fff1c9; outline-offset: 3px; }
    .v3-compact-battle button:disabled { cursor: default; }
    .v3-compact-header {
        display: flex; align-items: center; gap: 16px;
        flex: 0 0 auto; min-height: 58px; padding: 0 48px 12px 0;
        border-bottom: 1px solid #dbc08028;
    }
    .v3-compact-brand { display: flex; align-items: center; gap: 12px; margin-right: auto; }
    .v3-compact-brand > span {
        display: grid; place-items: center; width: 36px; height: 42px;
        color: #f5daa0; font-size: 30px; text-shadow: 0 0 22px #d1a04b70;
    }
    .v3-compact-brand small { display: block; color: #d1b879; font-size: 9px; letter-spacing: .17em; }
    .v3-compact-brand strong { display: block; color: #f3eee1; font-size: clamp(19px, 3vw, 27px); font-weight: 600; letter-spacing: .015em; }
    .v3-compact-log-open, .v3-compact-round {
        flex-shrink: 0; border: 1px solid #aa95603d; border-radius: 5px;
        padding: 8px 12px; background: linear-gradient(150deg, #28303b91, #0c131ec7);
        color: #d7c697 !important; font-size: 11px !important; letter-spacing: .04em;
    }
    .v3-compact-log-open { min-height: 42px; }
    .v3-compact-round { color: #f4e0b0 !important; font-size: 14px !important; white-space: nowrap; }
    body.v3-compact-mode > .v3-settings-toggle {
        top: max(22px, env(safe-area-inset-top)); right: clamp(12px, 3vw, 34px);
        opacity: .85; border-color: #b59b644d; background: #101927c9; border-radius: 5px;
    }

    .v3-compact-team { min-width: 0; flex: 0 0 auto; --team-color: #8ed8e3; }
    .v3-compact-team--enemy { --team-color: #e09e8e; }
    .v3-compact-team h2 {
        display: flex; align-items: center; gap: 10px; margin: 0 0 9px;
        color: var(--team-color); font-size: 10px; font-weight: 700;
        letter-spacing: .15em; text-transform: uppercase;
    }
    .v3-compact-team h2::before { content: ""; width: 5px; height: 5px; background: var(--team-color); transform: rotate(45deg); }
    .v3-compact-team h2::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, #aac5cf30, transparent); }
    .v3-compact-team h2 small { order: 1; font-size: 10px; color: #b0bbc5; letter-spacing: .1em; }
    .v3-compact-roster { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: clamp(5px, 1.2vw, 14px); }
    .v3-compact-hero {
        position: relative; display: flex; flex-direction: column; align-items: stretch;
        min-width: 0; height: clamp(124px, 23vw, 254px); padding: 0; overflow: hidden;
        border: 1px solid #94a9bb64; border-radius: 9px 9px 5px 5px;
        background: #08121f; text-align: left;
        box-shadow: 0 7px 16px #0008, inset 0 0 0 2px #080c14;
        transition: border-color .18s, box-shadow .18s, transform .18s;
    }
    .v3-compact-hero::after { content: ""; position: absolute; inset: 3px; border: 1px solid #e1e8f11a; border-radius: 6px 6px 3px 3px; pointer-events: none; }
    .v3-compact-portrait {
        position: absolute; inset: 0; display: block; width: 100%; height: 100%;
        object-fit: cover; object-position: center 24%; border-radius: inherit;
        filter: saturate(.9); transition: filter .18s;
        mask-image: linear-gradient(#000 40%, #000d 62%, transparent 92%);
    }
    .v3-compact-name {
        position: relative; margin-top: auto; padding: 8px 9px 5px; z-index: 1;
        overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
        text-shadow: 0 2px 5px #000; color: #f6f1e7; font-size: clamp(10px, 1.7vw, 16px); font-weight: 700;
        background: linear-gradient(transparent, #08121f9c);
    }
    .v3-compact-level {
        position: absolute; top: 7px; left: 7px; display: grid; place-items: center;
        min-width: 23px; height: 23px; border: 1px solid #d2b5758c; border-radius: 4px;
        color: #f5d994; background: #071019d9; font-size: 10px; font-weight: 700;
    }
    .v3-compact-vital { position: relative; display: block; height: 5px; margin: 0 9px 4px; border-radius: 2px; background: #030810; overflow: hidden; box-shadow: 0 0 0 1px #ffffff0c; }
    .v3-compact-vital-fill { display: block; height: 100%; background: linear-gradient(90deg, #207d61, #8edca5); box-shadow: 0 0 6px #8ef2a577; transition: width .25s; }
    .v3-compact-vital--mana { height: 3px; margin-bottom: 8px; order: 3; }
    .v3-compact-vital--mana .v3-compact-vital-fill { background: linear-gradient(90deg, #285b98, #91cfff); }
    .v3-compact-hp-value { position: relative; padding: 0 9px 5px; color: #c9d9d6; font-size: 9px; font-variant-numeric: tabular-nums; }
    .v3-compact-effects { position: absolute; right: 7px; top: 7px; display: grid; place-items: center; width: 21px; height: 21px; border: 1px solid #c9d5e83d; border-radius: 50%; background: #0b1424e0; font-size: 10px; }
    .v3-compact-hero.is-selected { border-color: #efd08c; box-shadow: 0 0 0 1px #edc87a59, 0 9px 24px #000a; }
    .v3-compact-hero.is-selected::after { border-color: #eccc8b56; }
    .v3-compact-hero.is-current { border-color: #ffdc8e; box-shadow: 0 0 0 1px #edc87a7a, 0 0 24px #e8b85c4a; }
    .v3-compact-hero.is-current .v3-compact-name { color: #ffdfa2; }
    .v3-compact-hero.is-target { border-color: #ff8379; animation: v3CompactTargetPulse 1s ease-in-out infinite alternate; }
    .v3-compact-hero.is-ally-target { border-color: #7ae7bb; }
    .v3-compact-hero.is-defeated { opacity: .45; filter: grayscale(1); }
    .v3-compact-encounter { display: flex; flex: 0 0 auto; justify-content: center; align-items: center; gap: 12px; min-height: 53px; text-align: center; }
    .v3-compact-encounter::before, .v3-compact-encounter::after { content: ""; flex: 1; max-width: 220px; height: 1px; background: linear-gradient(90deg, transparent, #dbc1805e); }
    .v3-compact-encounter::after { transform: rotate(180deg); }
    .v3-compact-encounter-sigil { color: #d2ad63; font-size: 27px; text-shadow: 0 0 20px #f0be593b; }
    .v3-compact-phase { display: block; color: #eed8aa; font-size: clamp(13px, 2vw, 18px); font-weight: 500; }
    .v3-compact-phase-hint { display: block; margin-top: 3px; color: #94a4b7; font-size: 10px; }
    .is-targeting .v3-compact-phase { color: #ffb5a5; }

    .v3-compact-command-bar { display: grid; grid-template-columns: .8fr .8fr 1fr 1.2fr 1fr; gap: clamp(5px, 1vw, 10px); flex: 0 0 auto; }
    .v3-compact-command-bar button {
        display: flex; align-items: center; justify-content: center; gap: 9px;
        min-width: 0; min-height: 55px; padding: 8px 5px;
        border: 1px solid #a3b4c440; border-radius: 6px;
        background: linear-gradient(170deg, #34425291, #111c2bc9 58%, #091321);
        box-shadow: inset 0 1px #ffffff12, 0 4px 10px #0004;
        font-size: 11px; font-weight: 700; letter-spacing: .06em;
    }
    .v3-compact-command-bar svg { width: 23px; height: 23px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
    .v3-compact-command-bar button[data-v3-compact-command="roll"]:not(:disabled) { color: #ffedbf; border-color: #ddbc6e; background: linear-gradient(155deg, #82632ee0, #382a17e8); box-shadow: inset 0 1px #fff3c33d, 0 0 24px #b1842a26; }
    .v3-compact-command-bar button[data-v3-compact-command="attack"]:not(:disabled) { color: #f8c3b3; border-color: #b97560; background: linear-gradient(160deg, #694438a6, #2c1e20e8); }
    .v3-compact-command-bar button[data-v3-compact-command="shop"]:not(:disabled) { color: #aeecd9; border-color: #518b81; }
    .v3-compact-command-bar button.is-active { color: #aeecd9; border-color: #66c6a6; box-shadow: inset 0 0 20px #62e7ae16; }
    .v3-compact-command-bar button:disabled { color: #73808e; border-color: #70819526; background: #0b1422a1; box-shadow: none; }
    .v3-compact-panel {
        position: relative; flex: 0 0 auto; min-height: 0; padding: clamp(12px, 2vw, 23px);
        border: 1px solid #b9a47455; border-radius: 10px;
        background: radial-gradient(ellipse at 5% 0, #6a57292e, transparent 55%), linear-gradient(135deg, #15202de8, #08111fee);
        box-shadow: 0 18px 42px #0005, inset 0 1px #f6dca818;
    }
    .v3-compact-panel::before { content: ""; position: absolute; top: -1px; left: 25px; right: 25px; height: 1px; background: linear-gradient(90deg, transparent, #ddc087a6, transparent); }
    .v3-compact-panel-head { display: flex; align-items: center; gap: 13px; margin-bottom: 18px; }
    .v3-compact-feature-portrait { width: 61px; height: 69px; object-fit: cover; object-position: center 20%; border: 1px solid #d5b97c9c; border-radius: 6px; box-shadow: 0 4px 15px #0008; }
    .v3-compact-feature-copy { flex: 1; min-width: 0; }
    .v3-compact-panel-head small { color: #b5a17b; font-size: 10px; letter-spacing: .09em; text-transform: uppercase; }
    .v3-compact-panel-head h2 { margin: 3px 0 4px; color: #faf0d9; font-size: 25px; font-weight: 600; line-height: 1.1; }
    .v3-compact-feature-vitals { color: #96b2c5; font-size: 10px; letter-spacing: .04em; }
    .v3-compact-details-open { min-height: 44px; padding: 8px 13px; border: 1px solid #c0a36666; border-radius: 5px; background: linear-gradient(135deg, #b89b4321, #68562912); color: #e7d6b0 !important; font-size: 11px !important; }
    .v3-compact-details-open span { margin-left: 8px; color: #c3a36a; }
    .v3-compact-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 10px; max-width: 100%; }
    .v3-compact-action-wrap { position: relative; min-width: 0; }
    .v3-compact-action {
        display: flex; flex-direction: column; align-items: center; gap: 7px;
        width: 100%; min-height: 112px; height: 100%; padding: 11px 8px 8px;
        border: 1px solid #8c9fba49; border-radius: 7px;
        background: radial-gradient(ellipse at 50% 20%, #56749825, transparent 75%), linear-gradient(160deg, #21304499, #0b1422db);
        box-shadow: inset 0 1px #ffffff09;
    }
    .v3-compact-action img { width: clamp(42px, 6vw, 61px); height: clamp(42px, 6vw, 61px); object-fit: contain; border-radius: 6px; filter: drop-shadow(0 3px 7px #0008); }
    .v3-compact-action > span { width: 100%; color: #dce6ef; font-size: 11px; line-height: 1.25; text-align: center; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
    .v3-compact-action-cost { margin-top: auto; color: #80bce6; font-size: 9px; letter-spacing: .06em; }
    .v3-compact-action:disabled { border-color: #73849a2b; background: #0c1523a6; }
    .v3-compact-action:disabled img { filter: grayscale(.55) brightness(.65); }
    .v3-compact-action:disabled > span { color: #7c8ba0; }
    .v3-compact-action.is-selected { border-color: #e8c981; box-shadow: inset 0 0 18px #dbb75f26; }
    .v3-compact-action-info {
        position: absolute; top: 1px; right: 1px; display: grid; place-items: center;
        width: 32px; height: 32px; padding: 0; border: 0; border-radius: 6px;
        color: #bbcad8 !important; background: #0b1528c4; font: italic 15px Georgia, serif !important;
    }
    .v3-compact-badges-section { margin-top: 17px; border-top: 1px solid #b8a5782e; padding-top: 12px; }
    .v3-compact-badges-section h3 { margin: 0 0 10px; color: #a49d8b; font-size: 9px; font-weight: 500; text-transform: uppercase; letter-spacing: .16em; }
    .v3-compact-badges { grid-template-columns: repeat(auto-fit, minmax(115px, 1fr)); }
    .v3-compact-badges .v3-compact-action { flex-direction: row; justify-content: flex-start; gap: 10px; min-height: 68px; padding: 9px 28px 9px 10px; background: linear-gradient(130deg, #2633495c, #0b142296); }
    .v3-compact-badges .v3-compact-action img { width: 35px; height: 35px; flex-shrink: 0; }
    .v3-compact-badges .v3-compact-action > span { text-align: left; font-size: 11px; }

    .v3-compact-info, .v3-compact-details { position: fixed; inset: 0; z-index: 5; display: grid; place-items: center; padding: max(12px, env(safe-area-inset-top)) 12px; background: #020811d9; backdrop-filter: blur(12px); }
    .v3-compact-info-panel, .v3-compact-details-panel { position: relative; width: min(100%, 480px); max-height: calc(100dvh - 28px); overflow-y: auto; overscroll-behavior: contain; border: 1px solid #d1b4777d; border-radius: 12px; background: linear-gradient(135deg, #1b2738, #091320); box-shadow: 0 24px 70px #000b; }
    .v3-compact-info-panel { padding: 24px; }
    .v3-compact-info-panel h3 { margin: 0 35px 16px 0; color: #f3dbaa; font-size: 21px; line-height: 1.2; }
    .v3-compact-info-content { color: #c0ccd9; font-size: 14px; line-height: 1.6; overflow-wrap: anywhere; }
    .v3-compact-info-content img { max-width: 100%; }
    .v3-compact-info-close, .v3-compact-details-close { width: 44px; height: 44px; border: 1px solid #ab977148; border-radius: 6px; background: #c9ad6121; color: #e9d6ad !important; font-size: 25px !important; }
    .v3-compact-info-close { position: absolute; top: 8px; right: 8px; }
    .v3-compact-details-panel > header { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: #101b2af5; border-bottom: 1px solid #ab977138; }
    .v3-compact-details-panel h2 { margin: 0; color: #eed8af; font-size: 21px; }
    .v3-compact-card-stage { display: flex; justify-content: center; min-height: 580px; padding: 10px 0 18px; overflow: hidden; }
    .v3-compact-card-stage > .v3-card { flex: 0 0 auto; }
    body.v3-compact-mode .v3-ability-choice-overlay { box-sizing: border-box; padding: 10px; }
    body.v3-compact-mode .v3-ability-choice-panel { box-sizing: border-box; width: 100%; max-height: calc(100dvh - 20px); padding: 22px 12px 12px; overflow-y: auto; }
    body.v3-compact-mode .v3-ability-choice-options { grid-template-columns: 1fr; gap: 8px; }
    body.v3-compact-mode .v3-ability-choice-option { display: grid; grid-template-columns: 48px 1fr; align-items: center; gap: 4px 10px; min-height: 56px; padding: 5px 9px; text-align: left; }
    body.v3-compact-mode .v3-ability-choice-option > .v3-ability-choice-option-icon { grid-row: span 2; width: 46px; height: 46px; margin: 0; }
    @keyframes v3CompactTargetPulse { to { box-shadow: 0 0 19px #ff8b6859; } }
}
@media (max-width: 540px) {
    body.v3-compact-mode .v3-compact-battle { gap: 10px; padding: max(10px, env(safe-area-inset-top)) 10px max(18px, env(safe-area-inset-bottom)); }
    .v3-compact-header { gap: 8px; min-height: 54px; padding-right: 35px; }
    .v3-compact-brand { gap: 5px; }
    .v3-compact-brand > span { width: 22px; font-size: 23px; }
    .v3-compact-brand small { font-size: 6px; letter-spacing: .1em; }
    .v3-compact-brand strong { font-size: 17px; }
    .v3-compact-round { padding: 6px 7px; font-size: 11px !important; }
    .v3-compact-log-open { padding: 5px 8px; font-size: 9px !important; max-width: 52px; min-height: 36px; }
    body.v3-compact-mode > .v3-settings-toggle { top: max(15px, env(safe-area-inset-top)); right: 10px; width: 31px; height: 36px; }
    .v3-compact-team h2 { font-size: 9px; margin-bottom: 7px; }
    .v3-compact-hero { height: clamp(115px, 30vw, 154px); border-radius: 6px; }
    .v3-compact-level { top: 4px; left: 4px; min-width: 17px; height: 18px; font-size: 8px; }
    .v3-compact-effects { right: 4px; top: 4px; width: 16px; height: 17px; font-size: 8px; }
    .v3-compact-name { padding: 6px 4px 5px; font-size: 10px; }
    .v3-compact-vital { margin-left: 4px; margin-right: 4px; height: 4px; }
    .v3-compact-vital--mana { height: 3px; margin-bottom: 6px; }
    .v3-compact-hp-value { display: none; }
    .v3-compact-encounter { gap: 8px; min-height: 41px; }
    .v3-compact-encounter-sigil { font-size: 20px; }
    .v3-compact-phase { font-size: 13px; }
    .v3-compact-phase-hint { font-size: 9px; }
    .v3-compact-command-bar { grid-template-columns: .8fr .8fr 1fr 1fr 1.15fr; gap: 4px; }
    .v3-compact-command-bar button { flex-direction: column; gap: 4px; min-height: 57px; padding: 6px 2px; font-size: 8px; letter-spacing: 0; }
    .v3-compact-command-bar svg { width: 21px; height: 21px; }
    .v3-compact-panel { padding: 12px 10px; }
    .v3-compact-panel-head { gap: 10px; margin-bottom: 13px; }
    .v3-compact-feature-portrait { width: 45px; height: 55px; }
    .v3-compact-panel-head h2 { font-size: 21px; }
    .v3-compact-panel-head small { font-size: 8px; letter-spacing: .04em; }
    .v3-compact-feature-vitals { font-size: 9px; }
    .v3-compact-details-open { padding: 7px; font-size: 10px !important; }
    .v3-compact-details-open span { margin-left: 2px; }
    .v3-compact-actions { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
    .v3-compact-action { padding: 9px 4px 6px; gap: 6px; min-height: 98px; }
    .v3-compact-action img { width: 38px; height: 38px; }
    .v3-compact-action > span { font-size: 9px; }
    .v3-compact-action-info { width: 28px; height: 28px; font-size: 13px !important; }
    .v3-compact-badges { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .v3-compact-badges .v3-compact-action { min-height: 62px; padding: 8px 23px 8px 7px; gap: 6px; }
    .v3-compact-badges .v3-compact-action img { width: 28px; height: 28px; }
    .v3-compact-badges .v3-compact-action > span { font-size: 10px; }
}
@media (min-width: 541px) and (max-width: 1100px) and (min-height: 900px) {
    body.v3-compact-mode .v3-compact-battle { gap: clamp(16px, 2vh, 26px); }
    .v3-compact-hero { height: clamp(180px, 18vh, 240px); }
    .v3-compact-encounter { min-height: 60px; }
}
@media (max-width: 360px) {
    .v3-compact-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .v3-compact-badges { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1100px) and (orientation: landscape) and (max-height: 600px) {
    body.v3-compact-mode .v3-compact-battle {
        display: grid; grid-template-columns: minmax(270px, 46%) minmax(0, 1fr);
        grid-template-rows: 43px minmax(0, 1fr) 28px minmax(0, 1fr) 48px;
        gap: 6px 14px; overflow: hidden; padding: 8px 12px;
    }
    .v3-compact-header { grid-column: 1 / -1; min-height: 0; padding-bottom: 5px; }
    .v3-compact-brand strong { font-size: 18px; }
    .v3-compact-team--enemy { grid-column: 1; grid-row: 2; }
    .v3-compact-team--ally { grid-column: 1; grid-row: 4; }
    .v3-compact-team { display: flex; flex-direction: column; min-height: 0; }
    .v3-compact-team h2 { font-size: 8px; margin-bottom: 3px; }
    .v3-compact-roster { flex: 1; min-height: 0; gap: 5px; }
    .v3-compact-hero { height: 100%; min-height: 0; }
    .v3-compact-name { font-size: 9px; padding: 3px 4px; }
    .v3-compact-vital { height: 3px; margin: 0 4px 3px; }
    .v3-compact-vital--mana { height: 2px; }
    .v3-compact-hp-value { display: none; }
    .v3-compact-level, .v3-compact-effects { top: 3px; height: 16px; min-width: 16px; width: 16px; font-size: 8px; }
    .v3-compact-encounter { grid-column: 1; grid-row: 3; min-height: 0; }
    .v3-compact-phase { font-size: 11px; }
    .v3-compact-phase-hint { display: none; }
    .v3-compact-command-bar { grid-column: 1; grid-row: 5; align-self: stretch; }
    .v3-compact-command-bar button { min-height: 0; padding: 3px; gap: 2px; flex-direction: column; font-size: 8px; }
    .v3-compact-command-bar svg { width: 18px; height: 18px; }
    .v3-compact-panel { grid-column: 2; grid-row: 2 / 6; overflow-y: auto; padding: 12px; }
    .v3-compact-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
    .v3-compact-badges { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .v3-compact-action { min-height: 92px; }
    .v3-compact-action img { width: 40px; height: 40px; }
    body.v3-compact-mode > .v3-settings-toggle { top: 8px; right: 12px; width: 34px; height: 34px; }
}
@media (hover: hover) {
    .v3-compact-hero:hover { border-color: var(--rank-color); transform: translateY(-2px); }
    .v3-compact-hero:hover .v3-compact-portrait { filter: saturate(1.12); }
    .v3-compact-action:not(:disabled):hover, .v3-compact-command-bar button:not(:disabled):hover { border-color: #eed59d; filter: brightness(1.13); }
}
/* The compact HUD uses the original card's rank palette and skin layers. */
.v3-compact-hero {
    --rank-color: #b9c2cc; --rank-glow: #f4f7fa;
    isolation: isolate; border-color: var(--rank-color);
    box-shadow: 0 7px 16px #0008, inset 0 0 0 2px #080c14, 0 0 12px color-mix(in srgb, var(--rank-color) 17%, transparent);
}
.v3-compact-hero::after { z-index: 2; border-color: color-mix(in srgb, var(--rank-color) 38%, transparent); }
.v3-compact-hero .v3-skin-effect { z-index: 1; border-radius: inherit; }
.v3-compact-name, .v3-compact-vital, .v3-compact-hp-value { z-index: 3; }
.v3-compact-level { z-index: 4; border-color: var(--rank-color); color: var(--rank-glow); }
.v3-compact-hero.is-selected, .v3-compact-hero.is-current {
    border-color: var(--rank-color);
    box-shadow: 0 0 0 1px var(--rank-color), 0 0 22px color-mix(in srgb, var(--rank-color) 36%, transparent), 0 9px 24px #000a;
}
.v3-compact-hero.is-selected::after { border-color: var(--rank-glow); }
.v3-compact-hero.is-current .v3-compact-name::before { content: "◆"; margin-right: 4px; color: var(--rank-glow); font-size: .65em; }
.v3-compact-hero.is-target::after { border: 2px solid #ff8379; }
.v3-compact-hero.is-ally-target::after { border-color: #7ae7bb; }
.v3-compact-class {
    position: absolute; right: 6px; top: 6px; z-index: 4;
    width: 30px; height: 30px; padding: 3px; object-fit: contain;
    border: 1px solid color-mix(in srgb, var(--rank-color) 65%, transparent); border-radius: 50%;
    background: radial-gradient(#263141ed, #070e19ed); filter: drop-shadow(0 2px 5px #000b);
}
.v3-compact-effect-rail { position: absolute; z-index: 4; top: 43px; left: 7px; right: 7px; display: flex; flex-wrap: wrap; gap: 3px; pointer-events: none; }
.v3-compact-effect, .v3-compact-effect-more { display: grid; place-items: center; flex: 0 0 21px; width: 21px; height: 21px; border: 1px solid #8bddbf; border-radius: 3px; overflow: hidden; background: #071019ed; box-shadow: 0 2px 5px #000a; }
.v3-compact-effect.is-debuff { border-color: #f38a82; }
.v3-compact-effect img { width: 100%; height: 100%; object-fit: cover; }
.v3-compact-effect-more { color: #e1ceb0; border-color: #baa173; font-size: 8px; }
.v3-compact-auto-controls { display:grid;grid-template-rows:1fr 1fr;gap:4px;min-width:0; }
.v3-compact-command-bar .v3-compact-auto-controls button { min-height:26px;padding:4px 2px;gap:3px;flex-direction:row;font-size:9px; }
.v3-compact-auto-controls button > img { width:16px;height:16px;object-fit:contain; }
.v3-compact-command-bar button[data-v3-compact-command="exit"]:not(:disabled) { color:#ffd5d8;border-color:#b56870; }
.v3-compact-command-bar > button > img { width: 29px; height: 29px; object-fit: contain; filter: drop-shadow(0 2px 6px #0008); }
.v3-compact-command-bar > button:disabled > img { opacity: .55; }
.v3-compact-equipment-section { margin-top: 18px; padding-top: 13px; border-top: 1px solid #b8a5782e; }
.v3-compact-equipment-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.v3-compact-equipment-heading h3 { margin: 0; color: #b9ab90; font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: .16em; }
.v3-compact-dice { display: flex; gap: 6px; }
.v3-compact-dice .dice { flex: 0 0 26px; width: 26px; height: 26px; font-size: 11px; }
.v3-compact-inventory { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 9px; }
.v3-compact-item-wrap { position: relative; min-width: 0; }
.v3-compact-item { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; width: 100%; height: 100%; min-height: 90px; padding: 9px 5px; border: 1px solid #899db544; border-radius: 7px; background: radial-gradient(ellipse at 50% 15%, #52728d24, transparent 75%), #0a1422b3; }
.v3-compact-item.is-empty { border-style: dashed; border-color: #9aacbb29; background: #08111b66; }
.v3-compact-item.is-ready { border-color: #84dbb4; box-shadow: inset 0 0 18px #68d5a817; }
.v3-compact-item.is-consumable { border-color: #bda36765; }
.v3-compact-item-art { position: relative; display: block; width: 44px; height: 44px; }
.v3-compact-item-art > .item-icon { width: 100%; height: 100%; object-fit: contain; border-radius: 4px; }
.v3-compact-item-art .spell-slot-cooldown-overlay { position: absolute; inset: 0; display: grid; place-items: center; border-radius: 4px; background: #030814a6; color: white; font-size: 16px; font-weight: 700; text-shadow: 0 2px 4px #000; }
.v3-compact-item-art .hero-consumable-count { position: absolute; right: -3px; bottom: -3px; padding: 1px 4px; border: 1px solid #c4ab72; border-radius: 3px; background: #111b29; color: #f5dca0; font-size: 10px; }
.v3-compact-item-art .ogerpon-forge-slot-aura { position: absolute; inset: -2px; border: 1px solid #efbc60; border-radius: 5px; box-shadow: 0 0 8px #f8ad594d; pointer-events: none; }
.v3-compact-item-art .ogerpon-forge-slot-hammer { position: absolute; right: -4px; bottom: -4px; width: 19px; height: 19px; object-fit: contain; filter: drop-shadow(0 1px 3px #000); }
.v3-compact-item-label { max-width: 100%; color: #a8b5c3; font-size: 10px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.v3-compact-slot-mark { display: grid; place-items: center; width: 44px; height: 44px; color: #7e91a35c; font-size: 29px; font-weight: 300; }
.v3-compact-item-info { position: absolute; top: 1px; right: 1px; z-index: 1; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 5px; background: #0b1528d9; color: #becbd7; font: italic 14px Georgia, serif !important; }
.v3-compact-status-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.v3-compact-status { display: flex; align-items: center; gap: 6px; min-height: 40px; max-width: 100%; padding: 5px 9px; border: 1px solid #899db53d; border-radius: 5px; background: #0c1726; font-size: 10px !important; text-align: left; }
.v3-compact-status img { width: 25px; height: 25px; border-radius: 3px; }
@media (min-width: 1101px) {
    body.v3-compact-mode .v3-compact-battle { padding-inline: max(34px, calc((100vw - 1200px) / 2)); }
    .v3-compact-hero { height: clamp(180px, 21vh, 254px); }
}
@media (max-width: 540px), (orientation: landscape) and (max-height: 600px) {
    .v3-compact-class { top: 3px; right: 3px; width: 20px; height: 20px; padding: 2px; }
    .v3-compact-effect-rail { top: 28px; left: 4px; right: 4px; gap: 2px; }
    .v3-compact-effect, .v3-compact-effect-more { flex-basis: 14px; width: 14px; height: 14px; font-size: 7px; }
    .v3-compact-command-bar > button > img { width: 23px; height: 23px; }
    .v3-compact-inventory { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
    .v3-compact-item { min-height: 78px; }
    .v3-compact-item-label { font-size: 9px; }
    .v3-compact-item-art, .v3-compact-slot-mark { width: 36px; height: 36px; }
    .v3-compact-dice { gap: 4px; }
    .v3-compact-dice .dice { flex-basis: 23px; width: 23px; height: 23px; font-size: 10px; }
}
.v3-compact-stats-section { margin-top: 18px; padding-top: 14px; border-top: 1px solid #b8a5782e; }
.v3-compact-stats-section h3 { margin: 0 0 12px; color: #b9ab90; font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: .16em; }
.v3-compact-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 0; }
.v3-compact-stat { position: relative; min-width: 0; padding: 12px 12px 12px 55px; border: 1px solid #899db52e; border-radius: 6px; background: linear-gradient(120deg, #26334950, #09132199); box-shadow: inset 0 1px #ffffff05; }
.v3-compact-stat-label { color: #9eafc1; font-size: 11px; line-height: 1.35; overflow-wrap: anywhere; }
.v3-compact-stat-icon { position: absolute; left: 12px; top: 50%; width: 32px; height: 32px; object-fit: contain; transform: translateY(-50%); filter: drop-shadow(0 2px 5px #0008); }
.v3-compact-stat-value { margin: 4px 0 0; color: #f0e5ce; font-size: 18px; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
@media (max-width: 640px), (orientation: landscape) and (max-height: 600px) {
    .v3-compact-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
    .v3-compact-stat { padding: 10px 8px 10px 43px; }
    .v3-compact-stat-icon { left: 8px; width: 27px; height: 27px; }
    .v3-compact-stat-label { font-size: 10px; }
    .v3-compact-stat-value { font-size: 16px; }
}
/* Turn preview sits beside the encounter message, between the two teams. */
.v3-compact-encounter { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 16px; }
.v3-compact-encounter::before { width: 100%; max-width: none; }
.v3-compact-encounter::after { display: none; }
.v3-compact-encounter-message { display: flex; align-items: center; justify-content: center; gap: 12px; min-width: 0; }
.v3-compact-turn-order { min-width: 0; width: 100%; max-width: 430px; text-align: left; }
.v3-compact-turn-label { display: block; margin-bottom: 5px; color: #bca980; font-size: 8px; letter-spacing: .15em; text-transform: uppercase; }
.v3-compact-turn-list { display: flex; align-items: center; gap: 5px; min-width: 0; margin: 0; padding: 3px 2px 5px; list-style: none; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; scrollbar-color: #bca98055 transparent; }
.v3-compact-turn-list:empty { display: none; }
.v3-compact-turn { position: relative; flex: 0 0 30px; width: 30px; height: 34px; border: 1px solid #79ccda99; border-radius: 5px; background: #08111d; box-shadow: 0 2px 5px #0008; }
.v3-compact-turn > img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 4px; }
.v3-compact-turn.is-enemy { border-color: #df968599; }
.v3-compact-turn.is-completed { opacity: .36; filter: saturate(.3); }
.v3-compact-turn.is-defeated { opacity: .25; filter: grayscale(1); }
.v3-compact-turn.is-current { border-color: #ffe3a0; box-shadow: 0 0 0 1px #e6bd68, 0 0 12px #e6bd6840; }
.v3-compact-turn-number { position: absolute; bottom: -3px; right: -2px; min-width: 13px; padding: 1px 3px; border: 1px solid #b1b9c344; border-radius: 3px; background: #08111ded; color: #e0e8ef; font-size: 8px; line-height: 1.2; text-align: center; }
.v3-compact-turn.is-current .v3-compact-turn-number { color: #ffe3a0; border-color: #e6bd68; }
.v3-compact-turn-stun { position: absolute; left: -2px; top: -4px; color: #ffdb79; font-size: 14px; text-shadow: 0 1px 4px #000, 0 0 6px #e6bd68; }
.v3-compact-turn-empty { color: #8495a9; font-size: 10px; }
.v3-compact-hero.is-stunned .v3-compact-portrait { filter: saturate(.3) brightness(.48); }
.v3-compact-hero.is-stunned .v3-skin-effect { opacity: .18; }
.v3-compact-hero.is-stunned::after { border: 1px dashed var(--stun-color, #ffd34e); box-shadow: inset 0 0 20px color-mix(in srgb, var(--stun-color, #ffd34e) 23%, transparent); }
.v3-compact-stun { position: absolute; top: 48%; left: 3px; right: 3px; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 4px; transform: translateY(-50%); pointer-events: none; color: var(--stun-color, #ffd34e); text-align: center; text-shadow: 0 2px 5px #000; }
.v3-compact-stun img { width: 38px; height: 38px; object-fit: contain; border: 1px solid var(--stun-color, #ffd34e); border-radius: 50%; background: #111522df; box-shadow: 0 0 18px color-mix(in srgb, var(--stun-color, #ffd34e) 40%, transparent); }
.v3-compact-stun strong { font-size: 12px; letter-spacing: .12em; }
.v3-compact-stun small { padding: 2px 7px; border: 1px solid color-mix(in srgb, var(--stun-color, #ffd34e) 45%, transparent); border-radius: 3px; background: #08111dde; color: #f5e4bc; font-size: 10px; }
@media (max-width: 700px) {
    .v3-compact-encounter { display: flex; flex-direction: column; gap: 3px; min-height: 0; padding: 0; }
    .v3-compact-encounter::before { display: none; }
    .v3-compact-encounter-message { gap: 8px; }
    .v3-compact-turn-order { width: fit-content; max-width: 100%; }
    .v3-compact-turn-label { display: none; }
    .v3-compact-turn-list { gap: 3px; padding: 3px 2px 4px; }
    .v3-compact-turn { flex-basis: 22px; width: 22px; height: 24px; border-radius: 4px; }
    .v3-compact-turn > img { border-radius: 3px; }
    .v3-compact-turn-number { min-width: 10px; padding: 1px 2px; font-size: 7px; bottom: -2px; right: -1px; }
    .v3-compact-turn-stun { font-size: 11px; top: -3px; }
}
@media (max-width: 540px), (orientation: landscape) and (max-height: 600px) {
    .v3-compact-stun { top: 49%; gap: 2px; }
    .v3-compact-stun img { width: 21px; height: 21px; }
    .v3-compact-stun strong { font-size: 8px; letter-spacing: .03em; }
    .v3-compact-stun small { font-size: 7px; padding: 1px 4px; }
}
@media (max-width: 1100px) and (orientation: landscape) and (max-height: 600px) {
    body.v3-compact-mode .v3-compact-battle { grid-template-rows: 43px minmax(0, 1fr) 55px minmax(0, 1fr) 48px; }
    .v3-compact-encounter { display: flex; flex-direction: column; gap: 3px; padding: 0; }
    .v3-compact-encounter::before, .v3-compact-turn-label { display: none; }
    .v3-compact-encounter-message { gap: 6px; }
    .v3-compact-encounter-sigil { font-size: 16px; }
    .v3-compact-turn-order { width: fit-content; max-width: 100%; }
    .v3-compact-turn-list { gap: 3px; }
    .v3-compact-turn { flex-basis: 22px; width: 22px; height: 24px; }
}
@media (prefers-reduced-motion: reduce) {
    .v3-compact-battle *, .v3-compact-battle *::before, .v3-compact-battle *::after { animation: none !important; transition: none !important; }
}

