/* Deck List Buttons */
.deck-card-actions .btn-sm {
    height: 32px;
    padding: 0 0.875rem;
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    transition: border-color 0.15s, color 0.15s;
}



.deck-card-actions .btn-open {
    height: 32px;
    padding: 0 14px;
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    display: inline-flex;
    align-items: center;
    gap: 5px;
    text-decoration: none;
    transition: background 0.12s, border-color 0.12s;
}

.deck-card-actions .btn-open:hover {
    background: var(--color-bg);
    border-color: var(--color-accent);
}

.deck-card-actions .btn-delete {
    height: 32px;
    width: 32px;
    padding: 0;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    background: transparent;
    color: var(--color-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.deck-card-actions .btn-delete:hover {
    background: rgba(var(--color-danger-rgb), 0.08);
    border-color: var(--color-danger);
    color: var(--color-danger);
}

/* Deck list page */
.deck-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.deck-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    position: relative;
    overflow: hidden;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.deck-card:hover {
    border-color: var(--color-accent);
    box-shadow: var(--shadow-md);
}

.deck-card--has-commander::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: var(--commander-img);
    background-size: auto 350%;
    background-position: center 20%; 
    background-repeat: no-repeat;
    mask-image: linear-gradient(to right, rgba(0,0,0,0) 0%, rgba(0,0,0,0.18) 30%, rgba(0,0,0,0) 80%);
    -webkit-mask-image: linear-gradient(to right, rgba(0,0,0,0) 0%, rgba(0,0,0,0.18) 30%, rgba(0,0,0,0) 80%);
    pointer-events: none;
    z-index: 0;
}

.deck-card > * {
    position: relative;
    z-index: 1;
}

.deck-card-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
    text-decoration: none;
}

.deck-card-name:hover { color: var(--color-accent); }

.deck-card-meta {
    font-size: 0.8rem;
    color: var(--color-muted);
    margin-top: 0.2rem;
}

.deck-card-actions {
    display: flex;
    gap: 0.5rem;
}

.deck-atc {
    height: 24px;
    padding: 0 0.5rem;
    font-size: 0.7rem;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Builder layout */
.deck-builder-wrap {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 1.5rem;
    align-items: start;
}

.deck-builder-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Deck header form */
.deck-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.deck-name-input {
    flex: 1;
    font-size: 1.25rem;
    font-weight: 700;
    border: none;
    border-bottom: 2px solid var(--color-border);
    background: transparent;
    color: var(--color-text);
    padding: 0.25rem 0;
    outline: none;
    transition: border-color 0.15s;
}

.deck-name-input:focus { border-color: var(--color-accent); }

.deck-count {
    font-size: 0.875rem;
    color: var(--color-muted);
    white-space: nowrap;
}

.deck-meta-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.deck-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    flex: 1;
    min-width: 150px;
}

.deck-field-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-muted);
}

.deck-field-input,
.deck-field-select {
    height: 36px;
    padding: 0 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 0.875rem;
}

.deck-field-select:disabled {
    background: var(--color-bg);
    color: var(--color-muted);
    cursor: not-allowed;
}

.deck-filters-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.deck-total-price {
    font-size: 0.875rem;
    color: var(--color-text);
}

.deck-qty-btn {
    width: 20px;
    height: 20px;
    border: 1px solid var(--color-border);
    border-radius: 3px;
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 0.9rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.deck-qty-btn:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
}

.deck-card-qty {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text);
    min-width: 16px;
    text-align: center;
}

/* Add card form */
.add-card-form {
    display: flex;
    gap: 0.5rem;
    margin: 1rem 0;
}

.add-card-input {
    width: 100%;
    height: 38px;
    padding: 0 0.875rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 0.875rem;
}

/* Card columns */
.deck-columns {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
    margin-top: 0.5rem;
}

.deck-column {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.deck-column-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-muted);
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
}

.deck-column-count {
    background: var(--color-border);
    border-radius: 99px;
    padding: 1px 6px;
    font-size: 0.7rem;
}

.deck-card-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.8rem;
}

.deck-card-row:last-child { border-bottom: none; }

.deck-card-qty {
    font-weight: 600;
    color: var(--color-muted);
    min-width: 20px;
}

.deck-card-thumb {
    width: 24px;
    aspect-ratio: 5/7;
    object-fit: cover;
    border-radius: 2px;
    flex-shrink: 0;
}

.deck-card-thumb-placeholder {
    background: var(--color-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.5rem;
    color: var(--color-muted);
}

.deck-card-row-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

a.deck-card-row-name {
    color: var(--color-text);
    text-decoration: none;
}

a.deck-card-row-name:hover {
    color: var(--color-accent);
}

.deck-card-price {
    font-size: 0.75rem;
    color: var(--color-muted);
    white-space: nowrap;
}

.deck-remove-btn {
    background: none;
    border: none;
    color: var(--color-muted);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0 2px;
    flex-shrink: 0;
}

.deck-remove-btn:hover { color: var(--color-danger); }

.deck-empty {
    padding: 2rem;
    text-align: center;
    color: var(--color-muted);
    font-size: 0.875rem;
}

.color-identity-warning {
    color: var(--color-warning, #b85c00);
    font-size: 0.85rem;
    cursor: help;
    flex-shrink: 0;
}

/* Right sidebar panels */
.deck-panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.deck-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 1rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text);
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
}

