/* The Score window (score-window.js; design E "Face-off", owner 2026-11-21;
   teramud score-window-mockups.src.html). The theme's tokens, so Arcane,
   Daylight and every other theme draw it. One piece of markup; the shapes
   are container queries on the window itself, by both sides:
     strip    up to 130 high, or up to 340 high and at least 2.5x as wide:
              a ruled grid of cells, the fight first, as many rows as fit
     small    131-340 high, narrower than that: the face-off and numbers
     sidebar  taller, <= 300 wide: you above, the enemy below
     square   taller, 301-480 wide: the face-off spans the window
     large    taller and wider: bigger figures, every shield letter
   Fields carry p1..p5 (p = 6 - keep level). score-window.js measures: it
   shows every field, then drops whole keep levels, lowest first, only
   while something is hidden or clipped. Compact spacing (data-spacing on
   the window) only tightens the space; see the end of the shapes. */

/* not on a phone (the registry's phone: none), as the Compass and Scene:
   Play opens it pinned, and a phone's layout has no place for it */
body.lay-phone #scorewin { display: none !important; }

#scorewin {
  --sw-ink: var(--ink); --sw-raised: var(--ink-raised); --sw-high: var(--ink-high);
  --sw-rule: var(--rule); --sw-rule-strong: var(--rule-strong);
  --sw-text: var(--parchment); --sw-bright: var(--parchment-bright); --sw-muted: var(--muted);
  --sw-gilt: var(--gilt); --sw-gilt-bright: var(--gilt-bright); --sw-ember: var(--ember); --sw-verd: var(--verdigris);
  --sw-hp: var(--vitals-health); --sw-mp: var(--vitals-mana); --sw-vp: var(--vitals-vitality);
  --sw-el: color-mix(in srgb, var(--i9) 65%, var(--i11));
  --sw-ph: color-mix(in srgb, var(--i12) 50%, var(--muted));
  --sw-mi: var(--i13);
  --sw-ice: color-mix(in srgb, var(--i14) 70%, var(--parchment));
  --sw-moon: var(--ink-high);
  --bg: var(--ink-high);
  position: absolute;
  z-index: 4;
  container: sw / size;
  width: 360px; height: 360px;
  min-width: 150px; min-height: 40px;
  max-width: calc(100vw - 16px); max-height: calc(100vh - 16px);
  background: var(--sw-high);
  border: 1px solid var(--sw-gilt);
  box-shadow: var(--shadow);
  overflow: hidden;
  resize: both;
  color: var(--sw-text);
}
#scorewin[hidden] { display: none; }
#scorewin:focus { outline: none; }
#scorewin * { box-sizing: border-box; }
#scorewin .win { position: absolute; inset: 0; display: flex; flex-direction: column; overflow: hidden;
  font: 13px/1.4 "Marcellus", Georgia, serif; text-rendering: optimizeLegibility; }
#scorewin .hd { flex: none; display: flex; align-items: center; justify-content: space-between; height: 22px; padding: 0 3px 0 9px;
  color: var(--sw-gilt); border-bottom: 1px solid var(--sw-rule); font-size: 12px; letter-spacing: .05em; white-space: nowrap; overflow: hidden;
  cursor: move; touch-action: none; user-select: none; }
/* the title gives way first: the buttons, the × last of all, always show */
#scorewin .hd .ti { flex: 0 1 auto; min-width: 0; overflow: hidden; }
#scorewin .hd .hb { flex: none; display: inline-flex; align-items: center; gap: 1px; margin-left: auto; }
#scorewin .hd button { background: none; border: 0; padding: 0 4px; margin: 0; color: var(--sw-muted); font: 14px/1 "Marcellus", Georgia, serif; cursor: pointer; min-width: 0; height: 20px; }
#scorewin .hd .hb > button { flex: none; width: 24px; margin: 0; padding: 0; }
@container sw (width < 200px) {
  #scorewin .hd { padding-left: 4px; }
  #scorewin .hd .ti { display: none; }
  #scorewin .hd .hb { gap: 0; }
  #scorewin .hd .hb > button { width: 22px; }
}
#scorewin .hd button:hover, #scorewin .hd button:focus-visible { color: var(--sw-gilt-bright); }
#scorewin .hd button:focus-visible { outline: 1px solid var(--sw-gilt); }
#scorewin .bd { flex: 1; min-width: 0; min-height: 0; overflow: hidden; padding: 6px; display: grid; gap: 5px; grid-template-columns: minmax(0, 1fr); align-content: start; }
#scorewin .sw-empty { margin: 4px; color: var(--sw-muted); font-style: italic; }
#scorewin .g { min-width: 0; display: flex; flex-direction: column; }
#scorewin .lbl { color: var(--sw-gilt); font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase; white-space: nowrap; margin-bottom: 2px; }
#scorewin .fs { display: grid; grid-template-columns: minmax(0, 1fr); flex: 1; align-content: space-evenly; min-width: 0; }
#scorewin .f { position: relative; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; min-width: 0; white-space: nowrap; }
#scorewin .k { color: var(--sw-muted); flex: none; }
#scorewin .ks { display: none; }
#scorewin .v { position: relative; text-align: right; min-width: 0; }
/* A value too wide for its line moves below its label, then wraps; it never
   runs out of its field (fit() hides fields only for want of height). */
