/* HORO-BEAT sim: the builder lane's screens (deck builder, card detail, the card sheet, load / import / export windows).
   Owner: builder lane (DESIGN.md §10). Look: identity 3, Night Parade (reports/polish/identity-3/mockup.html "02 deck
   builder"): lacquer panels, gold structure, ONE vermilion action per view, washi only for card content.
   Flat paint here; decoration (glows, washes, gradients over big areas) in the @layer hb-fx block at the end, scoped
   to body:not(.hb-perf). Tokens and components come from theme/ (canonical identity-3 names only). */

@layer hb-screens {
  /* ================================================================== CARD DETAIL (builder column, windows, play)
     printings at the TOP · the art beside the plate (cost disc + power, name, 家紋 + race, type + keyword chips, the
     stepper) · ONE washi card-text box (rules, flavor, the printed trigger line, the foot strip) */
  .hb-detail { display: flex; flex-direction: column; gap: 12px; min-width: 0; min-height: 0; padding: 12px 14px 14px; }
  .hb-detail__live { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; flex: none; padding: 6px 10px; border-radius: var(--hb-r-ctl); background-color: var(--hb-ink-3);
    box-shadow: inset 0 0 0 1px var(--hb-line); color: var(--hb-text-2); font-size: var(--hb-fs-12); }
  .hb-detail__live .hb-num { font-size: var(--hb-fs-16); }
  .hb-detail__where { color: var(--hb-text); font-weight: 700; }
  .hb-detail__lost { color: var(--hb-danger-text); }

  /* the printing / alt-art strip: 40 px thumbs with their rarity tag; the chosen one lit gold; code + product at the end */
  .hb-detail__prints { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 10px; flex: none; padding-bottom: 10px; border-bottom: 1px solid var(--hb-line); }
  .hb-detail__printrow { display: flex; flex-wrap: wrap; gap: 8px; }
  .hb-print { position: relative; display: flex; flex-direction: column; align-items: center; gap: 5px; margin: 0; padding: 0; border: 0; background: none; cursor: pointer; }
  .hb-print img { display: block; width: 40px; aspect-ratio: 600 / 838; border-radius: var(--hb-r-thumb); opacity: .55; box-shadow: 0 0 0 1px var(--hb-line-2);
    transition: opacity var(--hb-dur-hover), transform var(--hb-dur-hover) var(--hb-ease-out), box-shadow var(--hb-dur-hover); }
  .hb-print:hover img { opacity: .9; transform: translateY(-2px); }
  .hb-print.is-on img { opacity: 1; box-shadow: 0 0 0 2px var(--hb-kin-hi), 0 0 0 3px #0b0604; }
  .hb-print .hb-rar { min-width: 26px; }
  .hb-detail__printmeta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; min-width: 0; margin-left: auto; color: var(--hb-text-3); font-size: var(--hb-fs-11); line-height: 1.4; text-align: right; }
  .hb-detail__printmeta b { color: var(--hb-text-2); font-weight: 700; white-space: nowrap; }
  .hb-detail__printextra { flex: 1 0 100%; }
  .hb-detail__useart { padding-left: 4px; }

  /* art + plate */
  .hb-detail__top { display: grid; grid-template-columns: clamp(110px, 44%, 200px) minmax(0, 1fr); gap: 14px; flex: none; align-items: stretch; }
  .hb-detail__img { min-width: 0; }
  .hb-detail__img .hb-cimg { box-shadow: 0 0 0 1px rgba(0,0,0,.7), 0 12px 26px rgba(0,0,0,.55); }
  .hb-detail__plate { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
  .hb-detail__band { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .hb-detail__pow { font-size: var(--hb-fs-28); }
  .hb-detail__name { font-size: var(--hb-fs-18); }
  .hb-detail__name[lang="ja"] { line-height: 1.5; }
  .hb-detail__tags { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
  .hb-detail__actions { display: flex; align-items: center; gap: 10px; margin-top: auto; padding-top: 2px; }
  .hb-bld__step > output { min-width: 42px; }

  /* the one card-text box: its body scrolls when the column is short, the foot strip stays printed at the bottom */
  .hb-detail__text { display: flex; flex-direction: column; flex: 0 1 auto; min-height: 0; }
  /* (the gutter is always reserved: a scrollbar that comes and goes re-wraps the text and Chromium could keep a stale
     height, cutting the last line off behind a scrollbar in a column with room to spare) */
  /* (2 px of padding inside the clip, given back by the margin: the trigger disc's ring and anything else flush with the
     text's edges is not cut, and the text keeps its width) */
  .hb-cardtext__body { min-height: 0; margin: -2px; padding: 2px; overflow: auto; overscroll-behavior: contain; scrollbar-gutter: stable; scrollbar-width: thin; scrollbar-color: rgba(90,70,54,.45) transparent; }
  .hb-cardtext__body > :first-child { margin-top: 0; }
  .hb-cardtext__sub { padding-left: 1.1em; }
  .hb-cardtext__note { color: var(--hb-ci-text-2); font-size: .88em; }
  .hb-cardtext__line { margin: 0; }
  .hb-cardtext__line--2 { margin-top: 8px; }
  .hb-cardtext__flavor:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
  .hb-cardtext__trig:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
  .hb-cardtext__trigtext { flex: 1 1 auto; min-width: 0; }
  .hb-cardtext__trig > .hb-trig, .hb-cardtext__trig > .hb-trigtag { flex: none; }
  .hb-cardtext__foot { flex: none; min-width: 0; }
  .hb-cardtext__foot > span { flex: none; white-space: nowrap; }
  .hb-cardtext__foot > span:not(.hb-rar) { line-height: 1.5; }   /* one line box for every text span: level, the "g" whole */
  .hb-cardtext__foot > span:last-child { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

  /* the play side panel: the same parts, smaller */
  .hb-detail--compact { gap: 8px; padding: 10px 12px 12px; }
  .hb-detail--compact .hb-detail__top { grid-template-columns: clamp(84px, 38%, 132px) minmax(0, 1fr); gap: 10px; }
  .hb-detail--compact .hb-detail__plate { gap: 6px; }
  .hb-detail--compact .hb-detail__pow { font-size: var(--hb-fs-22); }
  .hb-detail--compact .hb-detail__name { font-size: var(--hb-fs-16); }
  .hb-detail--compact .hb-cardtext { padding: 10px 12px 9px; font-size: var(--hb-fs-13); }

  /* the detail window (board tap, narrow screens) and the card sheet */
  .hb-detail-win .hb-window__body { padding: 0; }
  .hb-detail-win .hb-detail { padding: 2px 16px 16px; }
  .hb-detail-win .hb-detail__top { grid-template-columns: clamp(120px, 40%, 250px) minmax(0, 1fr); }
  .hb-detail-win .hb-window__head { padding-top: 10px; padding-bottom: 6px; }
  /* a window (not a phone sheet) is wide: the text box goes beside the art under the plate, so the plate column is not
     an empty hole beside the tall art and the window stays short */
  @media (min-width: 601px) {
    .hb-detail-win .hb-detail { display: grid; grid-template-columns: clamp(180px, 38%, 250px) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr);
      grid-template-areas: "img plate" "img text"; gap: 12px 18px; align-items: start; flex: none; }   /* (flex: none: shrunk to a short window the
      grid squeezed its text row and the text box hung out of the detail, its ring cut at the end of the scroll) */
    .hb-detail-win .hb-detail:has(> .hb-detail__live) { grid-template-rows: auto auto minmax(0, 1fr); grid-template-areas: "live live" "img plate" "img text"; }
    .hb-detail-win .hb-detail__top { display: contents; }
    .hb-detail-win .hb-detail__live { grid-area: live; }
    .hb-detail-win .hb-detail__img { grid-area: img; }
    .hb-detail-win .hb-detail__plate { grid-area: plate; }
    .hb-detail-win .hb-detail__text { grid-area: text; }
  }
  .hb-cardsheet .hb-window__title { display: flex; align-items: center; gap: 6px; font-size: var(--hb-fs-16); }
  .hb-cardsheet__pos { min-width: 64px; color: var(--hb-text-2); font: italic 900 var(--hb-fs-16)/1 var(--hb-font-num); text-align: center; }
  .hb-cardsheet__next .hb-icon { transform: rotate(180deg); }
  /* the pinned head of the card sheet: printings left, the stepper right (one band, not two), code + product under the
     thumbs */
  .hb-cardsheet__pin { position: sticky; top: 0; z-index: 3; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 6px 12px; padding: 2px 16px 10px;
    background-color: var(--hb-ink-2); border-bottom: 1px solid var(--hb-line); }
  .hb-cardsheet__pin > .hb-detail__prints { grid-column: 1; grid-row: 1; padding-bottom: 0; border-bottom: 0; }
  .hb-cardsheet__pin > .hb-detail__actions { grid-column: 2; grid-row: 1; margin-top: 0; padding-top: 4px; }
  .hb-cardsheet__pin .hb-detail__printmeta { flex: 1 0 100%; flex-flow: row wrap; align-items: baseline; gap: 0 8px; margin-left: 0; text-align: left; }
  @media (pointer: coarse) {
    .hb-cardsheet__pin .hb-step > button { width: 40px; height: 40px; }
  }
  .hb-cardsheet .hb-detail { padding-top: 12px; }

  /* ================================================================== DECK BUILDER: find | read | build */
  #scr-builder { overflow: hidden; }
  .hb-bld { display: grid; grid-template-columns: minmax(0, 1fr) clamp(320px, 27vw, 440px) clamp(290px, 22vw, 360px); grid-template-rows: minmax(0, 1fr);
    gap: 14px; height: 100%; max-width: 1760px; margin: 0 auto; padding: 14px 16px 16px; }
  .hb-bld__tabs { display: none; }

  /* ---- pool panel + toolbar (two rows at most whatever the data) */
  .hb-bld__pool { display: flex; flex-direction: column; gap: 10px; min-height: 0; padding: 12px 12px 0; }
  .hb-bld__bar { position: relative; display: flex; flex-direction: column; gap: 8px; flex: none; }
  .hb-bld__row1, .hb-bld__row2 { display: flex; align-items: center; gap: 8px; min-width: 0; }
  .hb-bld__search { flex: 1 1 220px; min-width: 150px; }
  .hb-bld__sortbox { display: flex; align-items: center; gap: 6px; flex: none; }
  /* "SORT" names the select, so its "Cost" never reads as a second Cost filter beside the Cost dropdown */
  .hb-bld__sortbox > .hb-bld__sortlab { flex: none; color: var(--hb-text-3); font: 700 var(--hb-fs-11)/1.2 var(--hb-font-ui); letter-spacing: .14em; text-transform: uppercase; white-space: nowrap; cursor: pointer; }
  :lang(ja) .hb-bld__sortbox > .hb-bld__sortlab { letter-spacing: .04em; }
  .hb-bld__sort { width: auto; max-width: 132px; padding-left: 10px; font-size: var(--hb-fs-13); }
  .hb-bld__diricon { width: 16px; height: 16px; }
  .hb-bld__size > button { min-width: 26px; padding: 0 7px; }
  .hb-bld__reset { padding: 0 8px; }
  .hb-bld__fold .hb-icon { transition: transform var(--hb-dur-hover) var(--hb-ease-out); transform: rotate(180deg); }
  .hb-bld.is-folded .hb-bld__fold .hb-icon { transform: none; }
  .hb-bld__fold.is-set { color: var(--hb-kin-text); }
  .hb-bld.is-folded .hb-bld__fold.is-set::after { content: ""; position: absolute; top: 4px; right: 4px; width: 6px; height: 6px; border-radius: 50%; background-color: var(--hb-kin-hi); }
  .hb-bld.is-folded .hb-bld__row2 { display: none; }
  /* the colour rail: 赤 緑 青 discs in one well (unpressed = dimmed; pressed = a bright gold ring) */
  .hb-bld__rail { display: flex; align-items: center; gap: 5px; flex: none; height: var(--hb-h-md); padding: 0 5px; border: 1px solid var(--hb-line-2); border-radius: var(--hb-r-ctl); background-color: var(--hb-well); }
  .hb-bld__cbtn { display: grid; margin: 0; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer;
    transition: transform var(--hb-dur-press) var(--hb-ease-out), filter var(--hb-dur-hover); }
  .hb-bld__cbtn .hb-gem { --s: 26px; }
  .hb-bld__cbtn[aria-pressed="false"] { filter: saturate(.4) brightness(.72); }
  .hb-bld__cbtn[aria-pressed="false"]:hover { filter: saturate(.8) brightness(.95); }
  .hb-bld__cbtn[aria-pressed="true"] .hb-gem { box-shadow: 0 0 0 2px #140a06, 0 0 0 3.5px var(--hb-kin-hi); }
  .hb-bld__cbtn:active { transform: scale(.9); }
  /* the dropdowns: one per dimension; they shrink (ellipsis) instead of wrapping into a third row */
  .hb-bld__drops { display: flex; align-items: center; gap: 8px; flex: 0 1 auto; min-width: 0; }
  .hb-fdd { display: flex; align-items: center; flex: 0 1 auto; min-width: 58px; }
  #bld-fdrops > .hb-fdd.is-more { display: none; }
  #bld-fdrops .hb-fdd__label { display: none; }
  .hb-dd.hb-bld__dd { max-width: 168px; padding: 0 9px 0 11px; }  /* .hb-dd--fluid: shrinks with an ellipsis */
  /* an empty dropdown keeps its whole name ("タイプ", "Trigger"); only the ones showing a pick ("ライガ・ファミリー ✕")
     give up width, with an ellipsis (the full pick is in the trigger's title) */
  #bld-fdrops > .hb-fdd:not(:has(> .hb-dd.is-set)) { flex-shrink: 0; }
  #bld-fdrops > .hb-fdd:has(> .hb-dd.is-set) { flex-shrink: 1; min-width: 72px; }
  .hb-bld__morebtn.hb-dd { flex: none; min-width: 0; gap: 7px; padding: 0 9px 0 10px; }
  .hb-bld__morebtn .hb-icon { width: 15px; height: 15px; color: var(--hb-kin); }
  .hb-bld__morebtn .hb-badge { box-shadow: 0 0 0 1.5px var(--hb-kin); }
  .hb-bld__morebtn.is-set { border-color: var(--hb-kin); background-color: var(--hb-kin-deep); color: var(--hb-text); }
  .hb-bld__morebtn.is-open .hb-dd__caret { transform: rotate(180deg); }
  /* the More popover (desktop): the other dropdowns as labelled rows */
  .hb-bld__morepop { width: 320px; padding: 12px; }
  .hb-bld__morebody { display: flex; flex-direction: column; gap: 8px; }
  .hb-bld.is-narrowbar .hb-bld__row1 > .hb-bld__sortbox { display: none; }
  .hb-bld.is-narrowbar .hb-bld__morebtn .hb-dd__label, .hb-bld.is-narrowbar .hb-bld__morebtn .hb-dd__caret { display: none; }
  .hb-bld.is-narrowbar .hb-bld__morebtn.hb-dd { position: relative; width: var(--hb-h-md); justify-content: center; padding: 0; }
  .hb-bld.is-narrowbar .hb-bld__morebtn .hb-badge { position: absolute; top: -6px; right: -6px; }
  .hb-bld.is-narrowbar #bld-fdrops { flex: 1 1 auto; }
  .hb-bld.is-narrowbar #bld-fdrops > .hb-fdd { flex: 1 1 0; }
  .hb-bld.is-narrowbar #bld-fdrops .hb-dd.hb-bld__dd { width: 100%; max-width: none; }
  .hb-bld__morebody .hb-fdd, .hb-fsheet__body .hb-fdd, .hb-fsheet__body .hb-bld__sortbox, .hb-bld__morebody .hb-bld__sortbox { display: flex; align-items: center; gap: 12px; min-width: 0; }
  .hb-bld__morebody .hb-bld__sortbox { gap: 8px; margin-top: 2px; }
  .hb-bld__morebody .hb-bld__sortbox > .hb-fdd__label { display: block; flex: none; min-width: 64px; color: var(--hb-text-3); font: 700 var(--hb-fs-11)/1.2 var(--hb-font-ui); letter-spacing: .14em; text-transform: uppercase; }
  .hb-bld__morebody .hb-bld__sort { flex: 1 1 auto; max-width: none; }
  /* (a dropdown names its dimension itself; only the sort row needs a label) */
  .hb-bld__morebody .hb-fdd__label, .hb-fsheet__body .hb-fdd .hb-fdd__label { display: none; }
  .hb-fsheet__body .hb-bld__sortbox > .hb-fdd__label, .hb-bld__sizelab { display: block; flex: none; min-width: 64px; color: var(--hb-text-3); font: 700 var(--hb-fs-11)/1.2 var(--hb-font-ui); letter-spacing: .14em; text-transform: uppercase; }
  :lang(ja) .hb-fsheet__body .hb-fdd__label, :lang(ja) .hb-bld__sizelab { letter-spacing: .04em; }
  .hb-bld__morebody .hb-dd.hb-bld__dd, .hb-fsheet__body .hb-dd.hb-bld__dd { flex: 1 1 auto; max-width: none; }
  .hb-bld__morefoot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--hb-line); }
  .hb-bld__sizebox { display: flex; align-items: center; gap: 8px; }
  /* the phone filter sheet */
  .hb-fsheet__body { display: flex; flex-direction: column; gap: 10px; padding: 4px 0 6px; }
  .hb-fsheet__body .hb-bld__sort { flex: 1 1 auto; max-width: none; }

  /* ---- the pool: tiles in the card's own look; the selected tile gold-ringed; count badge top-right */
  .hb-bld__grid { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--hb-tile), 1fr));
    gap: 16px 12px; align-content: start; margin: 0 -12px; padding: 10px 12px 18px; }
  .hb-bld__none { grid-column: 1 / -1; padding: 48px 16px; }
  .hb-tile { position: relative; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
  .hb-tile__card { position: relative; transition: transform var(--hb-dur-hover) var(--hb-ease-out); }
  .hb-tile__img { display: block; width: 100%; margin: 0; padding: 0; border: 0; border-radius: var(--hb-r-print); background: none; cursor: pointer; }
  .hb-tile .hb-cimg { box-shadow: 0 0 0 1px rgba(0,0,0,.6), 0 6px 14px rgba(0,0,0,.45); transition: box-shadow var(--hb-dur-hover), opacity var(--hb-dur-hover); }
  .hb-tile:hover .hb-tile__card { transform: translateY(-4px); }
  .hb-tile:hover .hb-cimg { box-shadow: 0 0 0 1.5px var(--hb-kin), 0 14px 24px rgba(0,0,0,.55); }
  .hb-tile.is-sel .hb-cimg { box-shadow: 0 0 0 2px var(--hb-kin-hi), 0 0 0 4px #0b0604, 0 10px 22px rgba(0,0,0,.5); }
  .hb-tile.is-max .hb-cimg { opacity: .48; }
  /* the count sits on the right edge just under the printed power (top-right on a HORO-BEAT card), never over it */
  .hb-tile__badge { position: absolute; top: 15.5%; right: -7px; z-index: 2; pointer-events: none; }
  .hb-tile__btn { position: absolute; z-index: 2; display: grid; place-items: center; width: 32px; height: 32px; margin: 0; padding: 0; border-radius: 50%; cursor: pointer; box-shadow: 0 4px 10px rgba(0,0,0,.5); }
  .hb-tile__btn::before { content: ""; position: absolute; inset: -6px; }
  .hb-tile__btn .hb-icon { width: 16px; height: 16px; }
  .hb-tile__add { right: 7px; bottom: 7px; border: 1px solid var(--hb-shu-hi); background-color: var(--hb-shu); color: #fff; opacity: 0; transform: scale(.7);
    transition: opacity var(--hb-dur-hover), transform var(--hb-dur-hover) var(--hb-ease-stamp), background-color var(--hb-dur-hover); }
  .hb-tile__add:hover { background-color: var(--hb-shu-hover); }
  .hb-tile:hover .hb-tile__add, .hb-tile__add:focus-visible { opacity: 1; transform: none; }
  .hb-tile__add[disabled] { visibility: hidden; }
  .hb-tile__dec { left: 7px; bottom: 7px; display: none; border: 1px solid var(--hb-kin-line); background-color: var(--hb-ink-3); color: var(--hb-text); }
  .hb-tile__btn:active { transform: scale(.9); }
  .hb-tile__name { overflow: hidden; padding: 0 2px; color: var(--hb-text-2); font: 700 var(--hb-fs-12)/1.3 var(--hb-font-ui); text-overflow: ellipsis; white-space: nowrap; }
  .hb-tile.is-sel .hb-tile__name { color: var(--hb-kin-text); }
  .hb-tile.is-max .hb-tile__name { color: var(--hb-text-3); }
  /* touch / narrow: the buttons are always there ("−" once the card is in the deck) */
  /* (always shown on every tile, so lacquer like the "−": one vermilion per view) */
  .hb-bld.is-sheetmode .hb-tile__add { opacity: 1; transform: none; border-color: var(--hb-kin-line); background-color: var(--hb-ink-3); color: var(--hb-text); }
  .hb-bld.is-sheetmode .hb-tile__add .hb-icon { color: var(--hb-kin-hi); }
  .hb-bld.is-sheetmode .hb-tile__dec:not([hidden]) { display: grid; }
  .hb-bld.is-sheetmode .hb-tile:hover .hb-tile__card { transform: none; }

  /* ---- the detail column */
  .hb-bld__detail { display: flex; flex-direction: column; min-height: 0; overflow: hidden; container: hb-bdetail / size; }
  .hb-bld__detail > .hb-detail { flex: 1 1 auto; }
  .hb-bld__detail > .hb-empty { flex: 1 1 auto; }
  /* a tall column (1920x1080 and up): beside the plate the art could not grow and the column was half empty; stack it
     instead (BZ: the art on top, as big as the height allows), the plate under it. The art keeps ~600 px for the
     printings, the plate and a few lines of text, and the text still scrolls inside its box when it is long. */
  @container hb-bdetail (min-height: 920px) and (min-width: 360px) {
    .hb-bld__detail .hb-detail__top { grid-template-columns: minmax(0, 1fr); justify-items: center; gap: 12px; }
    .hb-bld__detail .hb-detail__img { width: clamp(200px, calc((100cqh - 610px) * .716), 300px); }
    .hb-bld__detail .hb-detail__plate { justify-self: stretch; }
    .hb-bld__detail .hb-detail__actions { margin-top: 2px; }
  }

  /* ---- the deck panel */
  .hb-bld__deck { display: flex; flex-direction: column; gap: 10px; min-height: 0; overflow: hidden; padding: 12px; }
  /* a name that does not fit beside the count (a narrow column, a long name): it gets its own line instead of an
     ellipsis after 7 letters (builder.js sets .is-longname when the input overflows) */
  .hb-bld__dhead.is-longname { flex-wrap: wrap; row-gap: 2px; }
  .hb-bld__dhead.is-longname > .hb-bld__dirty { order: -2; }
  .hb-bld__dhead.is-longname > .hb-bld__name { order: -1; flex: 1 0 calc(100% - 16px); }
  .hb-bld__dhead.is-longname > .hb-bld__total { margin-left: auto; }
  .hb-bld__dhead { display: flex; align-items: center; gap: 8px; flex: none; min-width: 0; }
  .hb-bld__dirty { flex: none; width: 7px; height: 7px; border-radius: 50%; background-color: var(--hb-warn); box-shadow: 0 0 0 2px var(--hb-warn-deep); }
  .hb-bld__name { flex: 1 1 auto; min-width: 0; height: 32px; margin-left: -6px; padding: 0 6px; border-color: transparent; background-color: transparent;
    font: 800 var(--hb-fs-16)/1.2 var(--hb-font-headtext); letter-spacing: .02em; text-overflow: ellipsis; }
  .hb-bld__name:hover { border-color: var(--hb-line-2); }
  .hb-bld__name:focus { background-color: var(--hb-well); }
  .hb-bld__total { flex: none; white-space: nowrap; }
  .hb-bld__total.is-short { color: var(--hb-text-2); }
  .hb-bld__valid { display: flex; flex: none; }
  .hb-bld__phoneacts { display: none; }
  .hb-bld__comp { flex: none; }
  .hb-curve--mini { flex: none; height: 50px; gap: 5px; }
  .hb-bld.is-info .hb-curve--mini { display: none; }   /* the Info tab shows the full curve: never two curves at once */
  .hb-curve__bar.is-zero { border-top-color: var(--hb-line-2); background-color: transparent; }
  .hb-curve--big { height: 104px; }
  .hb-curve__v { color: var(--hb-text-2); font-size: var(--hb-fs-12); }
  .hb-bld__dtabs { flex: none; margin: 0 -12px; padding: 0 4px; }
  .hb-bld__dtabs .hb-tab { height: 34px; }
  .hb-bld__list, .hb-bld__info { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; margin: -4px -8px 0; padding: 0 8px 6px; }
  .hb-bld__list > .hb-empty { padding-top: 40px; }
  .hb-bld__group { display: flex; justify-content: space-between; align-items: baseline; margin: 12px 0 4px; padding: 0 2px 0 6px; color: var(--hb-kin-text); font: 800 var(--hb-fs-11)/1 var(--hb-font-ui); letter-spacing: .14em; text-transform: uppercase; }
  .hb-bld__group b { font: italic 900 var(--hb-fs-13)/1 var(--hb-font-num); letter-spacing: 0; }
  :lang(ja) .hb-bld__group { letter-spacing: .06em; }
  /* a row: cost disc · name · power (dim) · count; − / + on hover (always on touch) */
  .hb-row { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto auto auto; align-items: center; gap: 0 8px; height: 32px; padding: 0 4px 0 6px; border-radius: var(--hb-r-item); }
  .hb-row:hover { background-color: var(--hb-ink-3); }
  .hb-row.is-sel { background-color: var(--hb-ink-3); box-shadow: inset 2px 0 0 var(--hb-kin); }
  .hb-row__name { display: flex; align-items: baseline; gap: 6px; min-width: 0; margin: 0; padding: 0; border: 0; background: none; color: var(--hb-text); cursor: pointer; text-align: left;
    font: 700 var(--hb-fs-13)/1.3 var(--hb-font-ui); }
  .hb-row__title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .hb-row__name .hb-rar { align-self: center; }
  .hb-row__sub { display: none; }
  .hb-row__pow, .hb-row > [data-dec] { grid-column: 3; grid-row: 1; justify-self: end; }
  .hb-row__pow { color: var(--hb-text-3); font: italic 700 var(--hb-fs-12)/1 var(--hb-font-num); transition: opacity var(--hb-dur-hover); }
  .hb-row__pow--edge { font-family: var(--hb-font-boostnum); font-style: normal; font-weight: 400; }   /* a ワザ's "+2000": the edge numerals */
  .hb-row__n { grid-column: 4; min-width: 16px; color: var(--hb-text); font: italic 900 var(--hb-fs-14)/1 var(--hb-font-num); text-align: right; }
  .hb-row__btn { display: grid; place-items: center; width: 22px; height: 22px; margin: 0; padding: 0; border: 1px solid var(--hb-kin-line); border-radius: var(--hb-r-ctl);
    background-color: var(--hb-ink-4); color: var(--hb-text); cursor: pointer; opacity: 0; pointer-events: none; transition: opacity var(--hb-dur-hover), background-color var(--hb-dur-hover); }
  .hb-row__btn .hb-icon { width: 12px; height: 12px; }
  .hb-row__btn:hover { border-color: var(--hb-kin); }
  /* (lacquer, not vermilion: a list of rows would otherwise put a dozen vermilion squares beside the one Save) */
  .hb-row__inc { grid-column: 5; width: 0; margin-left: -8px; border-width: 0; overflow: hidden; }
  .hb-row__btn[disabled] { filter: saturate(.3); cursor: not-allowed; }
  .hb-row:hover .hb-row__pow, .hb-row:focus-within .hb-row__pow { opacity: 0; pointer-events: none; }  /* opacity 0 still paints above the − and caught its clicks */
  .hb-row:hover .hb-row__btn, .hb-row:focus-within .hb-row__btn { opacity: 1; pointer-events: auto; }
  .hb-row:hover .hb-row__btn[disabled], .hb-row:focus-within .hb-row__btn[disabled] { opacity: .4; }
  .hb-row:hover .hb-row__inc, .hb-row:focus-within .hb-row__inc { width: 22px; margin-left: 0; border-width: 1px; }
  /* touch / narrow: taller rows with a sub-line, the steppers always there */
  .hb-bld.is-sheetmode .hb-row { height: 46px; }
  .hb-bld.is-sheetmode .hb-row__name { flex-wrap: wrap; row-gap: 1px; }
  .hb-bld.is-sheetmode .hb-row__sub { display: block; flex: 1 0 100%; min-width: 0; overflow: hidden; color: var(--hb-text-3); font: 500 var(--hb-fs-11)/1.25 var(--hb-font-ui); text-overflow: ellipsis; white-space: nowrap; }
  .hb-bld.is-sheetmode .hb-row__pow { display: none; }
  .hb-bld.is-sheetmode .hb-row__btn { width: 32px; height: 32px; margin-left: 0; border-width: 1px; opacity: 1; pointer-events: auto; }
  .hb-bld.is-sheetmode .hb-row__btn[disabled] { opacity: .4; }
  .hb-bld.is-sheetmode .hb-row__n { min-width: 20px; text-align: center; }
  /* the Info tab */
  .hb-bld__info section { margin: 12px 0 16px; }
  .hb-bld__ihead { margin: 0 0 8px; color: var(--hb-kin-text); font: 800 var(--hb-fs-11)/1.2 var(--hb-font-ui); letter-spacing: .14em; text-transform: uppercase; }
  :lang(ja) .hb-bld__ihead { letter-spacing: .06em; }
  .hb-ibar { display: grid; grid-template-columns: minmax(0, 1fr) minmax(60px, 90px) 26px; align-items: center; gap: 8px; min-height: 26px; color: var(--hb-text-2); font-size: var(--hb-fs-12); }
  .hb-ibar__l { display: flex; align-items: center; gap: 6px; min-width: 0; white-space: nowrap; }   /* (no clip: the disc / gem rings fill the cell; the label span ellipsizes itself) */
  .hb-ibar__l > span:last-child { overflow: hidden; text-overflow: ellipsis; }
  .hb-ibar__t { height: 6px; overflow: hidden; border-radius: var(--hb-r-bar); background-color: var(--hb-well); }
  .hb-ibar__t > i { display: block; height: 100%; background-color: var(--hb-kin); }
  .hb-ibar.c-red .hb-ibar__t > i, .hb-ibar.c-green .hb-ibar__t > i, .hb-ibar.c-blue .hb-ibar__t > i { background-color: var(--c); }
  .hb-ibar__n { color: var(--hb-text); font: italic 900 var(--hb-fs-13)/1 var(--hb-font-num); text-align: right; }
  /* the actions: Save is the one vermilion; Play it at the right end */
  .hb-bld__actions { display: flex; flex-direction: column; gap: 6px; flex: none; margin: 0 -12px -12px; padding: 10px 12px 12px; border-top: 1px solid var(--hb-line); }
  .hb-bld__arow { display: flex; align-items: center; gap: 4px; min-width: 0; }
  .hb-bld__arow > .hb-btn { flex: none; padding: 0 8px; }
  .hb-bld__arow > .hb-btn--ghost:first-child { margin-left: -4px; }
  .hb-bld__arow > .hb-btn--ghost:last-child { margin-right: -4px; }
  .hb-bld__test .hb-icon { color: var(--hb-tama); }
  .hb-bld__test[aria-disabled="true"] .hb-icon { color: inherit; }

  /* ---- the load window, the deck menu sheet, ghosts */
  .hb-loadlist { display: grid; gap: 6px; }
  .hb-loadrow { grid-template-columns: 44px minmax(0, 1fr) auto; }
  .hb-loadrow__art { position: relative; display: block; width: 44px; height: 44px; overflow: hidden; border-radius: 50%; background-color: var(--hb-ink-0); box-shadow: 0 0 0 2px var(--hb-kin), 0 0 0 3px var(--hb-ink-0); }
  .hb-loadrow__art img { position: absolute; left: -20%; top: -16%; width: 140%; max-width: none; }
  .hb-loadrow__text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
  .hb-loadrow .hb-deck__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .hb-loadrow .hb-deck__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
  .hb-loadrow__n { color: var(--hb-text); font: italic 900 var(--hb-fs-14)/1 var(--hb-font-num); }
  .hb-loadrow.is-cur { box-shadow: inset 0 0 0 1px var(--hb-kin), inset 3px 0 0 var(--hb-shu); }
  .hb-menusheet__list { display: flex; flex-direction: column; gap: 8px; padding-bottom: 8px; }
  .hb-menusheet__list .hb-btn { justify-content: flex-start; height: 46px; padding: 0 14px; }
  .hb-menusheet__why { margin-left: auto; overflow: hidden; color: var(--hb-text-3); font: 500 var(--hb-fs-11)/1.2 var(--hb-font-ui); text-overflow: ellipsis; white-space: nowrap; }
  .hb-bld-ghostrow { z-index: 760; border-radius: var(--hb-r-item); background-color: var(--hb-ink-3); }
  .hb-bld-ghostrow > .hb-row { height: 100%; }
}

@layer hb-phone {
  /* narrow windows and touch screens: two columns, the card opens as a sheet */
  .hb-bld.is-sheetmode { grid-template-columns: minmax(0, 1fr) clamp(282px, 34vw, 340px); }
  .hb-bld.is-sheetmode .hb-bld__detail { display: none; }
  @media (pointer: coarse) {   /* the filter sheet's sort row matches the 40 px dropdowns above it (this layer: after the theme's 34 px) */
    .hb-fsheet__body .hb-bld__sort { height: 40px; }
    .hb-fsheet__body .hb-bld__dir.hb-btn { width: 40px; height: 40px; }
  }
  @media (max-width: 760px) {
    /* phone: Cards | Deck tabs; the builder fills the screen between the app bar and the tab bar */
    .hb-bld, .hb-bld.is-sheetmode { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); gap: 8px; padding: 8px 8px 0; }
    .hb-bld__tabs { display: flex; }
    .hb-bld__tabs b { margin-left: 4px; font: italic 900 var(--hb-fs-14)/1 var(--hb-font-num); }
    .hb-bld__tabs .is-legal b { color: var(--hb-kin-hi); }
    .hb-bld__deck { display: none; }
    .hb-bld.is-deck .hb-bld__deck { display: flex; }
    .hb-bld.is-deck .hb-bld__pool { display: none; }
    .hb-bld__pool, .hb-bld__deck { border-radius: var(--hb-r-panel) var(--hb-r-panel) 0 0; }
    .hb-bld__pool { padding: 8px 8px 0; gap: 8px; }
    .hb-bld__row1 > .hb-bld__sortbox, .hb-bld__reset, .hb-bld__fold { display: none; }
    .hb-bld.is-folded .hb-bld__row2 { display: flex; }
    .hb-bld__search { flex-basis: 100%; }
    .hb-bld__row2 { gap: 6px; }
    .hb-bld__rail { gap: 4px; padding: 0 4px; }
    .hb-bld__cbtn .hb-gem { --s: 28px; }
    .hb-fdd { min-width: 0; }
    .hb-dd.hb-bld__dd { max-width: none; }
    #bld-fdrops { flex: 1 1 auto; }
    #bld-fdrops > .hb-fdd { flex: 1 1 0; }
    #bld-fdrops .hb-dd.hb-bld__dd { width: 100%; }
    .hb-bld__morebtn .hb-dd__label, .hb-bld__morebtn .hb-dd__caret { display: none; }
    .hb-bld__morebtn.hb-dd { width: 40px; justify-content: center; padding: 0; }
    .hb-bld__morebtn .hb-badge { position: absolute; top: -6px; right: -6px; }
    .hb-bld__grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 7px; margin: 0 -8px; padding: 8px 8px 16px; }
    .hb-tile__name { font-size: var(--hb-fs-10); }
    .hb-tile__badge { top: 15%; right: -5px; }
    .hb-tile__btn { width: 28px; height: 28px; }
    .hb-tile__add { right: 3px; bottom: 3px; }
    .hb-tile__dec { left: 3px; bottom: 3px; }
    .hb-tile__btn .hb-icon { width: 14px; height: 14px; }
    /* the deck pane: name on its own line; count · state … Save · ⋯; the action rows live in the ⋯ sheet */
    .hb-bld__deck { gap: 8px; padding: 10px 10px 0; }
    .hb-bld__dhead { flex-wrap: wrap; row-gap: 4px; }
    .hb-bld__name { order: -1; flex: 1 0 100%; }
    .hb-bld__phoneacts { display: flex; gap: 6px; flex: none; margin-left: auto; }
    .hb-bld__actions { display: none; }
    .hb-bld__dtabs { margin: 0 -10px; }
    .hb-bld__list, .hb-bld__info { margin: -4px -6px 0; padding: 0 6px 10px; }
    .hb-detail-win .hb-detail { padding: 2px 14px 16px; }
    .hb-detail-win .hb-detail__top { grid-template-columns: clamp(110px, 42%, 180px) minmax(0, 1fr); }
    .hb-cardsheet__pin { padding: 2px 14px 10px; }
    .hb-cardsheet__pin .hb-step > output { min-width: 34px; }
  }
  @media (max-width: 380px) {
    /* 360 px phones: the rail and the two dropdowns share ~326 px; keep "トリガー" / "Trigger" whole */
    .hb-bld__rail { gap: 3px; padding: 0 3px; }
    .hb-bld__cbtn .hb-gem { --s: 26px; }
    .hb-dd.hb-bld__dd { gap: 4px; padding: 0 7px 0 9px; }
    .hb-dd.hb-bld__dd .hb-dd__caret { width: 12px; height: 12px; }
  }
}

