/* ===== Combat screen (web/js/combat.js) =====
   One screen for a whole battle: you on the left, the enemies on the right,
   dice and scores in the middle, the battle's questions in the tray below.
   On phones the enemies sit on top, you below the dice. */

:root {
    --combat-bg: #0a0910;
    --combat-glow: rgba(196, 164, 78, 0.16);
    --combat-panel: rgba(22, 20, 30, 0.82);
    --combat-edge: rgba(196, 164, 78, 0.35);
    --combat-you: #c4a44e;
    --combat-foe: #c04040;
    --combat-win: #5cc46e;
    --combat-lose: #e05050;
    --die-face: #f4ecd6;
    --die-pip: #1c140a;
    --die-edge: #b49656;
    --die-foe-face: #6e1018;
    --die-foe-pip: #ffe9e0;
    --die-foe-edge: #300408;
    --die-fixed: #e7d29a;
    --chip-you: rgba(196, 164, 78, 0.16);
    --chip-foe: rgba(192, 64, 64, 0.18);
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
        --combat-bg: #ece6d8;
        --combat-glow: rgba(138, 116, 48, 0.18);
        --combat-panel: rgba(251, 248, 240, 0.9);
        --combat-edge: rgba(138, 116, 48, 0.4);
        --combat-you: #8a7430;
        --combat-foe: #b03030;
        --combat-win: #2a7a3a;
        --combat-lose: #b02a2a;
        --die-face: #fffaf0;
        --die-pip: #1c140a;
        --die-edge: #a08648;
        --die-foe-face: #8a1820;
        --die-foe-pip: #fff2ec;
        --die-foe-edge: #4a0810;
        --die-fixed: #ecd9a2;
        --chip-you: rgba(138, 116, 48, 0.14);
        --chip-foe: rgba(176, 48, 48, 0.12);
    }
}

:root[data-theme="dark"] {
    --combat-bg: #0a0910;
    --combat-glow: rgba(196, 164, 78, 0.16);
    --combat-panel: rgba(22, 20, 30, 0.82);
    --combat-edge: rgba(196, 164, 78, 0.35);
    --combat-you: #c4a44e;
    --combat-foe: #c04040;
    --combat-win: #5cc46e;
    --combat-lose: #e05050;
    --die-face: #f4ecd6;
    --die-pip: #1c140a;
    --die-edge: #b49656;
    --die-foe-face: #6e1018;
    --die-foe-pip: #ffe9e0;
    --die-foe-edge: #300408;
    --die-fixed: #e7d29a;
    --chip-you: rgba(196, 164, 78, 0.16);
    --chip-foe: rgba(192, 64, 64, 0.18);
}

.combat {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: flex;
    color: var(--text);
    font-family: var(--font-sans);
}

.combat[hidden] { display: none; }

.combat-backdrop {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 60% 45% at 50% 42%, var(--combat-glow), transparent 75%),
        var(--combat-bg);
}

.combat--won .combat-backdrop {
    background:
        radial-gradient(ellipse 60% 45% at 50% 42%, rgba(92, 196, 110, 0.14), transparent 75%),
        var(--combat-bg);
}

.combat--lost .combat-backdrop {
    background:
        radial-gradient(ellipse 60% 45% at 50% 42%, rgba(224, 80, 80, 0.14), transparent 75%),
        var(--combat-bg);
}

.combat-frame {
    position: relative;
    flex: 1;
    width: 100%;
    max-width: 120rem;
    margin: 0 auto;
    padding: 0.625rem var(--gutter) 0.625rem;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 0.625rem;
    overflow: hidden;
}

.combat--opening .combat-frame { animation: combat-open 0.3s ease both; }

@keyframes combat-open {
    from { opacity: 0; transform: scale(0.97); }
    to { opacity: 1; transform: none; }
}

/* --- Header --- */

.combat-head {
    display: flex;
    align-items: baseline;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.35rem 0.75rem;
    text-align: center;
}

.combat-title {
    margin: 0;
    font-size: 1.35rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent);
}

.combat-attr {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    color: #fff;
    background: var(--threat-red);
}

.combat-attr--wil { background: var(--threat-blue); }
.combat-attr--cun { background: var(--threat-yellow); color: #1a1405; }

.combat-stage {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.combat-watching {
    font-size: 0.72rem;
    padding: 0.15rem 0.6rem;
    border: 1px solid var(--combat-edge);
    border-radius: 999px;
    color: var(--text-muted);
}

/* --- The field: you, the dice, them ---
   The field is a size container: the art (your portrait, the enemy cards)
   is as tall as the field allows (--art-h, from its height) and as wide as
   its side leaves beside the plate (--art-room), so it grows when the tray
   below is short (after the dice, the verdict) and fits 1280x720 to
   2560x1440 alike. Each side is the art plus a compact plate of numbers,
   the plates towards the middle; there are no tall empty panels. */

.combat-field {
    --gap: 1rem;
    --centre-w: clamp(16.5rem, 20vw, 23rem);
    container-type: size;
    display: grid;
    --pf: 1;
    --ef: 1;
    grid-template-columns: minmax(0, 1fr) var(--centre-w) minmax(0, 1fr);
    grid-template-areas: "player centre enemy";
    grid-template-rows: minmax(0, 1fr);
    gap: var(--gap);
    min-height: 0;
}

/* A group of enemies takes more of the width than your one portrait. */
.combat-field:has(.combat-enemies[data-count="2"]) {
    --pf: 0.9;
    --ef: 1.1;
    grid-template-columns: minmax(0, 0.9fr) var(--centre-w) minmax(0, 1.1fr);
}

.combat-field:has(.combat-enemies:not([data-count="1"]):not([data-count="2"])) {
    --pf: 0.85;
    --ef: 1.2;
    grid-template-columns: minmax(0, 0.85fr) var(--centre-w) minmax(0, 1.2fr);
}

.combat-side {
    --side-w: calc((100cqw - var(--centre-w) - 2 * var(--gap)) * var(--pf) / (var(--pf) + var(--ef)));
    --plate-w: clamp(10rem, calc(var(--side-w) * 0.36), 13.5rem);
    --art-room: calc(var(--side-w) - var(--plate-w) - 1rem);
    --art-h: clamp(7rem, calc(100cqh - 1.25rem), 26rem);
    min-width: 0;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 1rem;
}

.combat-side--player { grid-area: player; }
/* Cards first in the page (and to screen readers); the plate goes on their left, by the middle. */
.combat-side--enemy {
    --side-w: calc((100cqw - var(--centre-w) - 2 * var(--gap)) * var(--ef) / (var(--pf) + var(--ef)));
    grid-area: enemy;
    flex-direction: row-reverse;
}

/* The numbers beside the art. */
.combat-plate {
    flex: none;
    width: var(--plate-w);
    max-height: 100cqh;
    overflow-y: auto;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.375rem;
    padding: 0.75rem 0.875rem;
    background: var(--combat-panel);
    border: 1px solid var(--combat-edge);
    border-radius: var(--radius-lg);
    box-shadow: 0 0.5rem 1.875rem rgba(0, 0, 0, 0.25);
}

.combat-side--player .combat-plate { border-top: 0.1875rem solid var(--combat-you); }
.combat-side--enemy .combat-plate { border-top: 0.1875rem solid var(--combat-foe); }

.combat-portrait {
    position: relative;
    flex: none;
    height: min(var(--art-h), calc(var(--art-room) / 0.9));
    aspect-ratio: 9 / 10;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 0.1875rem solid var(--combat-you);
    background: var(--art-bg);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), 0 0.75rem 2rem rgba(0, 0, 0, 0.45), 0 0 2.5rem var(--combat-glow);
}

.combat-portrait img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1;
}