.deck-panel-empty {
    padding: 1rem;
    font-size: 0.825rem;
    color: var(--color-muted);
    text-align: center;
}

.deck-tag-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 0.75rem;
    border-bottom: 1px solid var(--color-border);
}

/* Suggestion cards */
.suggestion-oos { opacity: 0.5; }

.suggestion-img {
    width: 32px;
    aspect-ratio: 5/7;
    object-fit: cover;
    border-radius: 3px;
    flex-shrink: 0;
}

.suggestion-img-placeholder {
    background: var(--color-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    color: var(--color-muted);
}

.suggestion-synergy { font-size: 0.7rem; color: var(--color-accent); font-weight: 600; margin-top: 1px; }

/* Recommended Cards: row-of-tiles layout, matching the wizard's bonus teaser */
.suggestion-tiles {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 1rem;
}

.suggestion-tile {
    width: 130px;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.suggestion-tile-link {
    text-decoration: none;
    color: var(--color-text);
    display: flex;
    flex-direction: column;
}

.suggestion-tile-link:hover .suggestion-tile-name {
    color: var(--color-accent);
}

.suggestion-tile-actions {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.suggestion-tile-actions .btn-atc {
    width: 100%;
    font-size: 0.7rem;
    height: 26px;
}

.btn-atc-primary {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: #fff;
}

.btn-atc-primary:hover:not(:disabled) {
    background: var(--color-accent-hover);
    border-color: var(--color-accent-hover);
    color: #fff;
}

.suggestion-tile-img {
    width: 130px;
    aspect-ratio: 5/7;
    object-fit: cover;
    border-radius: var(--radius-sm);
    margin-bottom: 0.4rem;
}

.suggestion-tile-name {
    font-size: 0.775rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.12s;
}

.suggestion-tile-meta { font-size: 0.7rem; color: var(--color-muted); margin-top: 1px; }

/* Stats */
.deck-stats-section {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--color-border);
}

.deck-stats-section:last-of-type { border-bottom: none; }

.deck-stats-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-muted);
    margin-bottom: 0.5rem;
}

.stat-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.3rem;
    font-size: 0.75rem;
}

.stat-label {
    width: 80px;
    flex-shrink: 0;
    color: var(--color-muted);
}

.stat-bars {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-bar-wrap {
    height: 5px;
    background: var(--color-bg);
    border-radius: 99px;
    overflow: hidden;
}

.stat-bar {
    height: 100%;
    border-radius: 99px;
    transition: width 0.3s;
}

.stat-numbers {
    width: 40px;
    text-align: right;
    color: var(--color-muted);
    flex-shrink: 0;
}

.stat-legend {
    font-size: 0.7rem;
    color: var(--color-muted);
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.stat-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.stat-dot-user { background: var(--color-accent); }
.stat-dot-avg  { background: var(--color-accent); opacity: 0.35; }

/* Precon upgrade page */
.precon-wrap {
    display: flex;
    flex-direction: row;
    gap: 1.5rem;
    align-items: flex-start;
    justify-content: center;
}

.precon-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    min-width: 30%;
}

.precon-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 1rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--color-border);
}