/* ------------------------------------------------------------------ decoration (gone in Performance mode) */
@layer hb-fx {
  /* tiles: a lantern glow under the lifted card; the selected one glows warm */
  body:not(.hb-perf) .hb-tile:hover .hb-cimg { box-shadow: 0 0 0 1.5px var(--hb-kin), 0 14px 24px rgba(0,0,0,.55), var(--glow-lantern); }
  body:not(.hb-perf) .hb-tile.is-sel .hb-cimg { box-shadow: 0 0 0 2px var(--hb-kin-hi), 0 0 0 4px #0b0604, 0 10px 22px rgba(0,0,0,.5), 0 0 22px -2px rgba(255,150,70,.45); }
  body:not(.hb-perf) .hb-tile:hover .hb-tile__add { box-shadow: 0 4px 10px rgba(0,0,0,.5), 0 0 14px var(--hb-shu-glow); }
  body:not(.hb-perf) .hb-bld__cbtn[aria-pressed="true"] .hb-gem { box-shadow: 0 0 0 2px #140a06, 0 0 0 3.5px var(--hb-kin-hi), 0 0 12px var(--hb-shu-glow); }
  body:not(.hb-perf) .hb-print.is-on img { box-shadow: 0 0 0 2px var(--hb-kin-hi), 0 0 0 3px #0b0604, 0 0 12px -2px rgba(255,150,70,.5); }
  /* the detail column: a faint wash of the card's colour behind the art, like lantern light on its frame */
  body:not(.hb-perf) .hb-bld__detail > .hb-detail { background-image: radial-gradient(120% 46% at 30% 22%, color-mix(in srgb, var(--c-deep) 55%, transparent), transparent 70%); }
  body:not(.hb-perf) .hb-detail--compact { background-image: linear-gradient(180deg, color-mix(in srgb, var(--c-deep) 40%, transparent), transparent 140px); }
  /* the deck panel's head: a seigaiha strip under it, as on the app bar */
  body:not(.hb-perf) .hb-bld__dtabs { background-image: var(--pat-seigaiha); background-size: 16px 8px; background-position: 0 100%; background-repeat: repeat-x; }
  body:not(.hb-perf) .hb-bld__dirty { animation: hb-flicker 3.1s linear infinite; }
  body:not(.hb-perf) .hb-bld__list > .hb-empty .hb-dama, body:not(.hb-perf) .hb-bld__detail > .hb-empty .hb-dama { color: var(--hb-tama); filter: drop-shadow(0 0 6px var(--hb-tama-glow)); animation: hb-float 2.8s var(--hb-ease-sway) infinite alternate; }
}
