/* Market Watch–style card drawer (scoped to #cardDrawer). Matches css/v2.md-* modal patterns. */

#cardDrawer.drawer-dialog--mw {
    width: min(1180px, calc(100vw - 24px));
    height: min(94dvh, 920px);
    max-height: min(94dvh, 920px);
    padding: 0;
    border: none;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#cardDrawer.drawer-dialog--mw::backdrop {
    background: rgba(0, 0, 0, 0.72);
}

#cardDrawer.drawer-dialog--mw > .close-button {
    display: none;
}

#cardDrawer #cardDrawerContent {
    margin: 0;
    padding: 0;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#cardDrawer #cardDrawerContent > .md-modal-shell {
    flex: 1 1 auto;
    min-height: 0;
    max-height: 100%;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    width: 100%;
    gap: 0;
}

#cardDrawer .md-modal-shell .md-modal {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    max-height: 100%;
}

#cardDrawer .md-modal {
    background: var(--panel, #1a1a1a);
    border: 2px solid;
    border-radius: 14px;
    overflow: hidden;
    flex: 1 1 auto;
    min-height: 0;
    max-height: 100%;
    display: flex;
    flex-direction: column;
}

#cardDrawer .md-body-scroll {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    padding: 0.45rem 0.85rem 0.5rem;
    gap: 0.35rem;
    scrollbar-width: thin;
}

#cardDrawer .md-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.5rem 0.75rem;
    padding: 0.55rem 1rem;
    border-bottom: 1px solid;
    background: rgba(0, 0, 0, 0.25);
    flex-shrink: 0;
}

#cardDrawer .md-brand {
    justify-self: start;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#cardDrawer .md-logo {
    height: 44px;
    width: auto;
    border-radius: 6px;
}

#cardDrawer .md-brand-text {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-sec, #c0c0c0);
    letter-spacing: 0.03em;
}

#cardDrawer .md-close {
    justify-self: end;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 1.1rem;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s;
    line-height: 1;
    padding: 0;
}

#cardDrawer .md-close:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.3);
}

#cardDrawer .md-drawer-nav-side {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.15rem;
    min-width: 44px;
}

#cardDrawer .md-drawer-list-nav-btn--side {
    width: 42px;
    height: 72px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    padding: 0;
    line-height: 1;
}

#cardDrawer .md-drawer-list-nav-btn--side:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(0, 230, 80, 0.45);
    color: #b8ffc8;
}

#cardDrawer .md-drawer-list-nav-btn--side:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

#cardDrawer .md-drawer-hero-rail {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    justify-content: center;
    gap: 0.4rem;
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
}

#cardDrawer .md-drawer-hero-column-inner {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

#cardDrawer .md-drawer-hero-rail .md-drawer-nav-side {
    align-self: center;
    min-height: 120px;
}

#cardDrawer .md-drawer-main {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(280px, 1.05fr);
    gap: 0.85rem 1.15rem;
    align-items: stretch;
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

#cardDrawer .md-drawer-left {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    align-self: stretch;
    min-height: 0;
    overflow: hidden;
    position: static;
}

#cardDrawer .md-drawer-right {
    min-width: 0;
    min-height: 0;
    position: relative;
    z-index: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    align-self: stretch;
    overflow-x: visible;
    overflow-y: hidden;
}

#cardDrawer .md-drawer-right--ez {
    gap: 0.45rem;
}

#cardDrawer .md-price-ez {
    display: flex;
    align-items: baseline;
    gap: 0.65rem;
    margin: 0.1rem 0 0.3rem;
    flex-shrink: 0;
}

#cardDrawer .md-price-ez-label {
    font-size: 0.72rem;
    font-weight: 650;
    color: var(--text-sec, #b0b0b0);
}

#cardDrawer .md-price-ez-value {
    font-size: 1.35rem;
    font-weight: 900;
    letter-spacing: -0.02em;
}

#cardDrawer .md-info-grid {
    margin: 0.15rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.28rem;
    flex-shrink: 0;
}

#cardDrawer .md-info-row {
    display: grid;
    grid-template-columns: 6.25rem 1fr;
    gap: 0.5rem 0.75rem;
    align-items: baseline;
    font-size: 0.78rem;
}

#cardDrawer .md-info-row dt {
    margin: 0;
    font-weight: 650;
    color: var(--text-sec, #b0b0b0);
}

#cardDrawer .md-info-row dd {
    margin: 0;
    color: var(--text, #f0f0f0);
    word-break: break-word;
}

#cardDrawer .md-fin-foil {
    color: #ffd700;
    font-weight: 700;
}

#cardDrawer .md-stats-ez {
    display: flex;
    justify-content: space-between;
    gap: 0.35rem;
    padding: 0.55rem 0.15rem;
    margin: 0.15rem 0 0.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    flex-shrink: 0;
}

#cardDrawer .md-stat-ez {
    flex: 1;
    text-align: center;
    min-width: 0;
}

