:root {
    --bg: #ffffff;
    --bg-alt: #f7f7f7;
    --bg-hover: #f0f0f0;
    --text: #37352f;
    --text-muted: #787774;
    --border: #e3e2e0;
    --accent: #2383e2;
    --accent-light: #e8f0fe;
    --header-bg: #fbfbfa;
    --common: #8b8b8b;
    --uncommon: #1a8c37;
    --rare: #1a6bdc;
    --very-rare: #7b2d8b;
    --legendary: #d4a017;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
    font-size: 15px;
}

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

a:hover {
    text-decoration: underline;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

.page-heading {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.heading-token {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.heading-anchor-target {
    position: relative;
}

.heading-anchor {
    position: absolute;
    left: -1.2em;
    text-decoration: none;
    color: var(--text-muted);
    opacity: 0;
    font-weight: 400;
    font-size: 0.8em;
    transition: opacity 0.2s;
}

.heading-anchor-target:hover .heading-anchor {
    opacity: 1;
}

h1 {
    font-size: 1.875rem;
    font-weight: 700;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}

h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    color: var(--text);
}

h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.section ul {
    margin-left: 1.25rem;
    padding-left: 0;
}

.section img {
    max-width: 100%;
    height: auto;
}

.math {
    font-style: italic;
    font-family: serif;
}

.section ul ul {
    margin-left: 1.25rem;
    margin-top: 0.25rem;
    margin-bottom: 0.25rem;
}

/* Index page */
.character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.character-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    background: var(--bg);
    transition: box-shadow 0.15s ease;
    text-decoration: none;
    color: inherit;
}

.character-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.card-token {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.card-body {
    min-width: 0;
}

.character-card h3 {
    margin: 0 0 0.25rem 0;
}

.character-card .meta {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.character-card .meta span + span::before {
    content: " \00b7 ";
}

/* Properties table */
.props-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.props-table td {
    padding: 0.375rem 0.75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.props-table td:first-child {
    font-weight: 600;
    width: 160px;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Two-column layout */
.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-top: 0.5rem;
}

.inventory-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-top: 0.5rem;
}

.inventory-cell h3 {
    margin-top: 0;
    margin-bottom: 0.5rem;
}

/* Three-column layout */
.three-col {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1.5rem;
    margin-top: 0.5rem;
}

.three-col h3 {
    margin-top: 0;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    padding-bottom: 0.25rem;
}

.three-col ul {
    list-style: none;
    padding: 0;
}

.three-col li {
    padding: 0.25rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9375rem;
}

.section .three-col ul {
    list-style: disc;
    margin-left: 1.25rem;
}

.section .three-col li {
    border-bottom: none;
    padding: 0.125rem 0;
}

/* Data tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.5rem;
    font-size: 0.9375rem;
}

.data-table th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    background: var(--header-bg);
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-muted);
    white-space: nowrap;
}

.data-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.data-table tbody tr:hover {
    background: var(--bg-hover);
}

.data-table td.numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.data-table tfoot td {
    font-weight: 600;
    border-top: 2px solid var(--border);
    background: var(--header-bg);
}

/* Rarity badges */
.rarity {
    font-size: 0.8125rem;
    font-weight: 600;
    padding: 0.125rem 0.5rem;
    border-radius: 3px;
    white-space: nowrap;
}

.rarity-common { background: #e8e8e8; color: #555; }
.rarity-uncommon { background: #e6f4ea; color: var(--uncommon); }
.rarity-rare { background: #e8f0fe; color: var(--rare); }
.rarity-very-rare { background: #f3e8f9; color: var(--very-rare); }
.rarity-legendary { background: #fef7e0; color: #8a6d00; }

/* Attunement */
.attunement {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

/* Token images */
.token-images {
    display: flex;
    gap: 0.5rem;
    margin: 0.5rem 0;
}

.token-images img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
}

.token-image {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
}

/* Log type badges */
.type-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.125rem 0.5rem;
    border-radius: 3px;
    white-space: nowrap;
}

.type-game { background: #e6f4ea; color: #1a7f37; }
.type-trade { background: #e8f0fe; color: #1a56db; }
.type-service { background: #fef7e0; color: #8a6d00; }
.type-bastion { background: #fce4ec; color: #a04060; }
.type-downtime-activity { background: #f3e5f5; color: #7b1fa2; }
.type-factions { background: #e0f2f1; color: #00695c; }
.type-rebuild { background: #efebe9; color: #4e342e; }
.type-service-awards { background: #fef7e0; color: #8a6d00; }
.type-story-origin { background: #e8eaf6; color: #283593; }
.type-other { background: #f0f0f0; color: #555; }

/* Log body (inline rendered markdown) */
.log-body {
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.75rem;
    margin-top: 0.5rem;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    line-height: 1.6;
}

.log-body h3, .log-body h4 {
    margin-top: 0.5rem;
    font-size: 0.875rem;
}

.log-body p {
    margin-bottom: 0.5rem;
}

.log-body ul {
    margin-left: 1.25rem;
    margin-bottom: 0.5rem;
}

/* Back link */
.back-link {
    display: inline-block;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.back-link:hover {
    color: var(--accent);
}

/* Section divider */
.section {
    margin-bottom: 2rem;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--border);
}

.section-header h2 {
    margin: 0;
}

.site-footer {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-top: 3rem;
    padding: 1rem 0;
    border-top: 1px solid var(--border);
}

p + p {
    margin-top: 0.75rem;
}

/* Responsive */
@media (max-width: 768px) {
    .two-col, .three-col, .inventory-grid {
        grid-template-columns: 1fr;
    }

    .container {
        padding: 1rem;
    }

    .data-table {
        font-size: 0.8125rem;
    }

    .data-table th, .data-table td {
        padding: 0.375rem 0.5rem;
    }
}
