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kuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

/* One page, dark atmosphere, matches the D2 Raid & Dungeon Bingo look. */

html, body {
    height: 100%;
    margin: 0;
    background-color: #0a0a0f;
}

.app-backdrop {
    position: fixed;
    inset: 0;
    z-index: 0;
    background: radial-gradient(ellipse at top, #1a1a2e 0%, #0a0a0f 60%);
    pointer-events: none;
}

.mud-layout {
    position: relative;
    z-index: 1;
}

.app-bar-glass {
    background-color: rgba(15, 15, 22, 0.55) !important;
    backdrop-filter: blur(16px) saturate(1.3);
    -webkit-backdrop-filter: blur(16px) saturate(1.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.main-content-fill {
    min-height: 100vh;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.page-root {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    padding: 16px;
    box-sizing: border-box;
    gap: 16px;
}

.controls-bar {
    background-color: rgba(24, 24, 34, 0.6) !important;
    backdrop-filter: blur(14px) saturate(1.2);
    -webkit-backdrop-filter: blur(14px) saturate(1.2);
    border: 1px solid rgba(255, 255, 255, 0.06);
    padding: 16px;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 14px;
}

.mtg-card-tile {
    position: relative;
    border-radius: 10px;
    cursor: pointer;
    border: 3px solid transparent;
    transition: transform 0.12s ease, border-color 0.15s ease;
    background: rgba(8, 8, 14, 0.5);
    overflow: hidden;
}

.mtg-card-tile:hover {
    transform: translateY(-4px);
}

.mtg-card-tile.rotating {
    border-color: #e53935;
    box-shadow: 0 0 16px rgba(229, 57, 53, 0.55);
}

.mtg-card-tile.replaced {
    border-color: #4caf50;
    box-shadow: 0 0 16px rgba(76, 175, 80, 0.45);
}

.mtg-card-tile img {
    width: 100%;
    display: block;
    border-radius: 8px;
}

.mtg-card-count-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 0.8rem;
    font-weight: 700;
}

.mtg-card-replacement-badge {
    position: absolute;
    bottom: 6px;
    left: 6px;
    right: 6px;
    background: rgba(76, 175, 80, 0.9);
    color: #fff;
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mtg-card-missing {
    aspect-ratio: 5 / 7;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 8px;
    color: #ccc;
    background: rgba(40, 20, 20, 0.6);
    font-size: 0.85rem;
}

/* Replace-card dialog */

.replace-dialog-original-image {
    width: 140px;
    height: auto;
    flex: 0 0 auto;
    border-radius: 8px;
    display: block;
    align-self: flex-start;
}

.replace-dialog-header {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    flex: 0 0 auto;
}

.replace-dialog-header-text {
    flex: 1 1 auto;
    min-width: 260px;
}

.replace-suggestion-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    /* Without these, a grid that's itself height-constrained via flex (as
       .replace-results-grid is) shrinks its auto rows down to fit that
       height instead of sizing to content and overflowing/scrolling -
       collapsing every tile to a few px tall. */
    grid-auto-rows: min-content;
    align-content: start;
    gap: 10px;
    /* Buffer so the top row's hover lift (translateY) and selected-border
       glow don't get clipped by the scroll container's edge. */
    padding: 6px;
}

.replace-suggestion-tile {
    position: relative;
    cursor: pointer;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid transparent;
    transition: transform 0.12s ease, border-color 0.15s ease;
}

.replace-suggestion-tile:hover {
    transform: translateY(-3px);
    border-color: var(--mud-palette-primary);
}

.replace-suggestion-tile-selected {
    border-color: #4caf50;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.5);
}

.replace-suggestion-tile img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 6px;
}

.replace-upcoming-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(33, 150, 243, 0.9);
    color: #fff;
    border-radius: 6px;
    padding: 1px 6px;
    font-size: 0.65rem;
    font-weight: 600;
}

/* Single flex column: header (image/search box) fixed, results area grows
   and scrolls internally - keeps exactly one scrollbar instead of the outer
   dialog and the inner grid both scrolling at once. */
.replace-dialog-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    /* Leaves headroom for MudDialog's own content padding, so the outer
       .mud-dialog-content box never has to scroll even by a few px - only
       .replace-results-grid should ever show a scrollbar. */
    max-height: calc(70vh - 32px);
    /* Without this, excess content just spills past max-height instead of
       being clipped, and the ancestor .mud-dialog-content (which has its own
       overflow-y:auto) ends up scrolling too - the exact double-scrollbar bug
       this layout is meant to avoid. Only .replace-results-grid should scroll. */
    overflow: hidden;
}

.replace-columns {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.replace-column {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.replace-results-grid {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

@media (max-width: 700px) {
    /* Desktop keeps the header fixed and scrolls only the results area in its
       own nested box. On mobile the stacked header (image above the title/
       search box) already takes up much more height, so that fixed-height
       results box gets squeezed to a sliver. Simplest fix: let the whole
       dialog body scroll as one unit instead of fighting over that sliver. */
    .replace-dialog-body {
        max-height: 85vh;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .replace-columns {
        grid-template-columns: 1fr;
        overflow: visible;
    }

    .replace-column {
        flex: 0 0 auto;
    }

    .replace-results-grid {
        flex: 0 0 auto;
        overflow-y: visible;
    }

    /* The desktop layout puts the card image beside the title/search box with
       a 260px min-width text column - on narrow phone screens that min-width
       doesn't fit next to the image, squishing/clipping the text and search
       field. Stack them instead, and let the search box take the full width
       with the button below it rather than clipped off-screen. */
    .replace-dialog-header {
        flex-direction: column;
        align-items: center;
    }

    .replace-dialog-header-text {
        min-width: 0;
        width: 100%;
    }

    .replace-search-row {
        flex-wrap: wrap;
    }

    .replace-search-row > * {
        flex: 1 1 100%;
    }
}

/* Larger preview shown while hovering a card tile - positioned near the
   cursor (via inline left/top, computed relative to .replace-dialog-body's
   own bounding rect - see ReplaceCardDialog's OnTileHover for why: MudDialog
   applies a CSS transform for its open/close animation, which makes it the
   containing block for any "position: fixed" descendant, so genuinely
   viewport-fixed coordinates get silently clipped by the dialog's own
   overflow:hidden instead of escaping to the real screen). Positioning
   relative to this container (which is itself position:relative) keeps the
   preview correctly placed and never clipped on any screen size, and never
   sitting in a static corner blocking the view of other search results. */
.hover-preview {
    position: absolute;
    z-index: 30;
    pointer-events: none;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.15);
}

.hover-preview img {
    display: block;
    width: 320px;
    height: auto;
}
