:root {
    --bg: #0e0a0a;
    --bg-soft: radial-gradient(circle at 20% 20%, rgba(110,72,48,0.12), transparent 30%),
               radial-gradient(circle at 80% 0%, rgba(148,92,44,0.14), transparent 26%),
               #0e0a0a;
    --panel: #1b1310;
    --panel-elevated: #241712;
    --card: #241916;
    --border: rgba(255, 231, 195, 0.14);
    --text: #f5eddc;
    --muted: #c8b79e;
    --accent: #c6712c;
    --accent-strong: #e18c37;
    --accent-soft: rgba(198,113,44,0.12);
    --danger: #e25c4a;
    --shadow: 0 12px 30px rgba(0,0,0,0.35);
    --radius: 14px;
    --font-heading: 'Cinzel', 'Times New Roman', serif;
    --font-body: 'Source Serif 4', 'Inter', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--bg-soft);
    color: var(--text);
    min-height: 100vh;
}

a { color: inherit; }

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

.main-nav {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: linear-gradient(90deg, rgba(28,17,12,0.96), rgba(44,26,18,0.96));
    border-bottom: 1px solid var(--border);
    box-shadow: 0 8px 18px rgba(0,0,0,0.35);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
}

.nav-logo {
    margin: 0;
    font-family: var(--font-heading);
    letter-spacing: 1px;
    font-size: 1.25rem;
    color: var(--text);
}

.nav-menu {
    display: flex;
    gap: 8px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    padding: 10px 14px;
    color: var(--muted);
    text-decoration: none;
    border-radius: 10px;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    background: transparent;
}

.nav-link:hover {
    color: var(--text);
    border-color: var(--border);
    background: rgba(255,255,255,0.04);
}

.nav-link.active {
    color: var(--text);
    background: var(--accent-soft);
    border-color: rgba(198,113,44,0.35);
}

.hero {
    margin: 24px auto 12px;
    padding: 28px;
    background: linear-gradient(120deg, rgba(198,113,44,0.14), rgba(75,48,33,0.24));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.hero-title {
    margin: 0 0 6px;
    font-family: var(--font-heading);
    font-size: 1.9rem;
    letter-spacing: 0.5px;
}

.hero-subtitle {
    margin: 0;
    color: var(--muted);
    max-width: 680px;
}

.section-title {
    font-family: var(--font-heading);
    letter-spacing: 0.5px;
    margin: 0 0 12px;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 18px;
}

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
    position: relative;
}

.card h3 { margin-top: 0; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: 12px;
    border: 1px solid transparent;
    font-weight: 600;
    cursor: pointer;
    color: #0d0a0a;
    background: var(--accent);
    box-shadow: 0 8px 16px rgba(0,0,0,0.25);
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 20px rgba(0,0,0,0.3);
    background: var(--accent-strong);
}

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

.btn-secondary:hover {
    background: rgba(255,255,255,0.06);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-sm { padding: 8px 12px; font-size: 0.9rem; }

.message {
    margin-top: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.04);
    color: var(--text);
}

.message-success {
    border-color: rgba(99, 255, 176, 0.3);
    background: rgba(66, 160, 122, 0.14);
}

.message-error {
    border-color: rgba(226, 92, 74, 0.35);
    background: rgba(226, 92, 74, 0.14);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin: 14px 0;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }

.form-group label {
    font-weight: 600;
    color: var(--muted);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--panel-elevated);
    color: var(--text);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: 2px solid rgba(198,113,44,0.4);
}

.form-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.allowed-users-container {
    border: 1px solid var(--border);
    padding: 14px;
    border-radius: 10px;
    background: var(--panel-elevated);
    max-height: 220px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
}

.allowed-users-container > div {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 8px;
    background: var(--card);
    border: 1px solid var(--border);
    transition: all 0.2s ease;
}

.allowed-users-container > div:hover {
    background: var(--panel);
    border-color: var(--accent);
}

.allowed-users-container label {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    margin: 0;
    cursor: pointer;
    color: var(--text);
    font-weight: 500;
}

/* Login */
.login-shell {
    max-width: 420px;
    margin: 60px auto;
    padding: 26px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.error-message { color: var(--danger); text-align: center; }

/* Character manager */
.character-layout {
    display: grid;
    grid-template-columns: 1.05fr 1fr;
    gap: 18px;
    margin-top: 18px;
}

.character-list-card,
.character-form-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
}

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.character-list { display: grid; gap: 10px; }

.character-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    background: var(--card);
    cursor: pointer;
    transition: transform 0.12s ease, border-color 0.12s ease;
}

.character-card:hover { transform: translateY(-1px); border-color: rgba(198,113,44,0.45); }

.card-row { display: flex; justify-content: space-between; gap: 12px; }
.card-actions { display: flex; gap: 8px; }
.card-token-avatar { width: 80px; height: 80px; border-radius: 50%; background-size: cover; background-position: center; border: 2px solid #c6712c; flex-shrink: 0; }
.owner-label { color: var(--muted); font-size: 0.9rem; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-top: 10px;
}

/* Map */
.map-header { text-align: center; }

.map-main {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 16px;
    align-items: start;
}

.map-controls {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.map-info p { margin: 6px 0; color: var(--muted); }

#map-container {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    box-shadow: var(--shadow);
    position: relative;
}

#game-map {
    display: block;
    width: 100%;
    border: 2px solid rgba(198,113,44,0.35);
    background: linear-gradient(135deg, rgba(80,60,40,0.45), rgba(34,26,22,0.6));
}