#cardDrawer .md-stat-ez-lbl {
    display: block;
    font-size: 0.62rem;
    font-weight: 650;
    color: var(--muted, #9a9a9a);
    margin-bottom: 0.12rem;
}

#cardDrawer .md-stat-ez-val {
    display: block;
    font-size: 0.92rem;
    font-weight: 800;
}

#cardDrawer .md-flavor-ez {
    margin: 0.1rem 0 0.2rem;
    padding: 0.45rem 0.55rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

#cardDrawer .md-flavor-label {
    display: block;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-sec, #a8a8a8);
    margin-bottom: 0.2rem;
}

#cardDrawer .md-flavor-body {
    margin: 0;
    font-size: 0.74rem;
    font-style: italic;
    line-height: 1.45;
    color: #e6e6e6;
}

#cardDrawer .md-buy-footer {
    margin-top: auto;
    padding-top: 0.55rem;
    padding-inline: 6px;
    padding-bottom: 8px;
    width: 100%;
    flex-shrink: 0;
    overflow: visible;
    box-sizing: border-box;
}

#cardDrawer .md-buy-footer .md-buy-btn {
    margin-top: 0;
}

#cardDrawer .md-buy-footer .md-buy-unavailable {
    margin-top: 0;
}

#cardDrawer .md-hero-stack {
    position: relative;
    width: 100%;
    flex: 1 1 0;
    min-height: 0;
    line-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    gap: 0;
    overflow: visible;
}

#cardDrawer .md-hero-stack-art {
    position: relative;
    width: 100%;
    flex: 1 1 0;
    min-height: min(360px, 56vh);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    overflow: hidden;
    line-height: 0;
}

#cardDrawer .md-drawer-hero-thumb {
    position: relative;
    box-sizing: border-box;
}

/*
 * Portrait cards need a definite height chain: inner must absorb the flex lane (flex: 1; min-height: 0)
 * so img max-height: 100% maps to visible space. Row flex + align-items:center on the thumb shrank the
 * inner to intrinsic bitmap height → overflow clipped by .md-hero-stack-art.
 */
#cardDrawer .md-hero-stack:not(.md-hero-stack--battlefield) .md-drawer-hero-thumb {
    flex: 1 1 auto;
    min-height: min(320px, 52vh);
    width: 100%;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#cardDrawer .md-hero-stack:not(.md-hero-stack--battlefield) .md-drawer-hero-thumb.md-drawer-hero-thumb--deck-champion {
    padding: 8px;
    box-sizing: border-box;
}

#cardDrawer .md-hero-stack:not(.md-hero-stack--battlefield) .md-hero-stack-art-inner {
    position: relative;
    flex: 0 1 auto;
    width: min(360px, 100%);
    aspect-ratio: 5 / 7;
    min-width: 0;
    min-height: 0;
    max-width: min(420px, 100%);
    max-height: 100%;
    align-self: center;
    overflow: hidden;
    border-radius: 14px;
    line-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#cardDrawer .md-hero-stack:not(.md-hero-stack--battlefield) .md-hero-stack-art-inner .md-card-img {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    min-width: 0;
    min-height: 0;
    flex: 0 1 auto;
    object-fit: cover;
    object-position: center center;
    display: block;
    line-height: 0;
    border-radius: 14px;
    clip-path: inset(0 round 14px);
    background: #05070b;
}

/* Borrowed/base fallback art: darken + caption only when the selected image is missing. */
#cardDrawer .md-hero-stack-art-inner--catalog-ref {
    position: relative;
}

#cardDrawer .md-hero-stack-art-inner--catalog-ref::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.88) 0%, rgba(0, 0, 0, 0.42) 42%, transparent 72%);
    z-index: 1;
    border-radius: inherit;
}

#cardDrawer .md-hero-stack:not(.md-hero-stack--battlefield) .md-hero-stack-art-inner--catalog-ref .md-card-img {
    position: relative;
    z-index: 0;
}

#cardDrawer .md-hero-stack--battlefield .md-hero-stack-art-inner--catalog-ref.md-hero-stack-art-inner--battlefield .md-card-img {
    z-index: 0;
}

#cardDrawer .md-hero-art-ref-caption {
    position: absolute;
    left: 50%;
    top: 50%;
    width: min(86%, 18rem);
    transform: translate(-50%, -50%);
    padding: 0.85rem 0.75rem;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(0, 0, 0, 0.56);
    z-index: 2;
    pointer-events: none;
    display: none;
    flex-direction: column;
    gap: 0.18rem;
    line-height: 1.2;
    text-align: center;
}

#cardDrawer .md-hero-stack-art-inner--catalog-ref .md-hero-art-ref-caption {
    display: flex;
}

#cardDrawer .md-hero-art-ref-missing {
    font-size: 1.05rem;
    font-weight: 900;
    color: #ffffff;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.95);
}

#cardDrawer .md-hero-art-ref-name {
    font-size: 0.82rem;
    font-weight: 800;
    color: #f3f6fa;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.95);
}

