/* elvi-cards.css: Elvi's data cards (black metal, emerald circuit, silver bevel). Loaded after elvi-console.css.
   Markup: menuView.rowHtml -> elviCardRowHtml / elviPileRowHtml, only when the renderer passes the Elvi flag; cardDungeonView.cardFaceHtml/draftDetailHtml add
   data-ec-face / data-ec-pack for her pack detail; the renderer keeps #actionSidebar[data-ec-pack="sealed|opening|open"] and one persistent button.ec-seal for the
   pack opening. Everything is scoped to html[data-protagonist="elvi"] and to li[data-ec-card] / li[data-ec-pile] / [data-ec-face] / [data-ec-pack] / .ec-seal,
   so Liz, the spell book, the inventory and the lab rows keep their existing look.
   Art: assets/ui/elvi-cards/v1/front.webp (empty plate, 384x576) and back.webp (common back). Plate zones (share of the card): safe x 10-89%; name y 8-18%; art y 23-68%;
   uses y 74-90%. Text is real DOM; the images carry no text. Selection never repaints the plate: it lifts, gets an emerald edge + glow and a pointer mark.
   An unidentified card (data-ec-card="unknown") has no data-el / data-ec-kind: it can only show the neutral plate and a "?".
   Geometry (size, margin) is !important on purpose: the tray/list layers (fitList's --lay-row-h, the fixed dense row height, the pile-tile rule) all size every .ui-row. */

html[data-protagonist="elvi"] {
  --ec-card-front: url("../../../assets/ui/elvi-cards/v1/front.webp");
  --ec-card-back: url("../../../assets/ui/elvi-cards/v1/back.webp");
}