.token { position: absolute; width: 30px; height: 30px; border-radius: 50%; }

/* Admin */
.admin-container { max-width: 1200px; margin: 30px auto; padding: 0 24px 40px; }
.admin-header { margin-bottom: 18px; }
.admin-lead { color: var(--muted); }

.stat-card {
    background: linear-gradient(135deg, rgba(198,113,44,0.45), rgba(102,66,40,0.7));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
}

.stat-card h3 { margin: 0 0 6px; color: #fdf6e3; font-size: 0.95rem; letter-spacing: 0.3px; }
.stat-value { font-size: 2rem; font-weight: 700; }

.admin-tabs { display: flex; gap: 10px; border-bottom: 1px solid var(--border); margin: 18px 0; }
.admin-tab {
    background: transparent;
    border: none;
    color: var(--muted);
    padding: 12px 14px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    font-weight: 600;
}

.admin-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab-content { display: none; }
.tab-content.active { display: block; }

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

.user-table { width: 100%; border-collapse: collapse; }
.user-table th, .user-table td { padding: 12px; border-bottom: 1px solid var(--border); text-align: left; }
.user-table th { color: var(--muted); font-size: 0.9rem; letter-spacing: 0.4px; }
.user-table tr:hover { background: rgba(255,255,255,0.03); }

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
}

.badge-admin { background: rgba(226,92,74,0.18); color: #f5c0b6; }
.badge-user { background: rgba(99,255,176,0.15); color: #d2ffe9; }

.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 2000;
}

.modal-content {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    width: 90%;
    max-width: 520px;
    margin: 60px auto;
    box-shadow: var(--shadow);
}

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-close { cursor: pointer; font-size: 1.4rem; color: var(--muted); }

.activity-log { max-height: 360px; overflow-y: auto; }
.activity-item { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.activity-time { color: var(--muted); font-size: 0.9rem; }

.info-table { width: 100%; border-collapse: collapse; }
.info-table td { padding: 10px; border-bottom: 1px solid var(--border); }

footer {
    text-align: center;
    color: var(--muted);
    padding: 18px 0 28px;


/* Custom Scrollbar Styling */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--panel);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 5px;
    border: 2px solid var(--panel);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-strong);
}

/* Firefox Scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--accent) var(--panel);
}

/* ============ UNIFIED INVENTORY STYLES ============ */
.inventory-unified-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 400px;
    overflow-y: auto;
    padding: 4px;
}

.inventory-unified-item {
    background: linear-gradient(135deg, #1a1a1a 0%, #0d0d0d 100%);
    padding: 12px 16px;
    border-radius: 6px;
    border-left: 4px solid var(--accent);
    display: grid;
    grid-template-columns: 1fr 80px auto;
    gap: 12px;
    align-items: center;
    border: 1px solid rgba(255, 170, 0, 0.1);
    transition: all 0.2s ease;
}

.inventory-unified-item:hover {
    background: linear-gradient(135deg, #242424 0%, #141414 100%);
    border-color: rgba(255, 170, 0, 0.3);
    box-shadow: 0 0 8px rgba(255, 170, 0, 0.15);
}

.inv-unified-input {
    background: #0a0a0a;
    color: var(--text);
    border: 1px solid rgba(255, 170, 0, 0.2);
    border-radius: 4px;
    padding: 8px 10px;
    font-size: 0.95em;
    font-family: inherit;
    transition: all 0.2s ease;
}

.inv-unified-input.inv-name {
    flex: 1;
    min-width: 150px;
}

.inv-unified-input.inv-qty {
    width: 80px;
    text-align: center;
}

.inv-unified-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 6px rgba(255, 170, 0, 0.4), inset 0 0 4px rgba(255, 170, 0, 0.1);
    background: #0f0f0f;
}

.inventory-unified-add {
    background: linear-gradient(135deg, #1a1a1a 0%, #0d0d0d 100%);
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    border: 1px solid rgba(255, 170, 0, 0.15);
    display: grid;
    grid-template-columns: 1fr 80px auto;
    gap: 10px;
    align-items: flex-end;
}

.inventory-unified-add input {
    padding: 10px 12px;
    background: #0a0a0a;
    border: 1px solid rgba(255, 170, 0, 0.2);
    border-radius: 4px;
    color: var(--text);
    font-family: inherit;
    transition: all 0.2s ease;
}

.inventory-unified-add input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.inventory-unified-add input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 6px rgba(255, 170, 0, 0.4), inset 0 0 4px rgba(255, 170, 0, 0.1);
    background: #0f0f0f;
}

.inventory-unified-add button {
    background: linear-gradient(135deg, var(--accent) 0%, #cc8800 100%);
    color: var(--bg);
    border: 1px solid rgba(255, 170, 0, 0.3);
    padding: 10px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    white-space: nowrap;
    font-family: inherit;
}

.inventory-unified-add button:hover {
    background: linear-gradient(135deg, #ffaa00 0%, #ffbb22 100%);
    box-shadow: 0 0 12px rgba(255, 170, 0, 0.5);
    transform: translateY(-1px);
}

.inv-delete-btn {
    background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
    color: white;
    border: 1px solid rgba(220, 38, 38, 0.3);
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
    white-space: nowrap;
    transition: all 0.2s ease;
    font-weight: 500;
    font-family: inherit;
}

.inv-delete-btn:hover {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    box-shadow: 0 0 8px rgba(220, 38, 38, 0.4);
    transform: translateY(-1px);
}