#cardDrawer .md-hero-art-ref-meta {
    font-size: 0.72rem;
    font-weight: 650;
    color: rgba(220, 228, 236, 0.92);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

/*
 * Drawer battlefield hero: 16:9 stage (deck panel parity). Landscape fills with contain;
 * portrait pixel maps use JS (translate + rotate) like {@link normalizeDeckPanelBattlefieldPresentation}.
 */
#cardDrawer .md-hero-stack--battlefield {
    flex: 0 1 auto;
}

#cardDrawer .md-hero-stack--battlefield .md-hero-stack-art {
    aspect-ratio: 16 / 9;
    max-height: min(56vh, 520px);
    flex: 0 0 auto;
    overflow: hidden;
}

#cardDrawer .md-hero-stack--battlefield .md-drawer-hero-thumb--battlefield-stage {
    width: 100%;
    height: 100%;
    min-height: 0;
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

#cardDrawer .md-hero-stack--battlefield .md-hero-stack-art-inner--battlefield {
    position: relative;
    overflow: hidden;
    border-radius: 10px;
    width: 100%;
    height: 100%;
    min-height: 0;
    line-height: 0;
}

#cardDrawer .md-hero-stack--battlefield .md-hero-stack-art-inner--battlefield .md-card-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    min-width: 0;
    min-height: 0;
    flex: unset;
    object-fit: contain;
    object-position: center;
    transform-origin: center center;
    image-orientation: from-image;
}

#cardDrawer .md-hero-stack--battlefield.drawer-hero-battlefield-portrait .md-hero-stack-art-inner--battlefield .md-card-img {
    inset: auto;
    right: auto;
    bottom: auto;
    object-fit: contain;
    image-orientation: none;
}

#cardDrawer .md-img-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

#cardDrawer .md-img-fallback {
    cursor: default;
}

#cardDrawer .md-buy-unavailable {
    margin: 0.6rem 0 0;
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    background: rgba(255, 193, 7, 0.08);
    border: 1px solid rgba(255, 193, 7, 0.25);
    color: var(--text-sec, #c0c0c0);
    font-size: 0.74rem;
    line-height: 1.4;
    text-align: center;
}

#cardDrawer .md-buy-unavailable i {
    margin-right: 0.35rem;
    color: var(--warn, #ffc107);
}

#cardDrawer .md-card-img {
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 100%;
    min-width: 0;
    min-height: 0;
    object-fit: contain;
    object-position: center center;
    border-radius: 10px;
    border: 2px solid;
    display: block;
}

#cardDrawer .md-drawer-price-block {
    margin-top: 0.35rem;
    margin-bottom: 0;
}

#cardDrawer .md-drawer-price-main {
    font-size: 1.75rem;
    font-weight: 900;
    letter-spacing: -0.02em;
}

#cardDrawer .md-buy-btn--ez {
    box-sizing: border-box;
    max-width: 100%;
    margin-inline: auto;
}

#cardDrawer .md-buy-btn--compact {
    margin-top: 0.5rem;
    padding: 0.52rem 0.65rem;
    font-size: 0.82rem;
}

#cardDrawer .md-buy-unavailable--inline {
    margin-top: 0.45rem;
    margin-bottom: 0;
    padding: 0.4rem 0.55rem;
    font-size: 0.7rem;
    text-align: center;
}

#cardDrawer .md-card-name {
    font-size: 1.25rem;
    font-weight: 800;
    margin: 0 0 0.2rem;
    line-height: 1.2;
    word-break: break-word;
    flex-shrink: 0;
}

#cardDrawer .md-subtitle {
    font-size: 0.75rem;
    color: var(--text-sec, #c0c0c0);
    margin: 0 0 0.3rem;
}

#cardDrawer .md-sep {
    color: var(--muted, #9a9a9a);
    margin: 0 0.15rem;
}

#cardDrawer .md-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem;
    margin-bottom: 0;
    flex-shrink: 0;
}

#cardDrawer .md-domain-chip {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 4px;
    font-size: 0.68rem;
    font-weight: 600;
}

#cardDrawer .md-tag-chip {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-sec, #c0c0c0);
    font-size: 0.72rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#cardDrawer .md-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
}

#cardDrawer .md-stat {
    font-size: 0.65rem;
    color: var(--text-sec, #c0c0c0);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    white-space: nowrap;
}

#cardDrawer .md-stat i {
    margin-right: 0.15rem;
    font-size: 0.58rem;
    opacity: 0.7;
}

#cardDrawer .md-stat-foil {
    color: #ffd700;
    border-color: rgba(255, 215, 0, 0.3);
    background: rgba(255, 215, 0, 0.08);
}

#cardDrawer .md-effect {
    padding: 0.45rem 0.65rem;
    border-radius: 6px;
    border: 1px solid;
    margin-bottom: 0;
    flex: 1 1 auto;
    min-height: 2.5rem;
    overflow-y: auto;
    scrollbar-width: thin;
}

