/* Millennium Rare is a card edition, not a new set of duel rules.
   Keep the image unobscured; identify it with a quiet prismatic edge. */
:root {
  --millennium-gold: #f5dc91;
  --millennium-prism: linear-gradient(125deg, #f5dc91, #edf8ff 30%, #c8b7f1 52%, #c0ead8 72%, #f5dc91);
}
.millennium-card,
.card-face.tier-9,
.art-card:has(> img[src*="assets/millennium/"]),
.db-preview-art:has(> img[src*="assets/millennium/"]),
.db-hand-cards button:has(> img[src*="assets/millennium/"]),
.db-art:has(> .db-inspect > img[src*="assets/millennium/"]),
.card-art[data-card-art*="assets/millennium/"],
.card-detail-art:has(> img[src*="assets/millennium/"]),
.source-card-art:has(> img[src*="assets/millennium/"]),
.inspected-art:has(> img[src*="assets/millennium/"]) {
  position: relative;
  isolation: isolate;
  outline: 1px solid var(--millennium-gold);
  outline-offset: 1px;
  box-shadow: 0 0 0 3px #f5dc911e, 0 0 16px #ddc58c24;
}
.millennium-card::before,
.card-face.tier-9::before,
.art-card:has(> img[src*="assets/millennium/"])::before,
.db-preview-art:has(> img[src*="assets/millennium/"])::before,
.db-hand-cards button:has(> img[src*="assets/millennium/"])::before,
.db-art:has(> .db-inspect > img[src*="assets/millennium/"])::before,
.card-art[data-card-art*="assets/millennium/"]::before,
.card-detail-art:has(> img[src*="assets/millennium/"])::before,
.source-card-art:has(> img[src*="assets/millennium/"])::before,
.inspected-art:has(> img[src*="assets/millennium/"])::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  border: 2px solid transparent;
  border-radius: inherit;
  background: var(--millennium-prism) border-box;
  -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
  mask-composite: exclude;
  pointer-events: none;
}
.millennium-card img, .card-face.tier-9 img { object-fit: contain; }
.millennium-forge .awakening-art > .millennium-card {
  padding: 0;
  border-radius: 3px;
}
.millennium-forge .awakening-art > .millennium-card img { aspect-ratio: auto; }
.millennium-forge .awakening-art:focus-visible { outline: none; }
.millennium-forge .awakening-art:focus-visible > .millennium-card {
  outline: 2px solid #fff2c8;
  outline-offset: 5px;
}

