:root {
    color-scheme: dark;
    --bg: #111318;
    --panel: #1b2027;
    --panel-2: #222833;
    --line: #323b47;
    --text: #f3f6fa;
    --muted: #9ca8b8;
    --teal: #43d3c3;
    --gold: #f4bf56;
    --coral: #ff6f61;
    --green: #70d879;
    --shadow: 0 16px 48px rgba(0, 0, 0, .25);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        linear-gradient(120deg, rgba(67, 211, 195, .08), transparent 38%),
        linear-gradient(300deg, rgba(244, 191, 86, .08), transparent 32%),
        var(--bg);
    color: var(--text);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
    font: inherit;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    height: 64px;
    padding: 0 clamp(16px, 4vw, 40px);
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    background: rgba(17, 19, 24, .86);
    backdrop-filter: blur(14px);
}

.brand {
    color: var(--text);
    font-size: 20px;
    font-weight: 800;
    text-decoration: none;
}

.nav {
    display: flex;
    gap: 8px;
}

.nav a,
.tiny-btn {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-2);
    color: var(--text);
    text-decoration: none;
}

.nav a {
    padding: 8px 12px;
    font-weight: 700;
}

.nav a.active {
    border-color: rgba(67, 211, 195, .65);
    color: var(--teal);
}

.shell {
    display: grid;
    grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
    gap: 18px;
    width: min(1760px, 100%);
    margin: 0 auto;
    padding: 18px;
}

.sidebar {
    display: grid;
    align-content: start;
    gap: 14px;
}

.panel {
    min-width: 0;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 8px;
    background: rgba(27, 32, 39, .94);
    box-shadow: var(--shadow);
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 48px;
    padding: 12px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
    font-weight: 800;
}

.count,
.muted {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.input {
    width: calc(100% - 24px);
    margin: 12px;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    outline: none;
    background: #111820;
    color: var(--text);
}

.input:focus {
    border-color: rgba(67, 211, 195, .7);
}

.pal-list,
.basis-list {
    display: grid;
    gap: 6px;
    max-height: 44vh;
    overflow: auto;
    padding: 0 10px 12px;
}

.basis-list {
    max-height: 260px;
}

.players-list {
    display: grid;
    gap: 8px;
    max-height: 260px;
    overflow: auto;
    padding: 12px;
}

.pal-row,
.player-row,
.basis-row {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    min-height: 50px;
    padding: 7px 9px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: rgba(255, 255, 255, .035);
    color: var(--text);
    cursor: pointer;
}

.player-row {
    grid-template-columns: minmax(0, 1fr) auto;
}

.pal-row:hover,
.player-row:hover,
.basis-row:hover {
    border-color: rgba(67, 211, 195, .36);
}

.pal-row.active,
.player-row.active,
.basis-row.active {
    border-color: rgba(67, 211, 195, .72);
    background: rgba(67, 211, 195, .11);
}

.pal-row img,
.basis-row img,
.pair-row img,
.pal-token img,
.combo-pal img,
.route-card img,
.selected-target img {
    width: 38px;
    height: 38px;
    object-fit: contain;
}

.name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 800;
}

.sub {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.tiny-btn {
    padding: 6px 9px;
    cursor: pointer;
}

.workspace {
    display: grid;
    align-content: start;
    gap: 18px;
    min-width: 0;
}

.hero-strip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    min-height: 128px;
    padding: 22px;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 8px;
    background:
        linear-gradient(110deg, rgba(67, 211, 195, .18), rgba(244, 191, 86, .10) 58%, rgba(255, 111, 97, .10)),
        var(--panel);
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--teal);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    font-size: clamp(28px, 4vw, 54px);
    line-height: 1;
}

.selected-target {
    min-width: 220px;
}

.selected-target .pal-token {
    justify-content: flex-end;
}

.view-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
}

.view-panel {
    min-height: calc(100vh - 236px);
}

.view-switch {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #111820;
}

.switch-btn {
    border: 0;
    border-radius: 6px;
    padding: 7px 10px;
    background: transparent;
    color: var(--muted);
    font-weight: 800;
    cursor: pointer;
}

.switch-btn.active {
    background: rgba(67, 211, 195, .18);
    color: var(--teal);
}

.view-body {
    min-height: calc(100vh - 286px);
}

.view-body.is-hidden {
    display: none;
}

.view-meta {
    display: flex;
    justify-content: flex-end;
    padding: 12px 14px 0;
}

.route-result,
.combo-list {
    padding: 14px;
}

.route-result.empty,
.combo-empty {
    color: var(--muted);
    font-weight: 700;
}

.combo-list {
    display: grid;
    gap: 10px;
    max-height: calc(100vh - 318px);
    overflow: auto;
}

.pair-grid {
    display: grid;
    grid-template-columns: minmax(220px, 320px) minmax(220px, 320px) minmax(280px, 1fr);
    gap: 14px;
    padding: 14px;
}

.pair-column,
.pair-result {
    min-width: 0;
    border: 1px solid rgba(255, 255, 255, .07);
    border-radius: 8px;
    background: rgba(255, 255, 255, .03);
}