#cardDrawer .md-effect strong {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.78rem;
}

#cardDrawer .md-effect p {
    margin: 0;
    font-size: 0.75rem;
    line-height: 1.5;
    color: #e0e0e0;
    white-space: pre-line;
    word-break: break-word;
}

#cardDrawer .md-effect--related {
    opacity: 0.95;
    margin-top: 0.15rem;
}

#cardDrawer .md-effect--related p {
    color: #d8d8d8;
    font-size: 0.72rem;
}

#cardDrawer .md-outbound-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 0;
    flex-shrink: 0;
}

/* Routed under details column (after buy CTA) — full width, separated from commerce row. */
#cardDrawer .md-drawer-right .md-outbound-row {
    width: 100%;
    margin-top: 0.55rem;
    padding-top: 0.6rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    justify-content: stretch;
    box-sizing: border-box;
}

/* Footer actions live inside details column (after buy CTA). */
#cardDrawer .md-drawer-right .md-deck-actions {
    margin-top: 0.5rem;
    padding-top: 0.55rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    width: 100%;
    box-sizing: border-box;
}

#cardDrawer .md-outbound-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
    font-size: 0.76rem;
    font-weight: 650;
    text-decoration: none;
    border: 1px solid var(--border, #303030);
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

#cardDrawer .md-outbound-link i {
    opacity: 0.85;
    font-size: 0.72rem;
}

#cardDrawer .md-outbound-sub {
    font-size: 0.62rem;
    font-weight: 600;
    opacity: 0.8;
}

#cardDrawer .md-outbound-link--mw {
    background: rgba(45, 113, 162, 0.14);
    border-color: rgba(45, 113, 162, 0.4);
    color: #7eb8e8;
}

#cardDrawer .md-outbound-link--mw:hover {
    background: rgba(45, 113, 162, 0.22);
    border-color: rgba(45, 113, 162, 0.55);
}

#cardDrawer .md-buy-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    width: 100%;
    padding: 0.6rem;
    margin-top: 0.75rem;
    border-radius: 8px;
    border: 2px solid;
    font-size: 0.9rem;
    font-weight: 800;
    text-decoration: none;
    transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
    cursor: pointer;
}

#cardDrawer .md-buy-btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

#cardDrawer .md-deck-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    flex-wrap: nowrap;
    gap: 0.45rem;
    justify-content: flex-start;
    margin-top: 0;
    flex-shrink: 0;
}

#cardDrawer .md-deck-summary {
    margin: 0;
    text-align: center;
    font-size: 0.78rem;
    color: var(--text-sec, #c0c0c0);
}

#cardDrawer .md-deck-clear-all {
    width: 100%;
    box-sizing: border-box;
    padding: 0.5rem 0.65rem;
    border-radius: 8px;
    border: 1px dashed rgba(255, 255, 255, 0.32);
    background: rgba(3, 5, 8, 0.72);
    color: #f2f2f2;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

#cardDrawer .md-deck-clear-all:hover:not(:disabled) {
    border-color: rgba(0, 179, 55, 0.45);
    color: var(--primary-h, #00cc40);
}

#cardDrawer .md-deck-clear-all:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

#cardDrawer .md-drawer-champion-fab-mount:not([hidden]) {
    position: absolute;
    left: 0.32rem;
    top: 0.32rem;
    z-index: 12;
    line-height: 0;
}

#cardDrawer .md-deck-make-champion-icon-btn {
    box-sizing: border-box;
    width: 2.08rem;
    height: 2.08rem;
    margin: 0;
    padding: 0;
    display: grid;
    place-items: center;
    border-radius: 999px;
    border: 1px solid rgba(228, 0, 124, 0.55);
    background: radial-gradient(circle at 30% 20%, rgba(255, 80, 180, 0.24), rgba(24, 2, 12, 0.96));
    color: var(--secondary, #e4007c);
    cursor: pointer;
    box-shadow:
        0 3px 14px rgba(0, 0, 0, 0.55),
        inset 0 1px 0 rgba(228, 0, 124, 0.18);
    transition: filter 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

#cardDrawer .md-deck-make-champion-icon-btn:hover {
    filter: brightness(1.1);
    border-color: rgba(255, 110, 200, 0.85);
    color: #ff7ab8;
}

#cardDrawer .md-deck-make-champion-icon-btn:focus-visible {
    outline: none;
    box-shadow:
        0 0 0 3px rgba(228, 0, 124, 0.35),
        0 3px 14px rgba(0, 0, 0, 0.55);
}

#cardDrawer .md-deck-make-champion-icon {
    font-size: 1.05rem;
    line-height: 1;
}

