/* ── Variables ───────────────────────────────────────── */
:root {
    --primary:    #8b5cf6;
    --primary-dk: #7c3aed;
    --bg:         #111115;
    --surface:    #1c1c22;
    --surface2:   #26262e;
    --surface3:   #30303a;
    --border:     #3a3a45;
    --text:       #e4e4f0;
    --muted:      #a0a0b8;
    --radius:     8px;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-size: 15px;
    line-height: 1.5;
}

.text-muted { color: var(--muted) !important; }
.small, small { font-size: .82em; }

/* ── Navbar ─────────────────────────────────────────── */
.navbar {
    background: rgba(13,13,17,.96) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255,255,255,.06);
    box-shadow: 0 1px 20px rgba(0,0,0,.6);
}
.navbar-brand { color: var(--text) !important; font-weight: 800; font-size: 1.05rem; letter-spacing: .06em; text-transform: uppercase; }
.brand-msf { color: var(--primary); }
.nav-link { color: var(--muted) !important; font-weight: 500; font-size: .82rem; text-transform: uppercase; letter-spacing: .07em; padding: .4rem .7rem !important; transition: color .15s; }
.nav-link:hover { color: var(--text) !important; }
.nav-username { font-size: .8rem; color: var(--primary) !important; }
.navbar-toggler { border-color: var(--border); }
.navbar-toggler-icon { filter: invert(.6); }

/* ── Main content ───────────────────────────────────── */
.main-content { flex: 1; padding-top: 56px; }

