#collection-library { display: none; position: fixed; inset: 0; z-index: 60; overflow: auto; overscroll-behavior: contain; color: #f7ecd1; background: #1b120b url(hs/table.webp) center / cover fixed; user-select: text; }
#collection-library.show { display: block; }
#collection-library::before { content: ''; position: fixed; inset: 0; background: rgba(13, 8, 3, .7); pointer-events: none; }
.library-wrap { position: relative; max-width: 1320px; margin: 0 auto; padding: 20px 30px 64px; }
.library-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 30px; }
.library-wordmark { color: #ffe3a1; font: 22px 'HS Belwe', Georgia, serif; letter-spacing: 1px; }
#collection-library h1, #collection-library h2, #collection-library h3 { font-family: 'HS Belwe', Georgia, serif; font-weight: 400; color: #ffe3a1; }
#collection-library h1 { font-size: clamp(36px, 5vw, 54px); margin: 0 0 24px; }
#collection-library h2 { font-size: 27px; line-height: 1.15; margin: 0 0 8px; }
#collection-library h3 { font-size: 20px; margin: 24px 0 8px; }
#collection-library p { line-height: 1.55; max-width: 68ch; }
#collection-library button { color: inherit; }
#collection-library button.primary { color: #291908; }
.library-tabs { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 28px; }
.library-tabs button[aria-pressed=true] { color: #ffe3a1; border-color: #f7ce70; background-color: #533616; }
.library-tools { display: flex; align-items: end; flex-wrap: wrap; gap: 20px 30px; margin-bottom: 18px; }
.library-tools label { display: flex; flex-direction: column; gap: 9px; font-size: 14px; }
.library-tools input[type=search] { width: min(380px, 100%); border: 1px solid #a8834a; background: #24170c; color: #fff4d6; font: 16px var(--body); padding: 12px 14px; border-radius: 6px; outline-offset: 3px; caret-color: #ffe3a1; }
.library-tools input::placeholder { color: #c4ae88; }
.library-tools .library-token-toggle { flex-direction: row; align-items: center; min-height: 44px; }
.library-token-toggle input { accent-color: #e5b958; width: 18px; height: 18px; }
.library-filters { display: flex; flex-wrap: wrap; gap: 8px; }
.library-filters button, .library-related button { font: 14px var(--body); min-height: 40px; padding: 8px 12px; background: #2d1f12; border: 1px solid #8a6a3e; border-radius: 5px; }
.library-filters button[aria-pressed=true] { color: #ffe3a1; background: #513819; border-color: #eac168; }
.library-count { color: #d7c39d; font-size: 14px; margin: 22px 0 8px; }
.library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 30px 24px; justify-items: center; padding: 16px 0; }
.library-card { display: flex; width: 210px; flex-direction: column; align-items: center; gap: 12px; border: 0; border-radius: 6px; background: transparent; padding: 6px 5px 12px; }
.library-card .card { flex: none; pointer-events: none; }
.library-card-caption { font: 16px 'HS Belwe', Georgia, serif; color: #f7ecd1; }
.library-card:hover { background: rgba(126, 90, 39, .18); }
.library-more { text-align: center; margin: 20px 0; }
.library-empty { grid-column: 1 / -1; text-align: center; padding: 35px 0; }
.library-intro { color: #d7c39d; margin: 0 0 30px; }
.library-return { margin-bottom: 28px; }
.library-detail { display: grid; grid-template-columns: 280px minmax(0, 620px); align-items: start; justify-content: center; gap: 48px; padding: 15px 0 40px; }
.library-detail-art { display: flex; justify-content: center; padding: 15px 35px 80px; }
.library-detail-art > .card { transform: scale(1.25); transform-origin: center top; flex: none; }
.library-detail-copy { min-width: 0; }
.library-meta { text-transform: capitalize; color: #d7c39d; font-size: 14px; }
.library-rules { font-size: 20px; }
.library-flavor { font-style: italic; color: #dfc995; }
.library-keywords dt { color: #ffe3a1; font-weight: 700; margin-top: 18px; }
.library-keywords dd { margin: 6px 0 0; line-height: 1.5; }
.library-related { display: flex; flex-wrap: wrap; gap: 8px; }
.library-credit { font-size: 12px; color: #c9b791; margin-top: 28px; overflow-wrap: anywhere; }
#collection-library a { color: #ffe3a1; text-underline-offset: 3px; }
.library-heroes, .library-decks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 40px; }
.library-hero, .library-deck { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 28px; align-items: start; padding: 28px 0; border: 0; border-bottom: 1px solid #795a30; background: transparent; text-align: left; }
.library-deck { grid-template-columns: 118px minmax(0, 1fr); gap: 24px; }
.library-deck:hover h2 { color: #fff2b5; }
.library-portrait { display: flex; justify-content: center; flex: none; padding-top: 10px; }
.library-portrait .h-art { margin: 0 !important; }
.library-company { color: #d7c39d; font-size: 14px; margin: 0 0 14px; }
.library-deck-link { color: #ffe3a1; display: inline-block; margin-top: 8px; }
.library-deck-detail { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 1fr); gap: 60px; align-items: start; }
.library-deck-title { display: flex; align-items: center; gap: 24px; }
.library-curve { display: flex; align-items: end; gap: 12px; height: 140px; max-width: 380px; margin-bottom: 26px; }
.library-curve > div { display: flex; flex: 1; flex-direction: column; align-items: center; gap: 6px; color: #ecd8ac; font-size: 13px; font-variant-numeric: tabular-nums; }
.library-curve i { display: block; width: 100%; min-height: 2px; background: #c69c49; border-radius: 3px 3px 0 0; }
.library-deck-list { display: flex; flex-direction: column; gap: 4px; }
.library-deck-list button { display: grid; grid-template-columns: 30px minmax(0, 1fr) 32px; gap: 10px; align-items: center; border: 1px solid #74552f; border-radius: 4px; padding: 10px; background: #291c10; text-align: left; font: 15px var(--body); min-height: 44px; }
.library-deck-list button:hover { background: #42301b; }
.library-cost { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: #25486d; color: #fff; font-weight: 700; }
#collection-library button:focus-visible, #collection-library input:focus-visible, #collection-library a:focus-visible { outline: 2px solid #ffe3a1; outline-offset: 4px; }
#collection-library ::selection { background: #876425; color: #fff7dc; }
@media (max-width: 1000px) { .library-heroes, .library-decks { grid-template-columns: 1fr; } }
@media (max-width: 650px) {
  .library-wrap { padding: 16px 20px 48px; }
  .library-header { margin-bottom: 24px; }
  .library-wordmark { font-size: 18px; }
  .library-tools, .library-tools > label:first-child { width: 100%; }
  .library-tools input[type=search] { width: 100%; min-width: 0; }
  .library-tabs { gap: 8px; }
  .library-grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
  .library-detail { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .library-detail-art { padding-bottom: 85px; }
  .library-hero { grid-template-columns: 110px minmax(0, 1fr); gap: 20px; }
  .library-hero .library-portrait .h-art { transform: scale(.73); transform-origin: top center; margin: 0 -20px -45px !important; }
  .library-deck { grid-template-columns: 90px minmax(0, 1fr); gap: 20px; }
  .library-deck .library-portrait .h-art { transform: scale(.76); transform-origin: top center; margin: 0 -16px -35px !important; }
  .library-deck-detail { grid-template-columns: 1fr; gap: 28px; }
  .library-deck-title { gap: 15px; }
  .library-deck-title .library-portrait { width: 110px; }
  .library-deck-title .h-art { transform: scale(.73); transform-origin: center; }
}

.library-news-source { font-size: 14px; color: #ead6ad; margin-top: 22px; }

/* Hearthstone Collection Manager (src/menu/Collection.ts). Layers come from hs-collection/ (local skin);
   coordinates are scene pixels of the CollectionManager prefab, the stage is scaled to the window. */
#collection-library.cm { overflow: hidden; user-select: none; background: #1b120b url(hs/table.webp) center / cover fixed; }
#collection-library.cm::before { background: radial-gradient(ellipse at 50% 50%, rgba(13, 8, 3, .15) 40%, rgba(13, 8, 3, .75) 100%); }
.cm-view { position: absolute; inset: 0; overflow: hidden; }
.cm-stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.cm-layer { position: absolute; pointer-events: none; user-select: none; -webkit-user-drag: none; }
.cm-stage button { position: absolute; display: block; margin: 0; padding: 0; border: 0; background: none; box-shadow: none; border-radius: 0;
  color: inherit; font: inherit; cursor: pointer; overflow: visible; min-height: 0; -webkit-tap-highlight-color: transparent; }
.cm-stage button[hidden] { display: none; }
.cm-stage button:focus { outline: none; }
.cm-stage button:focus-visible { outline: 6px solid rgba(255, 215, 110, .9); outline-offset: 4px; }
.cm-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* book and page */
.cm-book { position: absolute; background: url(hs-collection/page.webp) 0 0 / 100% 100% no-repeat; }
.cm-page { position: absolute; inset: 0; }
.cm-sheet { background: url(hs-collection/page.webp) 0 0 / 100% 100% no-repeat; transform-origin: 0 50%; backface-visibility: hidden;
  box-shadow: 18px 0 40px rgba(0, 0, 0, .35); z-index: 3; }
#collection-library .cm-page-name { position: absolute; margin: 0; transform: translate(-50%, -50%); white-space: nowrap; pointer-events: none;
  font: 400 54px/1 'HS Belwe', Georgia, serif; color: #2a1802; text-shadow: 0 1px 0 rgba(255, 240, 200, .5); }
#collection-library .cm-page-count { position: absolute; margin: 0; transform: translate(-50%, -50%); white-space: nowrap; pointer-events: none;
  font: 400 30px/1 'HS Belwe', Georgia, serif; color: #63564a; }
.cm-card, .cm-hero { width: 0; height: 0; transition: transform .14s cubic-bezier(.2, .8, .3, 1.3); }
.cm-card-face { position: absolute; left: 0; top: 0; display: block; transform-origin: 0 0; }
.cm-card-face .card { pointer-events: auto; filter: drop-shadow(0 10px 14px rgba(40, 20, 0, .45)); }
.cm-card:hover, .cm-card:focus-visible, .cm-hero:hover, .cm-hero:focus-visible { transform: scale(1.06); z-index: 2; }
.cm-card:hover .card, .cm-hero:hover .card { filter: brightness(1.08) drop-shadow(0 16px 20px rgba(40, 20, 0, .55)); }
.cm-card:active { transform: scale(1.02); }
#collection-library .cm-hero-power { position: absolute; left: 0; top: 168px; transform: translateX(-50%); white-space: nowrap; pointer-events: none;
  font: 400 27px/1 'HS Belwe', Georgia, serif; color: #3d2a12; }
#collection-library .cm-empty { position: absolute; left: 50% !important; top: 46%; transform: translate(-50%, -50%); text-align: center; color: #3b2a14; }
#collection-library .cm-empty h2 { font: 400 52px 'HS Belwe', Georgia, serif; margin: 0 0 14px; color: #2a1802; }
#collection-library .cm-empty p { font: 30px Georgia, serif; margin: 0; }

/* class tabs */
.cm-tab { transition: transform .18s cubic-bezier(.2, .8, .3, 1.25), filter .15s; }
.cm-tab:hover, .cm-tab:focus-visible { filter: brightness(1.18); }
.cm-tab.selected { z-index: 2; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .55)); }

/* page arrows */
.cm-arrow { z-index: 4; transition: transform .12s; }
.cm-arrow .glow { opacity: 0; mix-blend-mode: screen; transition: opacity .15s; }
.cm-arrow:hover .glow, .cm-arrow:focus-visible .glow { opacity: 1; }
.cm-arrow.left:active { transform: translateX(-6px); }
.cm-arrow.right:active { transform: translateX(6px); }

/* mana filter */
.cm-crystal { transition: transform .12s, filter .15s; }
.cm-crystal .glow { opacity: 0; mix-blend-mode: screen; transition: opacity .15s; }
.cm-crystal:hover .glow, .cm-crystal:focus-visible .glow { opacity: .55; }
.cm-crystal.selected .glow { opacity: 1; }
.cm-crystal.selected { transform: scale(1.08); }
.cm-crystal.dim { filter: brightness(.55) saturate(.55); }
.cm-crystal:active { transform: scale(.95); }
.cm-crystal .gem { filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .6)); }
.cm-crystal-num { position: absolute; top: 50%; transform: translate(-50%, -52%); pointer-events: none; white-space: nowrap;
  font: 400 44px/1 'HS BelweNumbers', 'HS Belwe', serif; color: #fff; -webkit-text-stroke: 7px #000; paint-order: stroke fill; }

/* search */
.cm-search { position: absolute; display: block; }
.cm-search input { position: absolute; left: 84px; right: 22px; top: 6px; bottom: 6px; width: auto; margin: 0; padding: 0; border: 0; background: transparent;
  font: 400 32px/1 'HS Belwe', Georgia, serif; color: #fff2d1; outline: none; caret-color: #ffe3a1; -webkit-appearance: none; appearance: none; }
.cm-search input::placeholder { color: rgba(255, 236, 196, .55); }
.cm-search input::-webkit-search-cancel-button { filter: sepia(1) saturate(3) hue-rotate(-10deg); cursor: pointer; }
.cm-search:focus-within { filter: brightness(1.12); }

/* deck tray */
#collection-library .cm-tray-title { position: absolute; margin: 0; transform: translate(-50%, -50%); white-space: nowrap; pointer-events: none; max-width: 300px;
  overflow: hidden; text-overflow: ellipsis; font: 400 34px/1.1 'HS Belwe', Georgia, serif; color: #fff; -webkit-text-stroke: 6px #1a0e04; paint-order: stroke fill; }
#collection-library .cm-tray-title.long { font-size: 26px; -webkit-text-stroke-width: 5px; }
#collection-library .cm-tray-count { position: absolute; margin: 0; transform: translate(-50%, -50%); white-space: nowrap; pointer-events: none;
  font: 400 30px/1 'HS Belwe', Georgia, serif; color: #fff; -webkit-text-stroke: 6px #1a0e04; paint-order: stroke fill; }
.cm-tray-list { position: absolute; overflow-x: hidden; overflow-y: auto; scrollbar-width: none; overscroll-behavior: contain; touch-action: pan-y; }
.cm-tray-list::-webkit-scrollbar { display: none; }
.cm-tray-list:focus-visible { outline: 4px solid rgba(255, 215, 110, .7); }
.cm-deckbox, .cm-bar { left: 0; width: 100%; transition: transform .12s, filter .12s; }
.cm-deckbox-inner, .cm-bar-inner { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.cm-deckbox-photo { position: absolute; inset: 0; -webkit-mask-size: 100% 100%; mask-size: 100% 100%; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; }
.cm-photo { position: absolute; inset: 0; background-size: cover; background-position: 70% 30%; }
.cm-photo svg { width: 100%; height: 100%; display: block; }
.cm-deckbox-name { position: absolute; top: 50%; transform: translateY(-58%); max-width: 175px; text-align: left; pointer-events: none;
  font: 400 21px/1.1 'HS Belwe', Georgia, serif; color: #fff; -webkit-text-stroke: 4px #000; paint-order: stroke fill; }
.cm-deckbox-name small { display: block; margin-top: 4px; font: 14px/1.1 Georgia, serif; color: #f1dcae; -webkit-text-stroke: 3px #000; }
.cm-deckbox:hover, .cm-deckbox:focus-visible { filter: brightness(1.15); transform: translateX(-6px); }
.cm-bar-art { position: absolute; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; }
.cm-bar-art .cm-photo { background-position: 50% 32%; }
.cm-bar-cost { position: absolute; display: grid; place-items: center; pointer-events: none;
  font: 400 50px/1 'HS BelweNumbers', 'HS Belwe', serif; color: #fff; -webkit-text-stroke: 8px #000; paint-order: stroke fill; }
.cm-bar-name { position: absolute; top: 50%; transform: translateY(-52%); max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  pointer-events: none; text-align: left; font: 400 31px/1.1 'HS Belwe', Georgia, serif; color: #fff; -webkit-text-stroke: 6px #000; paint-order: stroke fill; }
.cm-bar.r-legendary .cm-bar-name { color: #ffd98a; }
.cm-bar-count { position: absolute; right: 22px; top: 50%; transform: translateY(-52%); pointer-events: none;
  font: 400 38px/1 'HS BelweNumbers', 'HS Belwe', serif; color: #ffd44a; -webkit-text-stroke: 7px #000; paint-order: stroke fill; }
.cm-bar-count.star { font-family: Georgia, serif; color: #ffcf4d; }
.cm-bar:hover, .cm-bar:focus-visible { filter: brightness(1.2); }
.cm-done, .cm-play { z-index: 2; }
.cm-done .glow, .cm-play .glow { opacity: 0; mix-blend-mode: screen; transition: opacity .15s; }
.cm-done:hover .glow, .cm-done:focus-visible .glow, .cm-play:hover .glow, .cm-play:focus-visible .glow { opacity: 1; }
.cm-done:active, .cm-play:active { transform: translateY(3px); }
.cm-done-label { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -54%); pointer-events: none; white-space: nowrap;
  font: 400 32px/1 'HS Belwe', Georgia, serif; color: #ffe8b0; -webkit-text-stroke: 6px #2a1505; paint-order: stroke fill; }
.cm-bigcard { position: absolute; z-index: 6; pointer-events: none; opacity: 0; transform: translate(-50%, -50%) scale(1.55); transition: opacity .12s; }
.cm-bigcard.show { opacity: 1; }
.cm-bigcard .card { filter: drop-shadow(0 18px 30px rgba(0, 0, 0, .7)); }

/* book cover, card zoom */
.cm-cover { position: absolute; z-index: 8; transform-origin: 0 50%; pointer-events: none; }
.cm-zoom { position: absolute; inset: 0; z-index: 20; background: rgba(8, 5, 2, .72); box-shadow: 0 0 0 4000px rgba(8, 5, 2, .72); cursor: zoom-out; }
.cm-zoom[hidden] { display: none; }
.cm-zoom-card { position: absolute; left: 34%; top: 48%; transform: translate(-50%, -50%); pointer-events: none; }
.cm-zoom-card > .card { zoom: 2.35; filter: drop-shadow(0 18px 26px rgba(0, 0, 0, .75)); }
.cm-zoom-info { position: absolute; left: 54%; top: 50%; transform: translateY(-50%); width: 640px; max-height: 1100px; overflow: auto; cursor: auto;
  padding: 44px 50px; color: #2c1d0c; background: #ecdcb6 url(hs-collection/page.webp) center / cover; border: 6px solid #6e4b22;
  border-radius: 18px; box-shadow: 0 30px 70px rgba(0, 0, 0, .7), inset 0 0 0 3px rgba(255, 240, 200, .45); user-select: text; }
#collection-library .cm-zoom-info h2 { margin: 0 0 10px; font: 400 56px/1.05 'HS Belwe', Georgia, serif; color: #2a1802; }
#collection-library .cm-zoom-meta { margin: 0 0 22px; font: 26px Georgia, serif; text-transform: capitalize; color: #6a5338; }
#collection-library .cm-zoom-flavor { margin: 0 0 22px; font: italic 28px/1.4 Georgia, serif; color: #4a3518; }
.cm-zoom-info dl { margin: 0 0 22px; font: 26px/1.35 Georgia, serif; }
.cm-zoom-info dt { font: 400 30px 'HS Belwe', Georgia, serif; color: #2a1802; margin-top: 12px; }
.cm-zoom-info dd { margin: 4px 0 0; }
.cm-zoom-related { display: flex; flex-wrap: wrap; gap: 12px; margin: 0 0 22px; }
.cm-zoom-info button { position: relative !important; display: inline-block !important; padding: 10px 22px !important; border: 3px solid #7a5527 !important;
  border-radius: 10px !important; background: #f6e7c4 !important; font: 400 26px 'HS Belwe', Georgia, serif !important; color: #2a1802 !important; }
.cm-zoom-info button:hover { background: #fff3d6 !important; }
#collection-library .cm-zoom-credit { font: 20px/1.4 Georgia, serif; color: #5b4730; }
#collection-library .cm-zoom-credit a { color: #3a2208; }
.cm-zoom-close { margin-top: 6px; }
#collection-library .cm-stage p { max-width: none; }
/* touch: hit areas larger than the small book controls once the stage is scaled down on phones */
@media (pointer: coarse) {
  .cm-tab::after, .cm-crystal::after, .cm-arrow::after { content: ''; position: absolute; inset: -18px; }
  .cm-crystal::after { inset: -14px -4px; }
}