#scorewin :is(.fs .v, .duel .f-name .v, .duel .f-position .v, .cd .v, .vt .v) { white-space: normal; overflow-wrap: anywhere; }
#scorewin .vt .mx { display: inline-block; }
/* a number, the alignment and the vitals' figures stay whole */
#scorewin :is(.fs .n, .vt .cur, .vt .mx) { white-space: nowrap; overflow-wrap: normal; }
#scorewin .n { font-family: "Spectral", Georgia, serif; font-variant-numeric: tabular-nums lining-nums; color: var(--sw-bright); }
#scorewin .m2, #scorewin .m { color: var(--sw-muted); font-family: "Marcellus", serif; }
#scorewin .sl { color: var(--sw-muted); padding: 0 1px; }
#scorewin .mx { color: var(--sw-muted); }
#scorewin .ab { font-family: "IBM Plex Mono", monospace; font-size: .85em; color: var(--sw-ice); border: 1px solid color-mix(in srgb, var(--sw-ice) 45%, transparent); padding: 0 3px; }
#scorewin .lg { color: var(--sw-muted); display: none; }
#scorewin .f-gold .n { color: var(--sw-gilt-bright); }
#scorewin .f-exp .n { color: var(--sw-mi); }
#scorewin .f-time .n, #scorewin .f-worldtime .n { color: var(--sw-text); }
#scorewin .f-position .v { font-family: "Spectral", serif; font-style: italic; color: var(--sw-el); }
#scorewin .f-wounded .v { color: var(--sw-ember); }
#scorewin .f-name .v { color: var(--sw-gilt-bright); }
#scorewin .g-imm .n { color: var(--sw-ph); }
#scorewin .f-al { align-items: center; }
#scorewin .f-al .v { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
#scorewin .f-al .v > * { flex: none; }
#scorewin .ecl { flex: none; }
#scorewin .al-diabolical { color: var(--sw-ember); font-weight: 600; }
#scorewin .al-evil { color: var(--sw-ember); }
#scorewin .al-neutral { color: var(--sw-text); }
#scorewin .al-true-neutral { color: var(--sw-bright); }
#scorewin .al-good { color: var(--sw-verd); }
#scorewin .al-heavenly { color: var(--sw-gilt-bright); }
/* the delta tags: −77, +120, rising and fading */
#scorewin .dl { position: absolute; right: 100%; top: 0; margin-right: 6px; pointer-events: none; }
#scorewin .dl > i { position: absolute; right: 0; top: -.1em; font: italic 12px/1.4 "Spectral", serif; white-space: nowrap;
  background: var(--bg); padding: 0 3px; border-radius: 2px; animation: sw-delta 2.6s linear forwards; }