/* The required decision stays in the playable screen; its frame reuses Elvi's generated plate. */
#elviChoiceModal[hidden] { display: none !important; }
html[data-protagonist="elvi"] .elvi-choice {
  position: absolute; inset: 0; z-index: 120; display: grid; place-items: center;
  min-width: 0; min-height: 0; padding: 10px; box-sizing: border-box; background: #010704d9;
  overflow: hidden; color: var(--ec-ink, #e6fff0);
}
html[data-protagonist="elvi"] .elvi-choice__panel {
  box-sizing: border-box; width: min(620px, 100%); max-height: 100%; padding: 10px;
  border: 18px solid transparent; border-image: var(--ec-card-front) 64 fill / 18px stretch;
  overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
}
html[data-protagonist="elvi"] .elvi-choice h2 { margin: 0 0 12px; font: 700 18px/1.4 var(--ff-ui, sans-serif); color: var(--ec-hi, #46f27a); }
html[data-protagonist="elvi"] .elvi-choice__options { display: grid; gap: 8px; }
html[data-protagonist="elvi"] .elvi-choice__option {
  box-sizing: border-box; display: grid; gap: 4px; width: 100%; min-height: 56px; margin: 0; padding: 7px 10px;
  border: 9px solid transparent; border-image: var(--ec-card-front) 64 fill / 9px stretch;
  color: inherit; font: 400 14px/1.5 var(--ff-ui, sans-serif); text-align: left; cursor: pointer; overflow-wrap: anywhere;
}
html[data-protagonist="elvi"] .elvi-choice__option strong { font-weight: 700; color: var(--ec-hi, #46f27a); }
html[data-protagonist="elvi"] .elvi-choice__option span { white-space: pre-wrap; }
html[data-protagonist="elvi"] .elvi-choice__option:is(:focus-visible,[data-selected="true"]) { outline: 2px solid var(--ec-hi, #46f27a); outline-offset: -2px; }
html[data-protagonist="elvi"] .elvi-choice__option:disabled { opacity: .45; cursor: default; }
html[data-protagonist="elvi"] .ec-relic-details { margin: 0; }
html[data-protagonist="elvi"] .ec-relic-details dt { margin: 12px 0 4px; color: var(--ec-hi); font-weight: 700; }
html[data-protagonist="elvi"] .ec-relic-details dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
html[data-protagonist="elvi"] .card-relic-hud {
  appearance: none; flex: none; min-height: 24px; padding: 2px 5px; margin: 0;
  border: 5px solid transparent; border-image: var(--ec-card-front) 64 fill / 5px stretch;
  color: var(--ec-hi); background: none; font: 700 10px/1.2 var(--ff-ui); white-space: nowrap; cursor: pointer;
}
html[data-protagonist="elvi"] .card-relic-hud:focus-visible { outline: 2px solid var(--ec-hi); outline-offset: 1px; }
html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] #sidebarList .ui-row[data-ec-relics] {
  position: sticky; right: calc(8px + 2 * (var(--ec-pw) + 4px)); z-index: 6; box-sizing: border-box;
  display: flex !important; flex: none; flex-direction: column; justify-content: center; align-items: center; gap: 6px;
  width: var(--ec-pw) !important; height: calc((var(--ec-pw) - 8px) * 1.5 + 32px) !important;
  min-height: 0 !important; padding: 8px 2px !important; margin: 0 0 0 4px !important;
  background: var(--ec-card-front) center / 100% 100% no-repeat, #030806 !important;
  border: 0 !important; color: var(--ec-ink); cursor: pointer; transform: none;
}
html[data-protagonist="elvi"] .ec-relics-tile__label { font-size: 9px; font-weight: 700; line-height: 12px; white-space: nowrap; }
html[data-protagonist="elvi"] .ec-relics-tile__meta { font-size: 9px; line-height: 12px; white-space: nowrap; color: var(--ec-hi); }
html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] #sidebarList .ui-row[data-ec-relics][aria-selected="true"] { outline: 2px solid var(--ec-hi); outline-offset: 1px; }
@media (orientation: portrait) {
  html[data-protagonist="elvi"][data-native-aperture="1"] .elvi-choice {
    position: fixed; inset: auto; left: var(--native-screen-x); top: var(--native-screen-y);
    width: var(--native-screen-w); height: var(--native-screen-h); border-radius: 20px;
  }
}
html[data-protagonist="elvi"] :is(.ec-card__mp,.chd-card__mp) {
  position: absolute; z-index: 1; right: 11%; bottom: 10%; color: var(--ec-hi, #46f27a);
  font: 700 clamp(10px, 13cqw, 14px)/1 var(--ff-ui, sans-serif); text-shadow: 0 1px 3px #000;
}

/* Temporary hold reader; the existing generated card frame provides its chrome. It never catches the held pointer or the hand's drag. */
html[data-protagonist="elvi"] .card-hold-preview {
  position: fixed; z-index: 90; left: 50%; top: 50%; transform: translate(-50%, -50%);
  box-sizing: border-box; width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 32px - var(--safe-t, 0px) - var(--safe-b, 0px));
  margin: 0; padding: 18px 20px; overflow-y: auto; overflow-wrap: anywhere; pointer-events: none;
  border: 16px solid transparent; border-image: var(--ec-card-front) 64 fill / 16px stretch;
  background: #030806; color: var(--ec-ink, #e6fff0); font: 400 15px/1.6 var(--ff-ui, sans-serif);
}
html[data-protagonist="elvi"] .card-hold-preview__name { margin: 0 0 6px; font: 700 18px/1.4 var(--ff-ui, sans-serif); color: var(--ec-hi, #46f27a); }
html[data-protagonist="elvi"] .card-hold-preview__meta { margin: 0 0 10px; font-size: 12px; color: var(--ec-ink-2, #9ac9a7); }
html[data-protagonist="elvi"] .card-hold-preview__desc { margin: 0; white-space: pre-wrap; }
html[data-protagonist="elvi"] :is(.ui-row[data-ec-card], .card-face[data-ec-face]) { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }

/* ---- the card (hand and pack) ---- */
html[data-protagonist="elvi"] .ui-row[data-ec-card] {
  --ec-w: var(--card-w, 84px); --card-el: var(--ec-line);
  position: relative; isolation: isolate; box-sizing: border-box; display: block; flex: none; min-height: 0; padding: 0; margin: 0;
  width: var(--ec-w) !important; height: calc(var(--ec-w) * 1.5) !important; max-height: none !important;
  container-type: inline-size; overflow: visible; border: 0; border-radius: 4px; background: #030806; box-shadow: none; color: var(--ec-ink); text-align: center; cursor: pointer;
  transform-origin: 50% 110%; transition: transform 140ms cubic-bezier(0.22, 0.9, 0.3, 1), filter 140ms;
  filter: brightness(0.86);
}
/* the plate: an opaque dark body under the frame image, so a card can never show text of the card beneath it */
html[data-protagonist="elvi"] .ui-row[data-ec-card]::before {
  content: ""; position: absolute; inset: 0; z-index: 0; border-radius: 4px; pointer-events: none;
  background: var(--ec-card-front) center / 100% 100% no-repeat, #030806;
}
/* Reset the ordinary notebook's tick and hidden pseudo-element before painting the generated plate. */
html[data-protagonist="elvi"][data-skin] body #actionSidebar.ui-menu .ui-row[data-ec-card]::before {
  content: ""; display: block; inset: 0; width: auto; height: auto; margin: 0; transform: none; opacity: 1;
  background: var(--ec-card-front) center / 100% 100% no-repeat, #030806;
}
html[data-protagonist="elvi"] .ui-row[data-ec-card] > .ui-row__gutter, html[data-protagonist="elvi"] .ui-row[data-ec-card] > .ui-row__bullet { display: none; }
html[data-protagonist="elvi"] .ui-row[data-ec-card] > span { position: absolute; z-index: 1; margin: 0; }

/* name: centred on the plate (y 13%) in a 14px box, so a 10px line never depends on the 10%-high plate zone of a small card (320px: 7px) and cannot be clipped by the rail.
   In an overlapped hand only the left part of a card shows, so the name starts at the left edge of the safe area */
html[data-protagonist="elvi"] .ui-row[data-ec-card] .ec-card__name {
  left: 11%; right: 11%; top: calc(13% - 7px); height: 14px; display: block; overflow: hidden; text-align: left;
  font-size: clamp(10px, 14cqw, 14px); font-weight: 700; line-height: 14px; letter-spacing: 0; white-space: nowrap; text-overflow: ellipsis; color: #e6fff0; text-shadow: 0 0 3px #000, 0 0 2px #000, 0 1px 0 #000;
}
/* element band: a thin colour line on the lower edge of the name plate (neutral green for unidentified cards) */
html[data-protagonist="elvi"] .ui-row[data-ec-card] .ec-card__band { left: 12%; right: 12%; top: calc(18% + 1px); height: 1.5%; min-height: 2px; background: var(--card-el); opacity: 0.95; }
/* art: y 23-68%, the existing spell glyph / item art / kind symbol, centred and large */
html[data-protagonist="elvi"] .ui-row[data-ec-card] .ec-card__art { left: 15%; right: 15%; top: 24%; height: 43%; display: flex; align-items: center; justify-content: center; color: var(--ec-hi); }
html[data-protagonist="elvi"] .ui-row[data-ec-card] .ec-card__art > * { width: 100%; height: 100%; max-width: 100%; max-height: 100%; }
html[data-protagonist="elvi"] .ui-row[data-ec-card] .ec-card__art .ic-art { --ic-size: 100%; }
html[data-protagonist="elvi"] .ui-row[data-ec-card] .ec-card__art svg.ui-sym { fill: currentColor; width: 70%; height: 70%; }
html[data-protagonist="elvi"] .ui-row[data-ec-card] .ec-card__art .ec-q { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; font-size: clamp(26px, 44cqw, 48px); font-weight: 700; color: var(--ec-hi); text-shadow: 0 0 8px var(--ec-glow); }
/* uses: y 75-89%. The remaining count is the big figure, the maximum a small one; left-aligned like the name */
html[data-protagonist="elvi"] .ui-row[data-ec-card] .ec-card__uses {
  left: 11%; right: 11%; top: 75%; height: 14%; display: flex; align-items: center; justify-content: flex-start; gap: 1px; font-variant-numeric: tabular-nums; color: #e6fff0; text-shadow: 0 0 3px #000, 0 0 2px #000, 0 1px 0 #000;
}
html[data-protagonist="elvi"] .ui-row[data-ec-card] .ec-card__uses b { font-size: clamp(14px, 24cqw, 24px); font-weight: 700; line-height: 1; color: var(--ec-hi); }
html[data-protagonist="elvi"] .ui-row[data-ec-card] .ec-card__uses i { font-size: clamp(10px, 13cqw, 14px); font-style: normal; line-height: 1; align-self: flex-end; padding-bottom: 2px; }
/* selected: lifted, emerald edge and glow, a pointer mark under the card, name and uses centred; the plate itself is unchanged */
html[data-protagonist="elvi"] .ui-row[data-ec-card] .ec-card__mark { display: none; left: 50%; bottom: -9px; width: 0; height: 0; margin-left: -6px; border: 6px solid transparent; border-bottom-color: var(--ec-hi); border-top-width: 0; }
html[data-protagonist="elvi"] .ui-row[data-ec-card][aria-selected="true"] {
  z-index: 5; filter: drop-shadow(0 0 7px var(--ec-glow)) drop-shadow(0 0 2px var(--ec-hi)) brightness(1.08); transform: translateY(-10px) scale(1.05);
  outline: 2px solid var(--ec-hi); outline-offset: 1px;
}
html[data-protagonist="elvi"] .ui-row[data-ec-card][aria-selected="true"] .ec-card__mark { display: block; }
html[data-protagonist="elvi"] .ui-row[data-ec-card][aria-selected="true"] :is(.ec-card__name, .ec-card__uses) { justify-content: center; }
html[data-protagonist="elvi"] .ui-row[data-ec-card][aria-disabled="true"] { opacity: 0.6; filter: grayscale(0.6) brightness(0.7); }
html[data-protagonist="elvi"] .ui-row[data-ec-card][aria-disabled="true"][aria-selected="true"] { filter: grayscale(0.4) brightness(0.9); }
html[data-protagonist="elvi"] .ui-row[data-ec-card]:focus-visible { outline: 2px solid var(--ec-hi); outline-offset: 2px; }

/* ======================================================================================================
   HAND RAIL (Elvi). One explicit layout that replaces the generic two-row grid (components.css "RAIL FIT") and the PS1 fan for her rows:
   a single horizontal flex row = the cards, then the two pile counters (draw pile / discard pile).
   - The card width fits the five-card hand into the rail when it can (never below 86% of --card-w); each card shows a slice (--ec-step) of its width.
   - The card right after the selected one is pulled clear of it (6px), so the selected card is whole and no neighbour name runs on from it.
   - If the hand still does not fit (narrow rail), the rail scrolls horizontally with a visible thin scrollbar; the two pile counters are position:sticky at the
     right edge, so they are always visible and tappable, and scroll-padding keeps the selected card clear of them.
   Specificity: two ids + the Elvi attributes outrank the generic #sidebarList / PS1 :nth-child rules; the geometry is !important where those use it.
   ====================================================================================================== */
html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] #sidebarList.ui-list__rows:has(> .ui-row[data-ec-pile]) {
  --ec-pw: clamp(44px, calc(var(--card-w, 84px) * 0.5), 52px);                 /* pile counter width */
  --ec-aux: calc(var(--ec-pw) * 3 + 24px);                                       /* relic details and two pile counters */
  --ec-hand-w: min(var(--card-w, 84px), max(calc((100cqw - var(--ec-aux)) / (2 + 0.45 * (var(--d, 1) - 1))), calc(var(--card-w, 84px) * 0.86)));
  display: flex; flex-direction: row; flex-wrap: nowrap; align-items: flex-end; justify-content: flex-start; grid-template-rows: none; row-gap: 0; column-gap: 0;
  padding: 18px 8px 12px 8px; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; touch-action: pan-x;
  scroll-snap-type: none; scroll-padding-inline: 8px calc(var(--ec-aux) + 4px);
  scrollbar-width: thin; scrollbar-color: var(--ec-line) transparent;
}
html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] #sidebarList.ui-list__rows:has(> .ui-row[data-ec-pile])::-webkit-scrollbar { display: block; height: 6px; }
html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] #sidebarList.ui-list__rows:has(> .ui-row[data-ec-pile])::-webkit-scrollbar-thumb { background: var(--ec-line); border-radius: 3px; }
html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] #sidebarList.ui-list__rows:has(> .ui-row[data-ec-pile])::-webkit-scrollbar-track { background: var(--ec-bg1); }

/* cards: plate, fitted width, a slice of each shown */
html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] #sidebarList .ui-row[data-ec-card] {
  --ec-w: var(--ec-hand-w, var(--card-w, 84px));
  --ec-step: clamp(calc(var(--ec-w) * 0.45), calc((100cqw - var(--ec-aux, 150px) - 2 * var(--ec-w) - 6px) / max(var(--d, 1) - 1, 1)), calc(var(--ec-w) * 0.62));
  grid-row: auto; grid-column: auto; align-self: flex-end; flex: none; background: #030806; background-image: none; border: 0; border-radius: 4px; box-shadow: none; padding: 0; color: var(--ec-ink);
  margin: 0 0 0 calc(var(--ec-step) - var(--ec-w)) !important; scroll-snap-align: none;
}
html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] #sidebarList .ui-row[data-ec-card]:is(:first-child, .ui-row__group + .ui-row) { margin-left: 0 !important; }
html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] #sidebarList .ui-row[data-ec-card][aria-selected="true"] + .ui-row[data-ec-card] { margin-left: 6px !important; }
/* the PS1 generic fan (rotate on children 2/3/5/6) must not touch her cards; :nth-child(n) lifts the specificity above those rules */
html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] #sidebarList .ui-row[data-ec-card][data-kind="card"]:nth-child(n) { transform: none; margin-bottom: 0; }
html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] #sidebarList .ui-row[data-ec-card][data-kind="card"][aria-selected="true"]:nth-child(n) {
  z-index: 5; transform: translateY(-10px) scale(1.05); background: #030806; color: var(--ec-ink); outline: 2px solid var(--ec-hi); outline-offset: 1px;
}
html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] #sidebarList .ui-row[data-ec-card] .ec-card__name { display: block; flex: none; width: auto; min-width: 0; max-width: none; font-family: inherit; }
html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] #sidebarList .ui-row[data-ec-card] .ec-card__uses { position: absolute; border: 0; background: none; padding: 0; }
html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] #sidebarList .ui-row[data-ec-card][aria-disabled="true"] { opacity: 0.6; }

