        html {
            height: 100%;
        }

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

        :root {
            --primary: #1a1a2e;
            --secondary: #16213e;
            --accent: #d4af37;
            --danger: #e74c3c;
            --success: #2ecc71;
            --warning: #f39c12;
            --info: #3498db;
            --text: #ecf0f1;
            --text-dim: #bdc3c7;
        }

        body {
            background-color: var(--primary);
            color: var(--text);
            font-family: 'Courier New', monospace;
            overflow: hidden;
            height: 100vh;
        }

        .container {
            display: flex;
            height: 100vh;
            flex-direction: column;
        }

        .header {
            background-color: var(--secondary);
            padding: 15px 20px;
            border-bottom: 3px solid var(--accent);
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-shrink: 0;
        }

        .header-title {
            font-size: 24px;
            color: var(--accent);
            text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
            font-weight: bold;
            letter-spacing: 2px;
        }

        .header-stats {
            display: flex;
            gap: 30px;
            align-items: center;
            font-size: 14px;
        }

        .stat-item {
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .stat-label {
            color: var(--accent);
            font-weight: bold;
            min-width: 50px;
        }

        .stat-value {
            color: var(--text);
        }

        .bar-container {
            width: 150px;
            height: 20px;
            background-color: var(--secondary);
            border: 2px solid var(--accent);
            border-radius: 4px;
            overflow: hidden;
            position: relative;
        }

        .bar-fill {
            height: 100%;
            transition: width 0.3s ease;
            background: linear-gradient(90deg, var(--success), #27ae60);
        }

        .bar-fill.hp {
            background: linear-gradient(90deg, #e74c3c, #c0392b);
        }

        .bar-fill.mp {
            background: linear-gradient(90deg, #3498db, #2980b9);
        }

        .bar-text {
            position: absolute;
            top: 2px;
            left: 4px;
            color: var(--text);
            font-size: 11px;
            font-weight: bold;
            z-index: 2;
        }

        .main-content {
            display: flex;
            flex: 1;
            overflow: hidden;
            min-height: 0;
        }

        .sidebar {
            width: 250px;
            min-width: 250px;
            background-color: var(--secondary);
            border-right: 2px solid var(--accent);
            padding: 15px;
            overflow-y: auto;
            min-height: 0;
        }

        .content-area {
            flex: 1;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            min-height: 0;
        }

        .tabs {
            display: flex;
            background-color: var(--secondary);
            border-bottom: 2px solid var(--accent);
            gap: 0;
            flex-shrink: 0;
        }

        .tab-btn {
            flex: 1;
            padding: 12px 10px;
            background-color: transparent;
            color: var(--text-dim);
            border: none;
            cursor: pointer;
            font-family: 'Courier New', monospace;
            font-size: 12px;
            font-weight: bold;
            transition: all 0.2s;
            border-bottom: 3px solid transparent;
        }

        .tab-btn:hover {
            background-color: rgba(212, 175, 55, 0.1);
            color: var(--accent);
        }

        .tab-btn.active {
            color: var(--accent);
            border-bottom-color: var(--accent);
            background-color: rgba(212, 175, 55, 0.15);
        }

        .tab-locked {
            opacity: 0.4;
            cursor: not-allowed;
            pointer-events: none;
        }

        #combat-return-banner {
            background: #5c1a1a;
            border: 1px solid #c0392b;
            color: #f5c6cb;
            padding: 8px 14px;
            border-radius: 6px;
            margin-bottom: 10px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
        }

        #combat-return-banner button {
            background: #c0392b;
            color: white;
            border: none;
            padding: 4px 12px;
            border-radius: 4px;
            cursor: pointer;
            font-size: 0.85em;
        }

        #combat-return-banner button:hover {
            background: #e74c3c;
        }

        .tab-content {
            display: none;
            flex: 1;
            overflow-y: scroll;
            overflow-x: hidden;
            padding: 15px;
            min-height: 0;
            box-sizing: border-box;
        }

        .tab-content.active {
            display: block;
        }

        /* ── Scrollbar styling — all scrollable panels ──────────────────── */
        .tab-content::-webkit-scrollbar,
        .sidebar::-webkit-scrollbar {
            width: 10px;
        }
        .tab-content::-webkit-scrollbar-track,
        .sidebar::-webkit-scrollbar-track {
            background: rgba(212,175,55,0.08);
            border-left: 2px solid rgba(212,175,55,0.5);
        }
        .tab-content::-webkit-scrollbar-thumb,
        .sidebar::-webkit-scrollbar-thumb {
            background: rgba(212,175,55,0.6);
            border-radius: 3px;
            min-height: 40px;
            border: 2px solid #0d1220;
        }
        .tab-content::-webkit-scrollbar-thumb:hover,
        .sidebar::-webkit-scrollbar-thumb:hover {
            background: var(--accent);
        }
        /* Standard scrollbar API (Chrome 120+ / Firefox) */
        .tab-content,
        .sidebar {
            scrollbar-color: rgba(212,175,55,0.7) rgba(212,175,55,0.15);
        }

        .section-title {
            color: var(--accent);
            font-size: 16px;
            font-weight: bold;
            margin: 15px 0 10px 0;
            border-bottom: 2px solid var(--accent);
            padding-bottom: 5px;
        }

        .section-subtitle {
            color: var(--text-dim);
            font-size: 12px;
            margin: 8px 0;
        }

        .stats-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 6px;
            margin: 6px 0;
        }

        .stat-box {
            background-color: rgba(212, 175, 55, 0.1);
            border: 1px solid var(--accent);
            padding: 6px 8px;
            border-radius: 4px;
            cursor: help;
            transition: background 0.15s;
        }
        .stat-box:hover {
            background-color: rgba(212, 175, 55, 0.22);
        }

        .stat-name {
            color: var(--accent);
            font-size: 11px;
            font-weight: bold;
        }

        .stat-number {
            color: var(--text);
            font-size: 16px;
            font-weight: bold;
            margin-top: 1px;
        }

        .stat-bonus {
            color: var(--success);
            font-size: 10px;
            font-weight: bold;
        }

        /* Derived stats (DEF / AC) — no allocated point value, shown in a dimmer row */
        .stats-grid-derived {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 6px;
            margin: 0 0 4px 0;
        }

        .stat-box-derived {
            background-color: rgba(52, 152, 219, 0.08);
            border: 1px solid rgba(52, 152, 219, 0.5);
            padding: 5px 8px;
            border-radius: 4px;
            cursor: help;
            transition: background 0.15s;
        }
        .stat-box-derived:hover {
            background-color: rgba(52, 152, 219, 0.18);
        }
        .stat-box-derived .stat-name {
            color: var(--info);
        }
        .stat-box-derived .stat-number {
            font-size: 15px;
        }

        /* ── Stat tooltip ───────────────────────────────────────────────── */
        #stat-tooltip {
            position: fixed;
            z-index: 9998;
            pointer-events: none;
            display: none;
            min-width: 170px;
            max-width: 220px;
            background: #0d1b2e;
            border: 2px solid var(--info);
            border-radius: 6px;
            padding: 9px 12px;
            font-family: 'Courier New', monospace;
            font-size: 11px;
            color: var(--text);
            box-shadow: 0 4px 18px rgba(0,0,0,0.7);
        }
        #stat-tooltip .stt-name {
            font-size: 12px;
            font-weight: bold;
            color: var(--info);
            margin-bottom: 4px;
        }
        #stat-tooltip .stt-desc {
            color: var(--text-dim);
            line-height: 1.45;
        }

        .item-slot {
            background-color: rgba(0, 0, 0, 0.3);
            border: 2px solid var(--accent);
            padding: 10px;
            margin: 8px 0;
            border-radius: 4px;
            cursor: pointer;
            transition: all 0.2s;
            font-size: 12px;
        }

        .item-slot:hover {
            background-color: rgba(212, 175, 55, 0.2);
        }

        .item-name {
            color: var(--accent);
            font-weight: bold;
            margin-bottom: 3px;
        }

        .item-stats {
            color: var(--text-dim);
            font-size: 11px;
            line-height: 1.3;
        }

        .empty-slot {
            color: var(--text-dim);
            font-style: italic;
        }

        .inventory-grid {
            display: grid;
            grid-template-columns: repeat(5, 1fr);
            grid-auto-rows: 72px;
            gap: 6px;
            margin: 10px 0;
        }

        .inventory-item {
            height: 72px;
            background-color: rgba(212, 175, 55, 0.1);
            border: 2px solid var(--accent);
            padding: 4px;
            border-radius: 4px;
            cursor: pointer;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            font-size: 10px;
            text-align: center;
            transition: all 0.2s;
            position: relative;
            overflow: hidden;
        }

        .inventory-item:hover {
            background-color: rgba(212, 175, 55, 0.3);
            transform: scale(1.05);
        }

        .inventory-item-name {
            color: var(--accent);
            font-weight: bold;
            margin-bottom: 2px;
        }

        .inventory-item-qty {
            color: var(--text-dim);
            font-size: 9px;
        }

        .empty-inventory-item {
            border-color: var(--text-dim);
            opacity: 0.3;
        }

        /* ── Inventory filter bar ───────────────────────────────────────── */
        .inv-filter-bar {
            display: flex;
            gap: 4px;
            margin: 6px 0 8px;
            flex-wrap: wrap;
        }
        .inv-filter-btn {
            background: rgba(212,175,55,0.08);
            border: 1px solid var(--text-dim);
            color: var(--text-dim);
            font-family: var(--font-main);
            font-size: 10px;
            padding: 3px 9px;
            border-radius: 3px;
            cursor: pointer;
            transition: all 0.15s;
            text-transform: uppercase;
            letter-spacing: 0.04em;
        }
        .inv-filter-btn:hover {
            border-color: var(--accent);
            color: var(--accent);
        }
        .inv-filter-btn.active {
            background: rgba(212,175,55,0.22);
            border-color: var(--accent);
            color: var(--accent);
            font-weight: bold;
        }

        /* ── Item tooltip ───────────────────────────────────────────────── */
        #item-tooltip {
            position: fixed;
            z-index: 9999;
            pointer-events: none;
            display: none;
            min-width: 180px;
            max-width: 240px;
            background: #0d1b2e;
            border: 2px solid var(--accent);
            border-radius: 6px;
            padding: 10px 12px;
            font-family: 'Courier New', monospace;
            font-size: 11px;
            color: var(--text);
            box-shadow: 0 4px 20px rgba(0,0,0,0.7);
        }
        #item-tooltip .tt-name {
            font-size: 13px;
            font-weight: bold;
            color: var(--accent);
            margin-bottom: 4px;
        }
        #item-tooltip .tt-type {
            font-size: 10px;
            color: var(--text-dim);
            text-transform: uppercase;
            letter-spacing: 1px;
            margin-bottom: 6px;
            padding-bottom: 6px;
            border-bottom: 1px solid rgba(212,175,55,0.3);
        }
        #item-tooltip .tt-stats {
            margin-bottom: 6px;
        }
        #item-tooltip .tt-stat-row {
            display: flex;
            justify-content: space-between;
            color: var(--success);
            margin-bottom: 2px;
        }
        #item-tooltip .tt-effect-row {
            display: flex;
            justify-content: space-between;
            color: var(--info);
            margin-bottom: 2px;
        }
        #item-tooltip .tt-desc {
            color: var(--text-dim);
            font-style: italic;
            margin-top: 6px;
            padding-top: 6px;
            border-top: 1px solid rgba(212,175,55,0.3);
            line-height: 1.4;
        }
        #item-tooltip .tt-price {
            color: var(--warning);
            margin-top: 6px;
            font-size: 10px;
        }

        /* ── Gear rarity colors ─────────────────────────────────────────── */
        .rarity-common    { color: #cccccc; }
        .rarity-uncommon  { color: #2ecc71; }
        .rarity-rare      { color: #3498db; }
        .rarity-epic      { color: #9b59b6; }
        .rarity-legendary { color: #e67e22; }
        #item-tooltip .tt-rarity {
            font-size: 9px;
            font-weight: bold;
            text-transform: uppercase;
            letter-spacing: 1px;
            margin-bottom: 2px;
        }

        .combat-area {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 20px;
            margin: 15px 0;
        }

        .combatant {
            background-color: rgba(212, 175, 55, 0.1);
            border: 2px solid var(--accent);
            padding: 15px;
            border-radius: 4px;
        }

        .combatant-name {
            color: var(--accent);
            font-size: 16px;
            font-weight: bold;
            margin-bottom: 10px;
        }

        .combatant-hp {
            margin: 10px 0;
        }

        .combatant-hp-label {
            color: var(--text-dim);
            font-size: 11px;
            margin-bottom: 3px;
        }

        .combat-actions {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 10px;
            margin-top: 20px;
        }

        .combat-end-actions {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 10px;
            margin-top: 20px;
        }

        .action-btn {
            padding: 12px 15px;
            background-color: var(--secondary);
            color: var(--accent);
            border: 2px solid var(--accent);
            border-radius: 4px;
            cursor: pointer;
            font-family: 'Courier New', monospace;
            font-size: 12px;
            font-weight: bold;
            transition: all 0.2s;
        }

        .action-btn:hover:not(:disabled) {
            background-color: rgba(212, 175, 55, 0.2);
            box-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
        }

        .action-btn:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

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

        .action-btn.danger:hover:not(:disabled) {
            background-color: rgba(231, 76, 60, 0.2);
            box-shadow: 0 0 10px rgba(231, 76, 60, 0.3);
        }

        .combat-log {
            background-color: rgba(0, 0, 0, 0.3);
            border: 1px solid var(--accent);
            padding: 10px;
            border-radius: 4px;
            height: 200px;
            overflow-y: auto;
            font-size: 11px;
            line-height: 1.4;
        }

        .log-entry {
            margin-bottom: 5px;
            padding-bottom: 5px;
            border-bottom: 1px solid rgba(212, 175, 55, 0.2);
        }

        .log-entry:last-child {
            border-bottom: none;
        }

        .log-player {
            color: var(--success);
        }

        .log-enemy {
            color: var(--danger);
        }

        .log-neutral {
            color: var(--text-dim);
        }

        .quest-item {
            background-color: rgba(212, 175, 55, 0.1);
            border: 1px solid var(--accent);
            padding: 10px;
            margin: 8px 0;
            border-radius: 4px;
            cursor: pointer;
            transition: all 0.2s;
        }

        .quest-item:hover {
            background-color: rgba(212, 175, 55, 0.2);
        }

        .quest-status {
            display: inline-block;
            padding: 2px 8px;
            border-radius: 3px;
            font-size: 10px;
            font-weight: bold;
            margin-left: 10px;
        }

        .quest-status.available {
            background-color: rgba(52, 152, 219, 0.3);
            color: var(--info);
        }

        .quest-status.active {
            background-color: rgba(243, 156, 18, 0.3);
            color: var(--warning);
        }

        .quest-status.completed {
            background-color: rgba(46, 204, 113, 0.3);
            color: var(--success);
        }

        .quest-title {
            color: var(--accent);
            font-weight: bold;
            margin-bottom: 5px;
        }

        .quest-desc {
            color: var(--text-dim);
            font-size: 11px;
            margin-bottom: 5px;
        }

        .quest-reward {
            color: var(--success);
            font-size: 11px;
            margin-top: 5px;
        }

        .quest-progress {
            color: var(--text-dim);
            font-size: 10px;
            margin-top: 5px;
        }

        .quest-dialog {
            background-color: rgba(0, 0, 0, 0.3);
            border-left: 3px solid var(--accent);
            padding: 6px 10px;
            margin: 6px 0;
            font-size: 11px;
            color: #c8b88a;
            line-height: 1.5;
            border-radius: 0 4px 4px 0;
        }

        .quest-npc-name {
            color: var(--accent);
            font-weight: bold;
            font-style: normal;
        }

        .quest-accept-hint {
            color: var(--info);
            font-size: 10px;
            margin-top: 5px;
            opacity: 0.8;
        }

        .skill-item {
            background-color: rgba(212, 175, 55, 0.1);
            border: 1px solid var(--accent);
            padding: 10px;
            margin: 8px 0;
            border-radius: 4px;
        }

        .skill-name {
            color: var(--accent);
            font-weight: bold;
            margin-bottom: 5px;
        }

        .skill-level {
            color: var(--text);
            font-size: 12px;
            margin-bottom: 5px;
        }

        .skill-xp-bar {
            width: 100%;
            height: 15px;
            background-color: rgba(0, 0, 0, 0.3);
            border: 1px solid var(--accent);
            border-radius: 3px;
            overflow: hidden;
            margin-bottom: 5px;
        }

        .skill-xp-fill {
            height: 100%;
            background: linear-gradient(90deg, var(--info), #2980b9);
            width: 0%;
            transition: width 0.3s;
        }

        .skill-xp-text {
            color: var(--text-dim);
            font-size: 10px;
        }

        .skill-action-btn {
            background: linear-gradient(135deg, rgba(212,175,55,0.2), rgba(212,175,55,0.05));
            border: 1px solid var(--accent);
            color: var(--accent);
            padding: 4px 10px;
            cursor: pointer;
            font-family: 'Courier New', monospace;
            font-size: 10px;
            font-weight: bold;
            border-radius: 3px;
            transition: all 0.2s;
            margin-top: 3px;
            touch-action: manipulation;
        }

        .skill-action-btn:hover {
            background: rgba(212,175,55,0.3);
        }

        .skill-btn-disabled {
            opacity: 0.4;
            cursor: not-allowed;
            border-color: var(--text-dim);
            color: var(--text-dim);
        }

        /* ── Gathering zone banner (Skills tab) ────────────────────── */
        .gather-zone-banner {
            background: rgba(46, 204, 113, 0.08);
            border: 1px solid rgba(46, 204, 113, 0.35);
            border-radius: 4px;
            padding: 7px 10px;
            margin-bottom: 12px;
            font-size: 11px;
            display: flex;
            align-items: center;
            gap: 6px;
            flex-wrap: wrap;
        }
        .gather-zone-banner .zone-name-label {
            color: var(--success);
            font-weight: bold;
        }
        .gather-zone-banner .zone-travel-hint {
            color: var(--text-dim);
            font-size: 9px;
            margin-left: auto;
        }

        /* ── Per-skill yield hint ───────────────────────────────────── */
        .skill-yields-here {
            color: var(--success);
            font-size: 9px;
            margin-top: 4px;
            opacity: 0.85;
        }
        .skill-yields-none {
            color: var(--text-dim);
            font-size: 9px;
            margin-top: 4px;
            opacity: 0.7;
        }
        /* ── Leaderboard ── */
        .lb-tabs {
            display: flex;
            gap: 4px;
            margin-bottom: 8px;
            flex-wrap: wrap;
        }
        .lb-tab-btn {
            background: transparent;
            border: 1px solid rgba(212,175,55,0.3);
            color: #888;
            font-size: 10px;
            padding: 4px 8px;
            cursor: pointer;
            font-family: inherit;
            letter-spacing: 0.04em;
            transition: all 0.15s;
        }
        .lb-tab-btn:hover { color: var(--gold); border-color: rgba(212,175,55,0.6); }
        .lb-tab-btn.active {
            color: var(--gold);
            border-color: var(--gold);
            background: rgba(212,175,55,0.08);
        }
        .lb-table {
            width: 100%;
            border-collapse: collapse;
            font-size: 11px;
            margin-top: 4px;
        }
        .lb-table th {
            color: var(--gold);
            text-align: left;
            padding: 4px 6px;
            border-bottom: 1px solid rgba(212,175,55,0.3);
            font-size: 10px;
            letter-spacing: 0.05em;
        }
        .lb-table td {
            padding: 5px 6px;
            border-bottom: 1px solid rgba(255,255,255,0.04);
            color: #ccc;
        }
        .lb-table tr:hover td { background: rgba(212,175,55,0.06); }
        .lb-rank {
            color: var(--gold);
            font-weight: bold;
            width: 28px;
        }
        .lb-rank-1 { color: #ffd700; }
        .lb-rank-2 { color: #c0c0c0; }
        .lb-rank-3 { color: #cd7f32; }
        .lb-name  { color: #e8dcc8; font-weight: bold; }
        .lb-class { color: #9ac; font-size: 10px; }
        .lb-num   { text-align: right; color: #ccc; }
        .lb-gold-num { text-align: right; color: var(--gold); }
        .lb-deaths-zero { color: #5fa; }
        .lb-deaths-high { color: #f88; }
        .lb-you td { background: rgba(212,175,55,0.1) !important; }
        .lb-refresh {
            margin-top: 10px;
            background: transparent;
            border: 1px solid rgba(212,175,55,0.4);
            color: var(--gold);
            font-size: 10px;
            padding: 4px 12px;
            cursor: pointer;
            font-family: inherit;
            letter-spacing: 0.05em;
        }
        .lb-refresh:hover { background: rgba(212,175,55,0.1); }
        .lb-empty { color: #666; font-size: 11px; padding: 16px 0; text-align: center; }
        .lb-season-label { color: #888; font-size: 10px; margin-bottom: 6px; }
        .lb-title-sub { color: #9ac; font-size: 9px; font-style: italic; display: block; margin-top: 1px; }

        /* ── Achievement toast ── */
        #achievement-toasts {
            position: fixed;
            bottom: 20px;
            right: 20px;
            display: flex;
            flex-direction: column;
            gap: 8px;
            z-index: 9999;
            pointer-events: none;
        }
        .ach-toast {
            background: linear-gradient(135deg, rgba(20,15,5,0.97), rgba(40,30,10,0.97));
            border: 1px solid var(--gold);
            color: #e8dcc8;
            font-family: inherit;
            font-size: 11px;
            padding: 10px 14px;
            min-width: 220px;
            max-width: 280px;
            box-shadow: 0 0 16px rgba(212,175,55,0.4);
            animation: ach-slide-in 0.3s ease, ach-fade-out 0.4s ease 3.6s forwards;
        }
        .ach-toast-header { color: var(--gold); font-size: 9px; letter-spacing: 0.1em; margin-bottom: 4px; }
        .ach-toast-name   { font-weight: bold; font-size: 12px; }
        .ach-toast-desc   { color: #999; font-size: 10px; margin-top: 2px; }
        @keyframes ach-slide-in  { from { transform: translateX(120%); opacity:0; } to { transform: translateX(0); opacity:1; } }
        @keyframes ach-fade-out  { from { opacity:1; } to { opacity:0; } }

        /* ── Achievement stat tooltip (hover %) ────────────────────────── */
        #ach-stat-tooltip {
            position: fixed;
            z-index: 10000;
            pointer-events: none;
            display: none;
            background: rgba(10,8,5,0.96);
            border: 1px solid rgba(212,175,55,0.45);
            border-radius: 4px;
            padding: 6px 10px;
            font-size: 10px;
            color: #b8a890;
            white-space: nowrap;
            box-shadow: 0 2px 12px rgba(0,0,0,0.7);
            font-family: inherit;
        }
        #ach-stat-tooltip .ast-pct { color: var(--gold); font-weight: bold; }
        #ach-stat-tooltip .ast-rare { color: #9b59b6; font-weight: bold; }

        /* ── Mail tab ───────────────────────────────────────────────────── */
        .mail-unread-badge {
            display: inline-block;
            background: #c0392b;
            color: #fff;
            font-size: 9px;
            font-weight: bold;
            border-radius: 8px;
            padding: 1px 5px;
            margin-left: 4px;
            vertical-align: middle;
            line-height: 14px;
            min-width: 14px;
            text-align: center;
        }
        .mail-list { display: flex; flex-direction: column; gap: 8px; }
        .mail-item {
            border: 1px solid rgba(212,175,55,0.25);
            border-radius: 4px;
            padding: 10px 12px;
            background: rgba(212,175,55,0.04);
            cursor: pointer;
            transition: background 0.15s, border-color 0.15s;
        }
        .mail-item:hover { background: rgba(212,175,55,0.1); border-color: rgba(212,175,55,0.5); }
        .mail-item.unread { border-left: 3px solid var(--accent); }
        .mail-item.system-mail { border-left: 3px solid #8e44ad; }
        .mail-item.system-mail.unread { border-left: 3px solid #e74c3c; }
        .mail-item-header {
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            gap: 8px;
            margin-bottom: 4px;
        }
        .mail-item-sender {
            font-size: 10px;
            color: #9ac;
            font-weight: bold;
            white-space: nowrap;
        }
        .mail-item-sender.system { color: #b39ddb; }
        .mail-item-date { font-size: 9px; color: var(--text-dim); white-space: nowrap; }
        .mail-item-subject {
            font-size: 12px;
            color: var(--text);
            font-weight: bold;
            margin-bottom: 2px;
        }
        .mail-item.unread .mail-item-subject { color: var(--accent); }
        .mail-item-preview { font-size: 10px; color: var(--text-dim); }
        /* Expanded body */
        .mail-body {
            margin-top: 10px;
            padding-top: 10px;
            border-top: 1px solid rgba(212,175,55,0.2);
            font-size: 11px;
            color: var(--text);
            line-height: 1.6;
            white-space: pre-wrap;
            display: none;
        }
        .mail-item.expanded .mail-body { display: block; }
        .mail-empty { color: var(--text-dim); font-size: 12px; text-align: center; padding: 30px 0; }
        .mail-refresh-btn {
            background: transparent;
            border: 1px solid rgba(212,175,55,0.4);
            color: var(--accent);
            font-family: inherit;
            font-size: 10px;
            padding: 5px 14px;
            cursor: pointer;
            border-radius: 3px;
            margin-bottom: 12px;
            transition: background 0.2s;
        }
        .mail-refresh-btn:hover { background: rgba(212,175,55,0.1); }

        /* ── Achievement panel (in leaderboard sub-tab) ── */
        .ach-panel { margin-top: 4px; }
        .ach-title-strip {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 8px;
            flex-wrap: wrap;
            gap: 6px;
        }
        .ach-equipped-label { color: #9ac; font-size: 10px; }
        .ach-equipped-val   { color: var(--gold); font-weight: bold; font-size: 11px; }
        .ach-remove-btn {
            background: transparent;
            border: 1px solid rgba(255,100,100,0.4);
            color: #f88;
            font-size: 9px;
            padding: 2px 8px;
            cursor: pointer;
            font-family: inherit;
        }
        .ach-remove-btn:hover { background: rgba(255,100,100,0.1); }
        .ach-category-label {
            color: var(--gold);
            font-size: 10px;
            letter-spacing: 0.06em;
            margin: 10px 0 4px;
            border-bottom: 1px solid rgba(212,175,55,0.2);
            padding-bottom: 2px;
        }
        .ach-grid {
            display: flex;
            flex-direction: column;
            gap: 3px;
        }
        .ach-row {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 4px 6px;
            border-radius: 2px;
            font-size: 11px;
        }
        .ach-row.earned { background: rgba(212,175,55,0.06); }
        .ach-row.locked { opacity: 0.38; filter: grayscale(0.6); }
        .ach-icon  { font-size: 14px; width: 18px; text-align: center; flex-shrink: 0; }
        .ach-info  { flex: 1; min-width: 0; }
        .ach-name  { color: #e8dcc8; font-weight: bold; font-size: 11px; }
        .ach-desc  { color: #777; font-size: 9px; }
        .ach-date  { color: #555; font-size: 9px; white-space: nowrap; }
        .ach-equip-btn {
            background: transparent;
            border: 1px solid rgba(212,175,55,0.5);
            color: var(--gold);
            font-size: 9px;
            padding: 2px 7px;
            cursor: pointer;
            font-family: inherit;
            white-space: nowrap;
        }
        .ach-equip-btn:hover  { background: rgba(212,175,55,0.1); }
        .ach-equip-btn.active { border-color: #5fa; color: #5fa; cursor: default; }

        .skill-cooldown-hint {
            color: var(--info);
            font-size: 9px;
            margin-top: 3px;
            opacity: 0.85;
        }

        .recipe-list {
            display: flex;
            flex-direction: column;
            gap: 4px;
            text-align: left;
        }

        .recipe-row {
            display: flex;
            align-items: center;
            gap: 8px;
            flex-wrap: wrap;
        }

        .recipe-name {
            color: var(--accent);
            font-size: 11px;
            font-weight: bold;
            min-width: 110px;
        }

        /* ── Crafting Skill Orb Grid ── */
        .crafting-orb-grid {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 10px;
            padding: 4px 0;
        }

        .crafting-orb {
            display: flex;
            flex-direction: column;
            align-items: center;
            padding: 14px 8px 12px;
            background: var(--bg-panel, #0d0b08);
            border: 1px solid var(--border-subtle, #1e1a14);
            border-radius: 2px;
            cursor: pointer;
            transition: border-color 0.2s, background 0.2s, transform 0.15s;
        }
        .crafting-orb:hover:not(.crafting-orb--locked) {
            border-color: var(--orb-accent);
            background: var(--bg-panel-hover, #111009);
            transform: translateY(-2px);
        }
        .crafting-orb--locked {
            opacity: 0.28;
            cursor: not-allowed;
            filter: grayscale(1);
        }

        .crafting-orb__ring-wrap {
            position: relative;
            width: 56px;
            height: 56px;
            margin-bottom: 10px;
        }
        .crafting-orb__ring-wrap svg {
            width: 56px;
            height: 56px;
            transform: rotate(-90deg);
        }
        .crafting-orb__ring-icon {
            position: absolute;
            top: 50%; left: 50%;
            transform: translate(-50%, -50%);
            font-size: 20px;
            filter: drop-shadow(0 0 5px var(--orb-accent));
        }
        .crafting-orb__name {
            font-size: 10px;
            font-weight: 600;
            color: var(--text-primary, #d8cbb8);
            text-align: center;
            margin-bottom: 3px;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }
        .crafting-orb__level {
            font-family: monospace;
            font-size: 10px;
            color: var(--orb-accent);
            margin-bottom: 2px;
        }
        .crafting-orb__xp {
            font-family: monospace;
            font-size: 9px;
            color: var(--text-dim, #5a5040);
            text-align: center;
        }

        /* ── Crafting Detail View ── */
        .crafting-detail {
            display: none;
            flex-direction: column;
        }
        .crafting-detail--visible {
            display: flex;
        }

        .crafting-detail__header {
            display: flex;
            align-items: center;
            gap: 14px;
            padding: 14px 16px;
            background: var(--bg-panel, #0d0b08);
            border: 1px solid var(--border-subtle, #1e1a14);
            border-bottom: 1px solid var(--border-dim, #2a2520);
            margin-bottom: 0;
        }

        .crafting-detail__back {
            font-size: 10px;
            letter-spacing: 2px;
            color: var(--text-dim, #5a5040);
            cursor: pointer;
            padding: 5px 10px;
            border: 1px solid var(--border-dim, #2a2520);
            background: transparent;
            text-transform: uppercase;
            transition: color 0.2s, border-color 0.2s;
            flex-shrink: 0;
        }
        .crafting-detail__back:hover {
            color: var(--gold, #c8a96e);
            border-color: var(--gold, #c8a96e);
        }

        .crafting-detail__meta { flex: 1; min-width: 0; }
        .crafting-detail__skill-name {
            font-size: 14px;
            font-weight: 700;
            color: var(--text-primary, #e8e0d0);
            margin-bottom: 3px;
        }
        .crafting-detail__xp-bar {
            height: 3px;
            background: #1a1510;
            width: 100%;
            margin-bottom: 3px;
        }
        .crafting-detail__xp-fill { height: 100%; }
        .crafting-detail__xp-text {
            font-family: monospace;
            font-size: 10px;
            color: var(--text-dim, #5a5040);
        }

        .crafting-recipe-section-label {
            font-size: 9px;
            letter-spacing: 3px;
            text-transform: uppercase;
            color: var(--text-dim, #3a3228);
            padding: 9px 16px 5px;
            background: #0b0908;
            border-bottom: 1px solid var(--border-subtle, #1e1a14);
        }

        .crafting-recipe-row {
            display: grid;
            grid-template-columns: 30px 1fr auto;
            align-items: center;
            gap: 10px;
            padding: 10px 16px;
            background: var(--bg-panel, #0d0b08);
            border-bottom: 1px solid var(--border-subtle, #1e1a14);
            transition: background 0.15s;
        }
        .crafting-recipe-row:last-child { border-bottom: none; }
        .crafting-recipe-row:hover:not(.crafting-recipe-row--locked) {
            background: #131109;
            cursor: pointer;
        }
        .crafting-recipe-row--locked { opacity: 0.35; }

        .crafting-recipe-row__icon { font-size: 18px; text-align: center; }
        .crafting-recipe-row__name {
            font-size: 11px;
            font-weight: 600;
            color: var(--text-primary, #d8cbb8);
            margin-bottom: 3px;
            cursor: help;
        }
        .crafting-recipe-row__name--dim { color: var(--text-dim, #3a3228); }
        .crafting-recipe-row__ings { display: flex; flex-wrap: wrap; gap: 5px; }
        .crafting-ingredient {
            display: flex;
            align-items: center;
            gap: 3px;
            font-family: monospace;
            font-size: 10px;
            color: var(--text-dim, #5a5040);
        }
        .crafting-ingredient--have { color: #7ec99e; }
        .crafting-ingredient--miss { color: #c87070; }

        .crafting-craft-btn {
            font-size: 9px;
            letter-spacing: 1.5px;
            padding: 5px 10px;
            border: 1px solid var(--gold, #c8a96e);
            background: transparent;
            color: var(--gold, #c8a96e);
            cursor: pointer;
            white-space: nowrap;
            text-transform: uppercase;
            transition: background 0.2s;
            flex-shrink: 0;
        }
        .crafting-craft-btn:hover:not(.crafting-craft-btn--off) {
            background: rgba(200,169,110,0.12);
        }
        .crafting-craft-btn--off {
            border-color: var(--text-dim, #3a3228);
            color: var(--text-dim, #3a3228);
            cursor: default;
        }
        .crafting-craft-btn--req {
            border-color: var(--text-dim, #3a3228);
            color: var(--text-dim, #3a3228);
            cursor: default;
            font-size: 8px;
        }

        @keyframes craftRowFlash {
            0%   { background: rgba(200,169,110,0.16); }
            100% { background: var(--bg-panel, #0d0b08); }
        }
        .crafting-recipe-row--flashing {
            animation: craftRowFlash 0.45s ease;
        }

        .chat-box {
            background-color: rgba(0, 0, 0, 0.3);
            border: 1px solid var(--accent);
            border-radius: 4px;
            display: flex;
            flex-direction: column;
            height: 100%;
            margin-bottom: 10px;
        }

        .chat-messages {
            flex: 1;
            overflow-y: auto;
            padding: 10px;
            font-size: 11px;
            line-height: 1.4;
        }

        .chat-message {
            margin-bottom: 8px;
            padding-bottom: 5px;
            border-bottom: 1px solid rgba(212, 175, 55, 0.2);
        }

        .chat-message:last-child {
            border-bottom: none;
        }

        .chat-player {
            color: var(--accent);
            font-weight: bold;
        }

        .chat-text {
            color: var(--text);
            word-break: break-word;
        }

        .chat-input-area {
            padding: 10px;
            border-top: 1px solid var(--accent);
            display: flex;
            gap: 5px;
        }

        .chat-input {
            flex: 1;
            padding: 8px;
            background-color: rgba(0, 0, 0, 0.3);
            border: 1px solid var(--accent);
            border-radius: 3px;
            color: var(--text);
            font-family: 'Courier New', monospace;
            font-size: 11px;
        }

        .chat-input:focus {
            outline: none;
            box-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
        }

        .chat-send {
            padding: 8px 15px;
            background-color: var(--secondary);
            color: var(--accent);
            border: 1px solid var(--accent);
            border-radius: 3px;
            cursor: pointer;
            font-family: 'Courier New', monospace;
            font-weight: bold;
            transition: all 0.2s;
        }

        .chat-send:hover {
            background-color: rgba(212, 175, 55, 0.2);
        }

        /* ── Global / Zone Chat Panel (left sidebar) ────────────── */
        .global-chat-panel {
            margin-top: 10px;
            background-color: rgba(0, 0, 0, 0.3);
            border: 1px solid var(--accent);
            border-radius: 4px;
            display: flex;
            flex-direction: column;
            height: 280px;
            min-height: 200px;
        }

        .global-chat-header {
            display: flex;
            border-bottom: 1px solid var(--accent);
            flex-shrink: 0;
        }

        .global-chat-header .chat-tab {
            flex: 1;
            padding: 6px 0;
            background: transparent;
            color: var(--text-dim);
            border: none;
            border-bottom: 2px solid transparent;
            cursor: pointer;
            font-family: 'Courier New', monospace;
            font-size: 11px;
            font-weight: bold;
            text-transform: uppercase;
            letter-spacing: 0.05em;
            transition: all 0.2s;
        }

        .global-chat-header .chat-tab:hover {
            color: var(--text);
            background: rgba(212, 175, 55, 0.08);
        }

        .global-chat-header .chat-tab.active {
            color: var(--accent);
            border-bottom-color: var(--accent);
            background: rgba(212, 175, 55, 0.1);
        }

        .global-chat-messages {
            flex: 1;
            overflow-y: auto;
            padding: 8px;
            font-size: 11px;
            line-height: 1.4;
        }

        .global-chat-msg {
            margin-bottom: 6px;
            padding-bottom: 4px;
            border-bottom: 1px solid rgba(212, 175, 55, 0.12);
        }

        .global-chat-msg:last-child {
            border-bottom: none;
        }

        .global-chat-msg .gc-zone {
            color: var(--text-dim);
            font-size: 10px;
            margin-right: 4px;
        }

        .global-chat-msg .gc-name {
            color: var(--accent);
            font-weight: bold;
        }

        .global-chat-msg .gc-text {
            color: var(--text);
            word-break: break-word;
        }

        .global-chat-input-area {
            padding: 6px 8px;
            border-top: 1px solid var(--accent);
            display: flex;
            gap: 4px;
            flex-shrink: 0;
        }

        .global-chat-input {
            flex: 1;
            padding: 6px 8px;
            background-color: rgba(0, 0, 0, 0.3);
            border: 1px solid var(--accent);
            border-radius: 3px;
            color: var(--text);
            font-family: 'Courier New', monospace;
            font-size: 11px;
        }

        .global-chat-input:focus {
            outline: none;
            box-shadow: 0 0 8px rgba(212, 175, 55, 0.3);
        }

        .global-chat-send {
            padding: 6px 12px;
            background-color: var(--secondary);
            color: var(--accent);
            border: 1px solid var(--accent);
            border-radius: 3px;
            cursor: pointer;
            font-family: 'Courier New', monospace;
            font-weight: bold;
            font-size: 11px;
            transition: all 0.2s;
        }

        .global-chat-send:hover {
            background-color: rgba(212, 175, 55, 0.2);
        }

        .activity-feed {
            margin-top: 15px;
            border-top: 2px solid var(--accent);
            padding-top: 10px;
        }

        .activity-item {
            background-color: rgba(212, 175, 55, 0.1);
            border-left: 3px solid var(--accent);
            padding: 8px;
            margin-bottom: 8px;
            font-size: 11px;
            border-radius: 2px;
            color: var(--text);
        }

        .activity-player {
            color: var(--accent);
            font-weight: bold;
        }

        .activity-event {
            color: var(--success);
        }

        .online-players {
            margin-top: 15px;
            border-top: 2px solid var(--accent);
            padding-top: 10px;
        }

        .online-header {
            color: var(--accent);
            font-size: 12px;
            font-weight: bold;
            margin-bottom: 8px;
        }

        .player-item {
            background-color: rgba(46, 204, 113, 0.1);
            border-left: 3px solid var(--success);
            padding: 6px 8px;
            margin-bottom: 6px;
            font-size: 11px;
            border-radius: 2px;
            color: var(--text);
        }

        .player-name {
            color: var(--success);
            font-weight: bold;
        }

        .player-class {
            color: var(--text-dim);
            font-size: 10px;
        }

        /* ── Shop two-column layout ──────────────────────────────────── */
        .shop-layout {
            display: flex;
            gap: 16px;
            align-items: flex-start;
        }

        /* ── Mercenary Guild ── */
        .merc-active-banner {
            display: flex;
            align-items: center;
            justify-content: space-between;
            background: rgba(212,175,55,0.10);
            border: 1px solid var(--accent);
            border-radius: 4px;
            padding: 8px 12px;
            margin-bottom: 10px;
            font-size: 13px;
            color: var(--accent);
        }
        .merc-grid {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }
        .merc-card {
            display: flex;
            align-items: center;
            gap: 12px;
            background: rgba(212,175,55,0.07);
            border: 1px solid rgba(212,175,55,0.4);
            border-radius: 4px;
            padding: 10px 12px;
            transition: border-color 0.15s, background 0.15s;
        }
        .merc-card:hover { background: rgba(212,175,55,0.14); }
        .merc-card-active {
            border-color: var(--success);
            background: rgba(46,204,113,0.08);
        }
        .merc-icon { font-size: 24px; flex-shrink: 0; }
        .merc-info { flex: 1; min-width: 0; }
        .merc-name { color: var(--accent); font-weight: bold; margin-bottom: 2px; }
        .merc-flavor { color: var(--text-dim); font-size: 10px; margin-bottom: 3px; }
        .merc-stats { color: var(--text-dim); font-size: 11px; }
        .merc-hire-col { text-align: right; flex-shrink: 0; }
        .shop-col {
            flex: 1;
            min-width: 0;
        }

        .shop-item {
            background-color: rgba(212, 175, 55, 0.1);
            border: 1px solid var(--accent);
            padding: 10px;
            margin: 8px 0;
            border-radius: 4px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            cursor: pointer;
            transition: border-color 0.15s, background-color 0.15s;
        }

        .shop-item:hover {
            background-color: rgba(212, 175, 55, 0.18);
        }

        /* Highlighted selection — mirrors zone-select active style */
        .shop-item.selected {
            border-color: var(--info);
            background-color: rgba(52, 152, 219, 0.12);
            box-shadow: 0 0 6px rgba(52, 152, 219, 0.25);
        }

        .shop-item-info {
            flex: 1;
        }

        .shop-item-name {
            color: var(--accent);
            font-weight: bold;
            margin-bottom: 3px;
        }

        .shop-item-desc {
            color: var(--text-dim);
            font-size: 10px;
            margin-bottom: 5px;
        }

        .shop-item-price {
            color: var(--warning);
            font-weight: bold;
            font-size: 12px;
        }

        .shop-buttons {
            display: flex;
            gap: 5px;
        }

        .buy-btn {
            padding: 6px 12px;
            background-color: var(--secondary);
            color: var(--success);
            border: 1px solid var(--success);
            border-radius: 3px;
            cursor: pointer;
            font-family: 'Courier New', monospace;
            font-size: 12px;
            font-weight: bold;
            transition: all 0.2s;
        }
        .buy-btn:hover { background-color: rgba(46,204,113,0.15); }

        .sell-btn {
            padding: 6px 12px;
            background-color: var(--secondary);
            color: var(--warning);
            border: 1px solid var(--warning);
            border-radius: 3px;
            cursor: pointer;
            font-family: 'Courier New', monospace;
            font-size: 10px;
            font-weight: bold;
            transition: all 0.2s;
        }

        .sell-btn:hover {
            background-color: rgba(243, 156, 18, 0.15);
        }

        .modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.7);
            z-index: 1000;
            align-items: center;
            justify-content: center;
        }

        .modal.active {
            display: flex;
        }

        .modal-content {
            background-color: var(--secondary);
            border: 3px solid var(--accent);
            padding: 30px;
            border-radius: 8px;
            max-width: 500px;
            max-height: 90vh;
            overflow-y: auto;
            box-shadow: 0 0 30px rgba(212, 175, 55, 0.2);
            scrollbar-width: thin;
            scrollbar-color: var(--accent) rgba(255,255,255,0.05);
        }
        .modal-content::-webkit-scrollbar { width: 6px; }
        .modal-content::-webkit-scrollbar-track { background: rgba(255,255,255,0.05); border-radius: 3px; }
        .modal-content::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 3px; }

        .modal-title {
            color: var(--accent);
            font-size: 24px;
            font-weight: bold;
            margin-bottom: 20px;
            text-align: center;
        }

        .modal-form {
            display: flex;
            flex-direction: column;
            gap: 15px;
        }

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

        .form-label {
            color: var(--accent);
            font-size: 14px;
            font-weight: bold;
        }

        .form-input {
            padding: 10px;
            background-color: rgba(0, 0, 0, 0.3);
            border: 1px solid var(--accent);
            color: var(--text);
            font-family: 'Courier New', monospace;
            border-radius: 4px;
        }

        .form-input:focus {
            outline: none;
            box-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
        }

        .class-selector {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 15px;
            margin: 20px 0;
        }

        .class-option {
            background-color: rgba(212, 175, 55, 0.1);
            border: 2px solid var(--accent);
            padding: 15px;
            border-radius: 4px;
            cursor: pointer;
            transition: all 0.2s;
            text-align: center;
        }

        .class-option:hover {
            background-color: rgba(212, 175, 55, 0.2);
        }

        .class-option.selected {
            background-color: rgba(212, 175, 55, 0.3);
            box-shadow: 0 0 20px rgba(212, 175, 55, 0.4);
        }

        .class-name {
            color: var(--accent);
            font-size: 16px;
            font-weight: bold;
            margin-bottom: 10px;
        }

        .class-stats {
            color: var(--text-dim);
            font-size: 11px;
            line-height: 1.5;
            text-align: left;
        }

        .zone-select {
            background-color: rgba(212, 175, 55, 0.1);
            border: 1px solid var(--accent);
            padding: 10px;
            margin: 8px 0;
            border-radius: 4px;
            cursor: pointer;
            transition: all 0.2s;
        }

        .zone-select:hover {
            background-color: rgba(212, 175, 55, 0.2);
        }

        .zone-name {
            color: var(--accent);
            font-weight: bold;
            margin-bottom: 3px;
        }

        .zone-level {
            color: var(--text-dim);
            font-size: 10px;
        }

        .spell-item {
            background-color: rgba(52, 152, 219, 0.1);
            border: 1px solid var(--info);
            padding: 10px;
            margin: 8px 0;
            border-radius: 4px;
            cursor: pointer;
            transition: all 0.2s;
        }

        .spell-item:hover {
            background-color: rgba(52, 152, 219, 0.2);
        }

        .spell-item:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

        .spell-name {
            color: var(--info);
            font-weight: bold;
            margin-bottom: 5px;
        }

        .spell-info {
            color: var(--text-dim);
            font-size: 10px;
            line-height: 1.4;
        }

        .btn-modal-close {
            align-self: center;
            padding: 10px 20px;
            background-color: var(--secondary);
            color: var(--accent);
            border: 1px solid var(--accent);
            border-radius: 4px;
            cursor: pointer;
            font-family: 'Courier New', monospace;
            font-weight: bold;
            transition: all 0.2s;
            margin-top: 15px;
        }

        .btn-modal-close:hover {
            background-color: rgba(212, 175, 55, 0.2);
        }

        .footer {
            background-color: var(--secondary);
            border-top: 2px solid var(--accent);
            padding: 10px 20px;
            text-align: center;
            color: var(--text-dim);
            font-size: 11px;
        }

        .success-text {
            color: var(--success);
        }

        .danger-text {
            color: var(--danger);
        }

        .warning-text {
            color: var(--warning);
        }

        .info-text {
            color: var(--info);
        }

        .hidden {
            display: none;
        }

        .spinner {
            border: 3px solid rgba(212, 175, 55, 0.2);
            border-top: 3px solid var(--accent);
            border-radius: 50%;
            width: 30px;
            height: 30px;
            animation: spin 1s linear infinite;
            margin: 20px auto;
        }

        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        @keyframes screen-shake {
            0%   { transform: translateX(0); }
            15%  { transform: translateX(-6px); }
            30%  { transform: translateX(6px); }
            45%  { transform: translateX(-5px); }
            60%  { transform: translateX(5px); }
            75%  { transform: translateX(-3px); }
            90%  { transform: translateX(3px); }
            100% { transform: translateX(0); }
        }
        .anim-shake {
            animation: screen-shake 350ms ease-out;
        }

        @keyframes flash-red {
            0%   { background-color: transparent; }
            30%  { background-color: rgba(255, 0, 0, 0.4); }
            100% { background-color: transparent; }
        }
        @keyframes flash-green {
            0%   { background-color: transparent; }
            30%  { background-color: rgba(0, 200, 80, 0.35); }
            100% { background-color: transparent; }
        }
        .anim-flash-red {
            animation: flash-red 300ms ease-out;
            border-radius: 4px;
        }
        .anim-flash-green {
            animation: flash-green 300ms ease-out;
            border-radius: 4px;
        }

        .tooltip {
            position: relative;
            display: inline-block;
        }

        .tooltip .tooltiptext {
            visibility: hidden;
            width: 200px;
            background-color: var(--secondary);
            color: var(--text);
            text-align: left;
            border: 1px solid var(--accent);
            border-radius: 4px;
            padding: 8px;
            position: absolute;
            z-index: 1;
            bottom: 125%;
            left: 50%;
            margin-left: -100px;
            opacity: 0;
            transition: opacity 0.3s;
            font-size: 11px;
            line-height: 1.3;
        }

        .tooltip:hover .tooltiptext {
            visibility: visible;
            opacity: 1;
        }

        ::-webkit-scrollbar {
            width: 8px;
        }

        ::-webkit-scrollbar-track {
            background: var(--secondary);
        }

        ::-webkit-scrollbar-thumb {
            background: var(--accent);
            border-radius: 4px;
        }

        ::-webkit-scrollbar-thumb:hover {
            background: #e5c158;
        }

        /* ============ LOGIN SCREEN ============ */
        #login-screen {
            display: none;
            position: fixed;
            inset: 0;
            background: radial-gradient(ellipse at 50% 0%, #1e1e3a 0%, #0d0d1a 60%, #000 100%);
            z-index: 9999;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 32px;
            font-family: 'Courier New', monospace;
            overflow-y: auto;
            padding: 40px 20px;
        }
        .login-hero {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 20px;
            max-width: 700px;
            width: 100%;
        }
        .login-title-wrap {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 6px;
        }
        .login-title-deco {
            color: var(--accent);
            font-size: 13px;
            letter-spacing: 2px;
            opacity: 0.7;
        }
        #login-screen h1 {
            font-size: 46px;
            color: var(--accent);
            text-shadow: 0 0 20px rgba(212,175,55,0.6), 2px 2px 8px rgba(0,0,0,0.9);
            letter-spacing: 6px;
            margin: 0;
        }
        .login-subtitle {
            color: var(--text-dim);
            font-size: 13px;
            letter-spacing: 4px;
            text-transform: uppercase;
        }
        .login-lore {
            color: var(--text-dim);
            font-size: 14px;
            text-align: center;
            max-width: 520px;
            line-height: 1.7;
            border-left: 2px solid rgba(212,175,55,0.3);
            border-right: 2px solid rgba(212,175,55,0.3);
            padding: 10px 20px;
        }
        .login-features {
            display: flex;
            gap: 16px;
            flex-wrap: wrap;
            justify-content: center;
        }
        .login-feature {
            background: rgba(255,255,255,0.03);
            border: 1px solid rgba(212,175,55,0.2);
            padding: 14px 20px;
            min-width: 130px;
            text-align: center;
            flex: 1;
        }
        .login-feature-icon { font-size: 22px; margin-bottom: 6px; }
        .login-feature-name {
            color: var(--accent);
            font-size: 11px;
            letter-spacing: 2px;
            margin-bottom: 4px;
        }
        .login-feature-desc {
            color: var(--text-dim);
            font-size: 11px;
        }
        .login-card {
            background: rgba(22,33,62,0.8);
            border: 1px solid rgba(212,175,55,0.35);
            padding: 30px 40px;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 14px;
            max-width: 380px;
            width: 100%;
        }
        .login-card-title {
            color: var(--accent);
            font-size: 14px;
            letter-spacing: 3px;
            margin-bottom: 2px;
        }
        .login-card-sub {
            color: var(--text-dim);
            font-size: 12px;
            text-align: center;
            margin-bottom: 6px;
        }
        .login-btn {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 12px;
            padding: 14px 36px;
            border: 1px solid var(--accent);
            background: rgba(212,175,55,0.05);
            color: var(--accent);
            font-family: 'Courier New', monospace;
            font-size: 13px;
            font-weight: bold;
            cursor: pointer;
            letter-spacing: 1px;
            transition: all 0.2s;
            min-width: 280px;
        }
        .login-btn:hover {
            background: var(--accent);
            color: var(--primary);
        }
        .login-divider {
            color: var(--text-dim);
            font-size: 12px;
        }
        #login-status {
            color: var(--text-dim);
            font-size: 13px;
            min-height: 20px;
        }

        /* ============ COOKIE CONSENT ============ */
        #cookie-banner {
            display: none;
            position: fixed;
            bottom: 0;
            left: 0;
            right: 0;
            background: var(--secondary);
            border-top: 1px solid rgba(212,175,55,0.4);
            padding: 12px 24px;
            z-index: 10000;
            flex-direction: row;
            align-items: center;
            justify-content: space-between;
            gap: 16px;
            font-family: 'Courier New', monospace;
            font-size: 12px;
            flex-wrap: wrap;
        }
        #cookie-banner-text {
            color: var(--text-dim);
            flex: 1;
            min-width: 200px;
        }
        #cookie-banner-text a {
            color: var(--accent);
            text-decoration: underline;
            cursor: pointer;
        }
        .cookie-actions { display: flex; gap: 10px; flex-shrink: 0; }
        .cookie-btn {
            padding: 7px 20px;
            font-family: 'Courier New', monospace;
            font-size: 12px;
            font-weight: bold;
            letter-spacing: 1px;
            cursor: pointer;
            border: 1px solid var(--accent);
            transition: all 0.2s;
        }
        .cookie-accept { background: var(--accent); color: var(--primary); }
        .cookie-accept:hover { background: #e5c040; }
        .cookie-decline { background: transparent; color: var(--text-dim); border-color: var(--text-dim); }
        .cookie-decline:hover { color: var(--text); border-color: var(--text); }

        /* ─── Sidebar WoW-Style Character Sheet ────────────────────────────── */
        .char-sheet-header {
            text-align: center;
            padding-bottom: 8px;
            border-bottom: 1px solid rgba(212,175,55,0.3);
            margin-bottom: 8px;
        }
        .char-name-display {
            color: var(--accent);
            font-size: 14px;
            font-weight: bold;
        }
        .char-class-display { color: var(--text-dim); font-size: 11px; margin-top: 1px; }
        .char-zone-display  { color: var(--info);     font-size: 10px; margin-top: 2px; }

        .char-paper-doll {
            display: grid;
            grid-template-areas:
                "helmet   portrait  trinket"
                "mainhand portrait  offhand"
                ".        armor     ."
                ".        boots     .";
            grid-template-columns: 1fr auto 1fr;
            gap: 6px;
            margin: 6px 0 10px 0;
            align-items: center;
            justify-items: center;
        }
        .char-portrait-cell {
            grid-area: portrait;
            width: 58px;
            height: 58px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 34px;
            background: rgba(0,0,0,0.35);
            border: 2px solid rgba(212,175,55,0.3);
            border-radius: 50%;
            user-select: none;
        }
        .gear-slot {
            width: 54px;
            height: 54px;
            background: rgba(0,0,0,0.45);
            border: 2px solid rgba(212,175,55,0.4);
            border-radius: 6px;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: border-color 0.15s, background 0.15s;
            font-family: 'Courier New', monospace;
            text-align: center;
            padding: 3px 2px;
            position: relative;
            overflow: hidden;
            user-select: none;
        }
        .gear-slot:hover            { border-color: var(--accent); background: rgba(212,175,55,0.12); }
        .gear-slot.equipped         { border-color: var(--accent); background: rgba(212,175,55,0.1); }
        .gear-slot.drag-over        { border-color: var(--success) !important; background: rgba(46,204,113,0.2) !important; box-shadow: 0 0 8px rgba(46,204,113,0.4); }
        .gear-slot[data-slot="helmet"]   { grid-area: helmet; }
        .gear-slot[data-slot="mainhand"] { grid-area: mainhand; }
        .gear-slot[data-slot="offhand"]  { grid-area: offhand; }
        .gear-slot[data-slot="armor"]    { grid-area: armor; }
        .gear-slot[data-slot="boots"]    { grid-area: boots; }
        .gear-slot[data-slot="trinket"]  { grid-area: trinket; }
        .gear-slot.two-handed-locked { opacity: 0.4; cursor: not-allowed; border-style: dashed; }

        .gear-slot-icon       { font-size: 22px; line-height: 1; margin-bottom: 1px; }
        .gear-slot-empty-icon { font-size: 20px; opacity: 0.28; line-height: 1; margin-bottom: 1px; }
        .gear-slot-label      { color: var(--text-dim); font-size: 7.5px; text-transform: uppercase; letter-spacing: 0.4px; line-height: 1.2; }
        .gear-slot-name       { color: var(--accent); font-size: 7px; font-weight: bold; line-height: 1.2; max-height: 22px; overflow: hidden; word-break: break-word; padding: 0 2px; }
        .dragging             { opacity: 0.45 !important; }

        /* ─── Action Bar (sidebar section) ─────────────────────────────────── */
        .action-bar {
            border-top: 1px solid rgba(212,175,55,0.3);
            margin-top: 10px;
            padding-top: 4px;
        }
        .action-slots-grid {
            display: grid;
            grid-template-columns: repeat(2, 52px);
            gap: 8px;
            justify-content: center;
        }
        .action-slot {
            width: 52px;
            height: 52px;
            background: rgba(0,0,0,0.4);
            border: 2px solid rgba(212,175,55,0.35);
            border-radius: 6px;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: border-color 0.15s, background 0.15s;
            font-family: 'Courier New', monospace;
            text-align: center;
            padding: 3px 2px;
            position: relative;
            user-select: none;
        }
        .action-slot:hover          { border-color: var(--accent); background: rgba(212,175,55,0.15); }
        .action-slot.has-item       { border-color: var(--info); background: rgba(52,152,219,0.08); }
        .action-slot.has-item:hover { background: rgba(52,152,219,0.2); }
        .action-slot.drag-over      { border-color: var(--success) !important; background: rgba(46,204,113,0.2) !important; box-shadow: 0 0 8px rgba(46,204,113,0.4); }
        .action-slot-icon        { font-size: 21px; line-height: 1; }
        .action-slot-name        { color: var(--text-dim); font-size: 7px; margin-top: 1px; line-height: 1.1; overflow: hidden; max-height: 14px; word-break: break-word; padding: 0 1px; }
        .action-slot-qty         { position: absolute; bottom: 2px; right: 3px; background: rgba(0,0,0,0.78); color: var(--accent); font-size: 8px; font-weight: bold; padding: 0 2px; border-radius: 2px; line-height: 1.4; }
        .action-slot-key         { position: absolute; top: 1px; left: 3px; color: var(--text-dim); font-size: 8px; opacity: 0.5; font-family: 'Courier New', monospace; }
        .action-slot-empty       { font-size: 16px; opacity: 0.18; line-height: 1; }
        .action-slot-empty-label { color: var(--text-dim); font-size: 7px; opacity: 0.3; margin-top: 1px; }

        /* ─── Zone Minimap ─────────────────────────────────────────────────── */
        .minimap-panel {
            border-top: 1px solid rgba(212,175,55,0.3);
            padding: 4px 6px 6px 6px;
        }
        .minimap-toggle {
            font-size: 11px;
            color: var(--accent);
            cursor: pointer;
            text-align: center;
            letter-spacing: 1px;
            padding: 3px 0;
            user-select: none;
            font-family: 'Courier New', monospace;
        }
        .minimap-toggle:hover { color: #fff; }
        .minimap-body { padding-top: 4px; }
        .minimap-chain {
            display: flex;
            flex-direction: column;
            padding-left: 8px;
            border-left: 2px solid rgba(212,175,55,0.25);
            margin-left: 5px;
            gap: 2px;
        }
        .minimap-zone {
            display: flex;
            align-items: center;
            gap: 5px;
            padding: 3px 5px;
            border: 1px solid rgba(212,175,55,0.18);
            border-radius: 3px;
            cursor: pointer;
            font-size: 11px;
            color: var(--text-dim);
            background: rgba(0,0,0,0.2);
            position: relative;
            transition: border-color 0.15s, color 0.15s;
        }
        .minimap-zone:hover:not(.minimap-zone-locked) {
            border-color: rgba(212,175,55,0.5);
            color: var(--text);
        }
        .minimap-zone-current {
            border-color: var(--accent) !important;
            color: var(--accent) !important;
            background: rgba(212,175,55,0.08) !important;
            cursor: default;
        }
        .minimap-zone-locked {
            opacity: 0.38;
            cursor: not-allowed;
        }
        .minimap-zone-icon  { font-size: 12px; min-width: 14px; text-align: center; }
        .minimap-zone-info  { display: flex; flex-direction: column; flex: 1; min-width: 0; }
        .minimap-zone-name  { font-size: 10px; font-weight: bold; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
        .minimap-zone-level { font-size: 9px; opacity: 0.65; }
        .minimap-zone-marker { font-size: 9px; color: var(--accent); margin-left: auto; padding-left: 3px; flex-shrink: 0; }
        .minimap-zone-check  { font-size: 9px; color: #5a9; position: absolute; top: 2px; right: 3px; }

        /* ── Talent Tree ───────────────────────────────────────────────── */
        .talent-header          { display:flex; justify-content:space-between; align-items:center; margin-bottom:10px; }
        .talent-points-display  { background:rgba(212,175,55,0.12); border:1px solid rgba(212,175,55,0.4); border-radius:6px; padding:6px 12px; font-size:12px; color:var(--accent); font-weight:bold; }
        .talent-points-display span { color:var(--text-dim); font-size:10px; font-weight:normal; }
        .talent-trees           { display:flex; flex-direction:column; gap:12px; }
        .talent-tree            { background:rgba(0,0,0,0.25); border:1px solid rgba(212,175,55,0.2); border-radius:8px; padding:10px; }
        .talent-tree-title      { font-size:11px; font-weight:bold; color:var(--accent); text-transform:uppercase; letter-spacing:1px; margin-bottom:8px; padding-bottom:5px; border-bottom:1px solid rgba(212,175,55,0.2); }
        .talent-cards           { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
        .talent-card            { background:rgba(0,0,0,0.3); border:1px solid rgba(212,175,55,0.25); border-radius:6px; padding:8px; }
        .talent-card:hover      { border-color:rgba(212,175,55,0.55); }
        .talent-card-header     { display:flex; align-items:center; gap:6px; margin-bottom:4px; }
        .talent-icon            { font-size:16px; line-height:1; }
        .talent-name            { font-size:10px; font-weight:bold; color:var(--text-light); }
        .talent-desc            { font-size:9px; color:var(--text-dim); margin-bottom:6px; line-height:1.4; }
        .talent-rank-row        { display:flex; align-items:center; gap:6px; }
        .talent-rank-dots       { display:flex; gap:3px; flex:1; }
        .talent-rank-dot        { width:8px; height:8px; border-radius:50%; background:rgba(255,255,255,0.12); border:1px solid rgba(212,175,55,0.3); }
        .talent-rank-dot.filled { background:var(--accent); border-color:var(--accent); box-shadow:0 0 4px rgba(212,175,55,0.5); }
        .talent-btn             { font-size:14px; line-height:1; width:22px; height:22px; border:1px solid rgba(212,175,55,0.4); border-radius:4px; background:rgba(212,175,55,0.1); color:var(--accent); cursor:pointer; display:flex; align-items:center; justify-content:center; font-weight:bold; }
        .talent-btn:hover:not(:disabled) { background:rgba(212,175,55,0.25); border-color:var(--accent); }
        .talent-btn:disabled    { opacity:0.3; cursor:not-allowed; }
        .talent-refund-btn      { margin-top:10px; width:100%; padding:5px; background:rgba(231,76,60,0.1); border:1px solid rgba(231,76,60,0.35); border-radius:5px; color:var(--danger); font-size:10px; cursor:pointer; font-family:'Courier New',monospace; }
        .talent-refund-btn:hover { background:rgba(231,76,60,0.2); }
        .talent-locked-note     { font-size:10px; color:var(--text-dim); padding:8px 0; text-align:center; }

        /* ── Spec selection ─────────────────────────────────────────────── */
        .spec-section           { margin-bottom:12px; }
        .spec-section-title     { font-size:11px; color:var(--gold); font-weight:bold; margin-bottom:6px; text-transform:uppercase; letter-spacing:0.05em; }
        .spec-cards             { display:flex; gap:6px; flex-wrap:wrap; }
        .spec-card              { flex:1; min-width:90px; max-width:160px; padding:8px 6px; border:1px solid rgba(212,175,55,0.25); border-radius:6px; background:rgba(0,0,0,0.3); cursor:pointer; text-align:center; transition:all 0.15s; position:relative; }
        .spec-card:hover        { border-color:rgba(212,175,55,0.6); background:rgba(212,175,55,0.07); }
        .spec-card.spec-active  { border-color:var(--gold); background:rgba(212,175,55,0.12); box-shadow:0 0 8px rgba(212,175,55,0.25); }
        .spec-card-icon         { font-size:20px; margin-bottom:3px; }
        .spec-card-name         { font-size:10px; font-weight:bold; color:var(--text-light); margin-bottom:3px; }
        .spec-card-desc         { font-size:8px; color:var(--text-dim); line-height:1.3; }
        .spec-active-badge      { margin-top:4px; font-size:7px; font-weight:bold; color:var(--gold); letter-spacing:0.08em; }
        .spec-talents-section   { margin-bottom:12px; padding:8px; border:1px solid rgba(212,175,55,0.3); border-radius:6px; background:rgba(212,175,55,0.04); }

        /* ── Combat status bar (buffs / debuffs / DoT) ──────────────────── */
        .combat-status-bar      { display:flex; flex-wrap:wrap; gap:4px; min-height:4px; padding:2px 0 4px; }
        .combat-status-tag      { font-size:8px; padding:2px 5px; border:1px solid; border-radius:10px; white-space:nowrap; font-family:'Courier New',monospace; }

        /* ── Weapon mismatch warning ────────────────────────────────────── */
        .weapon-mismatch-warn   { font-size:9px; color:#ef5350; margin-top:3px; }
        .talent-next-point      { font-size:9px; color:var(--text-dim); text-align:right; }

        /* ── Auto-Harvest ──────────────────────────────────────────────── */
        .auto-harvest-section   { background:rgba(0,0,0,0.25); border:1px solid rgba(212,175,55,0.25); border-radius:8px; padding:10px; margin-bottom:12px; }
        .auto-harvest-title     { font-size:11px; font-weight:bold; color:var(--accent); text-transform:uppercase; letter-spacing:1px; margin-bottom:6px; }
        .auto-harvest-locked    { font-size:10px; color:var(--text-dim); padding:4px 0; }
        .auto-harvest-active    { background:rgba(46,204,113,0.08); border:1px solid rgba(46,204,113,0.3); border-radius:6px; padding:8px; }
        .auto-harvest-active-ttl { font-size:10px; color:var(--success); font-weight:bold; margin-bottom:4px; }
        .harvest-progress-bar   { height:8px; background:rgba(255,255,255,0.1); border-radius:4px; overflow:hidden; margin:4px 0; }
        .harvest-progress-fill  { height:100%; background:var(--success); border-radius:4px; transition:width 2s linear; }
        .harvest-time-left      { font-size:9px; color:var(--text-dim); }
        .harvest-claim-btn      { margin-top:6px; padding:5px 14px; background:rgba(46,204,113,0.15); border:1px solid rgba(46,204,113,0.4); border-radius:5px; color:var(--success); font-size:10px; cursor:pointer; font-family:'Courier New',monospace; }
        .harvest-claim-btn:hover { background:rgba(46,204,113,0.28); }
        .harvest-tiers          { display:grid; grid-template-columns:repeat(2,1fr); gap:6px; margin-top:6px; }
        .harvest-tier-btn       { padding:7px 4px; background:rgba(0,0,0,0.3); border:1px solid rgba(212,175,55,0.3); border-radius:5px; color:var(--accent); font-size:9px; text-align:center; cursor:pointer; font-family:'Courier New',monospace; line-height:1.5; }
        .harvest-tier-btn:hover:not(:disabled) { border-color:var(--accent); background:rgba(212,175,55,0.1); }
        .harvest-tier-btn:disabled { opacity:0.35; cursor:not-allowed; }
        .harvest-tier-cost      { color:var(--text-dim); font-size:8px; display:block; }
        .harvest-tier-eff       { color:#7fba7a; font-size:8px; display:block; }

        /* ── Character Select Modal ────────────────────────────────────── */
        .char-select-list       { display:flex; flex-direction:column; gap:8px; margin:12px 0; max-height:280px; overflow-y:auto; }
        .char-select-item       { display:flex; justify-content:space-between; align-items:center; padding:10px 12px; background:rgba(0,0,0,0.35); border:1px solid rgba(212,175,55,0.25); border-radius:6px; }
        .char-select-info       { display:flex; flex-direction:column; gap:2px; }
        .char-select-name       { font-size:13px; color:var(--text-light); font-weight:bold; }
        .char-select-meta       { font-size:10px; color:var(--text-dim); }
        .char-select-play-btn   { padding:5px 12px; background:rgba(212,175,55,0.15); border:1px solid rgba(212,175,55,0.5); border-radius:4px; color:var(--accent); font-size:10px; font-family:'Courier New',monospace; cursor:pointer; }
        .char-select-play-btn:hover { background:rgba(212,175,55,0.3); }
        .char-select-del-btn    { padding:5px 10px; background:rgba(231,76,60,0.1); border:1px solid rgba(231,76,60,0.4); border-radius:4px; color:var(--danger); font-size:10px; font-family:'Courier New',monospace; cursor:pointer; }
        .char-select-del-btn:hover  { background:rgba(231,76,60,0.25); }
        .char-select-actions    { display:flex; gap:8px; margin-top:8px; }
        .char-select-new-btn    { flex:1; padding:8px; background:rgba(46,204,113,0.1); border:1px solid rgba(46,204,113,0.4); border-radius:5px; color:var(--success); font-size:11px; cursor:pointer; font-family:'Courier New',monospace; }
        .char-select-new-btn:hover { background:rgba(46,204,113,0.2); }
        .char-select-logout-btn { flex:1; padding:8px; background:rgba(231,76,60,0.1); border:1px solid rgba(231,76,60,0.4); border-radius:5px; color:var(--danger); font-size:11px; cursor:pointer; font-family:'Courier New',monospace; }
        .char-select-logout-btn:hover { background:rgba(231,76,60,0.2); }

        /* ── Header switch button ──────────────────────────────────────── */
        .header-switch-btn      { font-size:10px; color:var(--text-dim); background:rgba(0,0,0,0.3); border:1px solid rgba(212,175,55,0.2); border-radius:4px; padding:3px 8px; cursor:pointer; font-family:'Courier New',monospace; align-self:center; white-space:nowrap; }
        .header-switch-btn:hover { color:var(--accent); border-color:var(--accent); }

        /* ============ MOBILE / RESPONSIVE ============ */
        #mobile-menu-btn {
            display: none;
            background: none;
            border: 1px solid rgba(212,175,55,0.4);
            color: var(--accent);
            font-size: 18px;
            line-height: 1;
            padding: 4px 9px;
            cursor: pointer;
            flex-shrink: 0;
            align-self: center;
        }
        #sidebar-overlay {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.65);
            z-index: 500;
        }
        #sidebar-overlay.active { display: block; }

        @media (max-width: 768px) {
            /* Show hamburger, let header wrap */
            #mobile-menu-btn { display: flex; align-items: center; }
            .header { padding: 8px 12px; flex-wrap: wrap; gap: 4px; }
            .header-title { font-size: 16px; flex: 1; }
            .header-stats { gap: 8px; font-size: 11px; width: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; }
            .bar-container { width: 70px; height: 15px; }
            .bar-text { font-size: 9px; top: 1px; }
            .stat-label { min-width: 24px; font-size: 10px; }
            .header-switch-btn { font-size: 9px; padding: 2px 6px; }

            /* Sidebar becomes a full-height drawer */
            .sidebar {
                position: fixed;
                top: 0;
                left: -290px;
                width: 280px;
                height: 100%;
                z-index: 600;
                transition: left 0.25s ease;
                min-width: unset;
                padding-top: 16px;
            }
            .sidebar.open { left: 0; }

            /* Tabs: single scrollable row */
            .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
            .tab-btn { flex-shrink: 0; font-size: 10px; padding: 10px 8px; min-width: 60px; }

            /* Login screen */
            #login-screen { padding: 20px 14px; gap: 18px; }
            #login-screen h1 { font-size: 26px; letter-spacing: 2px; }
            .login-title-deco { font-size: 9px; letter-spacing: 1px; }
            .login-subtitle { font-size: 11px; }
            .login-lore { font-size: 12px; padding: 8px 14px; }
            .login-features { gap: 8px; }
            .login-feature { min-width: 100px; padding: 10px 10px; }
            .login-feature-icon { font-size: 18px; }
            .login-card { padding: 20px 18px; }
            .login-btn { min-width: unset; width: 100%; font-size: 12px; padding: 12px 16px; }

            /* Cookie banner: stack */
            #cookie-banner { flex-direction: column; align-items: flex-start; padding: 12px 14px; }
            .cookie-actions { width: 100%; justify-content: flex-end; }

            /* Modals: full-width */
            .modal-content { width: 95vw; max-width: 95vw; margin: 0 auto; }
        }

        @media (max-width: 480px) {
            /* On very small phones hide the EXP bar to save space */
            .header-stats .stat-item:nth-child(2) { display: none; }
            #login-screen h1 { font-size: 22px; }
            .login-features { grid-template-columns: repeat(2, 1fr); display: grid; }
            .login-feature { min-width: unset; }
        }

        /* ── Sidebar Allocate Stats button ─────────────────────────────── */
        @keyframes allocGlow {
            0%   { box-shadow: 0 0 4px rgba(58,165,93,0.3); }
            50%  { box-shadow: 0 0 12px rgba(58,165,93,0.6); }
            100% { box-shadow: 0 0 4px rgba(58,165,93,0.3); }
        }

        #sidebar-alloc-wrap {
            margin: 6px 0;
            text-align: center;
        }

        #sidebar-alloc-btn {
            position: relative;
            width: 100%;
            background: linear-gradient(180deg, #2a4a3a, #1a3a2a);
            border: 1px solid #3aa55d;
            color: #3aa55d;
            border-radius: 4px;
            padding: 7px 10px;
            font-family: 'Courier New', monospace;
            font-size: 12px;
            font-weight: bold;
            letter-spacing: 0.08em;
            cursor: pointer;
            transition: background 0.15s, opacity 0.15s;
        }

        #sidebar-alloc-btn:hover:not(.alloc-dim) {
            background: linear-gradient(180deg, #335a46, #22472f);
        }

        #sidebar-alloc-btn.alloc-dim {
            border-color: #3a5a46;
            color: #5a8a6a;
            opacity: 0.6;
            cursor: default;
        }

        #sidebar-alloc-btn.alloc-glow {
            animation: allocGlow 2s ease-in-out infinite;
        }

        #sidebar-alloc-badge {
            position: absolute;
            top: -6px;
            right: -6px;
            background: #e53e3e;
            color: #fff;
            border-radius: 50%;
            width: 18px;
            height: 18px;
            font-size: 10px;
            font-weight: bold;
            display: flex;
            align-items: center;
            justify-content: center;
            pointer-events: none;
        }

        #sidebar-alloc-note {
            font-size: 10px;
            margin-top: 3px;
        }

        /* ── Class header bar ───────────────────────────────────────────── */
        #char-class-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            background: #1a2040;
            border: 1px solid #2a3060;
            border-radius: 4px;
            padding: 10px 14px;
            margin-bottom: 8px;
            gap: 10px;
        }

        .char-header-left {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .char-header-icon {
            width: 40px;
            height: 40px;
            border: 1px solid var(--accent);
            border-radius: 50%;
            background: #0d1428;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 20px;
            flex-shrink: 0;
        }

        .char-header-class-name {
            color: var(--accent);
            font-size: 14px;
            font-weight: bold;
            line-height: 1.2;
        }

        .char-header-spec {
            color: var(--text-dim);
            font-size: 10px;
            margin-top: 2px;
        }

        .char-header-flavor {
            color: var(--text-dim);
            font-size: 11px;
            font-style: italic;
            text-align: right;
            max-width: 55%;
            line-height: 1.4;
        }

        /* ── Player summary stat cards ──────────────────────────────────── */
        #char-summary-cards {
            display: grid;
            grid-template-columns: 1fr 1fr 1fr;
            gap: 8px;
            margin-bottom: 12px;
        }

        .char-summary-card {
            background: #1a2040;
            border: 1px solid #2a3060;
            border-radius: 4px;
            padding: 8px 6px;
            text-align: center;
        }

        .char-summary-value {
            color: var(--accent);
            font-size: 18px;
            font-weight: bold;
        }

        .char-summary-label {
            color: var(--text-dim);
            font-size: 9px;
            text-transform: uppercase;
            margin-top: 2px;
            letter-spacing: 0.05em;
        }

        /* ── Two-column spell grid ──────────────────────────────────────── */
        #spells-list {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 8px;
            margin-bottom: 4px;
        }

        .spell-card {
            background: #1a2040;
            border: 1px solid #2a3060;
            border-radius: 4px;
            padding: 10px 12px;
            display: flex;
            gap: 8px;
            align-items: flex-start;
            transition: background 0.15s;
        }

        .spell-card:hover {
            background: #202850;
        }

        .spell-card.locked-spell {
            border-style: dashed;
            opacity: 0.4;
        }

        .spell-card-icon {
            width: 32px;
            height: 32px;
            background: #0d1428;
            border: 1px solid #2a3060;
            border-radius: 4px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 18px;
            flex-shrink: 0;
        }

        .spell-card-body {
            flex: 1;
            min-width: 0;
        }

        .spell-card-name {
            color: var(--accent);
            font-size: 12px;
            font-weight: bold;
            margin-bottom: 4px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .spell-card-name.unlocked {
            color: var(--info);
        }

        .spell-card-pills {
            display: flex;
            gap: 4px;
            flex-wrap: wrap;
            margin-bottom: 4px;
        }

        .spell-pill {
            background: #0d1428;
            border: 1px solid #2a3060;
            border-radius: 2px;
            padding: 1px 5px;
            font-size: 9px;
            color: var(--text-dim);
        }

        .spell-card-desc {
            font-size: 10px;
            color: var(--text-dim);
            line-height: 1.35;
            overflow: hidden;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
        }