@keyframes sw-delta { 0% { opacity: 0; transform: translateY(4px); } 8% { opacity: 1; transform: none; } 60% { opacity: 1; transform: translateY(-2px); } 100% { opacity: 0; transform: translateY(-7px); } }
#scorewin .up { color: var(--sw-vp); } #scorewin .down { color: var(--sw-ember); } #scorewin .dg { color: var(--sw-gilt-bright); } #scorewin .dx { color: var(--sw-mi); }
/* vitals */
#scorewin .f-health { --c: var(--sw-hp); } #scorewin .f-mana { --c: var(--sw-mp); } #scorewin .f-vitality { --c: var(--sw-vp); }
#scorewin .vt { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 8px; align-items: baseline; }
#scorewin .vt .k { color: var(--c); }
#scorewin .vt .v { position: static; }
#scorewin .vt .dl { right: 0; top: auto; bottom: 0; margin: 0; z-index: 2; }
#scorewin .vt .dl > i { top: auto; bottom: 0; font-size: 11px; line-height: 1.15; }
#scorewin .bar { grid-column: 1 / -1; height: 6px; background: var(--sw-rule); position: relative; overflow: hidden; margin: 1px 0 4px; }
#scorewin .bar > b, #scorewin .pm > b { position: absolute; inset: 0 auto 0 0; background: var(--c); transition: width .45s ease-out, background-color .45s; }
/* conditions: the game's seven words, colour graded, with a seven-step meter */
#scorewin .cd { flex-wrap: wrap; }
#scorewin .pm { display: none; flex: 0 0 100%; height: 4px; background: var(--sw-rule); position: relative; overflow: hidden; margin: 1px 0 4px; }
#scorewin .pm::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 calc(100% / 7 - 2px), var(--bg) calc(100% / 7 - 2px) calc(100% / 7)); }
#scorewin .c7, #scorewin .c6 { color: var(--sw-vp); } #scorewin .c5 { color: color-mix(in srgb, var(--sw-vp) 50%, var(--sw-gilt-bright)); } #scorewin .c4 { color: var(--sw-gilt-bright); }
#scorewin .c3 { color: var(--sw-el); } #scorewin .c2, #scorewin .c1 { color: var(--sw-ember); } #scorewin .c0 { color: var(--sw-muted); }
#scorewin .pm > b.g7, #scorewin .pm > b.g6 { background: var(--sw-vp); } #scorewin .pm > b.g5 { background: color-mix(in srgb, var(--sw-vp) 50%, var(--sw-gilt-bright)); }
#scorewin .pm > b.g4 { background: var(--sw-gilt-bright); } #scorewin .pm > b.g3 { background: var(--sw-el); } #scorewin .pm > b.g2, #scorewin .pm > b.g1 { background: var(--sw-ember); } #scorewin .pm > b.g0 { background: transparent; }
/* a field drawn as only a bar, or only a number */
#scorewin .form-number .bar, #scorewin .form-number .pm { display: none !important; }
#scorewin .form-bar .v { visibility: hidden; }
#scorewin .form-bar.cd .v { display: none; }
#scorewin .form-bar.cd .pm { display: block; }
/* shields: the prompt's letters, each its own colour */
#scorewin .shs { display: inline-flex; flex-wrap: wrap; gap: 3px; align-items: baseline; }
#scorewin .sh { font: 400 .82em/1.25 "IBM Plex Mono", monospace; width: 1.35em; text-align: center; border: 1px solid currentColor; }
#scorewin .sh:not(.on) { display: none; opacity: .28; }
#scorewin .shs .none { color: var(--sw-muted); }
#scorewin .sB { color: var(--sw-ph); } #scorewin .sF { color: var(--sw-ember); } #scorewin .sC { color: var(--sw-mp); } #scorewin .sN { color: var(--sw-mi); }
#scorewin .sP { color: var(--sw-ice); } #scorewin .sT { color: var(--sw-vp); } #scorewin .sE { color: var(--sw-gilt-bright); } #scorewin .sI { color: var(--sw-muted); } #scorewin .sS { color: var(--sw-bright); }
#scorewin .grip { position: absolute; right: 1px; bottom: 1px; width: 10px; height: 10px; pointer-events: none;
  background: linear-gradient(135deg, transparent 0 55%, var(--sw-rule-strong) 55% 62%, transparent 62% 75%, var(--sw-rule-strong) 75% 82%, transparent 82%); }

/* ---------- E · Face-off ---------- */
#scorewin .duel { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); grid-template-areas: "n vs pp" "hp vs vc" "mp . vp"; gap: 1px 0; align-items: end; }
#scorewin .duel::before { content: "vs"; grid-area: vs; align-self: center; padding: 0 9px; font: italic 13px "Spectral", serif; color: var(--sw-muted); }
#scorewin .duel .f-name { grid-area: n; } #scorewin .duel .f-position { grid-area: pp; } #scorewin .duel .f-health { grid-area: hp; }
#scorewin .duel .f-enemy { grid-area: vc; } #scorewin .duel .f-mana { grid-area: mp; } #scorewin .duel .f-vitality { grid-area: vp; }
#scorewin .duel .f-name .k, #scorewin .duel .f-position .k, #scorewin .duel .f-enemy .k { display: none; }
#scorewin .duel .f-name { justify-content: flex-start; } #scorewin .duel .f-name .v { font-size: 16px; }
#scorewin .duel .f-position { justify-content: flex-end; }
#scorewin .f-health .bar, #scorewin .f-enemy .pm { height: 11px; margin: 1px 0 5px; }
#scorewin .f-enemy { justify-content: flex-end; }
#scorewin .f-enemy .pm { display: block; transform: scaleX(-1); }
#scorewin .f-health .cur { font-size: 17px; line-height: 1.1; }
#scorewin .f-enemy .v { font-size: 14px; }
#scorewin .f-mana .bar, #scorewin .f-vitality .bar { height: 3px; }
/* out of combat: no enemy side; your bars span the window */
#scorewin .duel.solo { grid-template-columns: minmax(0, 1fr) 14px minmax(0, 1fr); grid-template-areas: "n n pp" "hp hp hp" "mp . vp"; }
#scorewin .duel.solo::before { content: none; }
#scorewin .g { flex-direction: row; gap: 10px; align-items: baseline; border-top: 1px solid var(--sw-rule); padding-top: 3px; }
#scorewin .lbl { flex: 0 0 58px; margin: 0; color: var(--sw-verd); }
#scorewin .fs { display: flex; flex-wrap: wrap; gap: 1px 16px; align-content: flex-start; }
#scorewin .fs .f { justify-content: flex-start; gap: 0 6px; flex-wrap: wrap; max-width: 100%; }
#scorewin .fs :is(.f-gold, .f-exp) .v { display: inline-flex; align-items: baseline; gap: 5px; }
#scorewin .fs .dl { position: static; order: 2; display: inline-grid; margin: 0; }
#scorewin .fs .dl > i { position: static; grid-area: 1 / 1; background: none; padding: 0; }

