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

:root {
    --bg: #0d0d0d;
    --surface: #1a1a1a;
    --border: #2e2e2e;
    --accent: #c8a84b;
    --text: #e8e8e8;
    --text-muted: #888;
    --nav-height: 56px;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', system-ui, sans-serif;
    min-height: 100vh;
}

/* Navbar */
nav {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--nav-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 2rem;
    gap: 2rem;
}

nav .brand {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
    margin-right: auto;
}

nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.95rem;
    padding: 0.25rem 0;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}

nav a:hover,
nav a.active {
    color: var(--text);
    border-bottom-color: var(--accent);
}

/* Main content */
main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 3rem 2rem;
}

/* Hero */
.hero {
    text-align: center;
    padding: 4rem 0 3rem;
}

.hero h1 {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--accent);
    margin-bottom: 0.75rem;
}

.hero p {
    font-size: 1.1rem;
    color: var(--text-muted);
    max-width: 520px;
    margin: 0 auto;
}

/* Demo placeholder */
.demo-box {
    margin-top: 3rem;
    border: 1px dashed var(--border);
    border-radius: 8px;
    padding: 3rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* Homepage chart */
.chart-section {
    margin-top: 2rem;
}

.chart-section h2 {
    font-size: 1.4rem;
    color: var(--accent);
    margin-bottom: 0.35rem;
}

.chart-sub {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.chart-sub #chart-note { color: var(--accent); }

#theme-value-chart {
    min-height: 500px;
    width: 100%;
}

/* Theme accordion */
.theme-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 2rem;
}

details.theme {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

details.theme summary {
    padding: 0.85rem 1.25rem;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    user-select: none;
}

.theme-name { flex: 1; }

.theme-meta {
    font-weight: 400;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Highlight themes with multiple mythics, in the mythic rarity color. */
.theme-meta .mythic-hot {
    color: #ff7a2f;
    font-weight: 700;
}

details.theme summary::-webkit-details-marker { display: none; }

details.theme summary::before {
    content: '▶';
    font-size: 0.65rem;
    color: var(--accent);
    transition: transform 0.15s;
    flex-shrink: 0;
}

details.theme[open] summary::before {
    transform: rotate(90deg);
}

details.theme[open] summary {
    border-bottom: 1px solid var(--border);
}

/* Card table */
.table-wrap {
    overflow-x: auto;            /* swipe sideways on narrow screens instead of breaking layout */
    -webkit-overflow-scrolling: touch;
}

.card-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

/* Card-name column: soft ~12ch minimum so it keeps ~2 words per line — wraps to
   multiple lines when space is tight, stays on one line when there's room. */
.card-table th:first-child,
.card-table td:first-child {
    min-width: 12ch;
    overflow-wrap: break-word;
}

/* Short columns stay on a single line so the name column is the one that flexes. */
.card-table td.qty,
.card-table td.rarity,
.card-table td.center,
.card-table td.col-set {
    white-space: nowrap;
}

.card-table th {
    text-align: left;
    padding: 0.3rem 0.9rem;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}

.card-table td {
    padding: 0.22rem 0.9rem;
    border-bottom: 1px solid var(--border);
}

/* Column toggles hide these cells when the list container has the class. */
.hide-set .col-set,
.hide-shared .col-shared,
.hide-other .col-other { display: none; }

.card-table tbody tr:last-child td {
    border-bottom: none;
}

.card-table td.qty {
    width: 3rem;
    color: var(--accent);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.card-table td a {
    color: var(--text);
    text-decoration: none;
    border-bottom: 1px dotted var(--text-muted);
}
.card-table td a:hover { color: var(--accent); border-bottom-color: var(--accent); }

.card-table td.center {
    text-align: center;
    color: var(--accent);
    font-weight: 700;
}

.card-table td.muted {
    color: var(--text-muted);
    font-size: 0.8rem;
    max-width: 22rem;
}

.card-table td.price {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.card-table tr.basic td { color: var(--text-muted); }

/* Stats panel */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
    margin: 2rem 0 0.5rem;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent);
    line-height: 1.2;
}

.stat-label {
    margin-top: 0.35rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.prices-note {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.stat.wide { grid-column: 1 / -1; }

.stat-detail {
    margin-top: 0.2rem;
    font-size: 0.85rem;
    color: var(--text);
}

.stat-value .sep { color: var(--text-muted); font-weight: 400; }

.top-themes {
    list-style: none;
    margin-top: 0.5rem;
    display: grid;
    gap: 0.25rem;
}

.top-themes li {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    font-size: 0.9rem;
    padding: 0.15rem 0;
    border-bottom: 1px solid var(--border);
}
.top-themes li:last-child { border-bottom: none; }
.top-themes li span:last-child {
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

/* Sort control */
.controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin: 1.5rem 0 1rem;
}

.controls label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.controls select {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 0.4rem 0.6rem;
    font-size: 0.9rem;
    cursor: pointer;
}

.controls-spacer {
    margin-left: 0.5rem;
    padding-left: 0.85rem;
    border-left: 1px solid var(--border);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.controls .toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text);
    font-size: 0.85rem;
    cursor: pointer;
}

.controls .toggle input {
    cursor: pointer;
    accent-color: var(--accent);
}

/* Mana symbols in theme headers */
.mana-icons {
    display: inline-flex;
    gap: 2px;
    flex-shrink: 0;
}
.mana {
    width: 18px;
    height: 18px;
    display: block;
}

/* Rarity colors (tuned for the dark/gold theme) */
.card-table td.rarity {
    font-weight: 700;
    text-align: center;
    width: 2rem;
}
.rarity-common   { color: #d6d6d6; }
.rarity-uncommon { color: #9fb6c6; }   /* silver */
.rarity-rare     { color: var(--accent); }   /* gold */
.rarity-mythic   { color: #ff7a2f; font-weight: 700; }   /* bold orange */
.rarity-none     { color: var(--text-muted); }

/* Lands sub-section, visually separated from the spells table */
.lands {
    margin: 0.5rem 1.25rem 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.015);
    overflow-x: auto;            /* scroll fallback if it still can't shrink enough */
}
.lands-table th, .lands-table td { padding-left: 1rem; }
.lands-table { font-size: 0.85rem; }
.lands-table th {
    font-size: 0.7rem;
    color: var(--text-muted);
}