/* counters: 山札 / 捨て札. A small back (2:3) or a stack of backs, label and count under it; sticky at the right edge of the rail */
html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] #sidebarList .ui-row[data-ec-pile] {
  position: sticky; z-index: 6; grid-row: auto; grid-column: auto; align-self: flex-end; flex: none; box-sizing: border-box;
  display: flex !important; flex-direction: column !important; align-items: center; justify-content: flex-start; gap: 1px; overflow: hidden;
  width: var(--ec-pw) !important; height: calc((var(--ec-pw) - 8px) * 1.5 + 32px) !important; min-height: 0 !important; max-height: none !important; padding: 2px 1px 1px !important; margin: 0 0 0 4px !important;
  background: rgb(2 10 6 / 0.96) !important; background-image: none !important; border: 1px solid var(--ec-dim) !important; border-radius: 4px; box-shadow: none !important;
  color: var(--ec-ink); text-align: center; cursor: pointer; transform: none; filter: none; scroll-snap-align: none;
  transition: transform 140ms cubic-bezier(0.22, 0.9, 0.3, 1), border-color 140ms;
}
html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] #sidebarList .ui-row[data-ec-pile][data-kind="cardPile"][data-ec-pile="discard"] { right: 8px; }
html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] #sidebarList .ui-row[data-ec-pile][data-kind="cardPile"][data-ec-pile="draw"] { right: calc(8px + var(--ec-pw) + 4px); }
html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] #sidebarList .ui-row[data-ec-pile][data-kind="cardDraw"] { right: calc(8px + 2 * (var(--ec-pw) + 4px)); margin-left: 8px !important; box-shadow: -8px 0 8px -2px rgb(0 0 0 / 0.9) !important; }
html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] #sidebarList .ui-row[data-ec-pile][aria-selected="true"] {
  z-index: 7; transform: translateY(-8px); border-color: var(--ec-hi) !important; outline: 2px solid var(--ec-hi); outline-offset: 0; background: rgb(4 24 14 / 0.98) !important; color: var(--ec-ink);
}
html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] #sidebarList .ui-row[data-ec-pile][aria-disabled="true"] { opacity: 1; border-style: dashed !important; }
html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] #sidebarList .ui-row[data-ec-pile][aria-disabled="true"] :is(.ec-pile__stack, .ec-pile__name, .ec-pile__n) { opacity: 0.6; }
html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] #sidebarList .ui-row[data-ec-pile][aria-disabled="true"][aria-selected="true"] :is(.ec-pile__stack, .ec-pile__name, .ec-pile__n) { opacity: 0.85; }
/* an empty hand: the tile keeps the controls' height so the rail does not jump */
html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] #sidebarList .ui-row[data-kind="cardEmpty"] {
  grid-row: auto; flex: none; align-self: flex-end; width: max(96px, calc(var(--ec-pw, 44px) * 2.2)); height: calc((var(--ec-pw, 44px) - 8px) * 1.5 + 32px); margin: 0 0 0 0; padding: 4px; white-space: normal;
}