/* ================= shapes =================
   Chosen by both sides of the window. Each shape names itself in
   --sw-shape (score-window.js reads it to fit the fields). Nothing here
   hides a field: the script drops whole keep levels, lowest first, only
   while something does not fit (data-drop on the window). */
#scorewin .bd { --sw-shape: square; }
/* roomy windows: square and large name their areas */
@container sw (height > 340px) and (width > 300px) {
  #scorewin .bd { align-content: stretch; }
}
/* SQUARE */
@container sw (height > 340px) and (300px < width <= 480px) {
  #scorewin .bd { --sw-shape: square; font-size: 12px; line-height: 1.3; align-content: space-between; }
  #scorewin .fs .kl { display: none; } #scorewin .fs .ks { display: inline; }
}
/* LARGE */
@container sw (height > 340px) and (width > 480px) {
  #scorewin .bd { --sw-shape: large; font-size: 15px; gap: 7px; align-content: space-between; padding: 10px 14px; }
  #scorewin .pm { display: block; } #scorewin .lg { display: inline; } #scorewin .sh:not(.on) { display: inline-block; } #scorewin .shs .none { display: none; }
  #scorewin .lbl { font-size: 11px; }
  #scorewin .f-shields { flex-wrap: wrap; } #scorewin .f-shields .v { gap: 2px; } #scorewin .sh { font-size: .74em; }
  #scorewin .duel .f-name .v { font-size: 24px; } #scorewin .duel .f-position .v { font-size: 17px; }
  #scorewin .f-health .cur { font-size: 30px; } #scorewin .f-enemy .v { font-size: 20px; }
  #scorewin .f-health .bar, #scorewin .f-enemy .pm { height: 18px; margin-bottom: 8px; }
  #scorewin .f-mana .bar, #scorewin .f-vitality .bar { height: 5px; }
  #scorewin .duel::before { font-size: 18px; padding: 0 16px; }
  #scorewin .lbl { flex-basis: 76px; } #scorewin .fs { gap: 2px 26px; }
  #scorewin .fs .cd { flex-wrap: wrap; width: 215px; } #scorewin .f-wounded { order: 1; }
}
/* SIDEBAR: who and where you are, you, the enemy below, then the groups,
   Self first. Top-aligned; fit() grows the sizes and the spacing into spare
   height (--sw-z, --sw-gap) rather than leave a void at the bottom. */