#cardDrawer .md-deck-selected-champion-pill {
    box-sizing: border-box;
    min-width: 2.08rem;
    height: 2.08rem;
    padding: 0 0.42rem;
    display: grid;
    place-items: center;
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, var(--drawer-runed-primary-border, rgba(0, 179, 55, 0.82)) 70%, transparent);
    background: radial-gradient(
        circle at 30% 18%,
        color-mix(in srgb, var(--drawer-runed-primary-border, rgba(0, 179, 55, 0.9)) 42%, transparent),
        rgba(6, 10, 6, 0.96)
    );
    box-shadow:
        0 2px 12px rgba(0, 0, 0, 0.5),
        0 0 14px color-mix(in srgb, var(--drawer-runed-primary-border, rgba(0, 179, 55, 0.88)) 32%, transparent);
}

#cardDrawer .md-drawer-champion-fab-mount .md-deck-selected-champion-pill-star {
    color: #ffe98a;
    font-size: 1.06rem;
    line-height: 1;
    filter: drop-shadow(0 0 6px rgba(255, 220, 120, 0.55));
}

@property --md-drawer-champion-ring-angle {
    syntax: '<angle>';
    inherits: false;
    initial-value: 0deg;
}

@keyframes md-drawer-champion-ring-angle-kf {
    to {
        --md-drawer-champion-ring-angle: 360deg;
    }
}

#cardDrawer .md-drawer-hero-thumb--deck-champion .md-hero-stack-art-inner:not(.md-hero-stack-art-inner--battlefield) {
    isolation: isolate;
    box-sizing: border-box;
    padding: 0;
    /* Soft cap for highlights — no pure `white` mixes (they hit #fff corners in the conic band). */
    --md-drawer-ring-tint-soft: rgb(232 228 238);
    /* JS sets `--drawer-runed-*`; single-rune omits secondary → pearl band still stays rune-tinted. */
    --md-drawer-ring-p: var(--drawer-runed-primary-border, rgba(0, 179, 55, 0.88));
    --md-drawer-ring-s: var(
        --drawer-runed-secondary-border,
        color-mix(in srgb, var(--drawer-runed-primary-border, rgba(0, 179, 55, 0.88)) 76%, var(--md-drawer-ring-tint-soft))
    );
    --md-drawer-ring-hi: color-mix(in srgb, var(--md-drawer-ring-p) 86%, var(--md-drawer-ring-tint-soft));
    --md-drawer-ring-soft: color-mix(in srgb, var(--md-drawer-ring-p) 68%, transparent);
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.72),
        0 10px 26px rgba(0, 0, 0, 0.52),
        0 0 14px color-mix(in srgb, var(--md-drawer-ring-p) 16%, transparent);
}

/* Rotating halo sits behind the art; padding above reserves the visible ring area in Firefox too. */
#cardDrawer .md-drawer-hero-thumb--deck-champion .md-hero-stack-art-inner:not(.md-hero-stack-art-inner--battlefield)::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    z-index: 3;
    box-sizing: border-box;
    padding: 10px;
    pointer-events: none;
    filter: drop-shadow(0 0 10px color-mix(in srgb, var(--md-drawer-ring-p) 42%, transparent));
    /*
     * Dual-rune: `--md-drawer-ring-s` is the real secondary. Single-rune: it is an auto pearl band from primary
     * (different `%` vs `--md-drawer-ring-hi`) so rotation stays legible—no muddy solid ring.
     */
    background: conic-gradient(
        from var(--md-drawer-champion-ring-angle),
        var(--md-drawer-ring-p),
        var(--md-drawer-ring-hi),
        var(--md-drawer-ring-s),
        var(--md-drawer-ring-p),
        var(--md-drawer-ring-soft),
        color-mix(in srgb, var(--md-drawer-ring-s) 72%, transparent),
        var(--md-drawer-ring-p),
        color-mix(in srgb, var(--md-drawer-ring-hi) 58%, transparent),
        var(--md-drawer-ring-p)
    );
    animation: md-drawer-champion-ring-angle-kf 3.4s linear infinite;
    transform: none;
    mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    mask-composite: exclude;
    -webkit-mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
}

@media (prefers-reduced-motion: reduce) {
    #cardDrawer .md-drawer-hero-thumb--deck-champion .md-hero-stack-art-inner:not(.md-hero-stack-art-inner--battlefield)::after {
        animation: none;
        --md-drawer-champion-ring-angle: 72deg;
        opacity: 0.98;
        filter: drop-shadow(0 0 5px color-mix(in srgb, var(--md-drawer-ring-p) 18%, transparent));
    }

    #cardDrawer .md-deck-selected-champion-pill {
        filter: brightness(1.06);
    }
}

#cardDrawer .md-drawer-hero-thumb--deck-champion .md-hero-stack-art-inner:not(.md-hero-stack-art-inner--battlefield) .md-card-img {
    position: relative;
    z-index: 2;
    border-width: 0 !important;
    box-shadow: none !important;
}

#cardDrawer .md-drawer-hero-qty {
    flex-shrink: 0;
    box-sizing: border-box;
    width: 100%;
    margin-top: 0.45rem;
    padding: 0.45rem 0.65rem 0.5rem;
    border-radius: 8px;
    background: rgba(3, 5, 8, 0.88);
    border: 1px solid rgba(0, 179, 55, 0.24);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
}