/* ── Hero / Page Header ─────────────────────────────── */
.hero-section, .page-header { position: relative; overflow: hidden; color: #fff; }
.hero-section { background: linear-gradient(135deg, #0c051e 0%, #1a0942 45%, #0b1530 100%); padding: 5rem 0 4rem; }
.page-header { background: linear-gradient(135deg, #0c051e 0%, #180840 100%); padding: 2.5rem 0 2.2rem; border-bottom: 1px solid var(--border); }

.hero-section::before, .page-header::before {
    content: '';
    position: absolute; inset: 0;
    background-image: repeating-linear-gradient(-55deg, transparent, transparent 18px, rgba(255,255,255,.022) 18px, rgba(255,255,255,.022) 19px);
    pointer-events: none;
}

.page-title {
    font-weight: 800; text-transform: uppercase; letter-spacing: .06em;
    font-size: 1.8rem; line-height: 1.1;
    position: relative; display: inline-block;
    padding-left: 14px; margin-bottom: .35rem;
}
.page-title::before {
    content: ''; position: absolute;
    left: 0; top: .1em; bottom: .1em;
    width: 4px; background: var(--primary); border-radius: 2px;
}

/* ── Footer ─────────────────────────────────────────── */
.footer { background: #09090c; border-top: 1px solid rgba(255,255,255,.07); padding: 1.75rem 0 1.4rem; margin-top: auto; }
.footer-inner { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; margin-bottom: .9rem; padding-bottom: .9rem; border-bottom: 1px solid rgba(255,255,255,.04); }
.footer-logo { font-weight: 800; font-size: .85rem; letter-spacing: .1em; text-transform: uppercase; color: #cccce0; display: block; margin-bottom: 3px; }
.footer-sub { font-size: .76rem; color: var(--muted); margin: 0; }
.footer-legal { font-size: .75rem; color: #8888a8; text-align: center; margin: 0; }
.btn-kofi { background: #ff5e5b; border-color: #ff5e5b; color: #fff; }
.btn-kofi:hover { background: #e8504d; border-color: #e8504d; color: #fff; }

/* ── Home Feature Cards ─────────────────────────────── */
.home-link-card { border-radius: 12px; height: 185px; display: flex; align-items: center; justify-content: center; transition: transform .2s ease, box-shadow .2s ease; cursor: pointer; position: relative; overflow: hidden; }
.home-link-card::before { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(-55deg, transparent, transparent 12px, rgba(255,255,255,.04) 12px, rgba(255,255,255,.04) 13px); pointer-events: none; }
.home-link-card:hover { transform: translateY(-5px); box-shadow: 0 12px 30px rgba(0,0,0,.5); }
.home-link-card .icon { font-size: 2rem; }
.home-link-card h4 { font-weight: 700; letter-spacing: .04em; }
.home-link-card.characters       { background: linear-gradient(135deg, #1e3a5f, #2563eb); }
.home-link-card.abilities        { background: linear-gradient(135deg, #92400e, #d97706); }
.home-link-card.theorycrafting   { background: linear-gradient(135deg, #4c1d95, #8b5cf6); }
.home-link-card.towers           { background: linear-gradient(135deg, #7f1d1d, #dc2626); }
.home-link-card.analyzer         { background: linear-gradient(135deg, #064e3b, #10b981); }
.home-link-card.coming-soon  { opacity: .55; cursor: default; }
.home-link-card.coming-soon:hover { transform: none; box-shadow: none; }

/* ── Buttons ────────────────────────────────────────── */
.btn-primary           { background: var(--primary); border-color: var(--primary); font-weight: 600; }
.btn-primary:hover     { background: var(--primary-dk); border-color: var(--primary-dk); }
.btn-outline-primary   { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-outline-secondary { color: var(--muted); border-color: var(--border); }
.btn-outline-secondary:hover { color: var(--text); border-color: var(--muted); background: var(--surface2); }

/* ── Forms ──────────────────────────────────────────── */
label.form-label { color: var(--text); font-size: .85rem; }
.form-control { background: var(--surface2); border-color: var(--border); color: var(--text); }
.form-control:focus { background: var(--surface3); border-color: var(--primary); color: var(--text); box-shadow: 0 0 0 .2rem rgba(139,92,246,.2); }
.form-control::placeholder { color: var(--muted); opacity: .7; }
.input-group-text { background: var(--surface2); border-color: var(--border); color: var(--muted); }

/* ── Modals ─────────────────────────────────────────── */
.modal-content { background: #1a1928; border: 1px solid rgba(139,92,246,.2); border-top: 3px solid var(--primary); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.7), 0 0 40px rgba(139,92,246,.1); }
.modal-auth .modal-header { background: #1e1d30; border-color: rgba(139,92,246,.15); }
.modal-char-close {
    position: absolute;
    top: 0.7rem;
    right: 0.8rem;
    z-index: 10;
    background: none;
    border: none;
    color: var(--muted);
    font-size: 1rem;
    line-height: 1;
    padding: 4px 6px;
    border-radius: 4px;
    cursor: pointer;
    transition: color .15s, background .15s;
}
.modal-char-close:hover { color: var(--text); background: var(--surface3); }

/* ── Links ──────────────────────────────────────────── */
.theme-link { color: var(--primary); text-decoration: none; }
.theme-link:hover { color: var(--primary-dk); }

/* ── Trait Badges ───────────────────────────────────── */
.trait-badge { display: inline-block; padding: 1px 6px; border-radius: 10px; font-size: .64rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; line-height: 1.6; white-space: nowrap; background: var(--surface2); color: var(--muted); border: 1px solid var(--border); }
.trait-bio        { background: #052e1c; color: #34d399; border-color: #065f46; }
.trait-tech       { background: #0c1d3d; color: #60a5fa; border-color: #1d4ed8; }
.trait-mystic     { background: #220f4a; color: #c4b5fd; border-color: #5b21b6; }
.trait-skill      { background: #2d1f00; color: #fbbf24; border-color: #b45309; }
.trait-mutant     { background: #2d1000; color: #fb923c; border-color: #9a3412; }
.trait-cosmic     { background: #3b0728; color: #f9a8d4; border-color: #9d174d; }
.trait-city       { background: #1e293b; color: #94a3b8; border-color: #475569; }
.trait-global     { background: #042f2e; color: #2dd4bf; border-color: #0f766e; }
.trait-legendary  { background: #3d2000; color: #fcd34d; border-color: #92400e; }
.trait-epic       { background: #1e0a3c; color: #a78bfa; border-color: #4c1d95; }
.trait-mythic     { background: #2d0a0a; color: #fca5a5; border-color: #991b1b; }
.trait-hero       { background: #0a1e35; color: #7dd3fc; border-color: #0369a1; }
.trait-villain    { background: #2d0a0a; color: #fca5a5; border-color: #991b1b; }
.trait-brawler    { background: #2d1000; color: #fb923c; border-color: #9a3412; }
.trait-blaster    { background: #2d0d00; color: #f87171; border-color: #b91c1c; }
.trait-controller { background: #1c1c22; color: #b0b0c8; border-color: #4b4b5a; }
.trait-support    { background: #052e1c; color: #4ade80; border-color: #166534; }
.trait-protector  { background: #231700; color: #fde68a; border-color: #a16207; }

/* ── Filter Panel ───────────────────────────────────── */
.filter-panel { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; }
.filter-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.filter-group-label { font-size: .62rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 700; width: auto; flex-shrink: 0; }

@media (min-width: 768px) {
    .filter-panel { display: flex; flex-wrap: wrap; gap: 6px 20px; align-items: center; padding: 10px 14px; }
    .filter-panel .filter-row { margin-bottom: 0 !important; flex-shrink: 0; }
}

@media (max-width: 768px) {
    .filter-group-label { width: 45px; }
}
.filter-chip { padding: 3px 10px; border-radius: 20px; font-size: .74rem; font-weight: 600; border: 1px solid var(--border); background: transparent; color: var(--muted); cursor: pointer; transition: all .15s ease; white-space: nowrap; line-height: 1.5; }
.filter-chip:hover         { color: var(--text); border-color: var(--muted); }
.filter-chip.active        { background: var(--primary); border-color: var(--primary); color: #fff; }
.filter-chip.exclude       { background: #7f1d1d; border-color: #ef4444; color: #fff; }
.filter-chip.exclude:hover { background: #991b1b; border-color: #f87171; color: #fff; }
/* Origin chips */
.trait-chip-bio:not(.active):not(.exclude)    { color: #34d399; border-color: #065f46; }
.trait-chip-tech:not(.active):not(.exclude)   { color: #60a5fa; border-color: #1e3a8a; }
.trait-chip-mystic:not(.active):not(.exclude) { color: #c4b5fd; border-color: #4c1d95; }
.trait-chip-skill:not(.active):not(.exclude)  { color: #fbbf24; border-color: #78350f; }
.trait-chip-mutant:not(.active):not(.exclude) { color: #fb923c; border-color: #9a3412; }
.trait-chip-bio.active    { background: #065f46; border-color: #10b981; }
.trait-chip-tech.active   { background: #1e3a8a; border-color: #3b82f6; }
.trait-chip-mystic.active { background: #4c1d95; border-color: #8b5cf6; }
.trait-chip-skill.active  { background: #78350f; border-color: #f59e0b; }
.trait-chip-mutant.active { background: #7c2d12; border-color: #f97316; }
/* Domain chips */
.trait-chip-cosmic:not(.active):not(.exclude) { color: #f9a8d4; border-color: #831843; }
.trait-chip-city:not(.active):not(.exclude)   { color: #94a3b8; border-color: #475569; }
.trait-chip-global:not(.active):not(.exclude) { color: #2dd4bf; border-color: #0f766e; }
.trait-chip-cosmic.active { background: #831843; border-color: #ec4899; }
.trait-chip-city.active   { background: #1e293b; border-color: #64748b; }
.trait-chip-global.active { background: #042f2e; border-color: #14b8a6; }
/* Rarity chips */
.trait-chip-legendary:not(.active):not(.exclude) { color: #fcd34d; border-color: #92400e; }
.trait-chip-epic:not(.active):not(.exclude)      { color: #a78bfa; border-color: #4c1d95; }
.trait-chip-mythic:not(.active):not(.exclude)    { color: #fca5a5; border-color: #991b1b; }
.trait-chip-legendary.active { background: #78350f; border-color: #f59e0b; color: #fcd34d; }
.trait-chip-epic.active      { background: #3b0764; border-color: #7c3aed; }
.trait-chip-mythic.active    { background: #7f1d1d; border-color: #ef4444; }

/* ── Result count ───────────────────────────────────── */
.char-count-text { font-size: .83rem; color: var(--text); font-weight: 500; }

/* ── Character Grid ─────────────────────────────────── */
.char-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    gap: 8px;
}

/* ── Character Card ─────────────────────────────────── */
.char-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: 3px solid var(--card-color, var(--border));
    border-radius: var(--radius);
    cursor: pointer;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    user-select: none;
}
.char-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 0 18px var(--card-color, var(--primary)), 0 6px 22px rgba(0,0,0,.6);
    border-color: var(--card-color, var(--primary));
    z-index: 2;
    position: relative;
}

/* 128×190 native portrait ratio */
.char-portrait-wrap { position: relative; width: 100%; aspect-ratio: 128 / 190; background: #0a0a10; overflow: hidden; }
.char-portrait-wrap img { width: 100%; height: 100%; object-fit: contain; display: block; transition: transform .25s ease; }
.char-card:hover .char-portrait-wrap img { transform: scale(1.06); }

.char-class-badges { position: absolute; bottom: 5px; left: 5px; z-index: 2; gap: 2px; max-width: calc(100% - 10px); }
.char-class-badge { font-size: .54rem !important; padding: 1px 4px !important; }

.char-card-body { padding: 5px 6px 6px; display: flex; flex-direction: column; gap: 3px; flex: 1; }
.char-name { font-size: .74rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.2; }

/* ── Coming soon box ────────────────────────────────── */
.coming-soon-box { max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 3rem 2rem; }

/* ── Character Detail Modal ─────────────────────────── */
.char-detail-header { padding-bottom: 1rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.char-detail-portrait-wrap { width: 80px; height: 80px; border-radius: 50%; overflow: hidden; flex-shrink: 0; background: #0a0a10; border: 2px solid var(--border); }
.char-detail-portrait-wrap img { width: 100%; height: 100%; object-fit: contain; }

/* ── Ability Cards ──────────────────────────────────── */
.ability-card { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.ability-card-header { background: var(--surface3); padding: 10px 14px; border-bottom: 1px solid var(--border); }
.ability-card[data-type="passive"]  .ability-card-header { border-left: 3px solid #6b7280; }
.ability-card[data-type="basic"]    .ability-card-header { border-left: 3px solid #3b82f6; }
.ability-card[data-type="special"]  .ability-card-header { border-left: 3px solid #f97316; }
.ability-card[data-type="ultimate"] .ability-card-header { border-left: 3px solid #ef4444; }
.ability-icon { width: 38px; height: 38px; border-radius: 6px; object-fit: cover; flex-shrink: 0; }
.ability-type-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 700; }
.ability-name { font-weight: 600; color: var(--text); font-size: .88rem; }
.adoption-badge { font-size: .68rem; color: var(--muted); white-space: nowrap; background: var(--surface); padding: 2px 8px; border-radius: 10px; border: 1px solid var(--border); }
.level-toggle .btn-level-indicator { min-width: 46px; pointer-events: none; font-size: .75rem; font-weight: 600; cursor: default; color: var(--text); background: var(--surface3); border-color: var(--border); }
.ability-desc-body { min-height: 70px; }
.ability-description-text { font-size: .9rem; line-height: 1.65; color: var(--text); }
.next-upgrade { background: #0c0c20; border: 1px solid #2d2d5e; border-radius: 6px; padding: 10px 14px; font-size: .85rem; color: #a5b4fc; margin-top: 10px; }
.next-upgrade-label { font-size: .62rem; text-transform: uppercase; letter-spacing: .1em; color: #6366f1; font-weight: 700; display: block; margin-bottom: 4px; }

/* ── Character stats grid (modal) ───────────────────── */
.char-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 6px;
    margin: 12px 0 4px;
    padding: 10px 12px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
}

.stat-label {
    font-size: .6rem;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--muted);
    font-weight: 600;
    white-space: nowrap;
}

.stat-value {
    font-size: .92rem;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.stat-item.stat-power .stat-value {
    color: var(--primary);
}

.char-dates      { display: flex; gap: 16px; flex-wrap: wrap; margin: 0 0 10px; }
.char-date-item  { font-size: .72rem; color: var(--muted); }
.char-date-label { font-weight: 600; color: var(--text); margin-right: 4px; }
.char-stats-note {
    font-size: .72rem;
    color: #8888a8;
    text-align: right;
    margin: 0 0 12px;
    padding-right: 2px;
}

/* ── Level nav disabled state (grey, not primary colour) */
.dlevel-prev:disabled, .dlevel-next:disabled,
.btn-level-nav:disabled {
    background: var(--surface3) !important;
    border-color: var(--border) !important;
    color: var(--muted) !important;
    opacity: 1 !important;
}

/* ── Detail view level nav ──────────────────────────── */
.dlevel-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 6px;
}
.dlevel-nav .btn { font-size: .68rem; line-height: 1.4; padding: 1px 7px; }
.dlevel-ind {
    font-size: .72rem;
    color: var(--muted);
    min-width: 34px;
    text-align: center;
}

/* ── ISO-8 Inline (inside carousel items + detail view) */
.iso8-inline {
    background: #0d0d1e;
    border: 1px solid #2d2d5e;
    border-left: 3px solid #6366f1;
    border-radius: 6px;
    padding: 7px 12px;
    font-size: .8rem;
    line-height: 1.5;
}
.iso8-inline-label {
    color: #6366f1;
    font-weight: 700;
    font-size: .62rem;
    text-transform: uppercase;
    letter-spacing: .07em;
    margin-right: 8px;
    white-space: nowrap;
}
.iso8-inline-text { color: #c7d2fe; }
.iso8-sep { color: #3a3a5a; }
.iso8-awakened .iso8-inline-label { color: #f59e0b; }
.iso8-awakened .iso8-inline-text  { color: #fde68a; }

/* ── ISO-8 Notes bar ────────────────────────────────── */
.iso8-notes { display: flex; flex-wrap: wrap; gap: 5px; padding-top: 6px; }
.iso8-note { font-size: .7rem; color: #a5b4fc; background: #12122a; border: 1px solid #2d2d5e; border-radius: 10px; padding: 1px 8px; }

.speed-mechanics-list { font-size: .82rem; line-height: 1.7; color: #6ee7b7; }
.speed-mechanics-list br + * { display: inline; }
mark.speed-hl { background: rgba(99,179,237,.35); color: inherit; }

/* ── Detail View Cards ──────────────────────────────── */
#abilityGrid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* 2-column grid on wide screens — stretch keeps both cards in a row equal height */
@media (min-width: 1100px) {
    #abilityGrid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        align-items: stretch;
    }
    .detail-card { height: 100%; }
}

.detail-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--card-color, var(--border));
    border-radius: var(--radius);
    display: flex;
    flex-direction: row;
    align-items: stretch;
    overflow: hidden;
    position: relative;
    transition: border-color .15s, box-shadow .15s;
}
.char-exclude-btn {
    position: absolute; top: 4px; right: 5px;
    background: transparent; color: var(--muted);
    border: none; border-radius: 3px;
    width: 18px; height: 18px; padding: 0;
    font-size: 10px; line-height: 1;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: background .12s, color .12s;
    z-index: 5;
}
.char-exclude-btn:hover { background: rgba(220,38,38,.75); color: #fff; }
.excluded-chip {
    display: inline-flex; align-items: center; gap: 3px;
    background: rgba(220,38,38,.12); border: 1px solid rgba(220,38,38,.3);
    color: #f87171; border-radius: 4px; padding: 1px 5px; margin: 1px 2px;
}
.excluded-chip-remove {
    background: none; border: none; color: #f87171;
    cursor: pointer; font-size: 12px; line-height: 1; padding: 0 1px;
}
.excluded-chip-remove:hover { color: #ef4444; }
.detail-card:hover {
    border-color: var(--card-color, var(--primary));
    box-shadow: -2px 0 14px var(--card-color, var(--primary)), 2px 2px 8px rgba(0,0,0,.4);
}

/* Portrait column */
.detail-portrait {
    width: 72px;
    flex-shrink: 0;
    background: #0a0a10;
    display: flex;
    align-items: center;
    justify-content: center;
}
.detail-portrait img {
    width: 72px;
    height: 108px; /* 128×190 ratio */
    object-fit: contain;
    display: block;
}

/* Main content area */
.detail-main {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.detail-char-header { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }
.detail-char-name { font-weight: 700; font-size: .88rem; color: var(--text); white-space: nowrap; margin-right: 4px; background: none; border: none; padding: 0; cursor: pointer; text-align: left; }
.detail-char-name:hover { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }
.detail-char-traits { display: flex; flex-wrap: wrap; gap: 3px; }

.detail-abilities { display: flex; gap: 8px; align-items: flex-start; min-width: 0; }

/* Ability icon column */
.detail-icons { display: flex; flex-direction: column; gap: 4px; flex-shrink: 0; }
.detail-icon { display: flex; align-items: center; gap: 5px; cursor: pointer; padding: 3px 6px; border-radius: 5px; border: 1px solid transparent; transition: all .12s; opacity: .5; }
.detail-icon:hover { opacity: .8; border-color: var(--border); }
.detail-icon.active { opacity: 1; background: var(--surface2); border-color: var(--border); }
.detail-icon img { width: 26px; height: 26px; border-radius: 4px; object-fit: cover; flex-shrink: 0; }
.detail-icon span { font-size: .6rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); white-space: nowrap; display: none; }

/* Description area */
.detail-desc-area { flex: 1; min-width: 0; }
.detail-ability-name { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 4px; }
.detail-ability-text { font-size: .82rem; line-height: 1.55; color: var(--text); }

/* Show icon labels on medium+ screens */
@media (min-width: 600px) {
    .detail-icon span { display: inline; }
}

/* ── Mobile: stack detail card vertically under ~500px ── */
@media (max-width: 499px) {
    .detail-card { flex-direction: column; }

    .detail-portrait {
        width: 100%;
        height: 70px;
        flex-direction: row;
        justify-content: flex-start;
        padding: 0 12px;
        gap: 10px;
        align-items: center;
    }
    .detail-portrait img {
        width: 44px;
        height: 66px;
    }

    .detail-abilities { flex-direction: column; }

    .detail-icons {
        flex-direction: row;
        overflow-x: auto;
        gap: 4px;
        padding-bottom: 2px;
    }
    .detail-icon span { display: inline; font-size: .6rem; }
}

/* ── Scrollbar ──────────────────────────────────────── */
::-webkit-scrollbar       { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: #09090c; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ── Alert overrides ────────────────────────────────── */
.alert-danger { background: #2d0a0a; border-color: #7f1d1d; color: #fca5a5; }

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 576px) {
    .char-grid { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 6px; }
    .hero-section { padding: 3.5rem 0 3rem; }
    .filter-group-label { display: none; }
    .filter-panel { padding: 10px 12px; }
}

@media (min-width: 1400px) {
    .char-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
}

/* ── Abilities page ──────────────────────────────────── */
.abilities-filter-panel { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.filter-label { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); display: block; margin-bottom: 5px; }

/* ── Select2 dark theme ──────────────────────────────── */
.select2-container--default .select2-selection--multiple { background: var(--surface3); border-color: var(--border); border-radius: var(--radius); min-height: 38px; }
.select2-container--default.select2-container--focus .select2-selection--multiple { border-color: var(--primary); box-shadow: 0 0 0 .2rem rgba(139,92,246,.2); outline: none; }
.select2-container--default .select2-selection--multiple .select2-selection__rendered { padding: 3px 6px; }
.select2-container--default .select2-selection--multiple .select2-selection__choice { background: var(--primary); border: none; color: #fff; border-radius: 4px; padding: 1px 6px; font-size: .76rem; margin-top: 4px; }
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove { color: rgba(255,255,255,.65); margin-right: 4px; }
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover { color: #fff; }
.select2-container--default .select2-selection--multiple .select2-search__field { color: var(--text); background: transparent; margin-top: 4px; }
.select2-container--default .select2-selection--multiple .select2-search__field::placeholder { color: var(--muted); opacity: .8; }
.select2-dropdown { background: var(--surface2); border-color: var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.5); }
.select2-container--default .select2-search--dropdown .select2-search__field { background: var(--surface3); border-color: var(--border); color: var(--text); border-radius: 4px; padding: 5px 8px; }
.select2-container--default .select2-results__option { color: var(--text); font-size: .84rem; padding: 5px 10px; }
.select2-container--default .select2-results__option--highlighted[aria-selected] { background: var(--primary); color: #fff; }
.select2-container--default .select2-results__option[aria-selected=true] { background: var(--surface3); color: var(--muted); }
.select2-results__group { color: var(--muted); font-size: .62rem; text-transform: uppercase; letter-spacing: .09em; font-weight: 700; padding: 7px 10px 3px; }

/* ── Active filter pills (characters page) ───────────── */
#activeFiltersBar { display: flex; flex-wrap: wrap; gap: 5px; }
.active-filter-pill {
    display: inline-flex; align-items: center; gap: 3px;
    padding: 2px 7px 2px 6px; border-radius: 20px;
    font-size: .73rem; font-weight: 600; line-height: 1.6; white-space: nowrap;
}
.afp-include { background: rgba(34,197,94,.12); border: 1px solid rgba(34,197,94,.4); color: #86efac; }
.afp-exclude { background: rgba(239,68,68,.14); border: 1px solid rgba(239,68,68,.55); color: #fca5a5; }
.afp-prefix { font-size: .7rem; font-weight: 700; opacity: .75; }
.afp-remove { background: none; border: none; padding: 0 0 0 2px; line-height: 1; cursor: pointer; color: inherit; opacity: .5; font-size: .9rem; vertical-align: middle; }
.afp-remove:hover { opacity: 1; }

/* ── Keyword highlight (abilities page) ──────────────── */
mark { background: rgba(253,224,71,.3); color: inherit; border-radius: 3px; padding: 0 2px; outline: 1px solid rgba(253,224,71,.4); }

/* Ability icon indicator when a keyword match exists in that ability */
.detail-icon.has-kw-match {
    border-color: rgba(253,224,71,.45) !important;
    background: rgba(253,224,71,.06) !important;
    position: relative;
}
.detail-icon.has-kw-match::after {
    content: '';
    position: absolute;
    top: 3px; right: 3px;
    width: 5px; height: 5px;
    border-radius: 50%;
    background: #fde047;
    box-shadow: 0 0 5px rgba(253,224,71,.75);
}

/* ── Ability type checkboxes (abilities page) ────────── */
.form-check-input { background-color: var(--surface3); border-color: var(--border); }
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }
.form-check-input:focus { box-shadow: 0 0 0 .2rem rgba(139,92,246,.25); border-color: var(--primary); }
.atype-toggle { font-size: .75rem; padding: 2px 10px; border-radius: 20px; border-color: var(--border); color: var(--muted); }
.atype-toggle:hover { border-color: var(--primary); color: var(--text); }
.btn-check:checked + .atype-toggle { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ── Theorycrafting ──────────────────────────────────── */
.theory-team {
    margin-bottom: 40px;
}
.theory-team-label {
    font-size: 1rem; font-weight: 600; color: var(--text);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.theory-panel-title {
    font-size: 1rem; font-weight: 600; color: var(--text);
}

.theory-roster { display: flex; flex-direction: column; gap: 6px; }
.roster-item {
    display: flex; align-items: center; gap: 8px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 5px 8px;
}
.roster-portrait {
    width: 32px; height: 32px;
    border-radius: 4px; object-fit: cover; flex-shrink: 0;
}
.roster-name { flex: 1; font-size: .85rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.roster-level-wrap { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
.roster-level-label { font-size: .68rem; color: var(--muted); white-space: nowrap; }
.roster-level-select { width: 62px; font-size: .8rem; padding: 2px 4px; }

.theory-count { font-size: .75rem; color: var(--muted); }

.theory-textarea {
    width: 100%;
    height: 600px;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: .78rem;
    line-height: 1.55;
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 12px;
    resize: vertical;
    outline: none;
}
.theory-textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 .2rem rgba(139,92,246,.2); }
.panel-portraits { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.panel-portrait  { width: 28px; height: 28px; border-radius: 3px; object-fit: cover; cursor: pointer; }

/* ── Tower Planner ───────────────────────────────────── */
.tower-selector-row { display: flex; gap: 10px; flex-wrap: wrap; }
.tower-select-btn   { border-radius: 8px; font-size: .88rem; padding: 7px 18px; }
.tower-select-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.tower-title { font-size: 1.15rem; font-weight: 700; color: var(--text); margin-bottom: 16px; }

.tower-diff-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tower-diff-tab  {
    background: transparent; border: 1px solid var(--border);
    color: var(--muted); border-radius: 6px; padding: 4px 16px;
    font-size: .82rem; cursor: pointer; transition: all .15s;
}
.tower-diff-tab:hover  { border-color: var(--primary); color: var(--text); }
.tower-diff-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.tower-weeks      { display: flex; flex-direction: column; gap: 28px; }
.tower-week-label { font-size: .9rem; font-weight: 600; color: var(--text); margin-bottom: 10px;
                    padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.tower-floors     { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }

/* Floor card */
.tower-floor-card {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    cursor: pointer;
    transition: border-color .15s;
}
.tower-floor-card:hover { border-color: var(--primary); }

.tower-floor-header { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.tower-floor-num    { font-size: .82rem; font-weight: 700; color: var(--text); white-space: nowrap; }

.tower-badge          { font-size: .67rem; font-weight: 600; border-radius: 4px; padding: 2px 7px; white-space: nowrap; }
.tower-badge-war      { background: rgba(239,68,68,.18);  color: #f87171; }
.tower-badge-crucible { background: rgba(99,179,237,.18); color: #63b3ed; }
.tower-restr-badge    { font-size: .68rem; color: var(--muted); }

/* Slot circles */
.tower-slots { display: flex; gap: 7px; flex-wrap: wrap; }
.tower-slot  {
    width: 48px; height: 48px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
}
.tower-slot.empty {
    border: 2px dashed var(--border);
    background: transparent;
}
.tower-slot.filled img {
    width: 100%; height: 100%; object-fit: cover; display: block;
}
.slot-remove {
    display: none;
    position: absolute; inset: 0;
    background: rgba(0,0,0,.6);
    border: none; color: #fff;
    font-size: 1.1rem; line-height: 1;
    cursor: pointer;
    align-items: center; justify-content: center;
    border-radius: 50%;
    width: 100%; height: 100%;
}
.tower-slot.filled:hover .slot-remove { display: flex; }

.tower-suggested       { font-size: .72rem; color: var(--muted); margin-top: 10px; }
.tower-suggested-label { font-weight: 600; color: var(--text); }
.tower-guide-item      { margin-top: 3px; }
.tower-guide-link      { color: var(--primary); text-decoration: none; }
.tower-guide-link:hover{ text-decoration: underline; }
.tower-guide-label     { color: var(--muted); }

/* Character picker offcanvas */
.fp-canvas { width: 440px !important; background: var(--surface); }
@media (max-width: 480px) { .fp-canvas { width: 100vw !important; } }

.fp-canvas .offcanvas-header {
    background: var(--surface2);
    border-bottom: 1px solid var(--border);
    padding: 14px 16px;
}
.fp-header-text .offcanvas-title { font-size: 1rem; font-weight: 700; color: var(--text); }
.fp-search  { background: var(--surface2); border-color: var(--border); color: var(--text); }
.fp-search:focus { border-color: var(--primary); box-shadow: none; }

.fp-sort-row { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.fp-sort-btn {
    background: transparent; border: 1px solid var(--border);
    color: var(--muted); border-radius: 5px;
    padding: 2px 11px; font-size: .75rem; cursor: pointer; transition: all .15s;
}
.fp-sort-btn:hover  { border-color: var(--primary); color: var(--text); }
.fp-sort-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.fp-count { font-size: .72rem; color: var(--muted); }

/* Character grid */
.fp-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 8px;
    align-content: start;
}
.fp-char-card {
    display: flex; flex-direction: column; align-items: center;
    gap: 3px; cursor: pointer; border-radius: 8px;
    padding: 5px 3px; transition: background .12s;
    user-select: none;
}
.fp-char-card:hover { background: rgba(255,255,255,.06); }
.fp-char-card.fp-selected { background: rgba(139,92,246,.18); }
.fp-char-card.fp-used     { opacity: .35; cursor: default; }
.fp-char-card.fp-full     { opacity: .45; cursor: default; }

.fp-portrait-wrap {
    position: relative; width: 52px; height: 52px;
    border-radius: 50%; overflow: hidden; flex-shrink: 0;
}
.fp-portrait-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }

.fp-char-card.fp-selected .fp-portrait-wrap { outline: 2px solid var(--primary); outline-offset: 2px; }

.fp-overlay {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    font-size: .7rem; font-weight: 700;
}
.fp-overlay-sel  { background: rgba(139,92,246,.55); color: #fff; font-size: 1rem; }
.fp-overlay-used { background: rgba(0,0,0,.6); color: #aaa; }

.fp-char-name {
    font-size: .6rem; color: var(--text);
    text-align: center; line-height: 1.2;
    word-break: break-word; max-width: 66px;
}
.fp-char-speed { font-size: .6rem; color: var(--muted); }