.millennium-card:focus-visible, .card-face.tier-9:focus-visible {
  outline: 2px solid #fff2c8;
  outline-offset: 5px;
}
.rarity[data-tier="9"], .millennium-badge {
  color: var(--millennium-gold);
  border-color: #f5dc916b;
  background: linear-gradient(125deg, #443821, #292338 55%, #22362f);
  font-weight: 700;
  letter-spacing: .035em;
}
.millennium-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 3px 7px;
  border: 1px solid #f5dc916b;
  border-radius: 5px;
  font-size: 11px;
  line-height: 1.3;
}
.millennium-art-note { color: var(--soft); font-size: 11px; line-height: 1.6; }
.millennium-art-options { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0; }
.millennium-art-options button {
  width: 66px;
  padding: 4px;
  background: #ffffff04;
  border: 1px solid #ffffff24;
  border-radius: 6px;
  line-height: 0;
}
.millennium-art-options button[aria-pressed="true"] {
  border-color: var(--millennium-gold);
  background: #f5dc9114;
}
.millennium-art-options img { width: 100%; aspect-ratio: 421/614; object-fit: contain; }
.millennium-reveal {
  text-align: center;
  padding: clamp(18px, 4vw, 36px);
  background: radial-gradient(ellipse at 50% 35%, #aa854523, transparent 65%);
}
.millennium-reveal .card-face { max-width: 220px; margin: 24px auto; }
.millennium-reveal .millennium-card { animation: millennium-reveal-in .65s cubic-bezier(.18,.72,.3,1) both; }
.millennium-reveal h2 { margin: 10px 0; text-wrap: balance; }
.millennium-reveal p { max-width: 46ch; margin: 12px auto; line-height: 1.65; }
@keyframes millennium-reveal-in {
  from { opacity: 0; transform: translateY(12px) scale(.96); }
  to { opacity: 1; transform: none; }
}

/* The hub, store and farm pages share spacing, hit areas and readable controls.
   Scope these refinements away from the duel field's fixed geometry. */
:is(.site-workspace, .store-workspace) { --control-radius: 8px; }
:is(.site-workspace, .store-workspace) :is(button, a, input, select, summary) { touch-action: manipulation; }
:is(.site-workspace, .store-workspace) :is(input, select, textarea) { border-radius: var(--control-radius); }
:is(.site-workspace, .store-workspace) :is(button, a, input, select, summary):focus-visible {
  outline: 2px solid #f1dba0;
  outline-offset: 3px;
}
:is(.site-workspace, .store-workspace) :is(.btn, .buy, .subtle, .db-button, .section-link),
:is(.site-workspace, .store-workspace) .forge-tabs button,
:is(.site-workspace, .store-workspace) .farm-filters button {
  line-height: 1.35;
  text-align: center;
}
:is(.site-workspace, .store-workspace) :is(.buy, .db-button, .forge-tabs button, .farm-filters button) {
  transition: background-color .16s ease, border-color .16s ease, color .16s ease;
}
:is(.site-workspace, .store-workspace) button:disabled { cursor: not-allowed; }
:is(.site-workspace, .store-workspace) :is(.section-title, .db-heading, .panel-heading) { min-width: 0; }
:is(.site-workspace, .store-workspace) :is(h1, h2, h3) { overflow-wrap: break-word; }
:is(.site-workspace, .store-workspace) :is(.store-content, .rematch-main, .db-scroll, .forge-card-list) {
  scrollbar-color: #655571 transparent;
  scroll-padding-block: 18px;
}
.site-nav .site-nav-item { gap: 10px; }
.site-nav .site-nav-item:focus-visible { outline-offset: -2px; }
.site-balance { font-variant-numeric: tabular-nums; }
.hub-shortcut { transition: border-color .16s ease, background-color .16s ease; }
.hub-shortcut h2 { line-height: 1.45; }
.hub-shortcut p { max-width: 42ch; }
.hub-deck-preview > div { min-width: 0; }
.hub-collection-link { align-items: center; min-height: 44px; }
:is(.site-workspace, .store-workspace) .difficulty-picker { min-width: 0; }
:is(.site-workspace, .store-workspace) .difficulty-picker select { max-width: 100%; }
:is(.site-workspace, .store-workspace) .difficulty-picker > small { line-height: 1.65; }
.farm-workspace .difficulty-picker { flex-wrap: wrap; row-gap: 10px; }
.farm-workspace .farm-filters { flex-wrap: wrap; gap: 8px; }
.farm-workspace .rematch-chases button { min-height: 42px; padding-block: 2px; line-height: 1.45; }
.farm-workspace .rematch-actions { margin-top: 4px; }
.farm-workspace .rematch-actions .btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; }
.farm-workspace .rematch-duelist > div { min-width: 0; }
.farm-workspace .rematch-style { line-height: 1.6; }
#store .collection-toolbar :is(input, select),
#store .collection-filter-panel select,
#store .deck-toolbar :is(input, select) { min-height: 44px; }
#store .collection-filter-panel { gap: 12px; padding: 16px; }
#store .collection-filter-panel label { line-height: 1.5; }
#store .collection-results { line-height: 1.55; }
#store .card-tile .buy { min-height: 44px; }
#store .card-tile .copy-counts { font-variant-numeric: tabular-nums; }
#store .card-tile h3 { text-wrap: balance; }
#store .forge-tabs { gap: 8px; }
#store .forge-tabs button { min-height: 44px; }
#store .forge-requirements li { align-items: baseline; column-gap: 16px; }
#store .forge-requirements li b { font-variant-numeric: tabular-nums; }
#store .forge-requirements .buy { min-height: 44px; line-height: 1.4; }
#store .forge-card-list button { scroll-margin-block: 8px; }
#store .mastery-strip > span { flex-wrap: wrap; row-gap: 6px; line-height: 1.5; }
#store .db-statusbar p { line-height: 1.55; }
#store .db-bank-caption small { font-variant-numeric: tabular-nums; }
#store .db-art:focus-within { outline: 2px solid var(--gold); outline-offset: 3px; }
#store .db-tools > summary { cursor: pointer; min-width: 36px; }
#store .db-tools button { min-height: 38px; }
dialog .dialog-close { display: grid; place-items: center; min-width: 40px; min-height: 40px; padding: 0; line-height: 1; }
dialog :is(.source-pack-links, .source-featured-link, .source-farm-link) { font-variant-numeric: tabular-nums; }
dialog .source-rates { grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); }
dialog .source-rates > span { min-width: 0; }

