:root {
    --bg: #14100f;
    --bg-panel: #1d1714;
    --bg-card: #241b17;
    --border: #3a2c22;
    --text: #e9dfd0;
    --text-dim: #b3a48f;
    --accent: #c9a13b;
    --accent-dim: #8a6c2a;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Georgia, 'Times New Roman', serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

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

a:hover {
    text-decoration: underline;
}

.site-header {
    background: var(--bg-panel);
    border-bottom: 2px solid var(--accent-dim);
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.site-title {
    font-size: 1.5rem;
    letter-spacing: 0.05em;
    color: var(--accent);
    font-variant: small-caps;
}

.site-nav {
    display: flex;
    gap: 1.25rem;
}

.site-nav a {
    color: var(--text-dim);
    font-variant: small-caps;
    letter-spacing: 0.05em;
}

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

.layout {
    display: flex;
    align-items: flex-start;
    max-width: 1100px;
    margin: 0 auto;
}

.sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    padding: 1.5rem 1rem;
    min-height: calc(100vh - 4.5rem);
}

.sidebar h2 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    margin: 0 0 0.75rem;
}

#sidebar-filter {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    font-family: inherit;
    margin-bottom: 0.75rem;
}

#sidebar-filter:focus {
    outline: 1px solid var(--accent-dim);
}

.sidebar ul {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: calc(100vh - 10rem);
    overflow-y: auto;
}

.sidebar li {
    margin-bottom: 0.4rem;
}

.sidebar a {
    color: var(--text-dim);
    font-size: 0.95rem;
}

.sidebar a.active,
.sidebar a:hover {
    color: var(--accent);
}

.content {
    flex: 1;
    padding: 2rem 2.5rem;
}

h1 {
    color: var(--accent);
    margin-bottom: 0.2rem;
    font-variant: small-caps;
    letter-spacing: 0.03em;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
}

.page-header-text {
    flex: 1;
    min-width: 0;
}

.sprite-box {
    flex-shrink: 0;
    background-repeat: no-repeat;
    image-rendering: pixelated;
    border: 1px solid var(--border);
    border-radius: 6px;
    background-color: var(--bg-card);
}

.quest-stage {
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-panel);
    padding: 1rem 1.25rem;
    margin: 1.5rem 0;
}

.quest-stage h2 {
    color: var(--accent);
    font-variant: small-caps;
    letter-spacing: 0.03em;
    margin: 0 0 0.3rem;
}

.btn {
    background: var(--bg-card);
    border: 1px solid var(--accent-dim);
    color: var(--text);
    padding: 0.35rem 0.9rem;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
}

.btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn:disabled {
    opacity: 0.6;
    cursor: default;
}

.btn-secondary {
    border-color: var(--border);
}

.wiki-entry-section {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem 1.25rem;
}

.wiki-entry-view {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    justify-content: space-between;
}

.wiki-entry-text {
    white-space: pre-wrap;
    flex: 1;
    margin: 0;
}

.wiki-entry-text:empty::after {
    content: "No custom entry yet.";
    font-style: italic;
    color: var(--text-dim);
}

.wiki-entry-textarea {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
    padding: 0.6rem;
    border-radius: 4px;
    resize: vertical;
}

.wiki-entry-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.form-label {
    display: block;
    color: var(--text-dim);
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}

.text-input {
    width: 100%;
    max-width: 480px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
    padding: 0.45rem 0.6rem;
    border-radius: 4px;
    margin-top: 0.3rem;
}

.lore-name {
    margin-bottom: 0.75rem;
}

.lore-text {
    white-space: pre-wrap;
    margin: 0 0 1rem;
}

.content h4 {
    color: var(--text-dim);
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    margin: 0.75rem 0 0.3rem;
}

.intro {
    color: var(--text-dim);
    max-width: 60ch;
}

.title {
    font-style: italic;
    color: var(--text-dim);
    margin-top: 0;
}

.domains,
.home {
    margin: 0.2rem 0;
}

.deity-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.deity-card {
    display: block;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
    color: var(--text);
    transition: border-color 0.15s ease, transform 0.15s ease;
}

.deity-card:hover {
    border-color: var(--accent-dim);
    text-decoration: none;
    transform: translateY(-2px);
}

.deity-card h3 {
    margin: 0 0 0.3rem;
    color: var(--accent);
}

.deity-card .title,
.deity-card .domains {
    font-size: 0.85rem;
    margin: 0.1rem 0;
}

.description {
    background: var(--bg-panel);
    border-left: 3px solid var(--accent-dim);
    padding: 0.75rem 1rem;
    margin: 1.2rem 0;
}