.precon-add   { background: #f0fdf4; color: #166534; }
.precon-lands { background: #fefce8; color: #854d0e; }
.precon-cut   { background: #fef2f2; color: #991b1b; }

.precon-count {
    background: var(--color-border);
    border-radius: 99px;
    padding: 1px 8px;
    font-size: 0.7rem;
    color: var(--color-text);
}

.precon-card-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--color-border);
    transition: background 0.1s;
}

.precon-card-row:last-child { border-bottom: none; }
.precon-card-row:hover { background: var(--color-bg); }
.precon-oos { opacity: 0.5; }
.precon-in-deck { background: #f0fdf4; }
.precon-in-deck:hover { background: #dcfce7; }

.precon-card-img {
    width: 36px;
    aspect-ratio: 5/7;
    object-fit: cover;
    border-radius: 3px;
    flex-shrink: 0;
}

.precon-card-placeholder {
    background: var(--color-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    color: var(--color-muted);
}

.precon-card-info { flex: 1; min-width: 0; }

.precon-card-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.precon-card-name:hover { color: var(--color-accent); }

.precon-card-meta {
    font-size: 0.75rem;
    color: var(--color-muted);
    margin-top: 1px;
}

.precon-card-actions {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
}

.precon-btn{
    display:block;
    text-align:center;
    line-height:36px;
    text-decoration:none;
    font-size:0.825rem;
    margin:0.75rem;
}

/* EDHREC link */
.edhrec-link {
    display: block;
    padding: 0.6rem 1rem;
    font-size: 0.8rem;
    color: var(--color-accent);
    border-top: 1px solid var(--color-border);
    text-decoration: none;
}



.edhrec-link:hover { text-decoration: underline; }

/* Responsive */
@media (max-width: 820px) {
    .deck-builder-wrap { grid-template-columns: 1fr; }
    .deck-builder-sidebar { position: static; max-height: none; }
    .deck-columns { grid-template-columns: 1fr 1fr; }

    .precon-wrap {
    flex-direction: column;
    }

    .precon-section {
    min-width: 100%;
    }
}

/* Decision tree step indicator */
.dtree {
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.dtree-arrow {
    color: var(--color-border);
    font-size: 1.1rem;
    flex-shrink: 0;
    padding: 0 0.25rem;
}

.dtree-step {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    flex-shrink: 0;
}

.dtree-step-num {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 2px;
    background: var(--color-border);
    color: var(--color-muted);
}

.dtree-done .dtree-step-num {
    background: var(--color-accent);
    color: #fff;
}

.dtree-active .dtree-step-num {
    background: #f59e0b;
    color: #fff;
}

.dtree-locked .dtree-step-num {
    background: var(--color-border);
    color: var(--color-muted);
    opacity: 0.5;
}

.dtree-step-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-muted);
    margin-bottom: 2px;
}

.dtree-step-value {
    font-size: 0.825rem;
    font-weight: 500;
    color: var(--color-text);
}

.dtree-locked .dtree-step-label,
.dtree-locked .dtree-step-value {
    opacity: 0.4;
}

.dtree-pending {
    color: var(--color-muted);
    font-weight: 400;
    font-style: italic;
}

/* MTG color identity pips */
.dtree-pips {
    display: flex;
    gap: 4px;
    align-items: center;
    margin-top: 2px;
}

.pip {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: inline-block;
    border: 2px solid rgba(0,0,0,0.15);
    flex-shrink: 0;
}

.pip-w { background: #f9faf4; border-color: #c8b89a; }
.pip-u { background: #0e68ab; border-color: #0a4f82; }
.pip-b { background: #150b00; border-color: #4a3728; }
.pip-r { background: #d3202a; border-color: #a01820; }
.pip-g { background: #00733e; border-color: #005a30; }
.pip-c { background: #ccc6c0; border-color: #a8a29e; }

/* ── No commander prompt ── */
.suggestion-dtree-prompt {
    padding: 1.25rem 1rem;
    text-align: center;
}

.suggestion-dtree-prompt-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 0.4rem;
}

.suggestion-dtree-prompt-sub {
    font-size: 0.8rem;
    color: var(--color-muted);
    line-height: 1.5;
}
/* ── Deck creation wizard ── */
.wizard-wrap {
    max-width: 560px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.wizard-progress {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 1.5rem;
}

.wizard-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--color-border);
}

.wizard-dot-active { background: var(--color-accent); }
.wizard-dot-done   { background: var(--color-accent); opacity: 0.5; }

.wizard-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
}

.wizard-commander-img {
    width: 160px;
    aspect-ratio: 5/7;
    object-fit: cover;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
}

.wizard-commander-img-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    margin-right: auto;
    background: var(--color-bg);
    color: var(--color-muted);
    font-size: 2rem;
}

.wizard-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
}

.wizard-sub {
    font-size: 0.875rem;
    color: var(--color-muted);
    margin-bottom: 1.25rem;
}

.wizard-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.wizard-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.12s;
}

.wizard-option input { display: none; }

.wizard-option:hover { border-color: var(--color-accent); }

.wizard-option.active {
    border-color: var(--color-accent);
    background: var(--color-bg);
}

.wizard-option-num {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--color-bg);
    color: var(--color-muted);
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wizard-option.active .wizard-option-num {
    background: var(--color-accent);
    color: #fff;
}

.wizard-option-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.wizard-option-title {
    font-size: 0.9rem;
    font-weight: 600;
}

.wizard-option-desc {
    font-size: 0.775rem;
    color: var(--color-muted);
}

.wizard-tag-pill {
    font-size: 0.8rem;
    padding: 6px 14px;
}

.wizard-skip {
    display: block;
    width: 100%;
    text-align: center;
    background: none;
    border: none;
    color: var(--color-muted);
    font-size: 0.8rem;
    cursor: pointer;
    margin-top: 0.75rem;
    text-decoration: underline;
}

.wizard-skip:hover { color: var(--color-accent); }

.wizard-bonus {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--color-border);
}

.wizard-bonus-title {
    font-size: 0.8rem;
    color: var(--color-muted);
    margin-bottom: 0.75rem;
    line-height: 1.5;
}

.wizard-bonus-cards {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    justify-content: center;
}

.wizard-bonus-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    width: 72px;
}

.wizard-bonus-card .suggestion-img,
.wizard-bonus-card .suggestion-img-placeholder {
    width: 72px;
}

.wizard-bonus-card-name {
    font-size: 0.65rem;
    color: var(--color-muted);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

/* Full-page loading overlay while bracket/budget/playstyle changes reload the page */
.page-loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.page-loading-overlay.active {
    display: flex;
}

.page-loading-spinner {
    width: 42px;
    height: 42px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: page-loading-spin 0.8s linear infinite;
}

@keyframes page-loading-spin {
    to { transform: rotate(360deg); }
}