@container sw (height > 340px) and (width <= 300px) {
  #scorewin .bd { --sw-shape: sidebar; --z: var(--sw-z, 1); --gp: var(--sw-gap, 5px);
    align-content: start; gap: var(--gp); padding: calc(var(--gp) * .6 + 5px) 10px 8px; font-size: calc(13px * var(--z)); }
  #scorewin .hero { order: -2; } #scorewin .g-self { order: -1; }
  #scorewin .pm { display: block; }
  #scorewin :is(.g-company, .g-stance) .kl { display: none; } #scorewin :is(.g-company, .g-stance) .ks { display: inline; }
  #scorewin .duel { grid-template-columns: minmax(0, 1fr); grid-template-areas: "n" "pp" "hp" "mp" "vp" "vs" "vc"; row-gap: calc(1px + (var(--gp) - 5px) * .25); }
  #scorewin .duel.solo { grid-template-columns: minmax(0, 1fr); grid-template-areas: "n" "pp" "hp" "mp" "vp"; }
  #scorewin .duel::before { justify-self: center; padding: calc(var(--gp) * .3) 0; font-size: calc(13px * var(--z)); }
  #scorewin .duel .f-position, #scorewin .f-enemy { justify-content: flex-start; } #scorewin .f-enemy .pm { transform: none; }
  #scorewin .duel .f-position { margin-bottom: calc(var(--gp) * .4); } #scorewin .duel .f-position .v { text-align: left; }
  #scorewin .duel .f-name .v { font-size: min(calc(16px * var(--z)), 11cqi); text-align: left; }
  #scorewin .f-health .cur { font-size: min(calc(24px * var(--z)), 15cqi); }
  #scorewin .f-health .bar, #scorewin .f-enemy .pm { height: calc(13px * var(--z)); }
  #scorewin .f-mana .bar, #scorewin .f-vitality .bar { height: calc(3px * var(--z) + .5px); }
  #scorewin .f-enemy .v { font-size: min(calc(16px * var(--z)), 10.5cqi); text-align: left; }
  #scorewin .g { flex-direction: column; gap: 1px; padding-top: calc(var(--gp) * .45 + 1px); } #scorewin .lbl { flex: none; margin-bottom: calc((var(--z) - 1) * 6px); }
  #scorewin .fs { gap: calc(1px + (var(--z) - 1) * 8px) 14px; }
  #scorewin .fs .pm { display: none; }
}
@container sw (height > 340px) and (height <= 430px) and (width <= 300px) { #scorewin .pm { display: none; } }
/* a short window keeps a slim header */
@container sw (130px < height <= 340px) {
  #scorewin .hd { height: 17px; font-size: 10.5px; } #scorewin .hd button { font-size: 12px; height: 16px; }
}
/* SMALL: short and not much wider than high: the face-off and a line of numbers */
@container sw (130px < height <= 340px) and (aspect-ratio < 5/2) {
  #scorewin .bd { --sw-shape: small; display: flex; flex-wrap: wrap; padding: 4px 7px; gap: 2px 14px; font-size: 12.5px; align-content: space-evenly; }
  #scorewin .hero { flex: 0 0 100%; }
  #scorewin :is(.g, .fs) { display: contents; } #scorewin .lbl { display: none; }
  #scorewin .kl { display: none; } #scorewin .ks { display: inline; }
  #scorewin .vt .bar { height: 4px; margin-bottom: 2px; }
  #scorewin .duel { grid-template-columns: minmax(0, 1fr) 8px minmax(0, 1.15fr); grid-template-areas: "n . pp" "hp vs vc" "mp . vp"; }
  #scorewin .duel.solo { grid-template-columns: minmax(0, 1fr) 8px minmax(0, 1fr); grid-template-areas: "n n pp" "hp hp hp" "mp . vp"; }
  #scorewin .duel .vt { column-gap: 4px; } #scorewin .f-enemy .v { font-size: 12px; } #scorewin .duel::before { content: ""; padding: 0; }
  #scorewin .duel.solo::before { content: none; }
  #scorewin .duel .f-name .v { font-size: 13px; }
  #scorewin .f-health .bar, #scorewin .f-enemy .pm { height: 9px; }
  #scorewin .f-health .cur { font-size: 14px; }
  #scorewin .g { border: 0; padding: 0; }
  #scorewin .fs .cd { flex-wrap: nowrap; }
}
@container sw (130px < height <= 340px) and (aspect-ratio < 5/2) and (width >= 420px) {
  #scorewin .duel { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); grid-template-areas: "n vs pp" "hp vs vc" "mp . vp"; }
  #scorewin .duel.solo { grid-template-columns: minmax(0, 1fr) 14px minmax(0, 1fr); grid-template-areas: "n n pp" "hp hp hp" "mp . vp"; }
  #scorewin .duel:not(.solo)::before { content: "vs"; padding: 0 9px; }
}
/* STRIP: low, or short and wide. Every field one cell of a single grid that
   fills column by column; the script sets --rows to the fewest rows that
   fit the width (no more than the height holds). */
@container sw (height <= 130px) or ((height <= 340px) and (aspect-ratio >= 5/2)) {
  #scorewin .bd { --sw-shape: strip; display: grid; grid-auto-flow: column; grid-template-rows: repeat(var(--rows, 3), minmax(0, 1fr)); grid-template-columns: none; grid-auto-columns: auto;
    gap: 0; padding: 3px 0; font-size: 12px; align-content: stretch; justify-content: space-between; }
  #scorewin :is(.g, .fs, .hero) { display: contents; } #scorewin .lbl { display: none; }
  #scorewin .f { padding: 0 8px; border: 0; border-left: 1px solid var(--sw-rule); background: none; justify-content: space-between; gap: 7px; align-items: center;
    flex-direction: row; flex-wrap: nowrap; grid-area: auto; margin: 0; min-width: max-content; }
  #scorewin .kl { display: none; } #scorewin .ks { display: inline; }
  #scorewin .k { font-size: 11px; letter-spacing: .02em; text-transform: none; }
  #scorewin .v, #scorewin :is(.fs .v, .duel .f-name .v, .duel .f-position .v, .cd .v, .vt .v) { font-size: 12px; text-align: right; white-space: nowrap; }
  #scorewin .vt { display: flex; } #scorewin .vt .v { margin-left: auto; justify-self: auto; position: static; } #scorewin .vt .cur { font-size: 12px; }
  #scorewin .vt .bar { order: 3; flex: none; width: 40px; height: 5px; margin: 0; }
  #scorewin .pm { display: none !important; }
  #scorewin .dl { left: auto; right: 100%; top: 0; bottom: auto; margin: 0 4px 0 0; }
  #scorewin .dl > i { left: auto; right: 0; top: -.1em; bottom: auto; font-size: 12px; }
  /* a vital's change sits over its bar, never over its label */
  #scorewin .vt .dl { right: 8px; top: 50%; bottom: auto; margin: 0; }
  #scorewin .vt .dl > i { right: 0; top: auto; bottom: auto; transform: translateY(-50%); font-size: 11.5px; line-height: 1.3; animation-name: sw-delta-mid; }
  #scorewin .duel::before { display: none; }
  #scorewin .duel .f, #scorewin .duel.solo .f { grid-area: auto; }
  #scorewin .f-health { order: -6; } #scorewin .f-mana { order: -5; } #scorewin .f-vitality { order: -4; } #scorewin .f-name { order: -3; } #scorewin .f-position { order: -2; } #scorewin .f-enemy { order: -1; }
  #scorewin .duel :is(.f-enemy, .f-position, .f-name) .k { display: inline; }
  #scorewin .duel .f-name .v, #scorewin .f-enemy .v, #scorewin .duel .f-position .v { font-size: 12px; }
  #scorewin :is(.f-health, .f-mana, .f-vitality) .bar { height: 5px; }
  #scorewin .f-health .cur { font-size: 12px; }
}
/* a strip with room to spare: a little larger */
@container sw (130px < height <= 340px) and (aspect-ratio >= 5/2) {
  #scorewin .bd { padding: 4px 0; font-size: 13px; }
  #scorewin .f { padding: 0 11px; }
  #scorewin :is(.v, .vt .cur, .duel .f-name .v, .f-enemy .v, .duel .f-position .v) { font-size: 13.5px; }
  #scorewin .k { font-size: 12px; }
  #scorewin .vt .bar { width: 56px; height: 6px; }
}
/* the lowest the window may go: a strip with no header */
@container sw (height <= 130px) {
  #scorewin .win { flex-direction: row; }
  #scorewin .hd { width: 13px; height: auto; padding: 0; border-bottom: 0; border-right: 1px solid var(--sw-rule);
    background: repeating-linear-gradient(0deg, transparent 0 3px, var(--sw-rule-strong) 3px 4px) center / 5px 26px no-repeat; }
  #scorewin .hd > * { display: none; }
}
@keyframes sw-delta-mid { 0% { opacity: 0; transform: translateY(-30%); } 8% { opacity: 1; transform: translateY(-50%); } 60% { opacity: 1; transform: translateY(-60%); } 100% { opacity: 0; transform: translateY(-80%); } }