@media (max-width: 760px) {
  #store .collection-filter-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 12px; }
  #store .forge-tabs { gap: 6px; }
  #store .forge-tabs button { flex: 1 1 auto; padding: 10px 12px; }
  :is(.site-workspace, .store-workspace) .difficulty-picker > small { flex-basis: 100%; }
  .farm-workspace .rematch-actions { gap: 8px; }
  .farm-workspace .rematch-actions .btn { flex: 1 1 auto; }
  #store .db-tools button { min-height: 44px; }
  #store .db-pagination button, #store .db-mobile-tabs button { min-height: 40px; }
}
@media (max-width: 480px) {
  #store .collection-toolbar { gap: 10px; }
  #store .collection-toolbar .filter-toggle { gap: 10px; padding-inline: 12px; }
  #store .forge-requirements li { row-gap: 5px; }
  #store .forge-requirements li b { white-space: normal; }
  #store .db-result-tools { flex-wrap: wrap; gap: 8px; }
  #store .db-result-tools select { flex: 1; min-width: 120px; }
  .millennium-art-options { gap: 8px; }
  .millennium-reveal .card-face { max-width: 180px; }
}
@media (pointer: coarse) {
  :is(.site-workspace, .store-workspace) :is(.subtle, .text-btn, .filter-toggle, .collection-pagination button) { min-height: 44px; }
  :is(.site-workspace, .store-workspace) .db-icon, :is(.site-workspace, .store-workspace) .db-tools > summary { min-height: 40px; min-width: 40px; }
  :is(.site-workspace, .store-workspace) .db-kind-tabs button { min-height: 38px; }
}
:root[data-card-motion="off"] .millennium-reveal .millennium-card { animation: none; }
@media (prefers-reduced-motion: reduce) {
  .millennium-reveal .millennium-card { animation: none; }
  :is(.site-workspace, .store-workspace) :is(.buy, .db-button, .forge-tabs button, .farm-filters button, .hub-shortcut) { transition: none; }
}
@media (forced-colors: active) {
  .millennium-card::before, .card-face.tier-9::before { display: none; }
  .millennium-card, .card-face.tier-9 { outline: 2px solid Highlight; }
  .millennium-badge { border-color: Highlight; }
}

/* Millennium uses the same forge workbench but keeps its searchable card list
   available on phones; the Awakening-only mobile picker is not present here. */
.database-card .millennium-badge, .card-section-title .millennium-badge { color: var(--millennium-gold); }
.database-card .millennium-badge { align-self: flex-start; text-align: left; }
.millennium-intro { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.millennium-intro p { margin: 0; color: var(--soft); font-size: 12px; line-height: 1.6; }
.millennium-drop-note { margin-top: 20px; padding: 14px 16px; border: 1px solid #e8c77730; border-radius: 8px; background: #e8c77707; }
.millennium-drop-note b { font-size: 12px; color: var(--gold); }
.millennium-drop-note p { margin: 7px 0 0; font-size: 12px; line-height: 1.65; color: var(--soft); }
@media (max-width: 700px) {
 .millennium-forge .awakening-library { display: block; position: static; margin-bottom: 14px; padding: 14px; }
 .millennium-forge .awakening-card-list { max-height: 180px; overflow-y: auto; overscroll-behavior: contain; }
 .millennium-forge .awakening-card-choice { min-height: 58px; }
 .millennium-forge .awakening-search input { min-height: 44px; font-size: 13px; }
 .millennium-forge .awakening-filters button { min-height: 40px; }
 .millennium-intro { gap: 10px; margin-bottom: 14px; }
}

.millennium-chapter-rate{padding:12px 0;border-bottom:1px solid var(--border,#40384c)}
.millennium-chapter-rate:last-of-type{border-bottom:0}
.millennium-chapter-rate .source-rates{display:flex;flex-wrap:wrap;gap:12px}
.millennium-chapter-rate .source-rates>span{display:flex;flex-direction:column;gap:4px;flex:1;min-width:150px}
.millennium-chapter-rate .source-rates b{color:#f4d887;font-size:1.1rem}
.millennium-chapter-rate small{color:var(--muted,#b6aec4)}
