/* Import medieval-inspired fonts */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&family=Crimson+Text:ital,wght@0,400;0,600;0,700;1,400&display=swap');

/* Palette: gold is reserved for emphasis (selection, primary actions);
   everything else sits on warm neutrals so the graph highlight reads first */
:root {
    --bg: #0E0B09;
    --surface: #15110E;
    --surface-2: #1D1712;
    --surface-3: #261E17;
    --border: rgba(201, 163, 106, 0.22);
    --border-strong: rgba(201, 163, 106, 0.45);

    --text: #EFE3CC;
    --text-muted: #B9A78C;
    --text-faint: #8A7A66;

    --gold: #D9A84E;
    --gold-bright: #F2C76B;
    --bronze: #C9A36A;
    --crimson: #8B1E33;
    --crimson-bright: #B8324A;
    --ember: #FF9A4A;

    /* Edge-role hues: harm enemies / help own side / condition. Validated as a set
       (dataviz validate_palette.js, dark, surface --bg, all pairs: CVD ΔE 9.4, normal 20.9) */
    --role-harm: #d95926;
    --role-help: #199e70;
    --role-condition: #3987e5;
    --role-mixed: #EFE3CC;
    --role-place: var(--gold-bright); /* neutral highlight gold; places edges are dotted */
    /* card banner attribute colours (printed cards); graph rings use re-stepped CVD-safe versions in script.js */
    --str: #ED1C24;
    --agi: #0C9444;
    --int: #005C9E;

    --radius: 10px;
    --gap: 14px;
    --header-h: 64px;
    --focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--gold-bright);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Crimson Text', serif;
    font-size: 17px;
    line-height: 1.45;
    background:
        radial-gradient(ellipse at 15% 0%, rgba(139, 30, 51, 0.16) 0%, transparent 55%),
        radial-gradient(ellipse at 85% 100%, rgba(217, 168, 78, 0.07) 0%, transparent 55%),
        var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

button, input, select {
    font: inherit;
    color: inherit;
}

[hidden] { display: none !important; }

button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.45; }

:focus { outline: none; }
:focus-visible {
    outline: none;
    box-shadow: var(--focus);
    border-radius: 6px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    left: 12px;
    top: -60px;
    z-index: 100;
    background: var(--gold);
    color: var(--bg);
    padding: 8px 14px;
    border-radius: 6px;
    font-weight: 700;
}
.skip-link:focus { top: 12px; }

kbd {
    font-family: 'Cinzel', serif;
    font-size: 0.72em;
    padding: 1px 6px;
    border: 1px solid var(--border-strong);
    border-bottom-width: 2px;
    border-radius: 4px;
    color: var(--text-muted);
    background: var(--surface-2);
}

/* ------------------------------------------------------------------ */
/* Header                                                             */
/* ------------------------------------------------------------------ */

.header {
    height: var(--header-h);
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 14px;
    padding: 0 var(--gap);
    margin: 0 var(--gap) var(--gap);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    background: linear-gradient(180deg, rgba(139, 30, 51, 0.18), rgba(21, 17, 14, 0.9));
}

.header-sigil, .empty-sigil {
    width: 34px;
    height: 34px;
    fill: none;
    stroke: var(--gold);
    stroke-width: 1.2;
}

.header-titles {
    display: flex;
    align-items: baseline;
    gap: 16px;
    min-width: 0;
}

.title {
    font-family: 'Cinzel', serif;
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--gold-bright);
    text-shadow: 0 0 18px rgba(242, 199, 107, 0.25);
    white-space: nowrap;
}

.subtitle {
    font-family: 'Cinzel', serif;
    font-size: 0.82rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ------------------------------------------------------------------ */
/* Buttons                                                            */
/* ------------------------------------------------------------------ */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 8px;
    border: 1px solid var(--border-strong);
    background: var(--surface-2);
    font-family: 'Cinzel', serif;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.btn svg, .icon-btn svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.btn:not(:disabled):hover {
    border-color: var(--gold);
    box-shadow: 0 0 12px rgba(242, 199, 107, 0.18);
}

.btn-crimson {
    background: var(--crimson);
    border-color: var(--crimson-bright);
    color: var(--text);
}
.btn-crimson:not(:disabled):hover { background: var(--crimson-bright); }

.btn-gold {
    background: var(--gold);
    border-color: var(--gold-bright);
    color: #1A120C;
}
.btn-gold:hover { background: var(--gold-bright); }

.btn-ghost { background: rgba(21, 17, 14, 0.85); color: var(--text); }
.btn-ghost[aria-pressed="true"] {
    border-color: var(--gold);
    color: var(--gold-bright);
}

.btn-group {
    display: inline-flex;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: rgba(21, 17, 14, 0.85);
    overflow: hidden;
}

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 32px;
    background: transparent;
    border: none;
    color: var(--text);
    transition: background 0.2s, color 0.2s;
}
.btn-group .icon-btn + .icon-btn { border-left: 1px solid var(--border); }
.icon-btn:not(:disabled):hover { background: var(--surface-3); color: var(--gold-bright); }
.icon-btn:focus-visible { border-radius: 0; box-shadow: inset 0 0 0 2px var(--gold-bright); }

/* ------------------------------------------------------------------ */
/* Layout                                                             */
/* ------------------------------------------------------------------ */

.layout {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr) 272px;
    gap: var(--gap);
    padding: 0 var(--gap) var(--gap);
    height: calc(100vh - var(--header-h) - var(--gap));
    min-height: 560px;
}

.panel-column {
    display: flex;
    flex-direction: column;
    gap: var(--gap);
    min-height: 0;
}

.legend-panel { padding: 12px 14px; }

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
}

.right-column { overflow-y: auto; }

.panel-heading {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: none;
    border: none;
    font-family: 'Cinzel', serif;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--gold);
    text-align: left;
}

.chevron::after {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    border-right: 2px solid var(--text-muted);
    border-bottom: 2px solid var(--text-muted);
    transform: rotate(45deg) translateY(-2px);
    transition: transform 0.2s;
}
[aria-expanded="false"] .chevron::after { transform: rotate(-45deg); }

.collapse-body { margin-top: 12px; }

/* ------------------------------------------------------------------ */
/* Search                                                             */
/* ------------------------------------------------------------------ */

.search-panel { display: flex; flex-direction: column; gap: 12px; }

.search-box { position: relative; }

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    width: 18px;
    height: 18px;
    transform: translateY(-50%);
    fill: none;
    stroke: var(--text-muted);
    stroke-width: 2;
    stroke-linecap: round;
    pointer-events: none;
}

.search-box input {
    width: 100%;
    padding: 9px 40px 9px 40px;
    background: var(--bg);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    font-size: 1.02rem;
    color: var(--text);
}
.search-box input::placeholder { color: var(--text-faint); }
.search-box input:focus-visible {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(242, 199, 107, 0.2);
}
.search-box input::-webkit-search-cancel-button { filter: sepia(1) saturate(3); }

.search-kbd {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}
.search-box input:focus ~ .search-kbd,
.search-box input:not(:placeholder-shown) ~ .search-kbd { display: none; }

.suggestions {
    position: absolute;
    z-index: 30;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 340px;
    overflow-y: auto;
    list-style: none;
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
    padding: 4px;
}

.suggestions li {
    display: grid;
    grid-template-columns: 28px 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
}
.suggestions li img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    object-position: top;
    border: 1px solid var(--border-strong);
}
.suggestions li:hover,
.suggestions li[aria-selected="true"] { background: var(--surface-3); }
.suggestions li[aria-selected="true"] { box-shadow: inset 2px 0 0 var(--gold); }
.suggestions mark { background: none; color: var(--gold-bright); font-weight: 700; }
.suggestions .no-results { display: block; color: var(--text-muted); cursor: default; }
.sugg-glyph { display: grid; place-items: center; }
.sugg-type { font-size: 0.8rem; color: var(--text-faint); }
.sugg-name { min-width: 0; }
.search-pills { margin-top: 8px; }
.search-pills[hidden] { display: none; }
.search-pill { background: rgba(217, 168, 78, 0.16); border-color: var(--gold); color: var(--gold-bright); }
.search-pill-kind { font-size: 0.75rem; color: var(--text-faint); }
.search-pill-x { margin-left: 2px; font-size: 0.75rem; opacity: 0.7; }
.search-pill:hover .search-pill-x, .search-pill:focus-visible .search-pill-x { opacity: 1; }
.search-pill:hover { border-color: var(--gold-bright); }
.sugg-heroes { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.75rem; color: var(--text-muted); }
.sugg-glyph .ico { width: 18px; height: 18px; color: var(--gold); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
    padding: 3px 12px;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    background: transparent;
    font-size: 0.92rem;
    color: var(--text);
    transition: background 0.2s, border-color 0.2s;
}
.chip:hover { border-color: var(--gold); }
.chip[aria-pressed="true"] {
    background: var(--gold);
    border-color: var(--gold-bright);
    color: #1A120C;
    font-weight: 700;
}

.filter-summary {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 0.9rem;
    color: var(--text-muted);
}
.filter-summary strong { color: var(--gold); font-weight: 600; }

/* ------------------------------------------------------------------ */
/* Details panel                                                      */
/* ------------------------------------------------------------------ */

.details-panel {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    scrollbar-color: var(--border-strong) transparent;
}

.empty-state {
    display: grid;
    justify-items: center;
    gap: 14px;
    padding: 20px 6px;
    text-align: center;
    color: var(--text-muted);
}
.empty-sigil { width: 54px; height: 54px; opacity: 0.7; }

.shortcuts {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 12px;
    text-align: left;
    font-size: 0.92rem;
}
.shortcuts dt { text-align: right; }