/* ---------- compact spacing (`scorewin spacing compact`, owner 2026-11-21) ----------
   Only space changes: text sizes, colours and which values show stay. The
   strip's columns sit at their own width with a small fixed gap, packed
   from the left (the rest of the width stays empty at the right), each
   label close to its value; its rows are one line and a little (22px, as
   fit()'s STRIP_COMPACT), as many as the height holds, packed at the top. Sidebar, square and large keep their groups close
   with less padding, and spare height is not spread between them. Small is
   nearly as it is. */
@container sw (height > 340px) and (width > 300px) {
  #scorewin[data-spacing="compact"] .bd { align-content: start; gap: 3px; padding: 4px 6px; }
  #scorewin[data-spacing="compact"] .g { gap: 7px; padding-top: 2px; }
  #scorewin[data-spacing="compact"] .fs { gap: 0 11px; }
}
@container sw (height > 340px) and (width > 480px) {
  #scorewin[data-spacing="compact"] .bd { gap: 4px; padding: 6px 9px; }
  #scorewin[data-spacing="compact"] .fs { gap: 1px 16px; }
  #scorewin[data-spacing="compact"] .f-health .bar, #scorewin[data-spacing="compact"] .f-enemy .pm { margin-bottom: 4px; }
}
@container sw (height > 340px) and (width <= 300px) {
  #scorewin[data-spacing="compact"] .bd { --gp: var(--sw-gap, 4px); padding: calc(var(--gp) * .4 + 3px) 7px 5px; }
}
@container sw (130px < height <= 340px) and (aspect-ratio < 5/2) {
  #scorewin[data-spacing="compact"] .bd { gap: 2px 10px; padding: 3px 6px; }
}
@container sw (height <= 130px) or ((height <= 340px) and (aspect-ratio >= 5/2)) {
  #scorewin[data-spacing="compact"] .bd { justify-content: start; align-content: start; grid-template-rows: repeat(var(--rows, 3), minmax(0, 22px)); }
  #scorewin[data-spacing="compact"] .f { padding: 0 6px; gap: 4px; justify-content: flex-start; }
}

/* a strip too small for even the keep-5 fields whole (fitFields' last
   resort): the columns share the width, the bars shrink, a value is cut off
   at its field's edge; nothing runs past the window */