/* ---- control tile internals ---- */
html[data-protagonist="elvi"] .ui-row[data-ec-pile] > .ui-row__gutter, html[data-protagonist="elvi"] .ui-row[data-ec-pile] > .ui-row__bullet { display: none; }
html[data-protagonist="elvi"] .ui-row[data-ec-pile] .ec-pile__stack { position: relative; flex: none; width: calc(100% - 8px); aspect-ratio: 2 / 3; margin-top: 3px; }
html[data-protagonist="elvi"] .ui-row[data-ec-pile] .ec-pile__stack i {
  position: absolute; inset: 0; display: none; border-radius: 3px; background: var(--ec-card-back) center / 100% 100% no-repeat, #030806; box-shadow: 0 1px 2px #000;
}
html[data-protagonist="elvi"] .ui-row[data-ec-pile] .ec-pile__stack i:nth-child(1) { display: block; transform: translate(-3px, 3px); }
html[data-protagonist="elvi"] .ui-row[data-ec-pile] .ec-pile__stack i:nth-child(2) { transform: translate(-1.5px, 1.5px); }
html[data-protagonist="elvi"] .ui-row[data-ec-pile][data-ec-depth="2"] .ec-pile__stack i:nth-child(2), html[data-protagonist="elvi"] .ui-row[data-ec-pile][data-ec-depth="3"] .ec-pile__stack i:nth-child(-n+3) { display: block; }
html[data-protagonist="elvi"] .ui-row[data-ec-pile][data-ec-depth="1"] .ec-pile__stack i:nth-child(1) { transform: none; }
html[data-protagonist="elvi"] .ui-row[data-ec-pile][data-ec-depth="0"] .ec-pile__stack i:nth-child(1) { transform: none; opacity: 0.3; filter: grayscale(1); outline: 1px dashed var(--ec-dim); }
/* draw action: the back with a "+" so it reads as an action, not as the pile; discard: the same back, desaturated */
html[data-protagonist="elvi"] .ui-row[data-ec-pile][data-kind="cardDraw"] .ec-pile__stack::after { content: "+"; position: absolute; inset: 0; z-index: 4; display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700; color: #e6fff0; text-shadow: 0 0 6px #000, 0 0 8px var(--ec-hi); }
html[data-protagonist="elvi"] .ui-row[data-ec-pile][data-ec-pile="discard"] .ec-pile__stack i { filter: grayscale(0.7) brightness(0.8); }
html[data-protagonist="elvi"] .ui-row[data-ec-pile] .ec-pile__name { flex: none; max-width: 100%; margin: 0; padding: 0; font-size: 10px; font-weight: 700; line-height: 12px; white-space: nowrap; overflow: hidden; color: #e6fff0; text-shadow: 0 1px 0 #000; position: static; background: none; border: 0; }
html[data-protagonist="elvi"] .ui-row[data-ec-pile] .ec-pile__n { flex: none; max-width: 100%; margin: 0; padding: 0; font-size: 10px; line-height: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--ec-hi); text-shadow: 0 1px 0 #000; position: static; background: none; border: 0; }
html[data-protagonist="elvi"] .ui-row[data-ec-pile][aria-disabled="true"] .ec-pile__stack { outline: 1px dashed var(--ec-ink); outline-offset: 2px; }

/* ======================================================================================================
   PACK (Elvi): 3 plates side by side, then the selected offer in full. #actionSidebar[data-ec-pack] is set by the renderer for her pack in any stage.
   The menu is one explicit grid (head / list / detail / foot) in both orientations, so the detail takes the whole remaining height and scrolls instead of being
   squeezed to a strip under a large blank area. The tab strip is not used while a pack is held (the renderer already refuses tab changes).
   ====================================================================================================== */
html[data-protagonist="elvi"] body #actionSidebar.ui-menu[data-ec-pack] {
  display: grid !important; grid-template-columns: minmax(0, 1fr) !important; grid-template-rows: auto auto minmax(0, 1fr) auto !important;
  grid-template-areas: "head" "list" "detail" "foot" !important; row-gap: 6px; align-content: stretch;
}
html[data-protagonist="elvi"] body #actionSidebar.ui-menu[data-ec-pack] > .ui-tabs { display: none !important; }
html[data-protagonist="elvi"] body #actionSidebar.ui-menu[data-ec-pack] > .ui-menu__head { grid-area: head !important; }
html[data-protagonist="elvi"] body #actionSidebar.ui-menu[data-ec-pack] > .ui-menu__body { display: contents !important; }
html[data-protagonist="elvi"] body #actionSidebar.ui-menu[data-ec-pack] > .ui-desc { grid-area: foot !important; }
html[data-protagonist="elvi"] body #actionSidebar.ui-menu[data-ec-pack] .ui-menu__body > .ui-portrait { display: none !important; }
html[data-protagonist="elvi"] body #actionSidebar.ui-menu[data-ec-pack] .ui-menu__body > .ui-list { grid-area: list !important; align-self: start; height: auto !important; max-height: none !important; min-width: 0; }
html[data-protagonist="elvi"] body #actionSidebar.ui-menu[data-ec-pack] .ui-menu__body > .ui-detail {
  grid-area: detail !important; align-self: stretch !important; display: flex !important; flex-direction: column; height: auto !important; max-height: none !important; min-height: 0 !important;
  margin: 0 !important; overflow: hidden; z-index: auto !important;
}
html[data-protagonist="elvi"] body #actionSidebar.ui-menu[data-ec-pack] #sidebarDetail > .ui-detail__head { display: none; }
html[data-protagonist="elvi"] body #actionSidebar.ui-menu[data-ec-pack] #sidebarDetail .ui-detail__content { display: block; flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; }
html[data-protagonist="elvi"] body #actionSidebar.ui-menu[data-ec-pack] #sidebarDetail .ui-detail__hint { flex: none; margin: 4px 0 0; font-size: 11px; line-height: 1.3; }
@media (orientation: landscape) {
  html[data-protagonist="elvi"] body #actionSidebar.ui-menu[data-ec-pack] {
    grid-template-columns: minmax(0, 46%) minmax(0, 1fr) !important; grid-template-rows: auto minmax(0, 1fr) auto !important;
    grid-template-areas: "head head" "list detail" "foot foot" !important; column-gap: 8px;
  }
}

