.battle-map {
    --bm-party: #a5c49e;
    --bm-opposition: #e79a76;
    --bm-threat: #ffad79;
    display: flex;
    flex-direction: column;
    flex: none;
    position: relative;
    background: #18221c;
    border: 1px solid #465448;
    border-radius: 8px;
    overflow: hidden;
    isolation: isolate;
}
.battle-map[hidden], .battle-map [hidden] { display: none }
.bm-head, .bm-tally, .bm-key { display: flex; align-items: center }
.bm-head { padding: 8px 12px 4px; gap: 8px; justify-content: space-between }
.bm-titles { display: flex; align-items: baseline; flex-wrap: wrap; gap: 3px 12px; min-width: 0 }
.bm-titles .bm-title { font: 1.22rem/1.1 Georgia,serif; margin: 0; letter-spacing: 0; overflow-wrap: anywhere }
.bm-round, .bm-table-link { font-size: .75rem; color: var(--muted); white-space: nowrap }
.bm-table-link { color: var(--gold); padding: 3px 0 }
.bm-tally { flex-wrap: wrap; gap: 3px 5px; padding: 3px 12px 6px; font-size: .73rem; font-variant-numeric: tabular-nums }
.bm-count { display: inline-block; padding: 1px 6px; color: #d8d2ba; border: 1px solid #506050; border-radius: 12px }
.bm-count.fighting { color: #ffbd95; border-color: #ab7152; background: #3b2b21 }
.bm-count.asleep { color: #d3c7e4; border-color: #786a86 }
.bm-count.surrendered { color: #d9caab; border-color: #847654 }
.bm-count.zero { color: #a0a99c; border-color: transparent; padding-inline: 2px }
.bm-party-count { color: var(--bm-party); margin-left: auto; font-weight: 600 }
.bm-floor {
    position: relative;
    height: clamp(184px,34dvh,370px);
    overflow: hidden;
    border-block: 1px solid #344337;
    background-color: #18201b;
    background-image: radial-gradient(ellipse at 50% 115%,#35513b50,transparent 67%), radial-gradient(ellipse at 45% -20%,#6b493030,transparent 65%);
}
.bm-ink { position: absolute; inset: 0; pointer-events: none }
.bm-lane { position: absolute; left: 6px; transform: translateY(-50%); color: #c0ad9b; font-size: .66rem; letter-spacing: .01em; pointer-events: none }
.bm-lane.ally { color: #a7bfa1 }
.bm-wall { fill: #657066; stroke: #a2a89a; stroke-width: .6 }
.bm-link { fill: none; stroke-width: 1.7; stroke-linecap: round }
.bm-link.enemy { stroke: #db8e70 }
.bm-link.ally { stroke: #8eb797 }
.bm-link.missile, .bm-link.spell { stroke-dasharray: 4 4 }
.bm-arrow.enemy { fill: #db8e70 }.bm-arrow.ally { fill: #8eb797 }
.bm-link.picked { stroke-width: 3 }.bm-link.subdued { opacity: .25 }
.bm-token {
    position: absolute;
    z-index: 1;
    display: grid;
    place-items: center;
    padding: 0;
    transform: translate(-50%,-50%);
    width: var(--token-size);
    height: var(--token-size);
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--bm-party);
    line-height: 1;
    font: 650 clamp(.65rem,1vw,.86rem)/1 system-ui,sans-serif;
    touch-action: manipulation;
}
.bm-token:hover, .bm-token:focus-visible { z-index: 3; background: transparent }
.bm-token[aria-pressed="true"] .bm-face, .bm-token:hover .bm-face { outline: 1px solid #f2e3a9; outline-offset: 2px }
.bm-token.enemy { color: var(--bm-opposition) }
.bm-face { display: grid; position: absolute; inset: 0; place-items: center; border: 1.5px solid currentColor; border-radius: 50%; background: #263a2b }
.bm-token.enemy .bm-face { background: #473024 }
.bm-face img { position:absolute; inset:0; height: 100%; width: 100%; border-radius: 50%; object-fit: cover; object-position: center 8% }
.bm-token.threatened .bm-face { box-shadow: 0 0 0 2px #18201b,0 0 0 4px var(--bm-threat) }
.bm-token.hidden-actor .bm-face { border-style: dashed }
.bm-token.inactive .bm-face { border-style: dashed; border-color: #a0a295; color:#d2d0c1; background:#303630 }
.bm-state-mark { position: absolute; top: -4px; right: -6px; min-width: 11px; padding: 1px 2px; border-radius: 3px; background: #39423a; color: #f5e9c6; font: bold 9px/1 system-ui,sans-serif }
.bm-name { position: absolute; top: calc(100% + 2px); left: 50%; transform: translateX(-50%); width:max-content; color: #e0e5d5; text-shadow: 0 1px 2px #000; white-space: nowrap; font: 500 .65rem/1 system-ui,sans-serif; max-width: min(120px,var(--token-label)); text-overflow: ellipsis; overflow: hidden }
.bm-enemy-label { color: #dac0a7; font-size: .61rem }
.bm-token.inactive .bm-enemy-label { color: #bdbfab }
.bm-health { display: block; margin: 2px auto 0; height: 3px; width: 76%; min-width: 17px; border-radius: 2px; background: #475047 }
.bm-health i { display: block; height: 100%; border-radius: inherit; background: #96c390 }
.bm-token[data-wounds="wounded"] .bm-health i { background: #deb667 }
.bm-token[data-wounds="badly wounded"] .bm-health i { background: #f29078 }
.bm-token.enemy[data-wounds="wounded"] .bm-face { background: #66452a; border-bottom: 3px solid #e8bc6d }
.bm-token.enemy[data-wounds="badly wounded"] .bm-face { background: #74362b; border-bottom: 4px double #ffaf94 }
.bm-key { color: #acb7a9; font-size: .66rem; gap: 7px 16px; padding: 4px 12px; flex-wrap: wrap }
.bm-key span { display: inline-flex; align-items: center; gap: 5px }
.bm-key i { width: 13px; height: 0; border-top: 2px solid #c1aa8f }
.bm-key .ranged { border-top-style: dashed }
.bm-key .threat { width: 9px; height: 9px; border: 1.5px solid var(--bm-threat); border-radius: 50% }
.bm-rear-threats { display:flex; align-items:baseline; gap:2px 8px; flex-wrap:wrap; padding:3px 11px; background:#392a20; color:#f2c2a0; font-size:.73rem }
.bm-rear-threats strong { font-weight:600 }
.bm-rear-threats button { padding:1px 0; border:0; border-radius:0; background:transparent; color:#f4d8bd; font:inherit; text-align:left; text-decoration:underline; text-underline-offset:2px; text-decoration-color:#9e7860 }
.bm-inspect { z-index:4; position: absolute; inset: auto 8px 5px; padding: 7px 32px 8px 10px; color: #e6eadc; background: #202d24; border: 1px solid #adb99b; border-radius: 5px; box-shadow: 0 4px 15px #0005; font-size: .78rem; line-height: 1.3; max-height: 70%; overflow: auto }
.bm-facts { display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: baseline }
.bm-facts strong { color: #eee2b9 }.bm-facts span { color: #c1cebd }
.bm-targets { margin-top: 2px }
.bm-close { position: absolute; top: 1px; right: 1px; padding: 3px 7px; color: #e4ddc6; font: 1.2rem/1 system-ui; background: transparent; border: 0 }
.bm-sync { color: var(--gold); font-size: .76rem; padding-inline: 12px }
.chat-page.in-battle .chat-chart, .chat-page.in-battle .party-strip { display: none }
.chat-page.in-battle .chat-heading { padding-bottom: 6px }
.chat-page.in-battle .play-field { margin-top: 3px }
.battle-table-mode .site-header { display: none }
main.battle-table-page { padding: clamp(6px,1.3vw,20px); min-height: 100dvh; max-width: 1680px; display: flex }
.battle-map-table { width: 100%; min-height: calc(100dvh - clamp(12px,2.6vw,40px)) }
.battle-map-table .bm-floor { flex: 1; min-height: 260px }
.battle-map-table .bm-head { padding: 14px 18px 6px }
.battle-map-table .bm-title { font-size: clamp(1.5rem,3vw,2.6rem) }
.battle-map-table .bm-tally { font-size: clamp(.8rem,1.3vw,1.2rem); padding: 4px 18px 10px }
.battle-map-table .bm-key { font-size: .85rem; padding: 8px 18px }
.battle-map-table .bm-name, .battle-map-table .bm-lane { font-size: clamp(.65rem,1.3vw,.96rem) }

.battle-map-table .bm-token { font-size: clamp(.8rem,2vw,1.5rem) }
.battle-map-table .bm-inspect { position:relative; inset:auto; margin:0 12px 10px; width:fit-content; max-width:calc(100% - 24px); font-size:.95rem }
.bm-idle { margin: auto; text-align: center; padding: 12px }.bm-idle h1 { font-size: 2.3rem }.bm-idle p { color: var(--muted) }
.battle-typing .site-header, .battle-typing .chat-heading, .battle-typing .composer .quiet { display:none }
.battle-typing .chat-page.in-battle { height:var(--battle-visible-height) }
.battle-typing .chat-page.in-battle .bm-floor { height:clamp(78px,calc(var(--battle-visible-height) * .27),145px) }
@media(max-width:600px) {
    .chat-page.in-battle { padding-inline: 8px; padding-top: 4px }
    .chat-page.in-battle .chat-heading h1 { font-size: 1rem }
    .chat-page.in-battle .chat-heading small { display:none }
    .chat-page.in-battle .chat-destinations a { padding: 3px 6px; font-size: .75rem }
    .bm-head { padding: 5px 7px 2px }.bm-titles { gap: 3px 6px }.bm-titles .bm-title { font-size: 1rem }
    .bm-tally { padding: 2px 6px 4px; gap: 2px 3px; font-size: .67rem }.bm-count { padding: 1px 4px }
    .bm-floor { height: clamp(175px,31dvh,256px) }
    .bm-lane { left: 3px; font-size: .6rem }.bm-key { padding: 2px 7px; gap: 4px 10px; font-size: .6rem }
    .bm-name { font-size: .58rem }
    .bm-rear-threats { padding:2px 7px; font-size:.68rem }
    .bm-token::after { content:''; position:absolute; inset:-3px }
    .battle-map-table .bm-tally { padding-inline: 8px }.battle-map-table .bm-head { padding-inline: 9px }
    
}
@media(max-width:440px) {
    body:has(.chat-page.in-battle) .site-header { gap:5px; padding-inline:8px }
    body:has(.chat-page.in-battle) .sigil { display:none }
    body:has(.chat-page.in-battle) .wordmark { white-space:normal; min-width:0; flex:1; font-size:.8rem; line-height:1.14 }
    body:has(.chat-page.in-battle) nav { gap:7px }
    body:has(.chat-page.in-battle) nav a { font-size:.72rem }
}
@media(max-height:570px) {
    .chat-page.in-battle .chat-heading, .chat-page.in-battle .composer .quiet { display:none }
    .chat-page.in-battle .bm-floor { height: clamp(78px,25dvh,144px) }
    .chat-page.in-battle .bm-name { font-size:.54rem;top:100% }
    .chat-page.in-battle .composer textarea {min-height:38px;height:40px}
    .chat-page.in-battle .suggestion { padding-block:3px }
    body:has(.in-battle #paragraph:focus) .site-header { display: none }
    body:has(.in-battle #paragraph:focus) .chat-page.in-battle { height: 100dvh }
}
