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

body {
    font-family: Georgia, 'Times New Roman', serif;
    background: linear-gradient(to bottom, #000000 0%, #131d1f 100%);
    color: #e0d9c8;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    background-color: #050505;
    padding: 0;
    border-bottom: 2px solid #8b6914;
}

nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.nav-links {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.nav-user {
    color: #e8e0d0;
    padding: 0.6rem 0.2rem;
}

.nav-logout-form {
    margin: 0;
}

.nav-logout-form button {
    padding: 0.55rem 0.9rem;
}

.nav-links a {
    color: #d8c58c;
    text-decoration: none;
    font-weight: 600;
    padding: 0.6rem 0.8rem;
}

.nav-links a:hover {
    color: #f0d27d;
}

.nav-brand {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    padding: 0;
}

.nav-brand-logo {
    height: 100px;
    width: auto;
    display: block;
}

main {
    flex: 1;
    padding: 2rem;
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
}

footer {
    background-color: #050505;
    text-align: center;
    padding: 1rem;
    font-size: 0.85rem;
    color: #888;
    border-top: 1px solid #333;
}

.hero {
    text-align: center;
    padding: 4rem 1rem;
}

.hero h1 {
    font-size: 2.5rem;
    color: #c9a846;
    margin-bottom: 1rem;
}

.hero-actions {
    margin-top: 1.5rem;
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

.button-link,
button {
    display: inline-block;
    border: 1px solid #8b6914;
    background: #2a3557;
    color: #f1e8d0;
    text-decoration: none;
    padding: 0.55rem 0.9rem;
    border-radius: 6px;
    cursor: pointer;
}

.button-link:hover,
button:hover {
    background: #34436d;
}

button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

button.danger {
    border-color: #8b3a3a;
    background: #532222;
}

button.danger:hover {
    background: #6c2b2b;
}

.panel {
    background: #1f2745;
    border: 1px solid #32406d;
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 1.25rem;
}

.panel-subtitle {
    margin: 0.4rem 0 1rem;
    color: #c7c2b5;
}

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    background: #1a223a;
    border-radius: 8px;
    border: 1px solid #2e3e6a;
}

.filter-bar label {
    color: #c7c2b5;
    font-size: 0.875rem;
    white-space: nowrap;
}

.filter-bar select {
    background: #1e2a47;
    color: #e8e0d0;
    border: 1px solid #4d5c8e;
    border-radius: 6px;
    padding: 0.35rem 0.6rem;
    font-size: 0.875rem;
}

.filter-bar input[type="date"] {
    background: #1e2a47;
    color: #e8e0d0;
    border: 1px solid #4d5c8e;
    border-radius: 6px;
    padding: 0.35rem 0.6rem;
    font-size: 0.875rem;
}

.entity-form {
    display: grid;
    gap: 0.55rem;
}

.entity-form input,
.entity-form textarea,
.entity-form select {
    width: 100%;
    border: 1px solid #4d5c8e;
    border-radius: 6px;
    padding: 0.5rem;
    background: #121933;
    color: #e0d9c8;
}

.entity-form .multi-select {
    min-height: 6.5rem;
}

.auth-panel {
    max-width: 640px;
    margin-left: auto;
    margin-right: auto;
}

.auth-form {
    margin-top: 1rem;
}

.compact-form {
    margin-top: 0.75rem;
}

.admin-user-grid {
    align-items: start;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.checkbox-row input[type="checkbox"] {
    width: auto;
}

.compact-checkbox {
    font-size: 0.85rem;
    margin-top: 0.45rem;
}

.admin-users-table-wrap {
    overflow-x: auto;
}

.admin-users-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-users-table th,
.admin-users-table td {
    border-bottom: 1px solid #32406d;
    padding: 0.75rem 0.55rem;
    vertical-align: top;
    text-align: left;
}

.admin-users-table th {
    color: #ddbe62;
    font-size: 0.9rem;
}

.admin-users-table td input,
.admin-users-table td select {
    width: 100%;
    border: 1px solid #4d5c8e;
    border-radius: 6px;
    padding: 0.45rem;
    background: #121933;
    color: #e0d9c8;
}

.admin-role-select {
    min-height: 7rem;
}

.admin-users-username-cell {
    min-width: 10rem;
}

.admin-users-actions-cell {
    min-width: 20rem;
}

.admin-users-actions-cell form {
    display: inline-block;
    margin-right: 0.5rem;
}

.admin-users-actions-cell .button-link,
.admin-users-actions-cell button {
    margin-bottom: 0.35rem;
}

.admin-password-flag {
    margin-top: 0.4rem;
    font-size: 0.8rem;
    color: #f0d27d;
}

.draft-meta {
    margin-bottom: 0.55rem;
}

.email-draft-body {
    width: 100%;
    min-height: 16rem;
    border: 1px solid #4d5c8e;
    border-radius: 6px;
    padding: 0.75rem;
    background: #121933;
    color: #e0d9c8;
    resize: vertical;
    white-space: pre-wrap;
}

.entity-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
}

.entity-card {
    background: #151b34;
    border: 1px solid #34436d;
    border-radius: 8px;
    padding: 0.8rem;
}

.entity-card h3 {
    margin-bottom: 0.4rem;
    color: #ddbe62;
}

.entity-card p {
    margin-bottom: 0.35rem;
}

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

.stat-card {
    text-align: center;
    padding: 1rem;
    background: #18213d;
    border: 1px solid #34436d;
    border-radius: 8px;
}

.stat-card h2 {
    font-size: 1rem;
    color: #c9a846;
}

.stat-card p {
    margin-top: 0.4rem;
    font-size: 2rem;
    font-weight: bold;
}

.error-page {
    text-align: center;
    padding: 4rem 1rem;
}

.error-page h1 {
    font-size: 5rem;
    color: #8b3a3a;
    margin-bottom: 1rem;
}

.error-page a {
    color: #c9a846;
}

.flash {
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    border-radius: 4px;
}

.flash-error { background-color: #5a1a1a; border: 1px solid #8b3a3a; }
.flash-success { background-color: #1a3a1a; border: 1px solid #3a8b3a; }
.flash-info { background-color: #1a2a4a; border: 1px solid #3a5a8b; }

.chat-log-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-entry {
    background: #18213d;
    border: 1px solid #34436d;
    border-radius: 8px;
    padding: 1rem;
}

.chat-entry-header {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
}

.chat-npc { font-weight: bold; color: #c9a846; }
.chat-session { color: #9ba8cc; }
.chat-meta { color: #6a7a9a; margin-left: auto; }
.chat-model { color: #6a9a7a; font-style: italic; }
.chat-latency { color: #7a9a6a; }

.chat-player { color: #b0c8ff; }
.chat-npc-response { color: #e8d8a0; }

@media (max-width: 800px) {
    nav {
        flex-direction: column;
        align-items: flex-start;
    }

    .nav-links {
        flex-wrap: wrap;
    }
}

.card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.6rem;
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

/* Character sheet */
.character-sheet .sheet-header {
    margin-bottom: 1.25rem;
}

.sheet-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.sheet-stat {
    background: #18213d;
    border: 1px solid #34436d;
    border-radius: 8px;
    padding: 0.75rem 1.25rem;
    min-width: 120px;
    text-align: center;
}

.sheet-stat-label {
    display: block;
    font-size: 0.75rem;
    color: #9ba8cc;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.3rem;
}

.sheet-stat-value {
    display: block;
    font-size: 1.4rem;
    font-weight: bold;
    color: #ddbe62;
}

.sheet-section {
    margin-bottom: 1.25rem;
}

.sheet-section h2 {
    font-size: 1rem;
    color: #c9a846;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid #32406d;
    padding-bottom: 0.25rem;
}

.sheet-text {
    line-height: 1.6;
    color: #e0d9c8;
    white-space: pre-wrap;
}

.sheet-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.world-map-canvas {
    width: 100%;
    height: 72vh;
    min-height: 380px;
    border: 1px solid #34436d;
    border-radius: 10px;
    overflow: hidden;
}