#cardDrawer .md-drawer-hero-label {
    display: block;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-sec, #b0b0b0);
    margin-bottom: 0.25rem;
    text-align: center;
}

#cardDrawer .md-drawer-hero-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
}

#cardDrawer .md-drawer-hero-controls button {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

#cardDrawer .md-drawer-hero-controls button:hover {
    border-color: rgba(0, 179, 55, 0.5);
    color: var(--primary-h, #00cc40);
}

#cardDrawer .md-drawer-hero-controls [data-drawer-hero-qty] {
    min-width: 1.75rem;
    text-align: center;
    font-weight: 800;
    font-size: 1.05rem;
    color: var(--primary-h, #00cc40);
}

#cardDrawer .md-drawer-hero-qty-zones {
    margin-top: 0.38rem;
    text-align: center;
    font-size: 0.62rem;
    font-weight: 650;
    line-height: 1.25;
    color: rgba(200, 220, 210, 0.92);
    letter-spacing: 0.02em;
    font-variant-numeric: tabular-nums;
}

#cardDrawer .md-variant-strip-wrap {
    margin-top: 0.35rem;
    flex-shrink: 0;
    width: 100%;
    min-width: 0;
}

#cardDrawer .md-variant-strip-label {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-sec, #b0b0b0);
    margin-bottom: 0.35rem;
}

#cardDrawer .md-variant-strip {
    display: flex;
    flex-direction: row;
    gap: 0.45rem;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 0.2rem 0.15rem 0.35rem;
    scrollbar-width: thin;
    scroll-snap-type: x proximity;
}

#cardDrawer .md-variant-tile {
    flex: 0 0 auto;
    width: 86px;
    background: rgba(0, 0, 0, 0.42);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    padding: 0.25rem;
}

#cardDrawer .md-variant-tile.is-selected {
    outline: 2px solid rgba(0, 240, 110, 0.95);
    outline-offset: 2px;
    border-color: rgba(0, 230, 100, 0.65);
    box-shadow:
        0 0 0 1px rgba(0, 200, 85, 0.9),
        0 0 14px rgba(0, 179, 55, 0.35);
}

#cardDrawer .md-variant-thumb {
    display: block;
    width: 100%;
    padding: 0;
    margin: 0;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    background: transparent;
}

#cardDrawer .md-variant-thumb-inner {
    position: relative;
    display: block;
    width: 100%;
    border-radius: 6px;
    overflow: hidden;
    background: #0a0e14;
}

#cardDrawer .md-variant-thumb-inner--catalog-ref::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.82) 0%, rgba(0, 0, 0, 0.38) 48%, transparent 76%);
    z-index: 1;
    border-radius: inherit;
}

#cardDrawer .md-variant-art-missing-badge {
    position: absolute;
    left: 50%;
    top: 38%;
    z-index: 3;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    max-width: 92%;
    padding: 0.14rem 0.22rem;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.78);
    color: #f8fafc;
    font-size: 0.4rem;
    font-weight: 900;
    line-height: 1.05;
    letter-spacing: 0.02em;
    text-align: center;
    text-transform: uppercase;
    pointer-events: none;
}

#cardDrawer .md-variant-art-missing-badge span {
    display: block;
}

#cardDrawer .md-variant-thumb-inner--catalog-ref:not(.md-variant-thumb-inner--battlefield) > img {
    position: relative;
    z-index: 0;
}

#cardDrawer .md-variant-tile--battlefield .md-variant-thumb-inner--battlefield.md-variant-thumb-inner--catalog-ref > img {
    z-index: 0;
}

#cardDrawer .md-variant-thumb img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 63 / 88;
    object-fit: cover;
    object-position: center top;
    border-radius: 0;
}

#cardDrawer .md-variant-tile--battlefield .md-variant-thumb-inner--battlefield {
    aspect-ratio: 16 / 9;
}

#cardDrawer .md-variant-tile--battlefield .md-variant-thumb-inner--battlefield > img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    aspect-ratio: unset;
    object-fit: contain;
    object-position: center;
    transform-origin: center center;
    image-orientation: from-image;
}

#cardDrawer .md-variant-tile--battlefield .md-variant-thumb-inner--battlefield.drawer-variant-bf-portrait > img {
    inset: auto;
    right: auto;
    bottom: auto;
    object-fit: contain;
    image-orientation: none;
}

#cardDrawer .md-variant-price {
    position: absolute;
    left: 3px;
    bottom: 3px;
    max-width: calc(100% - 6px);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 0.48rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.2;
    color: #b4ffcc;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 1);
    background: rgba(0, 0, 0, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.14);
    pointer-events: none;
    z-index: 2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#cardDrawer .md-variant-tile.is-selected .md-variant-price {
    color: #7dffc0;
    border-color: rgba(0, 230, 100, 0.35);
}

