:root {
    --bg: #0e1015;
    --panel: #171a22;
    --panel-2: #1e2230;
    --border: #2b3040;
    --text: #d6d9e0;
    --muted: #8a90a0;
    --gold: #d4a017;
    --accent: #5b8def;
    --good: #3fbf6f;
    --bad: #e05555;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    font-size: 14px;
    line-height: 1.45;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topnav {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 10px 24px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
    flex-wrap: wrap;
}
.topnav .brand { font-weight: 700; color: var(--gold); white-space: nowrap; }
.topnav .links { display: flex; gap: 4px; flex-wrap: wrap; }
.topnav .links a {
    color: var(--muted);
    padding: 5px 10px;
    border-radius: 6px;
}
.topnav .links a:hover { color: var(--text); text-decoration: none; background: var(--panel-2); }
.topnav .links a.active { color: var(--gold); background: var(--panel-2); }

main { padding: 20px 24px 60px; max-width: 1500px; margin: 0 auto; }

h1 { font-size: 20px; margin: 8px 0 4px; color: #fff; }
h2 { font-size: 16px; margin: 24px 0 8px; color: var(--gold); }
.sub { color: var(--muted); margin: 0 0 16px; max-width: 900px; }

.flash {
    background: #16331f;
    border: 1px solid #2d6a41;
    color: #9fe0b5;
    padding: 8px 14px;
    border-radius: 8px;
    margin-bottom: 12px;
}
.flash.warn { background: #33290f; border-color: #7a641f; color: #e6cd7a; }
.flash.error { background: #331414; border-color: #7a2727; color: #e09a9a; }

table.grid {
    border-collapse: collapse;
    width: 100%;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}
table.grid th, table.grid td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}
table.grid th {
    background: var(--panel-2);
    color: var(--muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}
table.grid tr:last-child td { border-bottom: none; }
table.grid tr:hover td { background: rgba(255, 255, 255, 0.02); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.center, th.center { text-align: center; }

.scroll-x { overflow-x: auto; }

.item-name { color: #a335ee; font-weight: 600; } /* epic purple */
.muted { color: var(--muted); }
.gold { color: var(--gold); }
.good { color: var(--good); }
.bad { color: var(--bad); }
.small { font-size: 12px; }

.pill {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 12px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    color: var(--muted);
    white-space: nowrap;
}
.pill.rank1 { background: #3a2c05; border-color: var(--gold); color: var(--gold); font-weight: 700; }
.pill.rank2 { background: #232a3a; border-color: #6c7a96; color: #aebbd4; font-weight: 600; }
.pill.rank3 { background: #2c2118; border-color: #8a5a2b; color: #c98d4b; font-weight: 600; }

.cards { display: flex; gap: 14px; flex-wrap: wrap; margin: 14px 0 20px; }
.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 18px;
    min-width: 150px;
}
.card .big { font-size: 26px; font-weight: 700; color: #fff; }
.card .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 18px;
    margin-bottom: 18px;
}

form.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }

input[type="text"], input[type="password"], input[type="number"], select, textarea {
    background: var(--panel-2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 7px;
    padding: 6px 10px;
    font: inherit;
}
textarea { width: 100%; min-height: 160px; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
input:focus, select:focus, textarea:focus { outline: 1px solid var(--accent); }

button, .btn {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 7px;
    padding: 6px 14px;
    font: inherit;
    cursor: pointer;
}
button:hover, .btn:hover { filter: brightness(1.1); }
button.subtle {
    background: var(--panel-2);
    border: 1px solid var(--border);
    color: var(--muted);
    padding: 3px 9px;
}
button.danger { background: #5b2020; border: 1px solid #7a2f2f; color: #e09a9a; }

/* Tier piece toggles */
.piece-btn {
    width: 34px;
    height: 26px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--panel-2);
    color: var(--muted);
    font-size: 11px;
    cursor: pointer;
    padding: 0;
}
.piece-btn.owned { background: #1e4028; border-color: #3fbf6f; color: #9fe0b5; font-weight: 700; }
.piece-btn:hover { filter: brightness(1.25); }

/* Contested matrix */
td.cell-na { background: #12141a; color: #3c414f; }
td.cell-gain { font-variant-numeric: tabular-nums; }

.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs a {
    padding: 6px 14px;
    border-radius: 8px;
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--muted);
}
.tabs a.active { color: var(--gold); border-color: var(--gold); }
.tabs a:hover { text-decoration: none; color: var(--text); }

code.inline {
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 1px 6px;
    font-size: 12px;
}

.bar-wrap { background: var(--panel-2); border-radius: 4px; height: 8px; min-width: 80px; }
.bar { background: var(--gold); height: 8px; border-radius: 4px; }

/* Password gate */
.gate-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.gate { width: 100%; max-width: 340px; }
.gate-brand { font-weight: 700; color: var(--gold); font-size: 18px; margin-bottom: 4px; }
.gate form { display: flex; gap: 8px; margin-top: 14px; }
.gate input[type="password"] { flex: 1; min-width: 0; }
.gate .sub { margin-bottom: 0; }
.topnav .lock-form { margin-left: auto; }
.name-input { font-weight: 700; }

/* Tier rank pinning */
.rank-cell { white-space: nowrap; }
.rank-input {
    width: 42px;
    margin-left: 4px;
    padding: 2px 4px;
    font-size: 12px;
    text-align: center;
    background: var(--panel-2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 5px;
}
.rank-input::placeholder { color: #566; }
.pill.pinned { box-shadow: 0 0 0 2px var(--gold); }