.blurbs {
    display: grid;
    gap: 1rem;
    margin-top: 1.5rem;
}

.blurb h4 {
    margin: 0 0 0.2rem;
    color: var(--text-dim);
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.08em;
}

.blurb p {
    margin: 0;
}

.special-blurbs {
    margin-top: 2rem;
    border-top: 1px solid var(--border);
    padding-top: 1rem;
}

.special-blurbs h3 {
    color: var(--text-dim);
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.special-class {
    margin-bottom: 1rem;
}

.special-class h4 {
    color: var(--accent);
    margin: 0 0 0.3rem;
    text-transform: capitalize;
}

.special-entry {
    margin: 0 0 0.5rem 1rem;
}

.race-tag {
    display: inline-block;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 0.05rem 0.5rem;
    font-size: 0.75rem;
    text-transform: capitalize;
    color: var(--text-dim);
    margin-bottom: 0.2rem;
}

.special-entry p {
    margin: 0.2rem 0 0;
}

.stats-section,
.classes-section,
.flags-section {
    margin-top: 1.5rem;
}

.stats-section h3,
.classes-section h3,
.flags-section h3 {
    color: var(--text-dim);
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.5rem;
}

.stat-table {
    border-collapse: collapse;
    width: 100%;
    max-width: 480px;
}

.stat-table th,
.stat-table td {
    text-align: left;
    padding: 0.35rem 0.75rem 0.35rem 0;
    border-bottom: 1px solid var(--border);
}

.stat-table th {
    color: var(--text-dim);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-table td.positive {
    color: #7fbf6a;
}

.stat-table td.negative {
    color: #c76a5a;
}

.tag-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag-link {
    display: inline-block;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.25rem 0.7rem;
    font-size: 0.85rem;
    color: var(--text);
}

.tag-link:hover {
    border-color: var(--accent-dim);
    color: var(--accent);
    text-decoration: none;
}

.table-wrap {
    overflow-x: auto;
    margin-top: 1rem;
}

.ability-table {
    border-collapse: collapse;
    width: 100%;
    min-width: 480px;
}

.ability-table th,
.ability-table td {
    text-align: left;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
}

.ability-table th {
    color: var(--text-dim);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.ability-table tr:hover {
    background: var(--bg-card);
}

.worship-table th:not(:first-child),
.worship-table td:not(:first-child) {
    text-align: center;
}

.worship-table td:not(:first-child) {
    color: var(--accent);
    font-weight: bold;
}

.flags-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.4rem;
}

.flag-name {
    color: var(--text-dim);
}

.token {
    background: var(--bg-card);
    border: 1px solid var(--accent-dim);
    color: var(--accent);
    border-radius: 3px;
    padding: 0.05rem 0.35rem;
    font-family: 'Courier New', monospace;
    font-size: 0.85em;
}

.item-search {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin: 1rem 0;
}

.item-search input[type="text"],
.item-search select {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.45rem 0.7rem;
    border-radius: 4px;
    font-family: inherit;
}

.item-search input[type="text"] {
    flex: 1;
    min-width: 220px;
}

.item-search button {
    background: var(--accent-dim);
    border: 1px solid var(--accent-dim);
    color: var(--bg);
    padding: 0.45rem 1.1rem;
    border-radius: 4px;
    font-family: inherit;
    font-weight: bold;
    cursor: pointer;
}

.item-search button:hover {
    background: var(--accent);
    border-color: var(--accent);
}

.zone-map-viewer {
    position: relative;
}

.zone-map-canvas {
    position: relative;
    width: 100%;
    height: 70vh;
    overflow: hidden;
    background: #0a0806;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: grab;
    touch-action: none;
}

.zone-map-canvas.dragging {
    cursor: grabbing;
}

.zone-map-img {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
    max-width: none;
    image-rendering: pixelated;
    user-select: none;
    -webkit-user-drag: none;
}

.zone-map-controls {
    position: absolute;
    top: 0.6rem;
    right: 0.6rem;
    z-index: 2;
    display: flex;
    gap: 0.4rem;
}

@media (max-width: 800px) {
    .site-header {
        padding: 0.75rem 1rem;
    }

    .site-title {
        font-size: 1.2rem;
    }

    .site-nav {
        gap: 0.75rem;
    }

    .layout {
        flex-direction: column;
        align-items: stretch;
    }

    .sidebar {
        width: 100%;
        min-height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 1rem;
    }

    .sidebar ul {
        max-height: 40vh;
    }

    .content {
        padding: 1.25rem 1rem;
        min-width: 0;
        width: 100%;
    }
}