#cardDrawer .md-variant-meta {
    display: flex;
    flex-direction: column;
    gap: 1px;
    margin-top: 0.2rem;
    font-size: 0.58rem;
    line-height: 1.15;
    color: var(--text-sec, #c0c0c0);
    text-align: center;
}

#cardDrawer .md-variant-set {
    font-size: 0.55rem;
    font-weight: 600;
    color: var(--muted, #9a9a9a);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

#cardDrawer .md-variant-rarity {
    color: #ffb8e6;
    font-weight: 650;
}

#cardDrawer .md-variant-fin {
    opacity: 0.95;
}

#cardDrawer .md-variant-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.2rem;
    margin-top: 0.28rem;
    padding: 0.2rem 0.25rem;
    border-radius: 6px;
    background: rgba(4, 6, 10, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

#cardDrawer .md-variant-bar button {
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 0.95rem;
    font-weight: 800;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

#cardDrawer .md-variant-bar button:hover {
    border-color: rgba(0, 230, 80, 0.65);
    background: rgba(255, 255, 255, 0.2);
    color: #c8ffd4;
}

#cardDrawer .md-variant-qty-col {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.06rem;
}

#cardDrawer .md-variant-qty-zones {
    font-size: 0.54rem;
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: 0.02em;
    font-variant-numeric: tabular-nums;
    color: rgba(190, 210, 200, 0.9);
    text-align: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 0.05rem;
}

#cardDrawer .md-variant-qty {
    text-align: center;
    font-size: 0.75rem;
    font-weight: 800;
    color: #7af2a0;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.95);
}

#cardDrawer .md-variant-tile.is-selected .md-variant-qty {
    color: #00ff6a;
}

#cardDrawer .md-add-deck-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.85rem;
    border-radius: 8px;
    border: 1px solid var(--border, #303030);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text, #f0f0f0);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
}