.combat-portrait-initial {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 4rem;
    font-weight: 700;
    color: var(--accent);
}

.combat-info { text-align: center; min-width: 0; }
.combat-name { font-weight: 700; font-size: 1.05rem; line-height: 1.2; }
.combat-sub { font-size: 0.75rem; color: var(--text-muted); }

.combat-value {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
}

.combat-value-n {
    font-size: 2.6rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.combat-side--player .combat-value-n { color: var(--combat-you); }
.combat-side--enemy .combat-value-n { color: var(--combat-foe); }

.combat-value-label {
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-top: 0.125rem;
}

.combat-bump { animation: combat-bump 0.45s ease; }

@keyframes combat-bump {
    40% { transform: scale(1.3); text-shadow: 0 0 0.875rem currentColor; }
}

.combat-breakdown {
    list-style: none;
    margin: 0;
    padding: 0;
    width: 100%;
    font-size: 0.78rem;
}

.combat-breakdown li {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 1px 0;
    border-bottom: 1px dotted var(--border);
}

.combat-breakdown li:first-child { font-weight: 700; }
/* The enemy cards carry their values; the list only adds something with extras. */
.combat-breakdown--plain { display: none; }
.combat-breakdown-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combat-breakdown-n { font-variant-numeric: tabular-nums; font-weight: 700; }

.combat-chips {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.25rem;
}

.combat-chips:empty, .combat-trophies:empty { display: none; }

.combat-chip {
    font-size: 0.72rem;
    line-height: 1.25;
    text-align: center;
    padding: 0.125rem 0.5rem;
    border-radius: 0.75rem;
    border: 1px solid var(--combat-you);
    background: var(--chip-you);
}

.combat-side--enemy .combat-chip { border-color: var(--combat-foe); background: var(--chip-foe); }
.combat-chip--new { animation: combat-chip-in 0.6s ease both; }

@keyframes combat-chip-in {
    0% { transform: scale(0.4); opacity: 0; }
    60% { transform: scale(1.12); opacity: 1; box-shadow: 0 0 0.75rem var(--accent); }
    100% { transform: none; }
}

.combat-trophies {
    display: flex;
    justify-content: center;
    padding-left: 1.25rem;
    min-height: 0;
}

/* Taken cards pile up, each a little to the right of the last. */
.combat-trophies > .combat-trophy { margin-left: -1.25rem; box-shadow: -0.125rem 0 0.375rem rgba(0, 0, 0, 0.35); }

.combat-trophy {
    width: 2.75rem;
    aspect-ratio: 276 / 429;
    border-radius: 0.1875rem;
    overflow: hidden;
    border: 1px solid var(--accent);
    background: var(--art-bg);
    font-size: 0.5rem;
}

.combat-trophy img { width: 100%; height: 100%; object-fit: cover; }
.combat-trophy .rcard { border-radius: 0; }
.combat-trophy--landed { animation: combat-bump 0.4s ease; }

/* Enemy cards: one big, or a group side by side, fanned (overlapping a
   little) when the side is too narrow for them all at full size. */

.combat-enemies {
    --n: 1;
    --k: 1;
    --room: calc(var(--art-room) - 1rem - (var(--n) - 1) * 0.375rem);
    --cw: min(calc((var(--art-h) - 1rem) / 1.554), calc(var(--room) / var(--k)));
    flex: none;
    display: flex;
    align-items: center;
    padding: 0.25rem 0.5rem 1rem;
}

.combat-enemies[data-count="2"] { --n: 2; --k: 1.75; }
.combat-enemies[data-count="3"] { --n: 3; --k: 2.5; }
.combat-enemies[data-count="4"] { --n: 4; --k: 3.25; }
.combat-enemies[data-count="5"] { --n: 5; --k: 4; }
.combat-enemies[data-count="6"] { --n: 6; --k: 4.75; }

.combat-enemy {
    position: relative;
    flex: none;
    width: var(--cw);
    aspect-ratio: 276 / 429;
    border-radius: 0.375rem;
    overflow: visible;
    background: var(--art-bg);
    box-shadow: 0 0.75rem 1.75rem rgba(0, 0, 0, 0.5);
    transform-origin: 50% 100%;
    transition: opacity 0.3s, filter 0.3s, scale 0.15s;
}

.combat-enemy + .combat-enemy {
    margin-left: clamp(calc(var(--cw) * -0.25), calc((var(--room) - var(--n) * var(--cw)) / max(var(--n) - 1, 1)), 0.875rem);
}

/* A slight fan for a group; the hovered card comes forward. */
.combat-enemies[data-count="2"] .combat-enemy:nth-child(1) { rotate: -2deg; }
.combat-enemies[data-count="2"] .combat-enemy:nth-child(2) { rotate: 2deg; }
.combat-enemies[data-count="3"] .combat-enemy:nth-child(1) { rotate: -2.5deg; }
.combat-enemies[data-count="3"] .combat-enemy:nth-child(3) { rotate: 2.5deg; }
.combat-enemy:hover { z-index: 3; scale: 1.04; }

.combat-enemy img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 0.375rem;
    display: block;
}