/* the list of the pack: a row of three plates under the group header (the fixed row height of a plain list does not apply) */
html[data-protagonist="elvi"] .ui-list__rows:has(> .ui-row[data-kind="cardChoice"][data-ec-card]) {
  display: flex !important; flex-flow: row wrap; justify-content: center; align-items: flex-start; gap: 6px 8px; container-type: inline-size;
  height: auto !important; max-height: none !important; padding: 8px 6px 16px !important; overflow: visible !important;
}
html[data-protagonist="elvi"] .ui-list__rows:has(> .ui-row[data-kind="cardChoice"][data-ec-card]) > .ui-row__group { flex: 0 0 100%; height: auto; min-height: 0; }
html[data-protagonist="elvi"] .ui-row[data-ec-card][data-kind="cardChoice"] { --ec-w: min(120px, calc((100cqw - 28px) / 3)); margin: 0 !important; }
html[data-protagonist="elvi"] .ui-row[data-ec-card][data-kind="cardChoice"][aria-selected="true"] { transform: translateY(-4px) scale(1.03); }
html[data-protagonist="elvi"] .ui-row[data-ec-card][data-kind="cardChoice"] :is(.ec-card__name, .ec-card__uses) { justify-content: center; }

/* her pack detail: the same frame as the plates (a 9-sliced front.webp behind the text). The selected offer is full; the others stay as a name + choose button line */
html[data-protagonist="elvi"] .card-draft-host[data-ec-pack] .card-draft { gap: 8px; margin: 0; }
html[data-protagonist="elvi"] .card-draft-host[data-ec-pack] .card-face[data-ec-face] {
  position: relative; isolation: isolate; padding: 16px 18px; border: 0; border-radius: 4px; background: #030806; color: var(--ec-ink); box-shadow: none; outline: 0; filter: brightness(0.85);
}
html[data-protagonist="elvi"] .card-draft-host[data-ec-pack] .card-face[data-ec-face]::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; border: 16px solid transparent; border-image: var(--ec-card-front) 64 fill / 16px stretch;
}
html[data-protagonist="elvi"] .card-draft-host[data-ec-pack] .card-face[data-ec-face] > * { position: relative; }
html[data-protagonist="elvi"] .card-draft-host[data-ec-pack] .card-face[data-ec-face][data-selected="true"] { filter: drop-shadow(0 0 6px var(--ec-glow)) brightness(1.08); outline: 2px solid var(--ec-hi); outline-offset: 1px; background: #030806; color: var(--ec-ink); }
html[data-protagonist="elvi"] .card-draft-host[data-ec-pack] .card-face[data-ec-face] .card-face__name { color: #e6fff0; }
html[data-protagonist="elvi"] .card-draft-host[data-ec-pack] .card-face[data-ec-face] .card-face__cost { color: var(--ec-hi); border-color: var(--ec-line); }
html[data-protagonist="elvi"] .card-draft-host[data-ec-pack] .card-face[data-ec-face][data-selected="false"] :is(.card-face__meta, .card-face__fx) { display: none; }
html[data-protagonist="elvi"] .card-draft-host[data-ec-pack] .card-face[data-ec-face] .card-face__choose { color: var(--ec-hi); background: var(--ec-panel); border: 1px solid var(--ec-line); border-radius: 2px; }
html[data-protagonist="elvi"] .card-draft-host[data-ec-pack] .card-face[data-ec-face][data-selected="true"] .card-face__choose { color: #010302; background: var(--ec-line); font-weight: 700; }
html[data-protagonist="elvi"] .card-draft-host[data-ec-pack] .card-face[data-ec-face] .card-face__free { color: inherit; opacity: 0.9; }

/* ======================================================================================================
   PACK OPENING. button.ec-seal is created once by the renderer and persists across renders; only its data-stage changes, so the animation runs once per pack.
   sealed (idle glow, list/detail hidden) -> opening (about 0.6s: the three backs fan out, a ring and one soft flash, the cover fades) -> open (cover hidden).
   Reduced motion / data-reduced-motion / GB: the renderer starts at "open" and the cover is never shown. Animations are single-shot (no flicker).
   ====================================================================================================== */
.ec-seal[hidden] { display: none !important; }
.ec-seal {
  position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; margin: 0; padding: 0; border: 0; overflow: hidden;
  background: rgb(1 5 3 / 0.95); color: #e6fff0; font: inherit; text-align: center; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.ec-seal__glow { position: absolute; left: 50%; top: 46%; width: 70vmin; height: 70vmin; margin: -35vmin 0 0 -35vmin; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgb(39 217 122 / 0.32), rgb(39 217 122 / 0) 65%); }
.ec-seal__ring { position: absolute; left: 50%; top: 46%; width: 40vmin; height: 40vmin; margin: -20vmin 0 0 -20vmin; border-radius: 50%; pointer-events: none; border: 2px solid var(--ec-line, #27d97a); opacity: 0; }
.ec-seal__stack { position: relative; flex: none; height: min(46dvh, 250px); aspect-ratio: 2 / 3; }
.ec-seal__stack i { position: absolute; inset: 0; border-radius: 6px; background: var(--ec-card-back) center / 100% 100% no-repeat, #030806; box-shadow: 0 4px 12px #000; }
.ec-seal__stack i:nth-child(1) { transform: rotate(-5deg) translate(-4%, 1%); }
.ec-seal__stack i:nth-child(2) { transform: rotate(4deg) translate(4%, 1%); }
.ec-seal__band { position: absolute; left: -6%; right: -6%; top: 44%; height: 12%; border-top: 2px solid var(--ec-hi, #8dffbd); border-bottom: 2px solid var(--ec-line, #27d97a);
  background: linear-gradient(90deg, #04120a, #0b3a22 50%, #04120a); box-shadow: 0 0 10px var(--ec-glow, rgb(39 217 122 / 0.35)); }
.ec-seal__flash { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: radial-gradient(circle at 50% 46%, rgb(190 255 220 / 0.85), rgb(39 217 122 / 0) 55%); }
.ec-seal__label { position: relative; font-size: 16px; font-weight: 700; line-height: 1.2; color: var(--ec-hi, #8dffbd); }
.ec-seal__sub { position: relative; font-size: 12px; line-height: 1.2; color: var(--ec-ink, #bff5d6); }
.ec-seal:focus-visible { outline: 2px solid var(--ec-hi, #8dffbd); outline-offset: -6px; }
.ec-seal[data-stage="sealed"] .ec-seal__stack { animation: ec-seal-float 1.6s ease-in-out infinite; }
.ec-seal[data-stage="sealed"] .ec-seal__glow { animation: ec-seal-pulse 1.6s ease-in-out infinite; }
.ec-seal[data-stage="opening"] { animation: ec-seal-cover 620ms ease-in forwards; pointer-events: none; }
.ec-seal[data-stage="opening"] .ec-seal__stack i:nth-child(1) { animation: ec-fan-l 620ms cubic-bezier(0.2, 0.8, 0.3, 1) forwards; }
.ec-seal[data-stage="opening"] .ec-seal__stack i:nth-child(2) { animation: ec-fan-r 620ms cubic-bezier(0.2, 0.8, 0.3, 1) forwards; }
.ec-seal[data-stage="opening"] .ec-seal__stack i:nth-child(3) { animation: ec-fan-c 620ms cubic-bezier(0.2, 0.8, 0.3, 1) forwards; }
.ec-seal[data-stage="opening"] .ec-seal__band { animation: ec-band-open 260ms ease-out forwards; }
.ec-seal[data-stage="opening"] .ec-seal__ring { animation: ec-ring 560ms ease-out forwards; }
.ec-seal[data-stage="opening"] .ec-seal__flash { animation: ec-flash 420ms ease-out forwards; }
.ec-seal[data-stage="opening"] :is(.ec-seal__label, .ec-seal__sub) { opacity: 0; transition: opacity 160ms; }
@keyframes ec-seal-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes ec-seal-pulse { 0%, 100% { opacity: 0.6; } 50% { opacity: 1; } }
@keyframes ec-seal-cover { 0%, 55% { opacity: 1; } 100% { opacity: 0; } }
@keyframes ec-fan-l { to { transform: rotate(-22deg) translate(-70%, 6%); } }
@keyframes ec-fan-r { to { transform: rotate(22deg) translate(70%, 6%); } }
@keyframes ec-fan-c { to { transform: translateY(-8%) scale(1.08); } }
@keyframes ec-band-open { to { transform: scaleX(0); opacity: 0; } }
@keyframes ec-ring { 0% { opacity: 0.9; transform: scale(0.4); } 100% { opacity: 0; transform: scale(2.2); } }
@keyframes ec-flash { 0% { opacity: 0; } 30% { opacity: 0.8; } 100% { opacity: 0; } }
/* while sealed the offers stay out of sight (and out of the accessibility tree); calm modes never reach "sealed" */
@media (prefers-reduced-motion: no-preference) {
  html:not([data-reduced-motion="1"]):not([data-skin="gb"]) body #actionSidebar.ui-menu[data-ec-pack="sealed"] > .ui-menu__body { visibility: hidden; }
}
@media (prefers-reduced-motion: reduce) { .ec-seal { display: none !important; } }
html[data-reduced-motion="1"] .ec-seal, html[data-skin="gb"] .ec-seal { display: none !important; }

/* ---- GB: keep the plate, push it into the four green tones; plain contrast text ---- */
html[data-protagonist="elvi"][data-skin="gb"] .ui-row[data-ec-card]::before, html[data-protagonist="elvi"][data-skin="gb"] .ui-row[data-ec-pile] .ec-pile__stack i,
html[data-protagonist="elvi"][data-skin="gb"] .card-draft-host[data-ec-pack] .card-face[data-ec-face]::before {
  filter: grayscale(1) sepia(1) hue-rotate(35deg) saturate(2.2) contrast(1.15);
}
html[data-protagonist="elvi"][data-skin="gb"] .ui-row[data-ec-card], html[data-protagonist="elvi"][data-skin="gb"] .ui-row[data-ec-pile], html[data-protagonist="elvi"][data-skin="gb"] .card-draft-host[data-ec-pack] .card-face[data-ec-face] { filter: none; transition: none; }
html[data-protagonist="elvi"][data-skin="gb"] .ui-row[data-ec-card] :is(.ec-card__name, .ec-card__uses b), html[data-protagonist="elvi"][data-skin="gb"] .ui-row[data-ec-pile] :is(.ec-pile__name, .ec-pile__n),
html[data-protagonist="elvi"][data-skin="gb"] .card-draft-host[data-ec-pack] .card-face[data-ec-face] .card-face__name { color: #cfe86a; text-shadow: 0 0 2px #000, 0 1px 0 #000; }
html[data-protagonist="elvi"][data-skin="gb"] .ui-row[data-ec-card][aria-selected="true"],
html[data-protagonist="elvi"][data-skin="gb"] .card-draft-host[data-ec-pack] .card-face[data-ec-face][data-selected="true"] { filter: none; outline: 3px solid var(--ec-hi); outline-offset: 1px; }
html[data-protagonist="elvi"][data-skin="gb"] .ui-row[data-ec-card] .ec-card__band { background: var(--ec-line); }
html[data-protagonist="elvi"][data-skin="gb"] .ui-row[data-ec-card][aria-disabled="true"], html[data-protagonist="elvi"][data-skin="gb"] .ui-row[data-ec-pile][aria-disabled="true"] { filter: none; opacity: 0.55; }
html[data-protagonist="elvi"][data-skin="gb"] .card-draft-host[data-ec-pack] .card-face[data-ec-face][data-selected="true"] .card-face__choose { color: #071207; background: var(--ec-hi); }
/* GB hand: a selected card is marked by a thick outline, the pointer mark and the lift (no brightness); a selected control gets the same thick outline and a filled tile */
html[data-protagonist="elvi"][data-skin="gb"] body #actionSidebar[data-hand="1"] #sidebarList .ui-row[data-ec-card][data-kind="card"][aria-selected="true"]:nth-child(n) { outline: 3px solid var(--ec-hi); outline-offset: 1px; }
html[data-protagonist="elvi"][data-skin="gb"] body #actionSidebar[data-hand="1"] #sidebarList .ui-row[data-ec-pile][aria-selected="true"] { outline: 3px solid var(--ec-hi); background: var(--ec-panel) !important; }
html[data-protagonist="elvi"][data-skin="gb"] body #actionSidebar[data-hand="1"] #sidebarList .ui-row[data-ec-pile] { border-width: 2px !important; transition: none; }
/* GB has no element colours: the band stays the console line colour */
/* The hand's narrow reading pane uses inline effect pairs instead of a boxed table. */
html[data-protagonist="elvi"][data-skin="gb"] body #actionSidebar[data-hand="1"] .ui-detail__extra { gap: 0; }
html[data-protagonist="elvi"][data-skin="gb"] body #actionSidebar[data-hand="1"] .ui-effects {
  display: flex; flex-wrap: wrap; gap: 2px 8px; margin: 0; padding: 0; border: 0; background: none;
}
html[data-protagonist="elvi"][data-skin="gb"] body #actionSidebar[data-hand="1"] .ui-effects > div {
  display: flex; gap: 4px; margin: 0; padding: 0; border: 0; line-height: 12px;
}
html[data-protagonist="elvi"][data-skin="gb"] body #actionSidebar[data-hand="1"] .ui-detail__content {
  scrollbar-gutter: stable;
}

/* Keep several readable detail lines above the fixed commands on short portrait screens. */
@media (orientation: portrait) and (max-height: 640px) {
  html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] {
    --hand-h: clamp(276px, calc(100dvh - var(--native-screen-y, 0px) - var(--native-screen-h, 0px) + 28px), 420px);
  }
  html[data-protagonist="elvi"][data-skin] body.hand-drawer-open:not(.log-fullscreen) #messagePanel {
    transform: translateY(-40px);
  }
}

/* ---- motion ---- */
@media (prefers-reduced-motion: reduce) {
  html[data-protagonist="elvi"] .ui-row[data-ec-card], html[data-protagonist="elvi"] .ui-row[data-ec-pile] { transition: none !important; }
  html[data-protagonist="elvi"] .ui-row[data-ec-card][aria-selected="true"],
  html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] #sidebarList .ui-row[data-ec-card][data-kind="card"][aria-selected="true"]:nth-child(n) { transform: translateY(-6px); }
  html[data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] #sidebarList .ui-row[data-ec-pile][aria-selected="true"] { transform: none; }
}
html[data-reduced-motion="1"][data-protagonist="elvi"] .ui-row[data-ec-card], html[data-reduced-motion="1"][data-protagonist="elvi"] .ui-row[data-ec-pile] { transition: none !important; }
html[data-reduced-motion="1"][data-protagonist="elvi"] .ui-row[data-ec-card][aria-selected="true"],
html[data-reduced-motion="1"][data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] #sidebarList .ui-row[data-ec-card][data-kind="card"][aria-selected="true"]:nth-child(n) { transform: translateY(-6px); }
html[data-reduced-motion="1"][data-protagonist="elvi"][data-skin] body #actionSidebar[data-hand="1"] #sidebarList .ui-row[data-ec-pile][aria-selected="true"] { transform: none; }