#cardDrawer .md-add-deck-btn:hover {
    border-color: var(--primary, #00b337);
    color: var(--primary-h, #00cc40);
}

@media (max-width: 720px) {
    #cardDrawer.drawer-dialog--mw {
        width: min(100vw - 10px, 430px);
        height: calc(100dvh - 10px);
        max-height: calc(100dvh - 10px);
        margin: auto;
    }

    #cardDrawer #cardDrawerContent > .md-modal-shell {
        position: relative;
        display: block;
        overflow: hidden;
    }

    #cardDrawer .md-modal-shell .md-modal,
    #cardDrawer .md-modal {
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-width: 1px;
        border-radius: 16px;
    }

    #cardDrawer .md-header {
        grid-template-columns: minmax(0, 1fr) 36px;
        padding: 0.48rem 0.62rem;
        gap: 0.45rem;
    }

    #cardDrawer .md-logo {
        height: 34px;
    }

    #cardDrawer .md-brand {
        min-width: 0;
    }

    #cardDrawer .md-brand-text {
        min-width: 0;
        overflow: hidden;
        font-size: 0.82rem;
        line-height: 1.18;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    #cardDrawer .md-close {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }

    #cardDrawer .md-body-scroll {
        overflow-y: auto;
        overflow-x: hidden;
        padding: 0.55rem 0.62rem 0.7rem;
        gap: 0.58rem;
        -webkit-overflow-scrolling: touch;
    }

    #cardDrawer .md-drawer-hero-rail {
        position: relative;
        display: block;
    }

    #cardDrawer .md-drawer-hero-column-inner {
        width: 100%;
    }

    #cardDrawer .md-drawer-nav-side {
        position: absolute;
        top: 42%;
        z-index: 20;
        min-width: 0;
        padding: 0;
        pointer-events: none;
    }

    #cardDrawer .md-drawer-nav-side--start {
        left: 0.35rem;
    }

    #cardDrawer .md-drawer-nav-side--end {
        right: 0.35rem;
    }

    #cardDrawer .md-drawer-list-nav-btn--side {
        width: 36px;
        height: 46px;
        border-radius: 12px;
        background: rgba(0, 0, 0, 0.72);
        backdrop-filter: blur(10px);
        pointer-events: auto;
    }

    #cardDrawer .md-drawer-main {
        display: flex;
        flex-direction: column;
        grid-template-columns: 1fr;
        gap: 0.72rem;
        min-height: 0;
        overflow: visible;
        flex: 0 0 auto;
        flex-grow: 0;
        width: 100%;
    }

    #cardDrawer .md-drawer-left {
        position: static;
        flex: 0 0 auto;
        max-height: none;
        height: auto;
        min-height: 0;
        overflow: visible;
    }

    #cardDrawer .md-hero-stack {
        flex: 0 0 auto;
        gap: 0.5rem;
        align-items: center;
        width: 100%;
    }

    /*
     * Portrait hero: width and height were set independently (wide frame + short clamp),
     * which broke 5:7 and made art look square/cropped. Drive the frame from aspect-ratio
     * with a viewport-capped height so the image + contain layout matches desktop.
     */
    #cardDrawer .md-hero-stack:not(.md-hero-stack--battlefield) {
        height: auto;
    }

    #cardDrawer .md-hero-stack:not(.md-hero-stack--battlefield) .md-hero-stack-art {
        flex: 0 0 auto;
        width: min(320px, calc(100% - 2.75rem));
        max-width: calc(100% - 2.75rem);
        height: auto;
        aspect-ratio: 5 / 7;
        margin-inline: auto;
        overflow: hidden;
        min-height: 0;
    }

    #cardDrawer .md-hero-stack--battlefield {
        height: auto;
    }

    #cardDrawer .md-hero-stack--battlefield .md-hero-stack-art {
        flex: 0 0 auto;
        width: 100%;
        max-width: 100%;
        height: auto;
        max-height: min(38dvh, 300px);
        aspect-ratio: 16 / 9;
        margin-inline: 0;
        overflow: hidden;
        min-height: 0;
    }

    #cardDrawer .md-hero-stack:not(.md-hero-stack--battlefield) .md-drawer-hero-thumb {
        min-height: 0;
        height: 100%;
        flex: 1 1 auto;
    }

    #cardDrawer .md-hero-stack:not(.md-hero-stack--battlefield) .md-hero-stack-art-inner {
        max-width: 100%;
        width: 100%;
        height: auto;
        aspect-ratio: 5 / 7;
        max-height: 100%;
        box-sizing: border-box;
    }

    #cardDrawer .md-hero-stack:not(.md-hero-stack--battlefield) .md-hero-stack-art-inner .md-card-img {
        max-height: 100%;
        max-width: 100%;
        width: 100%;
        height: 100%;
        object-fit: cover;
        object-position: center center;
    }

    #cardDrawer .md-drawer-hero-qty {
        margin: 0 auto;
        width: min(240px, 78vw);
        padding: 0.38rem 0.55rem;
    }

    #cardDrawer .md-drawer-hero-label {
        display: none;
    }

    #cardDrawer .md-drawer-hero-controls button {
        width: 38px;
        height: 38px;
        border-radius: 10px;
    }

    #cardDrawer .md-variant-strip-wrap {
        margin-top: 0.15rem;
        margin-bottom: 0;
    }

    #cardDrawer .md-variant-strip {
        gap: 0.5rem;
        padding: 0.15rem 0.28rem 0.65rem;
        scroll-padding-inline: 0.28rem;
    }

    #cardDrawer .md-variant-tile {
        width: 76px;
        padding: 0.24rem;
        border-radius: 9px;
    }

    #cardDrawer .md-variant-meta {
        font-size: 0.52rem;
    }

    #cardDrawer .md-variant-set {
        display: none;
    }

    #cardDrawer .md-variant-bar {
        padding: 0.18rem;
    }

    #cardDrawer .md-variant-bar button {
        width: 32px;
        height: 32px;
        min-width: 32px;
    }

    #cardDrawer .md-drawer-right .md-deck-actions {
        margin-top: 0.35rem;
        padding-top: 0.5rem;
        gap: 0.5rem;
    }

    #cardDrawer .md-deck-clear-all {
        min-height: 44px;
    }

    #cardDrawer .md-drawer-right {
        display: flex;
        overflow: visible;
        flex: 0 0 auto;
        min-height: 0;
        gap: 0.48rem;
    }

    #cardDrawer .md-card-name {
        font-size: 1.18rem;
        line-height: 1.12;
        margin-top: 0.1rem;
    }

    #cardDrawer .md-price-ez {
        margin: 0;
        align-items: center;
    }

    #cardDrawer .md-price-ez-value {
        font-size: 1.45rem;
    }

    #cardDrawer .md-info-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.34rem 0.65rem;
        padding: 0.48rem 0;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    #cardDrawer .md-info-row {
        display: grid;
        grid-template-columns: 1fr;
        gap: 0.08rem;
        font-size: 0.72rem;
    }

    #cardDrawer .md-stats-ez {
        margin: 0;
        padding: 0.45rem 0;
    }

    #cardDrawer .md-effect {
        flex: 0 0 auto;
        max-height: none;
        min-height: 0;
        padding: 0.58rem 0.65rem;
    }

    #cardDrawer .md-effect p {
        font-size: 0.78rem;
        line-height: 1.48;
    }

    #cardDrawer .md-buy-footer {
        margin-top: 0.15rem;
        padding: 0.2rem 0 0.25rem;
    }

    #cardDrawer .md-buy-btn {
        min-height: 44px;
        margin-top: 0.35rem;
        font-size: 0.86rem;
    }

    #cardDrawer .md-drawer-right .md-outbound-row {
        margin-top: 0.5rem;
        padding-top: 0.65rem;
    }

    #cardDrawer .md-outbound-row {
        gap: 0.4rem;
    }

    #cardDrawer .md-outbound-link {
        width: 100%;
        justify-content: center;
        min-height: 44px;
        box-sizing: border-box;
    }

    #cardDrawer .md-deck-summary {
        font-size: 0.74rem;
    }
}