#scorewin[data-tight] .bd { grid-auto-columns: minmax(0, 1fr); justify-content: stretch; }
#scorewin[data-tight] .f { min-width: 0; overflow: hidden; padding: 0 4px; gap: 4px; }
#scorewin[data-tight] .vt .bar { flex: 1 1 0; width: auto; min-width: 0; }
#scorewin[data-tight] .v { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
/* the corner grip only where the corner resizes the window: not pinned to an
   edge (the side's divider sizes it), maximized, locked or attached */
#scorewin:is(.lay-pinned, .lay-max, .lay-locked, .lay-attached, .lay-sheet) .grip { display: none; }
body.lay-arranging #scorewin .grip { display: none; }

/* fields drop by keep level, the lowest first, only while they don't fit
   (score-window.js fit()); maxes go with their value, last of all */
#scorewin:is([data-drop="1"], [data-drop="2"], [data-drop="3"], [data-drop="4"], [data-drop="5"]) :is(.p5, .gp5) { display: none; }
#scorewin:is([data-drop="2"], [data-drop="3"], [data-drop="4"], [data-drop="5"]) :is(.p4, .gp4) { display: none; }
#scorewin:is([data-drop="3"], [data-drop="4"], [data-drop="5"]) :is(.p3, .gp3) { display: none; }
#scorewin:is([data-drop="4"], [data-drop="5"]) :is(.p2, .gp2) { display: none; }
#scorewin[data-drop="5"] .mx { display: none; }

/* ---------- the field panel (≡) ---------- */
.sw-fields { position: fixed; z-index: 12; width: 470px; max-width: calc(100vw - 8px); max-height: calc(100vh - 8px); display: flex; flex-direction: column;
  font: 13px/1.4 "Marcellus", Georgia, serif; background: var(--ink-high); border: 1px solid var(--gilt); box-shadow: var(--shadow); color: var(--parchment); }
.sw-fields[hidden] { display: none; }
.sw-fields:focus { outline: none; }
.sw-fields .hd { flex: none; display: flex; align-items: center; justify-content: space-between; height: 24px; padding: 0 3px 0 9px; color: var(--gilt);
  border-bottom: 1px solid var(--rule); font-size: 12px; letter-spacing: .05em; }
.sw-fields button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; }
.sw-fields button:focus-visible { outline: 1px solid var(--gilt); outline-offset: 1px; }
.sw-fields .hd .panel-close { color: var(--muted); font-size: 14px; padding: 0 5px; }
.sw-fields-scroll { overflow: auto; min-height: 0; }
.sw-fields table { border-collapse: collapse; width: 100%; }
.sw-fields th { font: 400 10.5px "Marcellus", serif; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); text-align: left; padding: 6px 6px 3px; border-bottom: 1px solid var(--rule); }
.sw-fields td { padding: 2px 6px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.sw-fields tr.off td { color: var(--muted); }
.sw-fields tr.off .nm { text-decoration: line-through; text-decoration-color: var(--rule-strong); }
.sw-fields .nm .m { color: var(--muted); font-size: 11px; }
.sw-fields td.ck { width: 11px; padding-left: 5px; padding-right: 4px; }
/* drag a row to a new place: grab it anywhere but its controls; the grip
   at its start shows where. The row lifts (.sw-lift, a copy over the page),
   the others slide apart to open its gap (.sw-hole), the drop settles it. */
.sw-fields td.hdl { --dot: radial-gradient(circle, var(--muted) 1px, transparent 1.3px); width: 9px; padding: 0 0 0 5px;
  background: var(--dot) 5px 50% / 4px 4px repeat-y, var(--dot) 9px 50% / 4px 4px repeat-y; background-clip: content-box; }
.sw-fields tr[data-k] { cursor: grab; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.sw-fields tr:hover td.hdl { --dot: radial-gradient(circle, var(--gilt) 1px, transparent 1.3px); }
html.sw-grabbing, html.sw-grabbing * { cursor: grabbing !important; }
.sw-fields.sw-sorting tr[data-k] { transition: transform 150ms cubic-bezier(.2, .7, .3, 1); }
.sw-fields tr.sw-hole > td { color: transparent; text-decoration: none; background: color-mix(in srgb, var(--gilt) 8%, transparent);
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--gilt) 30%, transparent), inset 0 -1px 0 color-mix(in srgb, var(--gilt) 30%, transparent); }
.sw-fields tr.sw-hole > td > * { visibility: hidden; }
.sw-fields tr.sw-landing > td { visibility: hidden; }
.sw-fields.sw-lift { position: fixed; z-index: 1000; width: auto; max-width: none; max-height: none; display: block; pointer-events: none;
  background: var(--ink-high); border: 1px solid var(--gilt); box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transform-origin: 50% 50%;
  transition: transform 120ms ease-out, box-shadow 120ms ease-out, opacity 120ms; }
.sw-fields.sw-lift.up { transform: scale(1.025); border-color: var(--gilt-bright);
  box-shadow: 0 10px 22px rgba(0, 0, 0, .5), 0 2px 5px rgba(0, 0, 0, .35), 0 0 0 1px color-mix(in srgb, var(--gilt-bright) 35%, transparent); }
