:root {
    --page: #12141c;
    --page-2: #1b1e29;
    --text: #eef0f5;
    --muted: #9aa1b2;
    --line: #2c3040;
    --gold-1: #f7e27a;
    --gold-2: #d6a92b;
    --card-w: 260px;
}

/* Type palettes: light tint, deep tone, and ink for text on the tint. */
.t-tech { --c1: #fff2a8; --c2: #f0c419; --deep: #b88a00; --ink: #3b2d00; }
.t-finance { --c1: #d4f0b0; --c2: #74b84a; --deep: #3f7d22; --ink: #1d3610; }
.t-inherited { --c1: #efd2f7; --c2: #b06ad1; --deep: #7a3a9a; --ink: #351344; }
.t-energy { --c1: #ffd2b3; --c2: #ec6a35; --deep: #b93d14; --ink: #4a1606; }
.t-media { --c1: #ffd6e8; --c2: #e874a8; --deep: #b23f74; --ink: #4a1330; }
.t-retail { --c1: #f6d6b2; --c2: #cf7f3a; --deep: #95501a; --ink: #3f2209; }
.t-realestate { --c1: #e8dfc2; --c2: #a8935a; --deep: #6f5f30; --ink: #2f2810; }
.t-health { --c1: #c8e9fb; --c2: #4b9be0; --deep: #1f66a8; --ink: #0c2a47; }
.t-industrial { --c1: #e3e8ee; --c2: #8d9cad; --deep: #56657a; --ink: #1d2531; }
.t-food { --c1: #c9f1e6; --c2: #33ad94; --deep: #17705e; --ink: #0b3129; }

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background:
        radial-gradient(1200px 600px at 10% -10%, #2a2440 0%, transparent 60%),
        radial-gradient(900px 500px at 100% 0%, #16304a 0%, transparent 55%),
        var(--page);
    color: var(--text);
    font-family: 'Archivo', system-ui, -apple-system, 'Segoe UI', sans-serif;
    line-height: 1.5;
    min-height: 100vh;
}

a { color: var(--gold-1); }

.visually-hidden {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
}

/* ----- Intro ----- */

.intro {
    max-width: 1200px;
    margin: 0 auto;
    padding: 56px 16px 24px;
    text-align: center;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--gold-1);
    font: 700 0.8rem/1 'Archivo Narrow', sans-serif;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

.intro h1 {
    margin: 0;
    font-size: clamp(2rem, 6vw, 3.6rem);
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: -0.02em;
    background: linear-gradient(180deg, #fff 30%, var(--gold-1) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.lede {
    max-width: 38em;
    margin: 16px auto 0;
    color: var(--muted);
    font-size: 1.05rem;
}

/* ----- History chart ----- */

.history {
    max-width: 1200px;
    margin: 0 auto;
    padding: 8px 16px;
}

.history-chart {
    position: relative;
    width: 100%;
    min-height: 240px;
}

.history-chart svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
    touch-action: pan-y;
}

.history-chart .grid { stroke: var(--line); stroke-width: 1; }

.history-chart .axis-label {
    fill: var(--muted);
    font: 500 11px 'Archivo Narrow', sans-serif;
    font-variant-numeric: tabular-nums;
}

.history-chart .series {
    stroke: var(--gold-1);
    stroke-width: 2.5;
    stroke-linecap: round;
}

.history-chart .series.gap { stroke-dasharray: 2 5; stroke-width: 2; opacity: 0.7; }

.history-chart .series-area { fill: rgba(247, 226, 122, 0.08); }

.history-chart .dot { fill: var(--gold-1); stroke: var(--page); stroke-width: 1; }

.history-chart .note {
    fill: var(--text);
    font: 600 11px 'Archivo', sans-serif;
}

.history-chart .note-line { stroke: var(--muted); stroke-width: 1; }

.history-chart .focus { fill: #fff; stroke: var(--gold-2); stroke-width: 2; pointer-events: none; }
.history-chart .focus-rule { stroke: rgba(255, 255, 255, 0.25); stroke-width: 1; pointer-events: none; }

.chart-tip {
    position: absolute;
    transform: translate(-50%, -100%);
    padding: 6px 10px;
    border-radius: 8px;
    background: #fff;
    color: #12141c;
    font-size: 0.8rem;
    line-height: 1.3;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

.chart-tip span { display: block; color: #555b68; font-size: 0.72rem; max-width: 220px; white-space: normal; }

.chart-note {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 0.78rem;
}

/* ----- Overview ----- */

.overview {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

@media (min-width: 860px) {
    .overview { grid-template-columns: 1.6fr 1fr; }
    .stats { grid-column: 1 / -1; }
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.stat, .panel {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 16px;
}

.stat-value {
    display: block;
    font-size: 1.9rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

.stat-label {
    color: var(--muted);
    font-size: 0.85rem;
}

.panel h2 {
    margin: 0 0 12px;
    font: 700 0.8rem/1 'Archivo Narrow', sans-serif;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
}

.type-bar {
    display: flex;
    height: 34px;
    border-radius: 8px;
    overflow: hidden;
    gap: 2px;
    background: var(--line);
}

.seg {
    display: grid;
    place-items: center;
    background: linear-gradient(180deg, var(--c1), var(--c2));
    color: var(--ink);
    min-width: 3px;
}

.seg .type-icon { width: 18px; height: 18px; }

.type-legend {
    list-style: none;
    margin: 14px 0 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 8px 16px;
}

.type-legend li {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.legend-name { flex: 1; }
.legend-val { color: var(--muted); font-variant-numeric: tabular-nums; }

.chip-dot {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, var(--c1), var(--c2));
    color: var(--ink);
    flex: none;
}

.chip-dot .type-icon { width: 13px; height: 13px; }

.state-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 4px;
}

.state-list button {
    width: 100%;
    display: grid;
    grid-template-columns: 2.4em 1fr 2em;
    align-items: center;
    gap: 10px;
    padding: 4px 6px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    text-align: left;
}

.state-list button:hover, .state-list button.is-active { background: rgba(255, 255, 255, 0.07); }
.state-list button.is-active .st-bar span { background: var(--gold-1); }

.st { font-weight: 700; }

.st-bar {
    height: 10px;
    border-radius: 5px;
    background: var(--line);
    overflow: hidden;
}

.st-bar span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--gold-2), var(--gold-1));
    border-radius: 5px;
}

.st-count { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

/* ----- Controls ----- */

.controls {
    position: sticky;
    top: 0;
    z-index: 10;
    max-width: 1200px;
    margin: 8px auto 0;
    padding: 12px 16px;
    background: rgba(18, 20, 28, 0.88);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}

.filters {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: thin;
}

.filter {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: none;
    padding: 7px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--page-2);
    color: var(--text);
    font: 600 0.85rem 'Archivo', sans-serif;
    cursor: pointer;
}

.filter span { color: var(--muted); font-weight: 400; }
.filter .type-icon { width: 15px; height: 15px; color: var(--c2); }

.filter.is-active {
    background: linear-gradient(180deg, var(--c1, #fff), var(--c2, #cfd3dc));
    color: var(--ink, #12141c);
    border-color: transparent;
}

.filter.is-active span, .filter.is-active .type-icon { color: inherit; opacity: 0.75; }

.tools {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.search { flex: 1 1 220px; }

.search input, .sort select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--page-2);
    color: var(--text);
    font: inherit;
    font-size: 0.9rem;
}

.sort {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 0.85rem;
}

.sort select { width: auto; }

.result-count {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 0.8rem;
}

/* ----- Deck ----- */

.deck {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 16px 48px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--card-w), 1fr));
    gap: 28px 22px;
    justify-items: center;
    perspective: 1200px;
}

.empty { grid-column: 1 / -1; color: var(--muted); }

/* ----- Card ----- */

.card {
    --rx: 0deg;
    --ry: 0deg;
    --mx: 50%;
    --my: 50%;
    position: relative;
    width: 100%;
    max-width: 300px;
    min-height: 400px;
    padding: 10px;
    border-radius: 14px;
    background: linear-gradient(145deg, var(--gold-1), var(--gold-2) 45%, var(--gold-1) 70%, var(--gold-2));
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.35);
    transform: rotateX(var(--rx)) rotateY(var(--ry));
    transition: transform 0.4s ease, box-shadow 0.4s ease;
    outline: none;
}

.card.is-tilting {
    transition: transform 0.08s linear;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55), inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.card:focus-visible { box-shadow: 0 0 0 3px #fff, 0 10px 28px rgba(0, 0, 0, 0.45); }

/* Holo sheen that follows the pointer */
.card::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    background:
        radial-gradient(circle at var(--mx) var(--my), rgba(255, 255, 255, 0.45), transparent 45%),
        linear-gradient(115deg, transparent 30%, rgba(255, 120, 220, 0.18) 42%, rgba(120, 220, 255, 0.18) 52%, rgba(255, 245, 140, 0.18) 62%, transparent 72%);
    background-size: 100% 100%, 250% 250%;
    background-position: center, var(--mx) var(--my);
    mix-blend-mode: overlay;
    opacity: 0;
    transition: opacity 0.3s;
}

.card.is-tilting::after { opacity: 1; }

.card-inner {
    position: relative;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 10px 8px;
    border-radius: 8px;
    color: var(--ink);
    background:
        radial-gradient(circle at 80% 10%, rgba(255, 255, 255, 0.55), transparent 40%),
        repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.10) 0 2px, transparent 2px 9px),
        linear-gradient(170deg, var(--c1) 0%, var(--c2) 100%);
    overflow: hidden;
}

.card-head {
    display: grid;
    grid-template-columns: 1fr auto auto;
    grid-template-rows: auto auto;
    align-items: end;
    column-gap: 4px;
}

.stage {
    grid-column: 1 / -1;
    font: 700 0.62rem/1.2 'Archivo Narrow', sans-serif;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    opacity: 0.75;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-name {
    margin: 0;
    font: 800 1.02rem/1.1 'Archivo', sans-serif;
    letter-spacing: -0.01em;
    min-width: 0;
}

.hp {
    font: 700 0.62rem/1 'Archivo Narrow', sans-serif;
    color: #b0161b;
    white-space: nowrap;
}

.hp small { font-size: 0.6rem; margin-right: 2px; letter-spacing: 0.05em; }
.hp b { font: 800 1.15rem/1 'Archivo', sans-serif; letter-spacing: -0.02em; }

.type-badge {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #fff 0%, var(--c1) 30%, var(--c2) 100%);
    color: var(--ink);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35), inset 0 0 0 1.5px rgba(255, 255, 255, 0.7);
}

.type-badge .type-icon { width: 15px; height: 15px; }

.type-icon {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.t-tech .type-icon, .t-energy .type-icon, .t-health .type-icon { fill: currentColor; stroke-width: 1.4; }

/* Portrait window with a silver frame */
.portrait {
    position: relative;
    display: grid;
    place-items: center;
    flex: none;
    aspect-ratio: 4 / 3;
    border: 4px solid transparent;
    border-radius: 3px;
    background:
        radial-gradient(circle at 50% 35%, var(--c1), var(--c2)) padding-box,
        linear-gradient(135deg, #f4f4f4, #9ea3ab 40%, #f4f4f4 60%, #8b9097) border-box;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    text-decoration: none;
}

.monogram {
    font: 800 3.4rem/1 'Archivo', sans-serif;
    color: var(--deep);
    opacity: 0.55;
    letter-spacing: -0.04em;
}

.portrait img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 50% 20%;
    opacity: 0;
    transition: opacity 0.4s;
}

.portrait.has-img img { opacity: 1; }

.strip {
    margin: -2px 6px 0;
    padding: 2px 6px;
    text-align: center;
    font: italic 700 0.68rem/1.3 'Archivo Narrow', sans-serif;
    background: linear-gradient(90deg, #c9ccd2, #f3f3f3 50%, #c9ccd2);
    color: #23262d;
    border-radius: 2px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.ability {
    padding: 2px 2px 0;
}

.ability-name {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 2px;
    font: 800 0.78rem/1.2 'Archivo', sans-serif;
}

.ability-name .type-icon {
    width: 16px;
    height: 16px;
    padding: 2px;
    border-radius: 50%;
    background: var(--c1);
    box-shadow: inset 0 0 0 1px var(--deep);
    flex: none;
}

.ability-text {
    margin: 0;
    font-size: 0.72rem;
    line-height: 1.35;
}

.card-foot {
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 5px;
    border-top: 1px solid rgba(0, 0, 0, 0.18);
    font: 700 0.6rem/1 'Archivo Narrow', sans-serif;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.rank {
    padding: 3px 6px;
    border-radius: 3px;
    background: var(--ink);
    color: var(--c1);
}

.rank.est, .est-pill {
    background: transparent;
    color: inherit;
    box-shadow: inset 0 0 0 1px currentColor;
    cursor: help;
}

.est-pill {
    padding: 1px 5px;
    border-radius: 3px;
    font: 700 0.7rem 'Archivo Narrow', sans-serif;
}

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

/* Legends get a platinum frame; the OG card also gets a slow sheen that sweeps across it. */
.card.is-legend {
    background: linear-gradient(145deg, #f4f6fa, #aab2bf 30%, #ffffff 50%, #9aa3b1 70%, #e9edf3);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.5), 0 0 24px rgba(200, 215, 255, 0.18);
}

.card.is-og .card-inner::before {
    content: '';
    position: absolute;
    inset: -50%;
    z-index: 2;
    pointer-events: none;
    background: linear-gradient(105deg,
        transparent 40%,
        rgba(255, 255, 255, 0.0) 44%,
        rgba(255, 255, 255, 0.38) 48%,
        rgba(255, 236, 170, 0.28) 50%,
        rgba(190, 220, 255, 0.24) 52%,
        rgba(255, 255, 255, 0.0) 56%,
        transparent 60%);
    mix-blend-mode: soft-light;
    transform: translateX(-60%);
    animation: legend-sheen 6s ease-in-out infinite;
}

@keyframes legend-sheen {
    0%, 15% { transform: translateX(-60%); }
    65%, 100% { transform: translateX(60%); }
}

.legend-tag {
    display: inline-block;
    padding: 1px 5px;
    border-radius: 3px;
    background: var(--ink);
    color: var(--c1);
    letter-spacing: 0.08em;
}

.hp-year {
    margin-left: 3px;
    color: var(--ink);
    opacity: 0.7;
}

.rank-legend {
    background: linear-gradient(135deg, #1b1b1f, #4a4d57);
    color: #fff3c4;
    letter-spacing: 0.14em;
    box-shadow: inset 0 0 0 1px rgba(255, 243, 196, 0.5);
}

.filter-legend .type-icon { color: #e9edf3; fill: currentColor; stroke-width: 1; }

.filter-legend.is-active {
    background: linear-gradient(180deg, #ffffff, #b6bdc9);
    color: #12141c;
}

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

.notes {
    max-width: 760px;
    margin: 0 auto;
    padding: 24px 16px 64px;
    color: var(--muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--line);
}

@media (prefers-reduced-motion: reduce) {
    .card, .card::after, .portrait img { transition: none; }
    .card.is-og .card-inner::before { animation: none; opacity: 0; }
}