.pair-head {
    padding: 12px 12px 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.pair-input {
    margin-top: 10px;
}

.pair-list {
    display: grid;
    gap: 6px;
    max-height: calc(100vh - 404px);
    overflow: auto;
    padding: 0 10px 12px;
}

.pair-row {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    min-height: 50px;
    padding: 7px 9px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: rgba(255, 255, 255, .035);
    color: var(--text);
    cursor: pointer;
}

.pair-row:hover,
.pair-row.active {
    border-color: rgba(67, 211, 195, .72);
}

.pair-row.active {
    background: rgba(67, 211, 195, .11);
}

.pair-result {
    display: grid;
    align-content: start;
    gap: 14px;
    padding: 14px;
}

.pair-parents,
.pair-child {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 28px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
}

.pair-child {
    grid-template-columns: 28px minmax(0, 1fr);
    padding: 10px;
    border: 1px solid rgba(67, 211, 195, .24);
    border-radius: 8px;
    background: rgba(67, 211, 195, .07);
}

.pair-results {
    display: grid;
    gap: 10px;
}

.pair-arrow {
    color: var(--teal);
    font-size: 22px;
    font-weight: 900;
    text-align: center;
}

.combo-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 28px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, .07);
    border-radius: 8px;
    background: rgba(255, 255, 255, .035);
}

.combo-plus {
    color: var(--gold);
    font-size: 22px;
    font-weight: 900;
    text-align: center;
}

.combo-pal,
.pal-token {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.combo-pal-button {
    width: 100%;
    border: 0;
    padding: 0;
    background: transparent;
    color: var(--text);
    text-align: left;
    cursor: pointer;
}

.combo-pal-button:hover .name {
    color: var(--teal);
}

.owner-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.owner-tag {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border-radius: 999px;
    padding: 2px 7px;
    background: rgba(112, 216, 121, .14);
    color: #b7f4bc;
    font-size: 11px;
    font-weight: 800;
}

.route-tree {
    overflow-x: auto;
    padding: 8px 0 4px;
}

.route-node {
    display: grid;
    justify-items: center;
    gap: 12px;
    min-width: min-content;
}

.route-card {
    display: grid;
    grid-template-columns: 44px minmax(110px, 1fr);
    align-items: center;
    gap: 10px;
    min-width: 190px;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 8px;
    background: var(--panel-2);
}

.route-alt {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 7px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
}

.route-alt-info,
.route-alt-step {
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border: 1px solid rgba(67, 211, 195, .34);
    border-radius: 50%;
    background: rgba(67, 211, 195, .08);
    color: var(--teal);
    cursor: pointer;
    font-size: 12px;
    font-weight: 900;
    line-height: 1;
}

.route-alt-step {
    border-color: rgba(255, 255, 255, .12);
    background: rgba(255, 255, 255, .05);
    color: var(--text);
}

.route-alt-info:hover,
.route-alt-step:hover {
    border-color: rgba(67, 211, 195, .72);
}

.route-alt-detail {
    display: none;
    margin-top: 6px;
    color: var(--gold);
    font-size: 11px;
    font-weight: 800;
    white-space: normal;
}

.route-alt-detail.open {
    display: block;
}

.route-card.owned {
    border-color: rgba(112, 216, 121, .55);
}

.route-card.missing {
    border-color: rgba(255, 111, 97, .6);
}

.route-children {
    display: grid;
    grid-template-columns: minmax(190px, 1fr) minmax(190px, 1fr);
    gap: 14px;
    align-items: start;
}

.route-op {
    border-radius: 999px;
    padding: 5px 10px;
    background: rgba(244, 191, 86, .16);
    color: #ffe0a0;
    font-size: 12px;
    font-weight: 900;
}

.route-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.summary-chip {
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 999px;
    padding: 7px 10px;
    background: rgba(255, 255, 255, .045);
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.missing-options {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.missing-option {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: start;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 8px;
    background: rgba(255, 255, 255, .04);
}

.missing-pals {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.missing-pal {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    max-width: 220px;
    border-radius: 999px;
    padding: 5px 8px;
    background: rgba(255, 111, 97, .12);
    color: #ffd2cd;
    font-size: 12px;
    font-weight: 800;
}

.missing-pal img {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.difficulty {
    color: var(--gold);
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
}

@media (max-width: 980px) {
    .shell,
    .view-grid {
        grid-template-columns: 1fr;
    }

    .pal-list {
        max-height: 360px;
    }

    .hero-strip {
        align-items: flex-start;
        flex-direction: column;
    }

    .selected-target {
        min-width: 0;
        width: 100%;
    }

    .selected-target .pal-token {
        justify-content: flex-start;
    }
}

@media (max-width: 620px) {
    .topbar {
        height: auto;
        align-items: flex-start;
        flex-direction: column;
        padding-top: 12px;
        padding-bottom: 12px;
    }

    .shell {
        padding: 12px;
    }

    .route-children,
    .combo-row,
    .pair-grid,
    .pair-parents,
    .missing-option {
        grid-template-columns: 1fr;
    }

    .combo-plus {
        line-height: 1;
    }
}

/* ── Owned target: direct breeding options ────────────────────── */

.owned-info {
    display: flex;
    justify-content: center;
    padding: 14px 0 8px;
}

.owned-breed-section {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid rgba(255, 255, 255, .08);
}

.owned-breed-heading {
    color: var(--gold);
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .02em;
    margin-bottom: 12px;
}

.owned-breed-list {
    display: grid;
    gap: 10px;
    max-height: calc(100vh - 480px);
    overflow: auto;
}

.owned-breed-section + .owned-breed-section {
    margin-top: 10px;
}