.sw-fields.sw-lift.out { opacity: .55; }
.sw-fields.sw-lift.settle { transition: top 150ms cubic-bezier(.2, .7, .3, 1), transform 150ms, box-shadow 150ms; }
.sw-fields.sw-lift table { table-layout: fixed; width: 100%; }
.sw-fields.sw-lift tr { cursor: grabbing; }
.sw-fields.sw-lift td { border-bottom-color: transparent; }
@media (prefers-reduced-motion: reduce) {
  .sw-fields.sw-sorting tr[data-k], .sw-fields.sw-lift, .sw-fields.sw-lift.settle { transition: none; }
}
.sw-fields .bx { display: inline-block; width: 11px; height: 11px; border: 1px solid var(--gilt); vertical-align: -1px; position: relative; }
.sw-fields .bx[aria-checked="true"]::after { content: ""; position: absolute; inset: 2px; background: var(--gilt-bright); }
.sw-fields .seg { display: inline-flex; border: 1px solid var(--rule-strong); font-size: 11.5px; }
.sw-fields .seg button { padding: 0 6px; color: var(--muted); }
.sw-fields .seg button[aria-pressed="true"] { background: var(--rule-strong); color: var(--parchment-bright); }
.sw-fields .pips { display: inline-flex; gap: 2px; }
.sw-fields .pips button { width: 9px; height: 9px; border: 1px solid var(--gilt); }
.sw-fields .pips button[aria-pressed="true"] { background: var(--gilt); }
.sw-fields .tok { font: 11.5px "IBM Plex Mono", monospace; color: var(--muted); }
.sw-fields .foot { flex: none; padding: 7px 9px 8px; display: flex; flex-direction: column; gap: 3px; }
.sw-fields .foot .m { color: var(--muted); font-size: 12px; }
.sw-fields .spc { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.sw-fields .spc .m { font-size: 12px; }
.sw-fields .acts { display: flex; gap: 8px; margin-bottom: 3px; }
.sw-fields .acts button { border: 1px solid var(--rule-strong); padding: 1px 9px; color: var(--parchment); }
.sw-fields .acts button:hover { border-color: var(--gilt); color: var(--gilt); }
/* a command as typed: fixed width; what you fill in italic gold with faint brackets */
.sw-fields .cmd { font-family: "IBM Plex Mono", ui-monospace, Consolas, monospace; font-size: .84em; color: var(--parchment-bright); white-space: nowrap; }
.sw-fields .cmd .arg { font-style: italic; color: var(--gilt-bright); }
.sw-fields .cmd .br { opacity: .4; font-style: normal; }

/* Settings › Score window: the field panel's controls, inline */
.sw-fields.sw-inline { position: static; z-index: auto; width: auto; max-width: none; max-height: none; background: none; border: 0; box-shadow: none; margin-top: 8px; }
.sw-fields.sw-inline .foot { padding-left: 0; padding-right: 0; }
#sec-scorewin h3 { margin: 0 0 4px; }

/* the window's menu (right-click, the Menu key, Shift+F10): the line
   menu's look (triggers.css #line-menu) */
#scorewin-menu { position: fixed; z-index: 20; min-width: 220px; padding: 4px 0; background: var(--ink-high); border: 1px solid var(--rule-strong);
  box-shadow: var(--shadow); font-family: var(--chrome-font); font-size: var(--chrome-size); color: var(--parchment); }
#scorewin-menu[hidden] { display: none; }
#scorewin-menu button { display: block; width: 100%; text-align: left; background: none; border: 0; color: var(--parchment); font: inherit; padding: 5px 14px 5px 28px; cursor: pointer; position: relative; }
#scorewin-menu button:hover, #scorewin-menu button:focus-visible { background: color-mix(in srgb, var(--gilt) 15%, transparent); color: var(--gilt-bright); outline: none; }
#scorewin-menu button[aria-checked="true"]::before { content: "✓"; position: absolute; left: 11px; color: var(--gilt); }
#scorewin-menu .mh { display: block; padding: 4px 14px 2px; color: var(--muted); font-size: .82em; letter-spacing: .08em; text-transform: uppercase; }
#scorewin-menu .keep { display: flex; align-items: center; padding: 0 10px 0 0; }
#scorewin-menu .keep .mh { padding: 0 8px 0 28px; }
#scorewin-menu .keep button { width: auto; flex: 1; text-align: center; padding: 4px 0; border: 1px solid transparent; }
#scorewin-menu .keep button[aria-checked="true"] { border-color: var(--gilt); color: var(--gilt-bright); }
#scorewin-menu .keep button[aria-checked="true"]::before { content: none; }
#scorewin-menu hr { border: 0; border-top: 1px solid var(--rule); margin: 4px 0; }
#sec-scorewin > .note { margin-left: 0; }