.combat-enemy-name {
    display: grid;
    place-items: center;
    height: 100%;
    padding: 0.375rem;
    font-size: 0.85rem;
    text-align: center;
}

.combat-enemy-value {
    position: absolute;
    left: 50%;
    bottom: -0.75rem;
    transform: translateX(-50%);
    z-index: 2;
    min-width: 2.125rem;
    height: 2.125rem;
    padding: 0 0.3rem;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: var(--combat-foe);
    color: #fff;
    font-weight: 800;
    font-size: 1.05rem;
    border: 0.125rem solid rgba(255, 255, 255, 0.85);
    box-shadow: 0 0.125rem 0.375rem rgba(0, 0, 0, 0.4);
}

.combat-enemy--dealt { animation-name: combat-deal; animation-timing-function: cubic-bezier(.2, .8, .3, 1.1); animation-fill-mode: both; }

@keyframes combat-deal {
    from { transform: translate(3.75rem, -1.875rem) rotate(10deg) scale(0.8); opacity: 0; }
    to { transform: none; opacity: 1; }
}

/* (no animation: the deal's held last frame would keep it opaque) */
.combat-enemy--taken { opacity: 0.22; filter: grayscale(1); animation: none; }

.combat-ghost {
    position: fixed;
    z-index: 70;
    pointer-events: none;
    margin: 0;
    rotate: none;
}

/* --- The middle: dice and scores --- */

.combat-centre {
    grid-area: centre;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: safe center;
    gap: 0.75rem;
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0.5rem 0;
}

.combat-dice {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    min-height: 3.75rem;
}

.combat-scores {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    max-width: 100%;
}

.combat-score {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 6.5rem;
    padding: 0.4rem 0.75rem 0.3rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--combat-panel);
    box-shadow: 0 0.375rem 1.25rem rgba(0, 0, 0, 0.25);
    transition: border-color 0.3s, box-shadow 0.3s;
}

.combat-score-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    max-width: 7rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.combat-score-n {
    font-size: 3.6rem;
    font-weight: 800;
    line-height: 1.02;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.combat-score--player .combat-score-n { color: var(--combat-you); }
.combat-score--enemy .combat-score-n { color: var(--combat-foe); }

.combat-score--before .combat-score-n { opacity: 0.55; }
.combat-score--before .combat-score-n::after {
    content: "+ dice";
    font-size: 0.8rem;
    font-weight: 600;
    margin-left: 0.1875rem;
    vertical-align: middle;
}

.combat-score--ahead { border-color: var(--accent); box-shadow: 0 0 1.25rem var(--combat-glow), 0 0 0 1px var(--accent); }

.combat-vs {
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    text-transform: uppercase;
}

.combat-verdict { text-align: center; min-height: 0; }

/* No dice were rolled (evaded, or the battle never took place). */
.combat--no-roll .combat-dice,
.combat--no-roll .combat-score--before .combat-score-n::after { display: none; }
.combat-verdict--none { display: none; }

.combat-verdict-title {
    font-size: 2.6rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    line-height: 1.1;
    text-transform: uppercase;
    animation: combat-verdict-in 0.45s cubic-bezier(.2, .9, .3, 1.3) both;
}

.combat-verdict--won .combat-verdict-title { color: var(--combat-win); text-shadow: 0 0 1.5rem rgba(92, 196, 110, 0.45); }
.combat-verdict--lost .combat-verdict-title { color: var(--combat-lose); text-shadow: 0 0 1.5rem rgba(224, 80, 80, 0.4); }
.combat-verdict--tied .combat-verdict-title,
.combat-verdict--evaded .combat-verdict-title { color: var(--accent); }

.combat-verdict-line { font-size: 0.92rem; line-height: 1.35; color: var(--text-muted); }

@keyframes combat-verdict-in {
    from { transform: scale(2.2); opacity: 0; }
    to { transform: none; opacity: 1; }
}

/* Dice (combatdice.js): pips on a 3 x 3 grid. */

.cdie-group {
    display: inline-flex;
    align-items: center;
    gap: 0.1875rem;
    padding: 0.1875rem;
    border-radius: 0.625rem;
    border: 0.125rem solid transparent;
    background: none;
    color: inherit;
    font: inherit;
}

.cdie-group--ignored { opacity: 0.35; text-decoration: line-through; }

.cdie {
    --size: 3.25rem;
    width: var(--size);
    height: var(--size);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    padding: calc(var(--size) * 0.14);
    border-radius: calc(var(--size) * 0.2);
    background: var(--die-face);
    border: 1px solid var(--die-edge);
    box-shadow: inset 0 -0.1875rem 0 rgba(0, 0, 0, 0.18), 0 0.1875rem 0.5rem rgba(0, 0, 0, 0.35);
    flex-shrink: 0;
}

.cdie i {
    width: 70%;
    height: 70%;
    margin: auto;
    border-radius: 50%;
}

.cdie i.on { background: var(--die-pip); }

.combat-dice--enemy .cdie {
    background: var(--die-foe-face);
    border-color: var(--die-foe-edge);
}

.combat-dice--enemy .cdie i.on { background: var(--die-foe-pip); }

.cdie--number {
    display: grid;
    place-items: center;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--die-pip);
}