.hero-header {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 14px;
    align-items: center;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.trait-emblem {
    width: 76px;
    height: 76px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    border: 2px solid var(--border-strong);
    background: var(--surface-2);
}

.hero-name {
    font-family: 'Cinzel', serif;
    font-size: 1.45rem;
    font-weight: 700;
    line-height: 1.15;
    color: var(--gold-bright);
    word-break: break-word;
}

.hero-id { color: var(--text-muted); font-style: italic; margin-bottom: 6px; }

.badges { display: flex; flex-wrap: wrap; gap: 6px; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 1px 10px;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    font-size: 0.92rem;
    background: var(--surface-2);
}

.detail-section { padding-top: 14px; }

/* Trait meaning: official effects are framed as a quoted rule */
.trait-desc { margin-top: 14px; color: var(--text); line-height: 1.5; }
.trait-desc p { margin: 0; }
.trait-desc--rule {
    padding: 10px 12px;
    border-left: 3px solid var(--gold);
    border-radius: 0 var(--radius) var(--radius) 0;
    background: var(--surface-2);
    font-style: italic;
}
.trait-desc-kicker, .tt-desc-kicker {
    display: block;
    margin-bottom: 4px;
    font-family: 'Cinzel', serif;
    font-size: 0.72rem;
    font-style: normal;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--gold);
}

.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-family: 'Cinzel', serif;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--gold);
}
.section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}
.count {
    font-family: 'Crimson Text', serif;
    letter-spacing: 0;
    color: var(--text-muted);
}

/* Hero card: parchment reference card (red number banner, round portrait, ruled abilities) */
.hero-card {
    --ink: #2A1D14;
    --ink-soft: #57412E;
    --card-red: #BE1E2D;
    --rule: rgba(42, 29, 20, 0.55);
    position: relative;
    padding: 0 14px 6px;
    border: 1px solid #8A6A43;
    border-radius: 6px;
    color: var(--ink);
    font-size: 1.04rem;
    line-height: 1.25;
    background:
        radial-gradient(ellipse at 25% 15%, rgba(255, 251, 238, 0.6), transparent 60%),
        radial-gradient(ellipse at 85% 95%, rgba(140, 98, 50, 0.22), transparent 55%),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .42 0 0 0 0 .3 0 0 0 0 .16 0 0 0 .28 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
        #E8DABD;
    box-shadow: inset 0 0 36px rgba(110, 72, 30, 0.35), 0 6px 18px rgba(0, 0, 0, 0.55);
}

.card-top {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 112px;
    grid-template-areas:
        "banner name name"
        "banner title portrait"
        "features features portrait";
    column-gap: 10px;
    padding-bottom: 10px;
}

.card-banner {
    grid-area: banner;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 0 16px;
    align-self: start;
    background: var(--card-red);
    color: #fff;
    clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 84%, 0 100%);
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.2);
}
.card-banner.attr--Strength { background: var(--str); }
.card-banner.attr--Agility { background: var(--agi); }
.card-banner.attr--Intelligence { background: var(--int); }
.card-number { font-family: 'Cinzel', serif; font-weight: 700; font-size: 1.05rem; line-height: 1; }
.card-banner-glyph { width: 26px; height: 26px; }
.card-banner-glyph path { fill: none; stroke: #fff; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

.card-title { grid-area: title; min-width: 0; }
.card-name {
    grid-area: name;
    padding-top: 12px;
    font-family: 'Cinzel', serif;
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--ink);
}
.card-vitality {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
    font-family: 'Cinzel', serif;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
}
.card-vitality svg { width: 24px; height: 24px; fill: var(--card-red); }
.card-type { margin-top: 2px; font-style: italic; color: var(--ink-soft); font-size: 0.92rem; }

.card-portrait {
    grid-area: portrait;
    align-self: start;
    width: 112px;
    height: 112px;
    margin-top: 4px;
    border-radius: 50%;
    object-fit: cover;
    object-position: top;
    border: 3px solid var(--ink);
    background: #D9C8A4;
    box-shadow: 0 2px 6px rgba(42, 29, 20, 0.35);
}

.card-features { grid-area: features; padding-top: 10px; }
.card-features h4 {
    font-family: 'Cinzel', serif;
    font-size: 0.98rem;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
}
.card-sync { color: var(--card-red); font-weight: 700; }

.card-ability { padding: 8px 0 10px; border-top: 1px solid var(--rule); }
.card-ability--core {
    margin: 0 -6px;
    padding: 8px 8px 10px;
    border: 1.5px solid var(--ink);
}
.card-ability--core + .card-ability { border-top: 0; }
.card-ability-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
}
.card-ability-head h4 {
    font-family: 'Cinzel', serif;
    font-size: 0.98rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}
/* Range symbols are cut from the parchment rulebook sheet, so they blend straight into the card */
.card-range { height: 26px; width: auto; flex-shrink: 0; mix-blend-mode: multiply; }

.card-ability-body { display: flex; align-items: center; gap: 8px; }
.card-rows { flex: 1; min-width: 0; }
.card-row { display: flex; align-items: flex-start; gap: 8px; }
.card-row + .card-row { margin-top: 6px; }
.card-icon {
    flex: none;
    width: 20px;
    height: 20px;
    margin-top: 1px;
    fill: var(--card-red);
}
.card-art { flex: none; width: 64px; height: 64px; object-fit: contain; }

/* Trait chips stay dark, like stamped tags on the parchment */
.hero-card .ability-traits { margin-top: 8px; }
.hero-card .trait-chip { background: var(--surface-2); color: var(--text); }
.hero-card .trait-chip:hover { background: var(--surface-3); }

.ability-key {
    display: inline-block;
    min-width: 74px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--gold);
}

.trait-chips { display: flex; flex-wrap: wrap; gap: 6px; }

.trait-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 10px 2px 6px;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    background: transparent;
    font-size: 0.92rem;
    transition: border-color 0.2s, background 0.2s;
}
.trait-chip:hover { border-color: var(--gold); background: var(--surface-3); }

.glyph { flex: none; vertical-align: middle; }
.glyph path { fill: none; stroke: #1A120C; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.glyph-trait path { fill: #4A3A2D; stroke: var(--bronze); stroke-width: 1.2; }
.glyph-img { border-radius: 50%; }

.hero-list { display: grid; gap: 4px; }

.hero-link {
    display: grid;
    grid-template-columns: 28px 1fr auto;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 4px 8px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    text-align: left;
    font-family: 'Cinzel', serif;
    font-size: 0.88rem;
}
.hero-link img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    object-position: top;
    border: 1px solid var(--border-strong);
}
.hero-link:hover { background: var(--surface-2); border-color: var(--border); }
.shared { font-family: 'Crimson Text', serif; font-size: 0.86rem; color: var(--text-muted); }

/* ------------------------------------------------------------------ */
/* Graph                                                              */
/* ------------------------------------------------------------------ */

.graph-panel {
    position: relative;
    min-width: 0;
    min-height: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background:
        radial-gradient(circle at 50% 45%, rgba(217, 168, 78, 0.06) 0%, transparent 60%),
        var(--surface);
}

.graph-toolbar {
    position: absolute;
    z-index: 10;
    top: 12px;
    left: 12px;
    right: 12px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}