.combat-dice--enemy .cdie--number { color: var(--die-foe-pip); }

.cdie--blank {
    background: transparent;
    border: 0.125rem dashed var(--combat-you);
    box-shadow: none;
    color: var(--text-muted);
    opacity: 0.75;
}

.combat-dice--enemy .cdie--blank { background: transparent; color: var(--text-muted); border-color: var(--combat-foe); }

.cdie--fixed {
    background: var(--die-fixed);
    border: 0.125rem solid var(--accent);
    border-radius: 0.25rem;
}

.cdie-group--fixed::after {
    content: "power";
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.cdie--extra { --size: 2.6rem; outline: 0.125rem dashed var(--accent); outline-offset: 0.125rem; }
.cdie-plus { font-weight: 800; font-size: 1.3rem; color: var(--accent); }

/* What happened to a die, under it ("6 explodes: +1 die"). */
.cdie-group--captioned {
    flex-wrap: wrap;
    justify-content: center;
    max-width: 16.25rem;
}

.cdie-caption {
    flex-basis: 100%;
    text-align: center;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.2;
    color: var(--text-muted);
    text-decoration: none;
}

.cdie-caption--explode { color: var(--accent); font-weight: 700; }

/* Each score as a sum, and the dice rules of this battle. */
.combat-sums {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    max-width: 100%;
}

.combat-sum {
    margin: 0;
    font-size: 0.88rem;
    line-height: 1.3;
    text-align: center;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.combat-sum:empty { display: none; }
.combat-sum--player { color: var(--combat-you); }
.combat-sum--enemy { color: var(--combat-foe); }

.combat-dicerules {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1875rem;
    max-width: 100%;
}

.combat-dicerule {
    font-size: 0.8rem;
    line-height: 1.3;
    text-align: center;
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    background: var(--chip-you);
}

.combat-dicerule--enemy { background: var(--chip-foe); }
.combat-dicerule--basic { background: none; color: var(--text-muted); }
/* With the verdict up, the plain rule gives way to it. */
.combat--won .combat-dicerule--basic,
.combat--lost .combat-dicerule--basic { display: none; }

.combat-dicerule-src {
    margin-left: 0.4em;
    font-weight: 700;
}

.combat-dicerule-src::before { content: "— "; font-weight: 400; }

.combat--no-roll .combat-dicerules,
.combat--no-roll .combat-sums { display: none; }

.cdie--rolling { animation: cdie-tumble 0.28s linear infinite; }

@keyframes cdie-tumble {
    0% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-0.625rem) rotate(90deg) scale(0.92); }
    50% { transform: translateY(0) rotate(180deg); }
    75% { transform: translateY(-0.375rem) rotate(270deg) scale(0.95); }
    100% { transform: translateY(0) rotate(360deg); }
}

.cdie--landed { animation: cdie-land 0.3s ease-out; }

@keyframes cdie-land {
    0% { transform: scale(1.25); }
    60% { transform: scale(0.94); }
    100% { transform: none; }
}

.cdie--exploded {
    box-shadow: 0 0 0 0.125rem var(--accent), 0 0 1rem 0.25rem rgba(255, 190, 80, 0.7);
}

.cdie--pop { animation: cdie-pop 0.35s cubic-bezier(.2, .9, .3, 1.4) both; }

@keyframes cdie-pop {
    from { transform: scale(0) rotate(-120deg); opacity: 0; }
    to { transform: none; opacity: 1; }
}

/* --- Targets for picks (a die, an enemy) --- */

.combat-target {
    cursor: pointer;
    outline: none;
    animation: combat-target 1.4s ease-in-out infinite;
}

.cdie-group.combat-target { border-color: var(--reach); }
.combat-enemy.combat-target { box-shadow: 0 0 0 0.1875rem var(--reach), 0 0 1.375rem var(--reach-halo); }

.combat-target:hover,
.combat-target:focus-visible {
    animation: none;
    box-shadow: 0 0 0 0.1875rem var(--reach-hover), 0 0 1.625rem var(--reach-halo-hover);
    transform: translateY(-0.1875rem);
}

@keyframes combat-target {
    50% { box-shadow: 0 0 0 0.1875rem var(--reach), 0 0 1.625rem var(--reach-halo-hover); }
}

/* --- Hit and damage --- */

.combat-hit { animation: combat-shake 0.5s ease; }

@keyframes combat-shake {
    15%, 55% { transform: translateX(-0.4375rem) rotate(-2deg); }
    35%, 75% { transform: translateX(0.4375rem) rotate(2deg); }
}

.combat-damage {
    position: absolute;
    left: 50%;
    top: 40%;
    z-index: 2;
    transform: translateX(-50%);
    font-size: 1.4rem;
    font-weight: 800;
    color: #fff;
    background: var(--combat-lose);
    padding: 0.125rem 0.625rem;
    border-radius: 999px;
    white-space: nowrap;
    animation: combat-float 1.6s ease-out forwards;
}

@keyframes combat-float {
    from { opacity: 0; transform: translate(-50%, 0.625rem); }
    20% { opacity: 1; transform: translate(-50%, 0); }
    to { opacity: 0; transform: translate(-50%, -2.5rem); }
}

/* --- Battle motion (pixel effects play over these: fx.js) --- */

/* The dice are down: both sides lunge in towards the scores and back. */
.combat--clash .combat-portrait { animation: combat-lunge-in 0.6s cubic-bezier(.3, .7, .3, 1); }
.combat--clash .combat-enemies { animation: combat-lunge-in 0.6s cubic-bezier(.3, .7, .3, 1); --lunge: -1; }
.combat--clash .combat-score { animation: combat-score-hit 0.5s ease; }

@keyframes combat-lunge-in {
    0% { translate: 0 0; }
    30% { translate: calc(var(--lunge, 1) * 1.75rem) 0; scale: 1.03; }
    50% { translate: calc(var(--lunge, 1) * -0.375rem) 0; scale: 1; }
    100% { translate: 0 0; }
}