/* Controls wrap on the left; Clear Filters stays pinned top-right */
.graph-toolbar { flex-wrap: nowrap; align-items: flex-start; }
.toolbar-main { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.graph-toolbar > *, .toolbar-main > * { pointer-events: auto; }
/* the wrapper itself lets clicks through to the graph */
.toolbar-main { pointer-events: none; }

.graph-title {
    max-width: 320px;
    padding: 5px 14px;
    border-radius: 8px;
    border: 1px solid var(--border-strong);
    background: rgba(21, 17, 14, 0.9);
    font-family: 'Cinzel', serif;
    font-weight: 600;
    color: var(--gold-bright);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.legend-toggle { display: none; }
.toolbar-side { margin-left: auto; flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.toolbar-side > [hidden] { display: none; }

#graph {
    display: block;
    width: 100%;
    height: 100%;
    cursor: grab;
}
#graph:active { cursor: grabbing; }

.graph-hint {
    position: absolute;
    bottom: 10px;
    left: 14px;
    font-size: 0.85rem;
    color: var(--text-faint);
    pointer-events: none;
}

/* Nodes */
.node { cursor: pointer; transition: opacity 0.25s; }
.node:focus, .node:focus-visible { box-shadow: none; outline: none; }

.hero-bg { fill: var(--surface-3); }
.hero-ring { fill: none; stroke-width: 3; }
.halo, .focus-ring { fill: none; stroke: transparent; transition: stroke 0.2s; }
.type-badge circle { stroke: var(--surface); stroke-width: 1.5; }
.type-badge path { fill: none; stroke: #1A120C; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.vitality-tokens, .vitality-stack { pointer-events: none; }
.token-rim { fill: url(#token-rim); stroke: #0D0B09; stroke-width: 0.8; }
.token-face { fill: url(#token-ember); }
.token-heart { fill: #FFE0A3; }

.label-shape {
    fill: #4A3A2D;
    stroke: var(--bronze);
    stroke-width: 1.5;
}
.effect-ring { fill: none; }

.node:focus-visible .focus-ring {
    stroke: var(--text);
    stroke-width: 2;
    stroke-dasharray: 4 3;
}

.node:hover .halo { stroke: rgba(242, 199, 107, 0.6); stroke-width: 2; }

.node.is-selected .halo {
    stroke: var(--gold-bright);
    stroke-width: 3.5;
    filter: drop-shadow(0 0 8px rgba(242, 199, 107, 0.9));
}
.node.is-connected .halo { stroke: var(--ember); stroke-width: 2.5; }
/* The opposing band in a band view: lit like the band but with a dashed, colourless ring */
.node.is-rival .halo { stroke: var(--text-muted); stroke-width: 2.5; stroke-dasharray: 5 4; }
.node.is-secondary { opacity: 0.55; }
.node.is-secondary .node-name { font-size: 11px; fill: var(--text-muted); }
.node.is-secondary:hover { opacity: 1; }
.node.is-match .halo { stroke: var(--gold); stroke-width: 2; }
.node.is-dim { opacity: 0.14; }
.node.is-dim:hover, .node.is-dim:focus-visible { opacity: 0.95; }

/* Names: heroes always, traits only on demand, so the graph stays quiet */
.node-name {
    text-anchor: middle;
    pointer-events: none;
    paint-order: stroke fill;
    stroke: #0B0806;
    stroke-width: 4px;
    stroke-linejoin: round;
    transition: opacity 0.2s;
}
.node--hero .node-name {
    font-family: 'Cinzel', serif;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.03em;
    fill: var(--text);
}
.node--label .node-name {
    font-family: 'Crimson Text', serif;
    font-size: 14px;
    font-weight: 700;
    fill: #E6D3B0;
    opacity: 0;
}

#graph.show-all-names .node--label .node-name,
.node--label:hover .node-name,
.node--label:focus-visible .node-name,
.node--label.is-selected .node-name,
.node--label.is-connected .node-name,
.node--label.is-match .node-name { opacity: 1; }

.node.is-selected .node-name { fill: var(--gold-bright); font-size: 15px; }
.node.is-connected .node-name { fill: #FFE2B8; }
#graph.has-highlight .node.is-dim .node-name { opacity: 0; }
#graph.has-highlight .node.is-dim:hover .node-name { opacity: 1; }
#graph.zoomed-out:not(.show-all-names) .node--hero:not(.is-selected):not(.is-connected):not(.is-rival):not(:hover) .node-name { opacity: 0; }

/* Links */
.link {
    stroke: #8A6A45;
    stroke-opacity: 0.35;
    stroke-width: 1.2;
    transition: stroke-opacity 0.25s, stroke-width 0.25s;
}
.link--direct {
    stroke: var(--gold-bright);
    stroke-opacity: 1;
    stroke-width: 3.5;
    filter: drop-shadow(0 0 4px rgba(242, 199, 107, 0.7));
}
.link--secondary {
    stroke: var(--bronze);
    stroke-opacity: 0.7;
    stroke-width: 1.5;
    stroke-dasharray: 5 4;
}
.link--dim { stroke-opacity: 0.05; }

/* Role edges (selection's own edges, or the role filter) */
.link--role { stroke: var(--gold-bright); stroke-opacity: 1; stroke-width: 2.5; }
.link.kind--inflicts { stroke: var(--role-harm); }
.link.kind--grants, .link.kind--gains { stroke: var(--role-help); }
.link.kind--benefits_from { stroke: var(--role-condition); }
.link.kind--hindered_by { stroke: var(--role-harm); }
.link.kind--mixed { stroke: var(--role-mixed); }
.link.kind--gains, .link.kind--hindered_by { stroke-dasharray: 7 4; }
.link.kind--places { stroke: var(--role-place); stroke-dasharray: 2 4; stroke-linecap: round; }
.link[class*="kind--"] { filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.8)); }
/* One-way edges fade from tail to arrowhead (script.js edgeGradient) */
.grad-stop--harm { stop-color: var(--role-harm); }
.grad-stop--help { stop-color: var(--role-help); }
.grad-stop--condition { stop-color: var(--role-condition); }
.grad-stop--mixed { stop-color: var(--role-mixed); }
.grad-stop--place { stop-color: var(--role-place); }
.arrow--harm { fill: var(--role-harm); }
.arrow--help { fill: var(--role-help); }
.arrow--condition { fill: var(--role-condition); }
.arrow--mixed { fill: var(--role-mixed); }
.arrow--place { fill: var(--role-place); }

.link-hit { stroke: transparent; stroke-width: 10; pointer-events: stroke; cursor: pointer; }
#graph.synergy-mode .link-hit { pointer-events: none; }

/* Hero-to-hero synergy lines */
.syn-arc { fill: none; stroke-width: 2.6; stroke-linecap: round; filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.8)); pointer-events: none; }
.syn-arc--partner { stroke: var(--role-help); }
.syn-arc--conflict { stroke: var(--role-harm); stroke-dasharray: 7 4; }
.syn-arc--counter { stroke: var(--role-harm); }
.syn-arc--overview { stroke-opacity: 0.55; stroke-width: 1.8; }
.syn-arc-hit { fill: none; stroke: transparent; stroke-width: 12; pointer-events: stroke; cursor: pointer; }
.syn-arc.syn-arc--picked { stroke-width: 4.5; stroke-opacity: 1; filter: drop-shadow(0 0 4px var(--gold-bright)); }

/* Tooltip */
.tooltip {
    position: absolute;
    z-index: 20;
    width: 280px;
    padding: 12px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--gold);
    background: rgba(21, 17, 14, 0.97);
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.6);
    pointer-events: none;
    font-size: 0.95rem;
}
.tt-head { display: flex; align-items: center; gap: 10px; }
.tt-head img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    object-position: top;
    border: 2px solid var(--border-strong);
}
.tt-head strong {
    font-family: 'Cinzel', serif;
    font-size: 1.05rem;
    color: var(--gold-bright);
}
.tt-sub { display: flex; align-items: center; gap: 5px; color: var(--text-muted); font-size: 0.88rem; }
.tt-features { list-style: none; padding: 0; margin: 8px 0 0; }
.tt-features li::before {
    content: '\25C6';
    margin-right: 7px;
    font-size: 0.55rem;
    vertical-align: middle;
    color: var(--gold);
}
.tt-synergies {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 3px 10px;
    margin: 8px 0 0;
    padding-top: 6px;
    border-top: 1px solid var(--border);
    font-size: 0.86rem;
}
.tt-synergies dt { display: flex; align-items: center; gap: 5px; color: var(--text-muted); white-space: nowrap; }
.tt-synergies dd { margin: 0; color: var(--text); }
.tt-more, .tt-notes { color: var(--text-muted); }
.tt-notes { margin-top: 6px; font-size: 0.84rem; font-style: italic; }
.tt-desc { margin-top: 8px; line-height: 1.4; }
.tt-desc p { margin: 0; }
.tt-desc--rule p { font-style: italic; }
.tt-meta {
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.86rem;
}

/* ------------------------------------------------------------------ */
/* Legend                                                             */
/* ------------------------------------------------------------------ */

.legend-title {
    margin: 14px 0 6px;
    font-family: 'Cinzel', serif;
    font-size: 0.74rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.legend-title:first-child { margin-top: 0; }
/* toggled legend sections keep the normal gap above their heading */
.legend-section > .legend-title:first-child { margin-top: 14px; }
.legend-title small {
    font-family: 'Crimson Text', serif;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text-faint);
}

.legend-list { list-style: none; display: grid; gap: 3px; font-size: 0.95rem; }
.legend-list li { display: flex; align-items: center; gap: 8px; min-height: 24px; }
.legend-cols { grid-template-columns: 1fr 1fr; column-gap: 8px; }

.legend-filter {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 1px 6px;
    margin-left: -6px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: none;
    text-align: left;
}
.legend-filter:hover { background: var(--surface-2); }
.legend-filter[aria-pressed="true"] { border-color: var(--gold); background: var(--surface-2); color: var(--gold-bright); }

.legend-state .ls-fill { fill: var(--surface-3); stroke: var(--bronze); stroke-width: 1.5; }
.legend-state .ls-ring { fill: none; stroke: transparent; }
.legend-state.st-selected .ls-ring { stroke: var(--gold-bright); stroke-width: 2.5; }
.legend-state.st-connected .ls-ring { stroke: var(--ember); stroke-width: 2; }
.legend-state.st-rival .ls-ring { stroke: var(--text-muted); stroke-width: 2; stroke-dasharray: 3 2.5; }
.legend-state.st-secondary { opacity: 0.7; }
.legend-state.st-dim { opacity: 0.25; }
.legend-list .link { stroke-opacity: 0.6; }
.legend-list .link--dim { stroke-opacity: 0.18; }

.legend-hint { color: var(--text-faint); font-size: 0.82rem; }
.role-swatch { flex-shrink: 0; }
.role-swatch .sw-hero { fill: var(--surface-3); stroke: var(--bronze); stroke-width: 1.2; }
.role-swatch .sw-trait { fill: #4A3A2D; stroke: var(--bronze); stroke-width: 1.2; }
.role-swatch .sw-line { stroke-width: 2.5; }
.role-swatch .sw-dashed { stroke-dasharray: 5 3; }
.role-swatch .sw-dotted { stroke-dasharray: 1.5 3; stroke-linecap: round; }
.role-swatch.hue--place { --sw: var(--role-place); }
.role-swatch.hue--harm { --sw: var(--role-harm); }
.role-swatch.hue--help { --sw: var(--role-help); }
.role-swatch.hue--condition { --sw: var(--role-condition); }
.role-swatch.hue--mixed { --sw: var(--role-mixed); }
.role-swatch .sw-line { stroke: var(--sw); }
.role-swatch .sw-arrow { fill: var(--sw); }

.legend-sizes svg circle { fill: var(--surface-3); stroke: var(--bronze); stroke-width: 1.5; }
.legend-sizes .trait-sizes path { fill: #4A3A2D; stroke: var(--bronze); stroke-width: 1.2; }

/* ------------------------------------------------------------------ */
/* Footer                                                             */
/* ------------------------------------------------------------------ */

.footer {
    padding: 10px var(--gap) 16px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-faint);
}
.footer a { color: var(--bronze); font-weight: 600; }
.footer a:hover { color: var(--gold-bright); }

/* ------------------------------------------------------------------ */
/* Responsive                                                         */
/* ------------------------------------------------------------------ */

/* Medium screens: legend becomes a slide-over drawer */
@media (max-width: 1200px) {
    .layout { grid-template-columns: 320px minmax(0, 1fr); }

    .legend-toggle { display: inline-flex; }

    .right-column {
        position: fixed;
        z-index: 40;
        top: calc(var(--header-h) + var(--gap));
        right: var(--gap);
        bottom: var(--gap);
        width: 290px;
        transform: translateX(calc(100% + var(--gap) * 2));
        transition: transform 0.3s ease;
        visibility: hidden;
    }
    .right-column.open {
        transform: none;
        visibility: visible;
        box-shadow: -10px 0 40px rgba(0, 0, 0, 0.6);
    }
    .right-column .panel { background: var(--surface-2); }
}

/* Small screens: single column, graph first, panels collapsible below */
@media (max-width: 800px) {
    :root { --header-h: 54px; --gap: 10px; }
    body { font-size: 16px; }

    .title { font-size: 1.05rem; letter-spacing: 0.02em; }
    .header .btn { padding: 5px 10px; font-size: 0.72rem; }
    .subtitle { display: none; }
    .header-sigil { width: 26px; height: 26px; }

    .layout {
        grid-template-columns: 1fr;
        height: auto;
        min-height: 0;
    }
    .graph-panel { order: 1; height: 64vh; min-height: 380px; }
    .left-column { order: 2; }
    .details-panel { max-height: none; overflow: visible; }
    /* Nothing selected: the hint and keyboard shortcuts are noise on a phone */
    .details-panel:has(.empty-state) { display: none; }

    .right-column {
        order: 3;
        position: static;
        width: auto;
        transform: none;
        visibility: visible;
        overflow: visible;
    }
    .right-column .panel { background: var(--surface); }
    .legend-toggle { display: none; }

    .graph-title { max-width: 100%; flex-basis: 100%; }
    .graph-hint { display: none; }
    .tooltip { width: 240px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation: none !important;
        transition: none !important;
    }
}

@media (forced-colors: active) {
    .link--direct, .syn-arc { stroke: Highlight !important; }
    .node.is-selected .halo { stroke: Highlight; }
}

/* ------------------------------------------------------------------ */
/* Role chips (traits under each ability) and role markers            */
/* ------------------------------------------------------------------ */
.ability-traits { margin-top: 8px; }
.role-chip { border-left-width: 3px; border-radius: 12px; flex-wrap: wrap; text-align: left; }
.role-chip .role-tag, .role-chip .chip-label, .role-chip .role-on { white-space: nowrap; }
.role-chip .chip-label { display: inline-flex; align-items: center; gap: 5px; }
.role-chip.kind--inflicts { border-left-color: var(--role-harm); }
.role-chip.kind--grants, .role-chip.kind--gains { border-left-color: var(--role-help); }
.role-chip.kind--benefits_from { border-left-color: var(--role-condition); }
.role-chip.kind--hindered_by { border-left-color: var(--role-harm); }
.role-chip.kind--gains, .role-chip.kind--hindered_by { border-left-style: dashed; }
.role-chip.kind--places { border-left-color: var(--role-place); border-left-style: dotted; }
.role-tag {
    font-family: 'Cinzel', serif;
    font-size: 0.66rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.role-on { color: var(--text-faint); font-size: 0.85em; }

.role-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 6px;
    border-radius: 50%;
    border: 2px solid var(--bronze);
    vertical-align: middle;
}
.role-dot.kind--inflicts { border-color: var(--role-harm); background: var(--role-harm); }
.role-dot.kind--grants { border-color: var(--role-help); background: var(--role-help); }
.role-dot.kind--gains { border-color: var(--role-help); border-style: dashed; }
.role-dot.kind--benefits_from { border-color: var(--role-condition); background: var(--role-condition); }
.role-dot.kind--hindered_by { border-color: var(--role-harm); border-style: dashed; }
.role-dot.kind--places { border-color: var(--role-place); border-style: dotted; }

.tt-roles { list-style: none; padding: 0; margin: 6px 0 0; display: grid; gap: 3px; font-size: 0.92rem; }

/* Edge tooltip: the abilities behind the edge, as a slip of the parchment card */
.tooltip--edge { width: 340px; }
.tooltip--arc { width: min(600px, calc(100% - 16px)); }
.tt-sides { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; margin-top: 8px; }
.tt-side .hero-card.tt-abilities { margin-top: 4px; }
.tt-side-head { display: flex; align-items: center; gap: 7px; }
.tt-side-head img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; object-position: top; border: 1.5px solid var(--border-strong); }
.tt-side-head strong { font-family: 'Cinzel', serif; color: var(--gold-bright); font-size: 0.92rem; }

/* Clicked synergy arc: the arc tooltip pinned in the details panel, each side opening its hero's card */
.pair-header { padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.pair-header .hero-id small { color: var(--text-muted); }
.pair-body .tt-sides { grid-template-columns: 1fr; gap: 16px; margin-top: 12px; }
.pair-side-head {
    width: 100%;
    padding: 4px 8px 4px 4px;
    background: none;
    border: 1px solid transparent;
    border-radius: 6px;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.pair-side-head:hover, .pair-side-head:focus-visible { border-color: var(--border-strong); background: var(--surface-2); }
.pair-open { margin-left: auto; font-size: 0.85rem; color: var(--text-muted); }
.pair-side-head:hover .pair-open { color: var(--gold-bright); }
.hero-card.tt-abilities { margin-top: 8px; padding: 2px 12px 2px; font-size: 0.9rem; }
.tt-abilities .card-ability--core { margin-top: 8px; }
.tt-abilities .card-range { height: 22px; }
.tt-abilities .card-icon { width: 17px; height: 17px; }
.card-ability--level p { margin: 2px 0; }
.tt-ability-roles { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 6px; font-size: 0.82rem; color: var(--ink-soft); }
.role-tag-sm { display: inline-flex; align-items: center; gap: 4px; }
.tt-hint { margin-top: 6px; color: var(--text-faint); font-size: 0.8rem; font-style: italic; }

/* Clicked edge: its line glows and the abilities behind it are marked on the card */
.link.link--picked { stroke-width: 5; filter: drop-shadow(0 0 4px var(--gold-bright)); }
.card-ability--focus { box-shadow: inset 4px 0 0 var(--card-red); background: rgba(190, 30, 45, 0.08); padding-left: 10px; }
.card-ability--core.card-ability--focus { box-shadow: inset 4px 0 0 var(--card-red), 0 0 0 1px var(--card-red); }
.hero-card .trait-chip.role-chip--focus { outline: 2px solid var(--gold-bright); outline-offset: 1px; }

/* ------------------------------------------------------------------ */
/* Synergies                                                          */
/* ------------------------------------------------------------------ */
.synergies .syn-title {
    margin: 12px 0 6px;
    font-family: 'Cinzel', serif;
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    color: var(--gold);
}
.synergies .syn-title:first-of-type { margin-top: 0; }
.syn-row { margin-bottom: 8px; }
.syn-need { font-size: 0.95rem; color: var(--text); margin-bottom: 4px; }
.syn-rule { color: var(--text-faint); font-style: italic; font-size: 0.88em; }
.syn-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.syn-line { margin: 2px 0 6px; }
.syn-flag {
    margin-top: 8px;
    padding: 5px 10px;
    border-left: 3px solid var(--crimson-bright);
    border-radius: 0 6px 6px 0;
    background: rgba(139, 30, 51, 0.18);
}
.hero-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 10px 2px 3px;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    background: var(--surface-2);
    color: var(--text);
    font-size: 0.9rem;
    cursor: pointer;
}
.hero-chip img { border-radius: 50%; }
.hero-chip:hover, .hero-chip:focus-visible { border-color: var(--gold); color: var(--gold-bright); }

/* ------------------------------------------------------------------ */
/* Tabs (Graph | Draft)                                               */
/* ------------------------------------------------------------------ */
.tabs { display: flex; align-items: center; gap: 4px; }
.tab {
    position: relative;
    padding: 8px 16px;
    background: none;
    border: none;
    font-family: 'Cinzel', serif;
    font-size: 0.92rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.tab + .tab { border-left: 1px solid var(--border-strong); }
.tab:hover { color: var(--gold-bright); }
.tab[aria-selected="true"] { color: var(--gold-bright); }
.tab[aria-selected="true"]::after {
    content: '';
    position: absolute;
    left: 14px; right: 14px; bottom: 0;
    height: 2px;
    background: var(--gold);
    box-shadow: 0 0 10px rgba(242, 199, 107, 0.5);
}

/* ------------------------------------------------------------------ */
/* Draft tab                                                          */
/* ------------------------------------------------------------------ */
.draft-layout {
    --chip-synergy: var(--gold);
    --chip-counter: #2BA39A;
    --chip-warning: #E2533A;
    --parchment: #E8DABD;
    --ink: #2A1D14;
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 5fr) minmax(240px, 2fr);
    gap: var(--gap);
    padding: 0 var(--gap) var(--gap);
    height: calc(100vh - var(--header-h) - var(--gap));
    min-height: 560px;
}
.draft-layout > .panel { overflow-y: auto; min-height: 0; }
.draft-layout > .panel > * { flex-shrink: 0; } /* scroll the panel instead of squashing its sections */

.draft-heading {
    font-family: 'Cinzel', serif;
    font-size: 1.02rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--gold);
}
.draft-heading--enemy { color: var(--chip-warning); }
.mini-heading {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    font-family: 'Cinzel', serif;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--bronze);
}
.hint, .muted, .analysis-sub { color: var(--text-muted); font-size: 0.92rem; }
.link-btn {
    background: none;
    border: none;
    padding: 2px 4px;
    color: var(--gold);
    font-family: 'Cinzel', serif;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.04em;
}
.link-btn:hover { color: var(--gold-bright); text-decoration: underline; }
.empty-note { color: var(--text-muted); font-style: italic; padding: 8px 2px; list-style: none; }
.ico { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Pool */
.draft-pool { display: flex; flex-direction: column; gap: 10px; }
.draft-pool .chips { gap: 5px; }
.draft-pool .chips .chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; font-size: 0.9rem; }
.chip--Strength .ico { color: var(--str); }
.chip--Agility .ico { color: #2CC46B; }
.chip--Intelligence .ico { color: #3E9BE0; }
.pool-toggles { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.toggle { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 0.95rem; cursor: pointer; }
.toggle input { accent-color: var(--gold); }
.excluded { border-top: 1px solid var(--border); padding-top: 8px; }
.excluded-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; min-height: 28px; border-radius: 8px; }
.ex-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 4px 2px 10px;
    border: 1px solid var(--border-strong);
    border-radius: 14px;
    background: var(--surface-2);
    color: var(--text-muted);
    text-decoration: line-through;
    text-decoration-color: rgba(185, 167, 140, 0.6);
    font-size: 0.92rem;
}
.ex-chip.is-banned { padding-right: 10px; }
.ex-chip button { background: none; border: none; color: var(--text-muted); padding: 0 4px; text-decoration: none; }
.ex-chip button:hover { color: var(--gold-bright); }
.pool-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.step-badge {
    padding: 4px 12px;
    border-radius: 14px;
    border: 1px solid var(--gold);
    background: rgba(217, 168, 78, 0.1);
    color: var(--gold-bright);
    font-family: 'Cinzel', serif;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.04em;
}
.step-badge--p2 { border-color: var(--crimson-bright); background: rgba(184, 50, 74, 0.16); color: #FF9DAE; }
.step-badge--done { border-color: var(--border-strong); background: none; color: var(--text-muted); }
.pool-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.pool-count { color: var(--text-faint); font-size: 0.88rem; }
/* Random hero: a line-drawn die in the pool bar and on the next empty slot */
.random-btn { width: 30px; height: 28px; border: 1px solid var(--border-strong); border-radius: 8px; color: var(--gold); }
.random-btn:not(:disabled):hover { box-shadow: 0 0 12px rgba(242, 199, 107, 0.25); }
.random-btn:focus-visible { border-radius: 8px; }
.random-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.random-btn svg, .slot-fate svg { transition: transform 0.3s ease; }
.random-btn:not(:disabled):hover svg, .slot-fate:hover svg { transform: rotate(-20deg) scale(1.1); }
.sort-switch { margin-left: auto; display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.sort-switch button { padding: 3px 10px; border: none; background: none; color: var(--text-muted); font-size: 0.9rem; }
.sort-switch button + button { border-left: 1px solid var(--border); }
.sort-switch [aria-checked="true"] { background: rgba(217, 168, 78, 0.16); color: var(--gold-bright); }
.pool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); grid-auto-rows: 1fr; gap: 10px; }
.pool-grid > .hero-tile { display: flex; } /* every tile as tall as the tallest */
.pool-grid > .hero-tile > .tile-main { height: 100%; justify-content: flex-start; }
.pool-grid > .empty-note { grid-column: 1 / -1; }
/* Finished draft: the whole pool fades so attention moves to the band */
.pool-grid.is-done .tile-main { filter: grayscale(0.85) brightness(0.62); }
.hero-tile.is-top .tile-main { box-shadow: inset 0 0 22px rgba(110, 72, 30, 0.35), 0 0 0 2px rgba(217, 168, 78, 0.75); }

/* Parchment hero tile */
.hero-tile { position: relative; }
.tile-main {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 10px 6px 8px;
    border: 1px solid #8A6A43;
    border-radius: 6px;
    color: var(--ink);
    background:
        radial-gradient(ellipse at 25% 15%, rgba(255, 251, 238, 0.55), transparent 60%),
        radial-gradient(ellipse at 85% 95%, rgba(140, 98, 50, 0.25), transparent 55%),
        var(--parchment);
    box-shadow: inset 0 0 22px rgba(110, 72, 30, 0.35);
    transition: box-shadow 0.2s, transform 0.2s;
}
.hero-tile:not(.is-unavailable) .tile-main:hover {
    box-shadow: inset 0 0 22px rgba(110, 72, 30, 0.35), 0 0 0 2px var(--gold), 0 0 16px rgba(242, 199, 107, 0.35);
    transform: translateY(-1px);
}
.tile-main[aria-disabled="true"] { cursor: default; }
.tile-portrait, .slot-portrait, .enemy-portrait, .face-portrait, .picker-portrait {
    object-fit: cover;
    object-position: center 15%;
    border-radius: 50%;
    border: 2px solid #8A6A43;
    background: #2A1D14;
}
.tile-portrait { width: 64px; height: 64px; }
.portrait-wrap { position: relative; display: flex; }
.vitality-stack { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.tile-name {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    font-size: 0.84rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}
.tile-badge {
    position: absolute;
    bottom: 34px;
    left: 50%;
    transform: translateX(-50%);
    padding: 1px 8px;
    border-radius: 4px;
    background: rgba(14, 11, 9, 0.88);
    color: var(--text);
    font-family: 'Cinzel', serif;
    font-size: 0.74rem;
    letter-spacing: 0.06em;
    white-space: nowrap;
}
.is-facing .tile-badge { background: #6E1F14; }
.hero-tile.is-unavailable .tile-main { filter: grayscale(0.85) brightness(0.62); }
.hero-tile.is-excluded .tile-name, .hero-tile.is-banned .tile-name { text-decoration: line-through; }
.tile-corner {
    position: absolute;
    top: 6px; right: 6px;
    width: 22px; height: 22px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--ink);
    color: var(--gold-bright);
    font-weight: 700;
    pointer-events: none;
}
.tile-corner--p2 { background: var(--crimson); color: #FFE1E6; }
.tile-menu-btn {
    position: absolute;
    top: 30px; right: 6px;
    width: 22px; height: 22px;
    border-radius: 50%;
    border: none;
    background: rgba(42, 29, 20, 0.12);
    color: var(--ink);
    font-weight: 700;
    line-height: 1;
}
.tile-menu-btn:hover, .tile-menu-btn:focus-visible { background: var(--ink); color: var(--gold-bright); }

/* Attribute banner (the card's coloured number ribbon) */
.attr-banner {
    position: absolute;
    top: -1px; left: 8px;
    width: 22px;
    padding: 4px 0 8px;
    display: grid;
    place-items: center;
    color: #fff;
    clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 80%, 0 100%);
}
.attr-banner .ico { width: 14px; height: 14px; }
.attr--Strength .attr-banner { background: var(--str); }
.attr--Agility .attr-banner { background: var(--agi); }
.attr--Intelligence .attr-banner { background: var(--int); }

/* Battle-role pills */
.role-pills { display: inline-flex; gap: 3px; }
.role-pill {
    display: inline-grid;
    place-items: center;
    width: 22px; height: 22px;
    border-radius: 50%;
    border: 1px solid currentColor;
}
.role-pill .ico { width: 13px; height: 13px; stroke-width: 2.2; }
.tile-main .role-pill, .slot .role-pill { color: #57412E; }
.enemy-card .role-pill { color: var(--bronze); }

/* Mode switch */
.draft-main { display: flex; flex-direction: column; gap: 16px; }
.mode-switch { display: flex; gap: 10px; }
.mode-btn {
    position: relative;
    flex: 1;
    max-width: 320px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px 16px;
    border-radius: 10px;
    border: 1px solid var(--border-strong);
    background: var(--surface-2);
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
}
.mode-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.mode-btn[aria-checked="true"] {
    color: var(--gold-bright);
    border-color: var(--gold);
    box-shadow: 0 0 0 1px var(--gold), 0 0 18px rgba(242, 199, 107, 0.2);
}
.mode-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); }

/* Two-player setup and sequence tracker */
.setup { display: flex; flex-wrap: wrap; gap: 14px; }
.setup-summary { color: var(--text-muted); font-style: italic; }
.setup-group { border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px 10px; display: flex; flex-wrap: wrap; gap: 8px; }
.setup-group legend { padding: 0 6px; font-family: 'Cinzel', serif; font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--bronze); }
.radio-card, .radio-pill { display: inline-flex; align-items: flex-start; gap: 8px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); cursor: pointer; }
.radio-card span { display: flex; flex-direction: column; }
.radio-card small { color: var(--text-muted); font-size: 0.85rem; }
.radio-card:has(input:checked), .radio-pill:has(input:checked) { border-color: var(--gold); background: rgba(217, 168, 78, 0.08); }
.radio-card input, .radio-pill input { accent-color: var(--gold); margin-top: 4px; }
.sequence { display: flex; flex-wrap: wrap; gap: 4px; list-style: none; }
.seq-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 62px;
    padding: 4px 8px;
    border-radius: 8px;
    border: 1px solid var(--border);
    font-size: 0.82rem;
    line-height: 1.15;
}
.seq-action { font-family: 'Cinzel', serif; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; font-size: 0.72rem; }
.seq--p1 .seq-action { color: var(--gold); }
.seq--p2 .seq-action { color: #FF9DAE; }
.seq--p2.seq--current { border-color: var(--crimson-bright); box-shadow: 0 0 12px rgba(184, 50, 74, 0.35); }
.seq--ban { border-style: dashed; }
.seq--extra { border-style: dashed; border-color: var(--border-strong); color: var(--text-muted); }
.seq--extra .seq-action { color: var(--text-muted); }
.seq-remove { margin-left: 2px; padding: 0 2px; border: none; background: none; color: var(--text-muted); font-size: 0.75rem; }
.seq-remove:hover { color: var(--gold-bright); }
.seq-add-item { display: flex; align-items: center; }
.seq-add { padding: 4px 10px; border-radius: 8px; border: 1px dashed var(--border-strong); background: none; color: var(--gold); font-family: 'Cinzel', serif; font-size: 0.78rem; font-weight: 600; letter-spacing: 0.04em; }
.seq-add:hover { border-color: var(--gold); color: var(--gold-bright); }
.seq--done { opacity: 0.6; }
.seq--current { border-color: var(--gold); box-shadow: 0 0 12px rgba(242, 199, 107, 0.3); opacity: 1; }

/* Sections */
.draft-section { display: flex; flex-direction: column; gap: 10px; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; }
.head-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
/* Two-player: the band whose turn it is */
.draft-section.is-acting > .slots, .draft-section.is-acting > .against { padding: 8px; margin: -8px; border-radius: 12px; box-shadow: 0 0 0 1px var(--gold), 0 0 22px rgba(242, 199, 107, 0.14); }
.draft-section.is-acting.is-p2 > .slots { box-shadow: 0 0 0 1px var(--crimson-bright), 0 0 22px rgba(184, 50, 74, 0.2); }
.turn-tag { padding: 1px 10px; border-radius: 10px; background: var(--gold); color: var(--ink); font-family: 'Cinzel', serif; font-size: 0.74rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.is-p2 .turn-tag { background: var(--crimson-bright); color: #fff; }
.player-switch { display: inline-flex; align-self: flex-start; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.player-switch button { padding: 4px 12px; border: none; background: none; color: var(--text-muted); font-family: 'Cinzel', serif; font-size: 0.82rem; }
.player-switch button + button { border-left: 1px solid var(--border); }
.player-switch [aria-checked="true"] { background: rgba(217, 168, 78, 0.16); color: var(--gold-bright); }

/* Band slots */
.slots { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.slot {
    position: relative;
    min-height: 196px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 16px 8px 10px;
    border-radius: 8px;
    border: 1px solid #8A6A43;
    color: var(--ink);
    background:
        radial-gradient(ellipse at 25% 15%, rgba(255, 251, 238, 0.6), transparent 60%),
        radial-gradient(ellipse at 85% 95%, rgba(140, 98, 50, 0.22), transparent 55%),
        var(--parchment);
    box-shadow: inset 0 0 30px rgba(110, 72, 30, 0.35), 0 6px 18px rgba(0, 0, 0, 0.5);
}
.slot.is-empty {
    justify-content: center;
    background: none;
    border: 1px dashed var(--border-strong);
    box-shadow: none;
    color: var(--text-muted);
}
.slot.is-preview { opacity: 0.6; border-style: dashed; }
[data-card] { cursor: pointer; }
.slot[data-card]:hover, .enemy-card[data-card]:hover { box-shadow: 0 0 0 1px var(--gold), 0 0 16px rgba(242, 199, 107, 0.3); }
.slot.is-drop-target, .against.is-drop-target, .excluded-chips.is-drop-target { box-shadow: 0 0 0 2px var(--gold-bright); }
.slot-num { position: absolute; top: 8px; left: 10px; font-family: 'Cinzel', serif; font-weight: 700; font-size: 1.05rem; }
.slot.is-empty .slot-num { color: var(--text-muted); }
.slot-num--id { top: auto; bottom: 8px; }
.slot-add { display: flex; flex-direction: column; align-items: center; gap: 6px; background: none; border: none; color: var(--text-muted); }
.slot-add:not(:disabled):hover { color: var(--gold-bright); }
.slot-fate { display: inline-flex; align-items: center; gap: 6px; margin-top: 4px; background: none; border: none;
    color: var(--text-muted); font-family: 'Crimson Text', serif; font-style: italic; font-size: 0.92rem; }
.slot-fate .ico { color: var(--gold); }
.slot-fate:hover { color: var(--gold-bright); text-shadow: 0 0 10px rgba(242, 199, 107, 0.45); }
.slot.is-arrived { animation: slot-arrive 0.9s ease-out; }
@keyframes slot-arrive {
    0% { box-shadow: inset 0 0 30px rgba(110, 72, 30, 0.35), 0 0 0 3px var(--gold-bright), 0 0 30px rgba(242, 199, 107, 0.6); }
    100% { box-shadow: inset 0 0 30px rgba(110, 72, 30, 0.35), 0 6px 18px rgba(0, 0, 0, 0.5); }
}
.slot-plus { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; border: 1px solid currentColor; font-size: 1.5rem; }
.slot-portrait { width: 84px; height: 84px; }
.slot-name { font-family: 'Cinzel', serif; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.slot-ribbon {
    position: absolute; top: 10px; right: -2px;
    padding: 1px 8px;
    background: var(--gold); color: var(--ink);
    font-family: 'Cinzel', serif; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
}
.slot-remove {
    position: absolute; top: 6px; right: 6px;
    width: 24px; height: 24px;
    border-radius: 50%;
    border: none;
    background: var(--ink);
    color: var(--parchment);
    font-size: 0.8rem;
}
.slot-remove:hover { background: var(--crimson-bright); }
.slot-move { display: flex; gap: 6px; opacity: 0; transition: opacity 0.2s; }
.slot:hover .slot-move, .slot:focus-within .slot-move { opacity: 1; }
.slot-move button { border: 1px solid #8A6A43; background: rgba(255, 251, 238, 0.5); border-radius: 4px; color: var(--ink); font-size: 0.7rem; padding: 1px 6px; }
.slot[draggable="true"] { cursor: grab; }

/* Against row */
.against { display: flex; flex-wrap: wrap; gap: 10px; border-radius: 8px; min-height: 40px; }
.against.slots { display: grid; gap: 12px; }
.enemy-card {
    position: relative;
    width: 128px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 14px 8px 8px;
    border-radius: 8px;
    border: 1px solid #7A2A20;
    background: linear-gradient(180deg, rgba(139, 30, 51, 0.32), rgba(21, 17, 14, 0.9));
    box-shadow: inset 0 0 0 1px rgba(226, 83, 58, 0.25);
}
.enemy-card .attr-banner { left: 6px; }
.enemy-card .slot-num { left: auto; right: 10px; color: var(--text-muted); }
.enemy-mark { color: var(--chip-warning); width: 13px; height: 13px; vertical-align: -1px; }
.enemy-portrait { width: 56px; height: 56px; border-color: #7A2A20; }
.enemy-name { font-family: 'Cinzel', serif; font-weight: 600; font-size: 0.86rem; text-transform: uppercase; letter-spacing: 0.04em; }
.enemy-card .slot-remove { background: var(--surface-3); color: var(--text); }

/* Reasons (Why block, threats, synergy) */
.reason-list { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.reason { padding-left: 20px; position: relative; }
.reason::before { position: absolute; left: 0; }
.reason--positive::before { content: '✦'; color: var(--gold); }
.reason--counter::before { content: '⚔'; color: var(--chip-counter); }
.reason--warning::before { content: '⚠'; color: var(--chip-warning); }
.reason--info::before { content: '✓'; color: var(--text-muted); }

/* Completion cards */
.completions { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.band-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    text-align: left;
}
.band-card:hover, .band-card:focus-visible { border-color: var(--gold-bright); }
.band-faces { display: flex; gap: 4px; min-width: 0; }
.band-face { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 64px; min-width: 0; }
.face-portrait { width: 40px; height: 40px; }
.band-face.is-in-band .face-portrait { border-color: var(--gold-bright); box-shadow: 0 0 0 2px rgba(242, 199, 107, 0.35); }
.face-name { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.02em; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.band-pct { font-family: 'Cinzel', serif; font-weight: 700; color: var(--gold-bright); white-space: nowrap; }
.summary-card { padding: 12px 14px; border-radius: 10px; border: 1px solid var(--gold); display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.swap-list { list-style: none; display: flex; flex-direction: column; gap: 6px; width: 100%; }
.swap-btn {
    width: 100%;
    display: grid;
    grid-template-columns: 44px 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    text-align: left;
}
.swap-btn:hover, .swap-btn:focus-visible { border-color: var(--gold-bright); }
.why-block { border-top-color: var(--gold); }

/* Analysis */
.draft-analysis { display: flex; flex-direction: column; gap: 18px; }
.analysis-block { display: flex; flex-direction: column; gap: 8px; padding-top: 14px; border-top: 1px solid var(--border); }
.role-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.role-row { display: grid; grid-template-columns: 26px 1fr auto; align-items: center; gap: 8px; }
.role-ico { width: 22px; height: 22px; color: var(--bronze); }
.role-name { font-size: 1.02rem; }
.role-status { color: var(--chip-warning); font-size: 0.95rem; }
.role-row.is-covered .role-status { color: #7FD3A8; }
.role-row.is-changed .role-status, .is-changed { color: var(--gold-bright) !important; font-weight: 600; }
.band-score { font-family: 'Cinzel', serif; font-size: 2rem; line-height: 1.1; font-weight: 700; color: var(--gold-bright); }
.score-bar { height: 8px; }
/* The score's (i) and its explanation (hover / focus, or pinned open by a click) */
.band-score-row { position: relative; display: flex; align-items: center; gap: 10px; }
.info-tip[hidden] { display: none; }
.info-btn {
    display: inline-grid; place-items: center; width: 22px; height: 22px; padding: 0;
    border: 1px solid var(--bronze); border-radius: 50%; background: none; color: var(--gold);
    font: italic 700 0.85rem/1 'Crimson Text', serif; cursor: help;
}
.info-btn:hover, .info-btn:focus-visible, .info-tip.is-open .info-btn { color: var(--gold-bright); border-color: var(--gold-bright); box-shadow: 0 0 8px rgba(242, 199, 107, 0.35); }
.info-pop {
    position: absolute; z-index: 40; top: calc(100% + 6px); left: 0; right: 0;
    padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: 8px;
    background: var(--surface-2); box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
    color: var(--text-muted); font-size: 0.92rem; line-height: 1.4;
    visibility: hidden; opacity: 0; transition: opacity 0.15s ease, visibility 0.15s;
}
/* is-dismissed: Escape hides it until the pointer or focus comes back */
.info-tip:not(.is-dismissed):has(.info-btn:focus-visible) .info-pop, .info-tip.is-open .info-pop { visibility: visible; opacity: 1; }
@media (hover: hover) { .info-tip:not(.is-dismissed):hover .info-pop { visibility: visible; opacity: 1; } } /* touch: hover sticks after a tap */
.view-graph { justify-content: center; }
/* What the roles mean: a disclosure under Team balance (on phones too, at the top of the sheet) */
.role-help summary { cursor: pointer; color: var(--gold); font-size: 0.95rem; }
.role-help summary:hover, .role-help summary:focus-visible { color: var(--gold-bright); }
.role-help[open] summary { margin-bottom: 8px; }
.role-defs { display: grid; gap: 4px 0; margin-bottom: 8px; }
.role-defs dt { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.role-defs dt .role-ico { width: 18px; height: 18px; }
.role-defs dd { margin: 0 0 6px 24px; color: var(--text-muted); font-size: 0.92rem; }
.role-help a { color: var(--gold); }
.role-help a:hover { color: var(--gold-bright); }
.pop-explain { display: block; margin-top: 2px; font-size: 0.85rem; }

/* Hero picker dialog, card menu, toast */
.hero-picker {
    margin: auto;
    width: min(640px, 92vw);
    max-height: 80vh;
    padding: 16px;
    border-radius: 12px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
}
.hero-picker::backdrop { background: rgba(0, 0, 0, 0.65); }
.picker-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
#pickerSearch {
    width: 100%;
    padding: 8px 12px;
    margin-bottom: 12px;
    border-radius: 8px;
    border: 1px solid var(--border-strong);
    background: var(--surface-2);
}
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.picker-hero { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); font-size: 0.9rem; }
.picker-hero:hover, .picker-hero:focus-visible { border-color: var(--gold-bright); }
.picker-portrait { width: 48px; height: 48px; }
#poolSearch {
    width: 100%;
    padding: 8px 12px 8px 36px;
    border-radius: 8px;
    border: 1px solid var(--border-strong);
    background: var(--surface-2);
}
.card-menu {
    position: absolute;
    z-index: 50;
    min-width: 180px;
    display: flex;
    flex-direction: column;
    padding: 4px;
    border-radius: 8px;
    border: 1px solid var(--border-strong);
    background: var(--surface-3);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}
.card-menu button { padding: 7px 12px; border: none; border-radius: 6px; background: none; text-align: left; }
.card-menu button:hover, .card-menu button:focus-visible { background: var(--surface-2); color: var(--gold-bright); }
.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    z-index: 60;
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 10px 16px;
    border-radius: 10px;
    border: 1px solid var(--gold);
    background: var(--surface-3);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

@media (max-width: 1279px) {
    .draft-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); height: auto; }
    .draft-layout > .panel { overflow: visible; }
    .draft-analysis { grid-column: 1 / -1; }
}

@media (max-width: 900px) {
    .draft-layout { grid-template-columns: minmax(0, 1fr); }
    .draft-layout > * { min-width: 0; }
    .slots { gap: 8px; }
    .slot { min-height: 170px; }
    .slot-portrait { width: 64px; height: 64px; }
    .mode-btn { font-size: 0.86rem; padding: 8px; }
    .tabs .tab { padding: 6px 8px; font-size: 0.78rem; }
}

/* ------------------------------------------------------------------ */
/* Draft UX: tile chips and popover, grouped lists, phone layout       */
/* ------------------------------------------------------------------ */

/* Role pills: one colour per role; the role a hero would fill for this band is filled in */
.draft-layout { --role-controller: #3D7BC9; --role-attacker: #C2452D; --role-supporter: #2E9466; }
.role-pill.role--Controller { color: var(--role-controller) !important; }
.role-pill.role--Attacker { color: var(--role-attacker) !important; }
.role-pill.role--Supporter { color: var(--role-supporter) !important; }
/* Roles that would add nothing to this band (already covered) fade back */
.role-pill.is-covered { opacity: 0.28; border-style: dashed; }

/* Compact reason chips on every tile that has reasons */
.tile-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; width: 100%; margin-top: 2px; }
.tile-chip {
    max-width: 100%;
    padding: 0 6px;
    border-radius: 8px;
    font-size: 0.74rem;
    line-height: 1.5;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: rgba(42, 29, 20, 0.1);
    color: var(--ink);
}
.tile-chip--synergy span { color: #8A5A12; }
.tile-chip--counter { background: rgba(43, 163, 154, 0.18); }
.tile-chip--counter span { color: #1D6F69; }
.tile-chip--warning { background: rgba(226, 83, 58, 0.16); }
.tile-chip--warning span { color: #A83220; }
.tile-chip--more { font-weight: 700; }
.tile-counter {
    position: absolute;
    top: 56px; right: 6px;
    width: 22px; height: 22px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--chip-counter);
    color: #fff;
    font-size: 0.8rem;
}
/* The hovered hero and the partners of its best band */
.hero-tile.is-popped .tile-main { box-shadow: inset 0 0 22px rgba(110, 72, 30, 0.35), 0 0 0 2px var(--gold-bright), 0 0 16px rgba(242, 199, 107, 0.4); }
/* Random roll: the highlight hops between tiles, then the chosen one flares */
/* Hops are quicker than the tile transitions, so the highlight snaps from tile to tile */
.pool-grid.is-rolling .tile-main { transition: none; }
.pool-grid.is-rolling .hero-tile:not(.is-rolled) .tile-main { filter: brightness(0.55) saturate(0.7); }
.hero-tile.is-rolled .tile-main {
    transform: translateY(-3px);
    box-shadow: inset 0 0 22px rgba(110, 72, 30, 0.35), 0 0 0 2px #FFB347, 0 0 24px rgba(255, 140, 40, 0.65);
}
.hero-tile.is-fated .tile-main { animation: tile-fated 0.5s ease-out; }
@keyframes tile-fated {
    0% { transform: scale(1); }
    35% { transform: scale(1.06); box-shadow: 0 0 0 3px #FFB347, 0 0 40px rgba(255, 140, 40, 0.85); }
    100% { transform: scale(1); box-shadow: 0 0 0 2px #FFB347, 0 0 24px rgba(255, 140, 40, 0.65); }
}
.draft-pool.is-flash { animation: pool-flash 1.3s ease-out; }
@keyframes pool-flash {
    0%, 40% { box-shadow: 0 0 0 2px var(--gold-bright), 0 0 26px rgba(242, 199, 107, 0.45); }
    100% { box-shadow: none; }
}

/* Popover beside the hovered / focused tile (a bottom sheet on phones) */
.tile-pop {
    position: absolute;
    z-index: 45;
    width: 300px;
    max-height: min(70vh, 520px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--gold);
    background: var(--surface-3);
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.65);
}
.pop-head { display: flex; align-items: center; gap: 8px; }
.pop-rank { padding: 1px 8px; border-radius: 10px; background: var(--gold); color: var(--ink); font-family: 'Cinzel', serif; font-weight: 700; font-size: 0.8rem; }
.pop-name { font-family: 'Cinzel', serif; font-size: 1rem; color: var(--gold-bright); letter-spacing: 0.04em; }
.pop-name small { margin-left: 6px; font-family: 'Crimson Text', serif; font-size: 0.9rem; color: var(--text-muted); letter-spacing: 0; }
.pop-close { margin-left: auto; display: none; }
.pop-score, .pop-best { color: var(--text-muted); }
.pop-score strong, .pop-best strong { color: var(--gold-bright); }
.pop-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.pop-actions:empty { display: none; }
/* Desktop: a tooltip the mouse passes through (clicking the tile acts), until pinned (⋯ menu, right-click, I) */
.tile-pop:not(.is-sheet):not(.is-pinned) { pointer-events: none; }
.tile-pop:not(.is-sheet):not(.is-pinned) .pop-actions { display: none; }
.tile-pop.is-pinned { width: 340px; box-shadow: 0 0 0 1px var(--gold), 0 14px 40px rgba(0, 0, 0, 0.75); }
.tile-pop.is-pinned .pop-close { display: inline-flex; }

/* Popover sections: who the reasons are with, and how much they weigh */
.pop-section { display: flex; flex-direction: column; gap: 3px; }
.pop-section + .pop-section { padding-top: 6px; border-top: 1px solid var(--border); }
.pop-sec-head {
    display: flex; align-items: center; gap: 8px; width: 100%;
    font-family: 'Cinzel', serif; font-size: 0.8rem; font-weight: 600; letter-spacing: 0.06em;
    text-transform: uppercase; color: var(--gold); text-align: left;
}
button.pop-sec-head { padding: 3px 6px; margin: 0 -6px; width: calc(100% + 12px); border: 1px solid transparent; border-radius: 6px; background: none; cursor: pointer; }
button.pop-sec-head:hover, button.pop-sec-head:focus-visible { border-color: var(--border-strong); background: var(--surface-2); }
.pop-inspect { margin-left: auto; white-space: nowrap; font-family: 'Crimson Text', serif; font-size: 0.9rem; letter-spacing: 0; text-transform: none; color: var(--text-muted); }
button.pop-sec-head:hover .pop-inspect { color: var(--gold-bright); }
.pop-section--ban .pop-sec-head { color: #FF7D93; }
/* General (what the hero brings on its own) reads quieter than the interactions above it */
.pop-group--general .pop-sec-head { color: var(--text-muted); }
/* Bullet colour by topic (warnings and counters keep their own marks) */
.reason--positive.topic--synergy::before, .topic-legend .topic--synergy .topic-dot { color: var(--gold-bright); }
.reason--positive.topic--support::before, .topic-legend .topic--support .topic-dot { color: #4CC38A; }
.reason--positive.topic--roles::before, .topic-legend .topic--roles .topic-dot { color: #6FA8E8; }
.reason--positive.topic--theme::before, .topic-legend .topic--theme .topic-dot { color: #B79BE8; }
.reason--positive.topic--durability::before, .topic-legend .topic--durability .topic-dot { color: #BFC6CF; }
.reason--positive.topic--ban::before, .topic-legend .topic--ban .topic-dot { color: #FF7D93; }
.topic-legend { display: flex; flex-wrap: wrap; gap: 2px 12px; color: var(--text-muted); font-size: 0.85rem; }
.topic-dot { margin-right: 4px; }
.pop-line { padding: 1px 4px; margin-left: -4px; border: 1px solid transparent; border-radius: 5px; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.pop-line:hover, .pop-line:focus-visible { border-color: var(--border-strong); background: var(--surface-2); }
.pop-more, .pop-hint { color: var(--text-muted); font-size: 0.88rem; }
.pop-hint { font-style: italic; }
.pop-hint kbd { font-style: normal; }
.dots { color: var(--gold-bright); font-size: 0.62rem; letter-spacing: 1px; font-family: sans-serif; }
.dots-off { color: var(--border-strong); }
.dots--warning { color: var(--chip-warning); font-size: 0.85rem; }
.tile-pop.is-sheet {
    position: fixed;
    left: 0; right: 0; bottom: 0; top: auto !important;
    width: auto;
    max-height: 75vh;
    border-radius: 14px 14px 0 0;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
}
.tile-pop.is-sheet .pop-close { display: inline-flex; }
.tile-pop.is-sheet .pop-actions .btn { flex: 1; justify-content: center; padding: 12px; font-size: 1rem; }

/* Band analysis: the popover's sections for the whole band, and "Show N more" */
.analysis-reasons { display: flex; flex-direction: column; gap: 8px; }
.analysis-reasons .pop-inspect-word { display: none; } /* narrow panel: just the chevron */
.syn-new { color: var(--gold-bright); font-weight: 600; }
.more-btn { align-self: flex-start; margin-top: 4px; }
.analysis-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-close { display: none; }

/* Finished draft note (when editing it in the columns) */
.complete-note { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--gold); background: rgba(217, 168, 78, 0.08); }

/* Draft bar: phones only */
.draft-bar { display: none; }
.filters-toggle { display: none; }

/* Desktop: one compact row for the draft order; slimmer empty slots in two-player mode */
.sequence { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; padding-bottom: 2px; }
.seq-step { flex: none; min-width: 56px; padding: 3px 6px; }
#againstRow.slots .slot.is-empty, .draft-section.is-p2 .slot.is-empty,
.draft-main.is-started .slot.is-empty { min-height: 120px; }


@media (max-width: 900px) {
    /* Sticky draft bar: step, the band, roles and score; opens Band Analysis as a bottom sheet */
    .draft-bar {
        position: sticky;
        top: 0;
        z-index: 30;
        display: flex;
        align-items: center;
        gap: 10px;
        margin: 0 calc(var(--gap) * -1);
        padding: 8px var(--gap);
        border: none;
        border-bottom: 1px solid var(--border-strong);
        background: rgba(21, 17, 14, 0.96);
        color: var(--text);
        text-align: left;
        backdrop-filter: blur(4px);
    }
    .bar-step { font-family: 'Cinzel', serif; font-size: 0.8rem; font-weight: 600; color: var(--gold-bright); flex: 1; min-width: 0;
        overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    /* The bar opens a sheet: a chevron in a gold ring says so */
    .bar-open {
        flex: none;
        display: grid;
        place-items: center;
        width: 28px;
        height: 28px;
        border-radius: 50%;
        border: 1px solid var(--gold);
        background: rgba(217, 168, 78, 0.12);
        color: var(--gold-bright);
    }
    .bar-open svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
    .draft-bar:active .bar-open { background: rgba(217, 168, 78, 0.3); }
    .draft-bar[aria-expanded="true"] .bar-open svg { transform: rotate(180deg); }
    .bar-faces { display: flex; gap: 3px; }
    .bar-face { width: 30px; height: 30px; border-radius: 50%; border: 1px dashed var(--border-strong); overflow: hidden; }
    .bar-face:not(.is-empty) { border: none; }
    .bar-portrait { width: 30px; height: 30px; object-fit: cover; object-position: center 15%; border-radius: 50%; border: 2px solid #8A6A43; }
    .bar-roles { color: var(--text-muted); font-size: 0.85rem; white-space: nowrap; }
    .bar-score { font-family: 'Cinzel', serif; font-weight: 700; color: var(--gold-bright); font-size: 0.85rem; white-space: nowrap; }

    /* Band Analysis becomes a bottom sheet */
    .draft-analysis {
        position: fixed;
        left: 0; right: 0; bottom: 0;
        z-index: 55;
        max-height: 78vh;
        overflow-y: auto !important;
        border-radius: 14px 14px 0 0;
        background: var(--surface-2);
        box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.6);
        transform: translateY(105%);
        visibility: hidden;
        transition: transform 0.25s ease, visibility 0.25s;
    }
    .draft-analysis.is-open { transform: none; visibility: visible; }
    .sheet-close { display: inline-flex; }

    /* Once started, the mode switch shrinks to a single compact row */
    .draft-main.is-started .mode-btn { padding: 5px 8px; font-size: 0.8rem; gap: 6px; }
    .draft-main.is-started .mode-btn svg { width: 16px; height: 16px; }

    /* Filters collapse behind one button; the sort switch stays visible */
    .filters-toggle { display: inline-flex; padding: 4px 12px; font-size: 0.8rem; }
    .pool-filters { display: none; flex-direction: column; gap: 8px; }
    .pool-filters.is-open { display: flex; }

    /* Compact 3-column pool: portrait, name, rank and one chip */
    .pool-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
    .tile-main { padding: 8px 3px 6px; }
    .tile-portrait { width: 48px; height: 48px; }
    .tile-name { font-size: 0.72rem; }
    .tile-main .role-pills { gap: 2px; }
    .tile-main .role-pill { width: 17px; height: 17px; }
    .tile-main .role-pill .ico { width: 10px; height: 10px; }
    .tile-chip:not(:first-child) { display: none; }
    .tile-counter { top: 32px; left: 6px; right: auto; width: 18px; height: 18px; font-size: 0.68rem; }
    .tile-badge { bottom: 26px; }

}

/* Header: title and Graph | Draft tabs on separate rows, the tabs as a segmented control */
@media (max-width: 600px) {
    .header { height: auto; grid-template-columns: auto 1fr; row-gap: 6px; padding: 8px var(--gap); }
    .header-titles { min-width: 0; }
    .title { overflow: hidden; text-overflow: ellipsis; }
    .tabs { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 0; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
    .tabs .tab { padding: 7px 8px; font-size: 0.8rem; }
    .tab + .tab { border-left: 1px solid var(--border-strong); }
    .tab[aria-selected="true"] { background: rgba(217, 168, 78, 0.16); }
    .tab[aria-selected="true"]::after { display: none; }
    .draft-layout { min-height: 0; }
    .mode-btn { max-width: none; }
}

/* Score breakdown: points per factor */
.score-breakdown { list-style: none; display: grid; gap: 3px; margin-top: 8px; font-size: 0.9rem; }
.score-breakdown:empty { display: none; }
.bd-row {
    display: grid; grid-template-columns: 80px 1fr 40px 10px; align-items: center; gap: 8px; width: 100%;
    padding: 3px 4px; border: none; border-radius: 4px; background: none; color: var(--text-muted); font: inherit; text-align: left; cursor: pointer;
}
.bd-row:hover, .bd-row:focus-visible { background: var(--surface-2); color: var(--text); }
.bd-go { color: var(--text-faint); }
.bd-row:hover .bd-go, .bd-row:focus-visible .bd-go { color: var(--gold-bright); }
.score-breakdown .is-zero .bd-label, .score-breakdown .is-zero .bd-val { color: var(--text-faint); }
.bd-bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.bd-bar span { display: block; height: 100%; border-radius: 3px; background: var(--gold); }
.score-breakdown .is-loss .bd-bar span { background: var(--chip-warning); }
.bd-val { text-align: right; font-variant-numeric: tabular-nums; }

/* Draft inspector: the reasons in words, then each hero's abilities behind them */
.cards-dialog.inspect-dialog {
    --chip-counter: #2BA39A;
    --chip-warning: #E2533A;
    height: fit-content; max-height: min(92vh, 1000px); width: min(980px, 94vw);
}
.inspect-body { overflow-y: auto; padding: 14px 18px 18px; display: flex; flex-direction: column; gap: 12px; }
.inspect-items { display: flex; flex-direction: column; gap: 12px; }
.inspect-item { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.inspect-item-head { display: flex; align-items: flex-start; gap: 10px; }
.inspect-item-head .reason { flex: 1; font-size: 1.04rem; }
.inspect-item-head .dots { margin-top: 6px; }
.ov-sides { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px 16px; padding-left: 20px; }
.ov-side { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.ov-hero { display: inline-flex; align-items: center; gap: 6px; padding: 0; border: 0; background: none; color: var(--gold-bright); font: inherit; cursor: pointer; }
.ov-hero img { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; object-position: top; border: 1.5px solid var(--border-strong); }
.ov-hero strong { font-family: 'Cinzel', serif; font-size: 0.9rem; }
.ov-hero:hover strong, .ov-hero:focus-visible strong { text-decoration: underline; }
.ov-side.is-theirs .ov-hero { color: var(--chip-warning); }
.ov-notes { color: var(--text-muted); font-size: 0.88rem; }
.ov-abilities { list-style: none; width: 100%; padding-left: 30px; display: grid; gap: 1px; font-size: 0.95rem; }
.ov-ability { color: var(--text); font-style: italic; }
.ov-tags { color: var(--text-muted); font-size: 0.88rem; }
.ov-tags::before { content: '· '; }
.inspect-cards > summary { padding-left: 20px; color: var(--gold); cursor: pointer; font-size: 0.92rem; }
.inspect-cards[open] > summary { margin-bottom: 8px; }
.inspect-sides { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin-top: 0; }
.tt-side--theirs .tt-side-head strong { color: var(--chip-warning); }
.side-tag { font-size: 0.78rem; padding: 0 6px; border-radius: 8px; border: 1px solid var(--chip-warning); color: var(--chip-warning); }
.side-notes { margin: 4px 0 0; color: var(--text-muted); font-size: 0.9rem; }

/* Reference cards modal */
.cards-dialog {
    margin: auto;
    width: min(1240px, 94vw);
    height: min(92vh, 1000px);
    padding: 0;
    border-radius: 14px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
}
.cards-dialog[open] { display: flex; flex-direction: column; }
.cards-dialog::backdrop { background: rgba(0, 0, 0, 0.72); }
.cards-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.cards-head form { margin-left: auto; }
.cards-head .icon-btn { border: 1px solid var(--border-strong); border-radius: 8px; }
.cards-credit {
    padding: 10px 18px 12px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.92rem;
    font-style: italic;
    text-align: center;
}
.cards-credit a { color: var(--gold); }
.cards-credit a:hover { color: var(--gold-bright); }
.card-track {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
    align-items: start;
    gap: 16px;
    padding: 16px 18px 20px;
}

@media (max-width: 900px) {
    /* Phones: one card at a time, swipe between them */
    .cards-dialog { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; }
    .cards-dialog.inspect-dialog { width: 100vw; height: 100dvh; max-height: 100dvh; }
    .card-track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; padding: 12px; }
    .ref-card { flex: 0 0 90%; scroll-snap-align: center; }
    .pool-grid { grid-auto-rows: 1fr; }
}

/* One hero's card (from the pool): as wide as a card in a band, not the whole dialog */
@media (min-width: 901px) {
    .cards-dialog.is-single { width: 460px; height: auto; max-height: 92vh; }
    .cards-dialog.is-single .card-track { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
    .cards-dialog.is-single .ref-card { flex-basis: 100%; }
}

/* Reference cards: a cards-only view (full screen where supported) */
.cards-exit { display: none; }
.cards-dialog.is-cards-only .cards-head,
.cards-dialog.is-cards-only .cards-credit { display: none; }
.cards-dialog.is-cards-only { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border: 0; border-radius: 0; }
.cards-dialog.is-cards-only .cards-exit {
    display: grid;
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    opacity: 0.55;
    background: var(--surface-3);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
}
.cards-dialog.is-cards-only .cards-exit:hover, .cards-dialog.is-cards-only .cards-exit:focus-visible { opacity: 1; }

/* Phones: the random roll flicks through heroes in one place */
.fate-roll {
    position: fixed;
    left: 50%;
    top: 40%;
    transform: translate(-50%, -50%);
    z-index: 60;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 180px;
    padding: 14px 16px 16px;
    border-radius: 14px;
    border: 1px solid #FFB347;
    background: var(--surface-3);
    box-shadow: 0 0 0 2px rgba(255, 179, 71, 0.35), 0 0 30px rgba(255, 140, 40, 0.45), 0 16px 40px rgba(0, 0, 0, 0.7);
    pointer-events: none;
}
.fate-roll[hidden] { display: none; }
.fate-label { font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }
.fate-roll .portrait-wrap { width: 110px; }
.fate-portrait { width: 110px; height: 110px; object-fit: cover; border-radius: 50%; }
.fate-name { font-family: 'Cinzel', serif; font-weight: 700; font-size: 1.1rem; color: var(--gold-bright); }
.fate-roll.is-fated { box-shadow: 0 0 0 3px #FFB347, 0 0 44px rgba(255, 140, 40, 0.85), 0 16px 40px rgba(0, 0, 0, 0.7); }
.cards-dialog.is-single.is-cards-only .card-track { width: min(460px, 100%); margin: 0 auto; }