@keyframes combat-score-hit {
    30% { scale: 1.08; }
}

/* A won battle: the enemy cards reel from the blow. */
.combat-enemies--hit .combat-enemy { animation: combat-reel 0.55s ease; }

@keyframes combat-reel {
    0% { translate: 0 0; filter: brightness(2.4) saturate(0.4); }
    20% { translate: 0.75rem -0.25rem; }
    45% { translate: -0.5rem 0.125rem; filter: brightness(1.3); }
    70% { translate: 0.25rem 0; }
    100% { translate: 0 0; filter: none; }
}

/* Burnt away from the bottom up, in step with fx.js's flames (--burn: how
   far up). The ::after browns the card just above the seam. */
@property --burn {
    syntax: "<percentage>";
    inherits: false;
    initial-value: 100%;
}

.is-burning {
    -webkit-mask-image: linear-gradient(to top, transparent var(--burn), #000 var(--burn));
    mask-image: linear-gradient(to top, transparent var(--burn), #000 var(--burn));
    pointer-events: none;
}

.is-burning::after {
    content: "";
    --burn: inherit;
    position: absolute;
    inset: 0;
    z-index: 3;
    border-radius: inherit;
    pointer-events: none;
    background: linear-gradient(to top, transparent var(--burn), rgba(26, 10, 4, 0.92) var(--burn),
        rgba(70, 30, 10, 0.55) calc(var(--burn) + 7%), rgba(90, 50, 20, 0.18) calc(var(--burn) + 16%), transparent calc(var(--burn) + 24%));
}

.combat-enemy--gone { opacity: 0; scale: 0.9; transition: opacity 0.4s, scale 0.4s; }

/* Armour held: a gold flash round the portrait. */
.combat-saved { animation: combat-saved 1.2s ease; }

@keyframes combat-saved {
    0% { box-shadow: 0 0 0 0 rgba(245, 192, 74, 0); }
    25% { box-shadow: 0 0 0 0.375rem rgba(245, 192, 74, 0.85), 0 0 2.5rem rgba(245, 192, 74, 0.7); }
    100% { box-shadow: 0 0 0 0 rgba(245, 192, 74, 0), 0 0.75rem 2rem rgba(0, 0, 0, 0.45); }
}

.combat-damage--saved { background: #b8740a; }

/* Embers rising behind everything (fx.js, pfx.js's ambient). */
.combat-backdrop { overflow: hidden; }

.pfx-ambient {
    position: absolute;
    pointer-events: none;
    image-rendering: pixelated;
    transform-origin: 50% 50%;
    mix-blend-mode: screen;
}

/* --- The tray: the battle's question --- */

/* A row: the help line on top, then the cards and buttons, with Fight /
   Done on the right (or alone in the middle). */
.combat-tray {
    --tray-card: clamp(6.5rem, 8.5vw, 9.5rem);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.5rem 1.5rem;
    padding: 0.625rem 1rem;
    background: var(--combat-panel);
    border: 1px solid var(--combat-edge);
    border-radius: var(--radius-lg);
    z-index: 2;
    max-height: 50vh;
    overflow-y: auto;
}

.combat-tray > .combat-text,
.combat-tray > .combat-hint { flex-basis: 100%; }
.combat-tray > .combat-options { flex: 0 1 auto; min-width: 0; }

.combat-tray:empty { display: none; }

.combat-text {
    margin: 0;
    font-size: 0.95rem;
    text-align: center;
    color: var(--text);
}

.combat-text--watching,
.combat-text--busy { color: var(--text-muted); font-style: italic; }

.combat-hint { margin: 0; font-size: 0.78rem; text-align: center; color: var(--text-muted); }

.combat-options {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem 1.5rem;
}

.combat-group { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; max-width: 100%; }

.combat-group-title {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
}

.combat-cards {
    display: flex;
    gap: 0.625rem;
    overflow-x: auto;
    padding: 0.375rem 0.25rem 0.5rem;
}

.combat-card {
    position: relative;
    flex-shrink: 0;
    width: var(--tray-card);
    display: flex;
    flex-direction: column;
    padding: 0;
    border: 1px solid var(--option-edge);
    border-radius: 0.375rem;
    background: var(--option-bg);
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
    overflow: hidden;
    transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.combat-card img {
    width: 100%;
    aspect-ratio: 276 / 427;
    object-fit: cover;
    display: block;
}

.combat-card-cap { display: flex; flex-direction: column; padding: 0.1875rem 0.3125rem 0.25rem; gap: 1px; }
.combat-card-name { font-size: 0.74rem; font-weight: 700; line-height: 1.15; }

.combat-card-does {
    font-size: 0.7rem;
    line-height: 1.2;
    color: var(--text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.combat-card:hover:not(:disabled),
.combat-card:focus-visible {
    transform: translateY(-0.25rem);
    border-color: var(--accent);
    box-shadow: 0 0.375rem 1rem rgba(0, 0, 0, 0.35), 0 0 0 0.125rem var(--accent);
    outline: none;
}

.combat-card:disabled { cursor: not-allowed; opacity: 0.5; filter: grayscale(0.7); }

.combat-card-reason {
    font-size: 0.66rem;
    padding: 0 0.3125rem 0.25rem;
    color: var(--danger);
}

/* "Play" / "Use" on a glowing card, as on the panel's thumbnails. */
.combat-card-tag {
    position: absolute;
    right: 0.3rem;
    top: 0.3rem;
    z-index: 5;
    padding: 0.05rem 0.45rem;
    border-radius: 0.5rem;
    background: var(--use-tag-bg);
    color: var(--use-tag-ink);
    font-size: 0.66rem;
    font-weight: 800;
    line-height: 1.45;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    box-shadow: 0 1px 0.25rem rgba(0, 0, 0, 0.45);
    pointer-events: none;
}

/* On an upright redrawn card the tag and pips sit on the face's foot (straddling its lower
   edge), clear of the number badge, the cost plaque and the name at its top. */
.combat-card:has(.rcard:not(.rcard--wide)) .combat-card-tag,
.combat-card:has(.rcard:not(.rcard--wide)) .combat-pips {
    top: calc(var(--tray-card) * 427 / 276 - 0.6rem);
}

.combat-card--pointed { animation: combat-bump 0.5s ease 2; border-color: var(--accent); }

.combat-pips {
    position: absolute;
    left: 0.25rem;
    top: 0.25rem;
    display: flex;
    gap: 0.1875rem;
    padding: 0.1875rem 0.25rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.65);
}

.combat-pips i {
    width: 0.625rem;
    height: 0.625rem;
    border-radius: 50%;
    border: 1px solid #f2d27a;
}

.combat-pips i.on { background: #f2d27a; box-shadow: 0 0 0.25rem #f2d27a; }

.combat-buttons { display: flex; flex-wrap: wrap; gap: 0.375rem; }

.combat-opt {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
    max-width: 17.5rem;
    padding: 0.375rem 0.625rem;
    border: 1px solid var(--option-edge);
    border-radius: var(--radius);
    background: var(--option-bg);
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.combat-opt:hover:not(:disabled),
.combat-opt:focus-visible { border-color: var(--accent); outline: none; box-shadow: 0 0 0 0.125rem var(--accent-dim); }
.combat-opt:disabled { opacity: 0.5; cursor: not-allowed; }
.combat-opt-label { font-size: 0.82rem; font-weight: 700; }
.combat-opt-detail { font-size: 0.7rem; color: var(--text-muted); }
.combat-opt-reason { font-size: 0.66rem; color: var(--danger); }
.combat-ability { border-color: var(--combat-you); }

.combat-player-pick { flex-direction: row; align-items: center; gap: 0.5rem; }
.combat-player-pick img { width: 1.75rem; height: 1.75rem; border-radius: 50%; object-fit: cover; }

.combat-main {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
}

.combat-main .btn { width: auto; }
.combat-opt.btn-primary { background: var(--accent); color: var(--bg); border-color: transparent; }
.combat-opt.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.combat-opt.btn-secondary { background: transparent; border-color: var(--accent); color: var(--accent); }
.combat-opt.btn-secondary:hover:not(:disabled) { background: var(--accent); color: var(--bg); }
.combat-main .combat-opt.btn { align-items: center; text-transform: uppercase; }
.combat-main .combat-opt.btn .combat-opt-label { font-size: 0.85rem; }

.combat-go {
    min-width: 13.5rem;
    padding: 0.9rem 2.25rem;
    font-size: 1.15rem;
    letter-spacing: 0.12em;
    align-items: center;
    text-align: center;
    border: none;
    color: var(--bg);
}

.combat-go .combat-opt-label { font-size: 1.2rem; }
.combat-go:focus-visible { outline: 0.1875rem solid var(--reach); outline-offset: 0.125rem; }
.combat-go--fight { animation: combat-go 1.8s ease-in-out infinite; }

@keyframes combat-go {
    50% { box-shadow: 0 0 0 0.25rem var(--accent-dim), 0 0 1.5rem var(--combat-glow); }
}

/* --- Cards on their side (landscape, cardrender WIDE_LAYOUT) ---
   In the sidebar, and in the bottom tray when a row or two fits (combat.js
   layoutTray). The card shows its own name, so the caption is one line:
   the pips, what a click does, and the Play/Use tag. */

.combat--side .combat-card-name,
.combat-tray--wide .combat-card-name { display: none; }
.combat--side .combat-card-cap,
.combat-tray--wide .combat-card-cap { flex-direction: row; align-items: center; gap: 0.375rem; min-height: 1.5rem; }
.combat--side .combat-card-does,
.combat-tray--wide .combat-card-does { flex: 1; min-width: 0; -webkit-line-clamp: 1; font-size: 0.74rem; }
.combat--side .combat-pips,
.combat-tray--wide .combat-pips { position: static; flex: none; }
.combat--side .combat-card-tag,
.combat-tray--wide .combat-card-tag { position: static; flex: none; margin-left: auto; }
/* A card still waiting for its art shows the top of its scan. */
.combat--side .combat-card img,
.combat-tray--wide .combat-card img { aspect-ratio: 600 / 240; object-position: top; }

/* A Power card's number on its side (half-width in the sidebar): its own
   name is about 9 px there and "Its number…" says nothing the group title
   doesn't, so the caption gives the name instead. */
.combat--side .combat-group--numbers .combat-card-name,
.combat-tray--wide .combat-group--numbers .combat-card-name {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    flex: 1;
    min-width: 0;
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1.15;
    overflow: hidden;
}
.combat--side .combat-group--numbers .combat-card-does,
.combat-tray--wide .combat-group--numbers .combat-card-does { display: none; }

.combat-tray--wide .combat-card { width: var(--tray-wide, 16rem); }
.combat-tray--wide .combat-cards { flex-wrap: wrap; overflow-x: visible; }

/* --- The sidebar (wide screens, combat.js trayPlacement) ---
   The question in a column on the right: the help line on top, the cards
   stacked down it (scrolling when there are many), Fight / Done / Continue
   at its foot. The field keeps the whole height for the art and the dice. */

.combat--side .combat-frame {
    --sidebar-w: clamp(19rem, 23vw, 28rem);
    grid-template-columns: minmax(0, 1fr) var(--sidebar-w);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "head side" "field side";
    column-gap: 1rem;
}
/* The battle's dice (dice3d.js 'screen' overlay) land in the middle of the
   field, not of the window: shift them left by half the sidebar. */
body:has(#combat-screen.combat--side:not([hidden])) .dice3d-overlay {
    --side-shift: calc((clamp(19rem, 23vw, 28rem) + 1rem) / 2);
    box-sizing: border-box;
    padding-right: calc(2 * var(--side-shift));
}
body:has(#combat-screen.combat--side:not([hidden])) .dice3d-overlay::before { left: calc(50% - var(--side-shift)); }

.combat--side .combat-head { grid-area: head; }
.combat--side .combat-field { grid-area: field; --centre-w: clamp(15rem, 17vw, 21rem); }

/* The field is now tall and narrower: each side's plate goes under its art,
   as a compact row (name and value, then the breakdown and chips), so the
   art takes the side's whole width. */
.combat--side .combat-side,
.combat--side .combat-side--enemy {
    --art-room: var(--side-w);
    --art-h: clamp(7rem, calc(100cqh - 10.5rem), 36rem);
    flex-direction: column;
    justify-content: safe center;
    align-items: center;
    gap: 0.75rem;
}
.combat--side .combat-plate {
    width: min(100%, 20rem);
    max-height: none;
    overflow: visible;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "info value" "break break" "chips chips" "trophies trophies";
    align-items: center;
    gap: 0.25rem 0.75rem;
    padding: 0.5rem 0.875rem;
}
.combat--side .combat-plate .combat-info { grid-area: info; text-align: left; }
.combat--side .combat-plate .combat-value { grid-area: value; }
.combat--side .combat-plate .combat-breakdown { grid-area: break; }
.combat--side .combat-plate .combat-chips { grid-area: chips; justify-content: flex-start; }
.combat--side .combat-plate .combat-trophies { grid-area: trophies; justify-content: flex-start; }
.combat--side .combat-value-n { font-size: 2.3rem; }

/* --- Bottom tray on desktop (761 px and up, below the sidebar threshold:
   1024x768, 761-1000 px wide, Extra large UI on a laptop) ---
   The plates sat beside the art, which left a 88x97 portrait at 1024x768.
   Now, as in the sidebar layout, each plate goes under its art as a compact
   row and the art takes the side's whole width, as tall as the field
   allows less the plate. The sides don't scroll (a scroller clipped the
   portrait's and plates' shadows into faint bands in the light theme). */

@media (min-width: 761px) {
    .combat:not(.combat--side) .combat-side,
    .combat:not(.combat--side) .combat-side--enemy {
        --art-room: var(--side-w);
        --art-h: clamp(5.5rem, calc(100cqh - 7.25rem), 30rem);
        flex-direction: column;
        justify-content: safe center;
        align-items: center;
        gap: 0.5rem;
    }
    .combat:not(.combat--side) .combat-plate {
        width: min(100%, 19rem);
        max-height: none;
        overflow: visible;
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas: "info value" "break break" "chips chips" "trophies trophies";
        align-items: center;
        gap: 0.125rem 0.75rem;
        padding: 0.375rem 0.75rem;
    }
    .combat:not(.combat--side) .combat-plate .combat-info { grid-area: info; text-align: left; }
    .combat:not(.combat--side) .combat-plate .combat-value { grid-area: value; }
    .combat:not(.combat--side) .combat-plate .combat-breakdown { grid-area: break; }
    .combat:not(.combat--side) .combat-plate .combat-chips { grid-area: chips; justify-content: flex-start; }
    .combat:not(.combat--side) .combat-plate .combat-trophies { grid-area: trophies; justify-content: flex-start; }
    .combat:not(.combat--side) .combat-value-n { font-size: 2rem; }
    /* The enemy plate's "Same attribute: their values add up" would make it
       the tallest thing on the field: the cards show their values. */
    .combat:not(.combat--side) .combat-side--enemy .combat-sub { display: none; }
}

.combat--side .combat-tray {
    grid-area: side;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0.625rem;
    max-height: none;
    min-height: 0;
    overflow: hidden;
    padding: 0.75rem;
}
/* An empty sidebar stays (between questions) so the field doesn't jump. */
.combat--side .combat-tray:empty { display: flex; }
.combat--side .combat-tray > * { flex: none; }
.combat--side .combat-tray > .combat-text { text-align: left; }
.combat--side .combat-tray > .combat-options {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    flex-direction: column;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 0.75rem;
    /* Room for the glow ring and the hover lift inside the scroller, and
       a fade at its foot that the last card scrolls clear of. */
    margin: 0 -0.5rem;
    padding: 0.25rem 0.5rem 1.25rem;
    -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 1.25rem), transparent);
    mask-image: linear-gradient(to bottom, #000 calc(100% - 1.25rem), transparent);
}
.combat--side .combat-cards { flex-direction: column; overflow: visible; padding: 0.25rem 0 0.125rem; gap: 0.625rem; }
/* A Power card's number only needs its number and name: two to a row. */
.combat--side .combat-group--numbers .combat-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.combat--side .combat-group--numbers .combat-card-does { font-size: 0.68rem; }
.combat--side .combat-card { width: 100%; }
.combat--side .combat-buttons { flex-direction: column; }
.combat--side .combat-opt { max-width: none; }
.combat--side .combat-tray > .combat-main { margin-top: auto; flex-direction: column; align-items: stretch; order: 2; }

/* The battle log (combat.js): fills the sidebar while nothing is asked of
   you (a battle you watch, after your verdict); hidden under a question and
   in the bottom tray. */
.combat-log { display: none; }
.combat:not(.combat--side) .combat-tray:not(:has(> :not(.combat-log))) { display: none; }
.combat--side .combat-tray:not(:has(.combat-options, .combat-opt)) > .combat-log {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    gap: 0.375rem;
}
.combat-log-title {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--combat-muted, var(--text-muted));
    margin: 0;
}
.combat-log-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}
.combat-log-line {
    font-size: 0.85rem;
    line-height: 1.35;
    color: var(--combat-ink, var(--text));
    padding: 0.375rem 0.5rem;
    border-left: 0.1875rem solid var(--combat-edge);
    background: color-mix(in srgb, var(--combat-panel) 70%, transparent);
    border-radius: 0 0.25rem 0.25rem 0;
    animation: fade-in 0.3s ease;
}
.combat-log-line:last-child { border-left-color: var(--accent); }
.combat--side .combat-main .combat-go { min-width: 0; width: 100%; }

/* --- Narrow windows (761-1000 px): each side's plate under its art --- */

@media (min-width: 761px) and (max-width: 1000px) {
    .combat-field { --centre-w: clamp(14rem, 30vw, 17rem); --gap: 0.625rem; }
}

/* --- Phones: the enemies on top, you below the dice --- */

@media (max-width: 760px) {
    /* The field scrolls; the question stays in view at the bottom. */
    .combat-frame { padding: 0.5rem 0.625rem; gap: 0.5rem; }
    .combat-title { font-size: 1.05rem; }
    .combat-field {
        display: flex;
        flex-direction: column;
        gap: 0.625rem;
        overflow-y: auto;
        overscroll-behavior: contain;
    }
    .combat-side { flex: none; --art-room: calc(100cqw - 0.5rem); }
    .combat-side--enemy { order: 1; flex-direction: column; align-items: stretch; gap: 0.5rem; }
    .combat-centre { order: 2; flex: none; overflow: visible; padding: 0; gap: 0.375rem; }
    .combat-side--player { order: 3; align-items: stretch; justify-content: flex-start; gap: 0.625rem; }

    .combat-enemies {
        align-self: center;
        --room: calc(100cqw - 1.5rem);
        --cw: min(6.5rem, calc(var(--room) / var(--k)));
        padding: 0.25rem 0 0.875rem;
    }
    .combat-enemy-value { min-width: 1.75rem; height: 1.75rem; font-size: 0.9rem; bottom: -0.625rem; }

    /* Plates become a row: name on the left, the value on the right. */
    .combat-plate {
        width: auto;
        max-height: none;
        overflow: visible;
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas: "info value" "break break" "chips chips" "trophies trophies";
        align-items: center;
        gap: 0.25rem 0.625rem;
        padding: 0.5rem 0.75rem;
    }
    .combat-side--player .combat-plate { flex: 1; min-width: 0; }
    .combat-plate .combat-info { grid-area: info; text-align: left; }
    .combat-plate .combat-value { grid-area: value; }
    .combat-plate .combat-breakdown { grid-area: break; }
    .combat-plate .combat-chips { grid-area: chips; justify-content: flex-start; }
    .combat-plate .combat-trophies { grid-area: trophies; justify-content: flex-start; }

    .combat-portrait { height: 6.5rem; align-self: flex-start; }
    .combat-portrait-initial { font-size: 1.8rem; }

    .combat-value-n { font-size: 2rem; }
    .combat-breakdown { font-size: 0.72rem; }
    .combat-dice { min-height: 2.75rem; gap: 0.375rem; }
    .cdie { --size: 2.5rem; }
    .cdie--extra { --size: 2.1rem; }
    .combat-scores { gap: 0.625rem; }
    .combat-score { min-width: 4.75rem; padding: 0.25rem 0.5rem; }
    .combat-score-n { font-size: 2.5rem; }
    .combat-verdict-title { font-size: 1.65rem; }
    .combat-verdict-line { font-size: 0.82rem; }

    .combat-tray {
        --tray-card: 6.25rem;
        max-height: 46vh;
        box-shadow: 0 -0.5rem 1.25rem rgba(0, 0, 0, 0.25);
        padding: 0.5rem;
        gap: 0.375rem;
    }
    .combat-text { font-size: 0.85rem; }
    .combat-tray > .combat-options,
    .combat-tray > .combat-main { flex-basis: 100%; }
    .combat-options { gap: 0.375rem 1rem; }
    .combat-go { min-width: 10rem; padding: 0.7rem 1.5rem; }
    .combat-opt { max-width: 100%; }
    .cdie-caption { font-size: 0.66rem; }
    .cdie-group--captioned { max-width: 12.5rem; }
    .combat-sum { font-size: 0.74rem; }
    .combat-dicerule { font-size: 0.68rem; padding: 1px 0.375rem; }
}

@media (prefers-reduced-motion: reduce) {
    .combat *,
    .combat-ghost { animation: none !important; transition: none !important; }
}

/* Short laptop screens (1366x768, 1280x720): the art already goes by the
   field's height; the tray's cards, the dice and the scores are a little
   smaller so the field keeps its height. */
@media (min-width: 761px) and (max-height: 820px) {
    .combat-frame { padding-top: 0.375rem; padding-bottom: 0.375rem; gap: 0.5rem; }
    .combat-title { font-size: 1.15rem; }
    .combat-plate { gap: 0.25rem; padding: 0.5rem 0.75rem; }
    .combat-value-n { font-size: 2.1rem; }
    .combat-tray { --tray-card: clamp(5.75rem, 7.5vw, 7rem); max-height: 46vh; padding: 0.375rem 0.75rem; gap: 0.3rem 1.25rem; }
    .combat-text { font-size: 0.88rem; }
    .combat-card-does { -webkit-line-clamp: 1; }
    .combat-cards { padding-top: 0.25rem; padding-bottom: 0.25rem; }
    .combat-go { padding: 0.65rem 2rem; }
    .combat-centre { gap: 0.4rem; padding: 0.25rem 0; }
    .combat-dice { min-height: 3rem; }
    .combat-dice .cdie { --size: 2.75rem; }
    .combat-dice .cdie--extra { --size: 2.25rem; }
    .combat-scores { gap: 0.5rem; }
    .combat-score { min-width: 5.25rem; padding: 0.25rem 0.5rem 0.2rem; }
    .combat-score-n { font-size: 2.8rem; }
    .combat-score--before .combat-score-n::after { font-size: 0.7rem; }
    .combat-verdict-title { font-size: 2.1rem; }
}

/* A foe printed on the board: the tile it guards, its name over it. */
.combat-enemy-tile { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.combat-enemy:has(.combat-enemy-tile) .combat-enemy-name { position: relative; z-index: 1; padding: 0.3rem 0.6rem; border-radius: 0.3rem; background: rgb(0 0 0 / 0.65); color: #f2e6c8; }
