/* ==============================================================
           AHQ CANONICAL DESIGN SYSTEM TOKENS
           ============================================================== */
        :root {
            /* Palette: Gold & Ember Accents */
            --ahq-primary: #ffb500;
            --ahq-primary-hover: #ffc42e;
            --ahq-primary-dark: #c98f00;
            --ahq-gold-muted: #ffe08a;
            --ahq-ember-glow: #ff4500;
            
            /* Backgrounds & Dark Glass Surfaces */
            --ahq-bg: #090a0d;
            --ahq-surface: rgba(22, 25, 32, 0.94);
            --ahq-surface-subtle: rgba(18, 20, 26, 0.85);
            --ahq-surface-raised: rgba(28, 32, 42, 0.96);
            --ahq-surface-modal: rgba(20, 22, 28, 0.98);
            
            /* Borders & Dividers */
            --ahq-border-subtle: rgba(255, 181, 0, 0.22);
            --ahq-border-active: rgba(255, 181, 0, 0.65);
            --ahq-divider: rgba(255, 255, 255, 0.08);
            
            /* Text Colors */
            --ahq-text-primary: #f5f3ec;
            --ahq-text-secondary: #c0c4ce;
            --ahq-text-muted: #8b909a;
            --ahq-text-dark: #121212;
            
            /* Status / Semantic Colors */
            --ahq-success: #388e3c;
            --ahq-success-bg: rgba(56, 142, 60, 0.16);
            --ahq-warning: #f59e0b;
            --ahq-warning-bg: rgba(245, 158, 11, 0.16);
            --ahq-danger: #d32f2f;
            --ahq-danger-bg: rgba(211, 47, 47, 0.16);
            --ahq-info: #1976d2;
            --ahq-info-bg: rgba(25, 118, 210, 0.16);
            
            /* Typography */
            --ahq-font-display: 'Cinzel', serif;
            --ahq-font-body: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
            
            /* Shadows & Radii */
            --ahq-radius-sm: 6px;
            --ahq-radius-md: 10px;
            --ahq-radius-lg: 14px;
            --ahq-radius-pill: 9999px;
            
            --ahq-shadow-card: 0 10px 30px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.4);
            --ahq-shadow-modal: 0 24px 64px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(255, 181, 0, 0.35);
        }

        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }

        body {
            background-color: var(--ahq-bg);
            background-image: 
                radial-gradient(ellipse at 50% 0%, rgba(255, 181, 0, 0.08) 0%, transparent 60%),
                radial-gradient(circle at 100% 40%, rgba(255, 69, 0, 0.05) 0%, transparent 50%),
                linear-gradient(180deg, #090a0d 0%, #050608 100%);
            background-attachment: fixed;
            color: var(--ahq-text-primary);
            font-family: var(--ahq-font-body);
            line-height: 1.5;
            -webkit-font-smoothing: antialiased;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
        }

        /* ==============================================================
           APP BAR & HEADER
           ============================================================== */
        .ahq-appbar {
            position: sticky;
            top: 0;
            z-index: 100;
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0.75rem 2rem;
            background: rgba(14, 16, 22, 0.96);
            backdrop-filter: blur(12px);
            border-bottom: 1px solid var(--ahq-border-subtle);
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
        }

        .ahq-brand {
            display: flex;
            align-items: center;
            gap: 1rem;
            text-decoration: none;
        }

        .ahq-brand-icon {
            font-size: 1.8rem;
            filter: drop-shadow(0 0 8px var(--ahq-primary));
        }

        .ahq-brand-title {
            font-family: var(--ahq-font-display);
            font-size: 1.25rem;
            font-weight: 700;
            color: var(--ahq-primary);
            letter-spacing: 0.06em;
            text-shadow: 0 2px 8px rgba(0,0,0,0.8);
        }

        .ahq-brand-subtitle {
            font-size: 0.75rem;
            color: var(--ahq-text-muted);
            letter-spacing: 0.08em;
            text-transform: uppercase;
        }

        .ahq-appbar-controls {
            display: flex;
            align-items: center;
            gap: 1rem;
        }

        /* ==============================================================
           BUTTONS & CHIPS
           ============================================================== */
        .btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 0.5rem;
            padding: 0.5rem 1.1rem;
            border-radius: var(--ahq-radius-sm);
            font-family: var(--ahq-font-body);
            font-size: 0.85rem;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
            border: 1px solid transparent;
            text-decoration: none;
            white-space: nowrap;
        }

        button.btn-primary, .btn-primary {
            background: linear-gradient(135deg, var(--ahq-primary) 0%, var(--ahq-primary-dark) 100%) !important;
            color: #121212 !important;
            font-weight: 700 !important;
            border: 1px solid var(--ahq-primary) !important;
            box-shadow: 0 2px 8px rgba(255, 181, 0, 0.35) !important;
            text-shadow: none !important;
        }
        button.btn-primary:hover:not(:disabled), .btn-primary:hover:not(:disabled) {
            background: linear-gradient(135deg, var(--ahq-primary-hover) 0%, var(--ahq-primary) 100%) !important;
            color: #000000 !important;
            border-color: #ffd54f !important;
            box-shadow: 0 4px 16px rgba(255, 181, 0, 0.6) !important;
            transform: translateY(-1px);
        }
        button.btn-primary:disabled, .btn-primary:disabled, .btn-primary.disabled {
            background: rgba(45, 38, 20, 0.85) !important;
            color: #ffd54f !important;
            border: 1px solid rgba(255, 181, 0, 0.35) !important;
            box-shadow: none !important;
            opacity: 0.7 !important;
            cursor: not-allowed !important;
            transform: none !important;
        }

        button.btn-secondary, .btn-secondary {
            background: var(--ahq-surface-raised) !important;
            border: 1px solid var(--ahq-border-subtle) !important;
            color: var(--ahq-text-primary) !important;
            font-weight: 600 !important;
        }
        button.btn-secondary:hover:not(:disabled), .btn-secondary:hover:not(:disabled) {
            border-color: var(--ahq-primary) !important;
            background: rgba(36, 42, 54, 0.95) !important;
            color: var(--ahq-primary) !important;
            box-shadow: 0 2px 8px rgba(255, 181, 0, 0.25) !important;
            transform: translateY(-1px);
        }
        button.btn-secondary:disabled, .btn-secondary:disabled, .btn-secondary.disabled {
            background: rgba(20, 22, 28, 0.6) !important;
            border: 1px solid rgba(255, 255, 255, 0.1) !important;
            color: var(--ahq-text-muted) !important;
            opacity: 0.55 !important;
            cursor: not-allowed !important;
            transform: none !important;
        }

        button.btn-danger, .btn-danger {
            background: rgba(211, 47, 47, 0.18) !important;
            border: 1px solid rgba(211, 47, 47, 0.5) !important;
            color: #ff6b6b !important;
        }
        button.btn-danger:hover:not(:disabled), .btn-danger:hover:not(:disabled) {
            background: rgba(211, 47, 47, 0.35) !important;
            border-color: #ff8585 !important;
            color: #ffffff !important;
            transform: translateY(-1px);
        }
        button.btn-danger:disabled, .btn-danger:disabled {
            opacity: 0.4 !important;
            cursor: not-allowed !important;
            transform: none !important;
        }

        .btn-sm {
            padding: 0.3rem 0.65rem;
            font-size: 0.78rem;
        }

        .btn-icon {
            padding: 0.35rem 0.5rem;
            border-radius: var(--ahq-radius-sm);
            line-height: 1;
        }

        .chip {
            display: inline-flex;
            align-items: center;
            gap: 0.35rem;
            padding: 0.25rem 0.65rem;
            border-radius: var(--ahq-radius-pill);
            font-size: 0.75rem;
            font-weight: 600;
            border: 1px solid transparent;
        }
        .chip-gold {
            background: rgba(255, 181, 0, 0.12);
            border-color: var(--ahq-border-subtle);
            color: var(--ahq-gold-muted);
        }
        .chip-success {
            background: var(--ahq-success-bg);
            border-color: rgba(56, 142, 60, 0.4);
            color: #81c784;
        }
        .chip-danger {
            background: var(--ahq-danger-bg);
            border-color: rgba(211, 47, 47, 0.4);
            color: #ff8a80;
        }

        /* ==============================================================
           LAYOUT: MAIN WRAPPER & SIDEBAR NAV
           ============================================================== */
        .mock-container {
            display: flex;
            flex-direction: column;
            width: 100% !important;
            max-width: 100% !important;
            min-height: calc(100vh - 65px);
        }

        .main-layout {
            display: flex;
            gap: 1rem;
            align-items: flex-start;
            flex: 1;
            width: 100% !important;
            max-width: 100% !important;
        }

        .editor-main {
            flex: 1 1 0% !important;
            min-width: 0 !important;
            width: 100% !important;
        }

        /* Left Navigation Sidebar */
        .sidebar {
            background: var(--ahq-surface-subtle);
            border-right: 1px solid var(--ahq-border-subtle);
            padding: 1.25rem 1rem;
            display: flex;
            flex-direction: column;
            gap: 1.5rem;
            overflow-y: auto;
        }

        .ruleset-picker-box {
            background: var(--ahq-surface-raised);
            border: 1px solid var(--ahq-border-subtle);
            border-radius: var(--ahq-radius-md);
            padding: 1rem;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        }

        .field-label {
            font-family: var(--ahq-font-display);
            font-size: 0.72rem;
            text-transform: uppercase;
            letter-spacing: 0.08em;
            color: var(--ahq-primary);
            margin-bottom: 0.4rem;
            display: block;
        }

        .select-input, .text-input {
            width: 100%;
            background: rgba(14, 16, 22, 0.9);
            border: 1px solid rgba(255, 255, 255, 0.15);
            color: var(--ahq-text-primary);
            padding: 0.5rem 0.75rem;
            border-radius: var(--ahq-radius-sm);
            font-family: var(--ahq-font-body);
            font-size: 0.85rem;
            transition: all 0.2s;
        }
        .select-input:focus, .text-input:focus {
            outline: none;
            border-color: var(--ahq-primary);
            box-shadow: 0 0 8px rgba(255, 181, 0, 0.3);
        }

        .nav-category-title {
            font-family: var(--ahq-font-display);
            font-size: 0.75rem;
            font-weight: 700;
            letter-spacing: 0.1em;
            text-transform: uppercase;
            color: var(--ahq-text-muted);
            margin: 0.75rem 0.5rem 0.35rem;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .nav-table-list {
            list-style: none;
            display: flex;
            flex-direction: column;
            gap: 0.25rem;
        }

        .nav-table-item {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0.55rem 0.75rem;
            border-radius: var(--ahq-radius-sm);
            cursor: pointer;
            color: var(--ahq-text-secondary);
            font-size: 0.82rem;
            transition: all 0.15s ease;
            border: 1px solid transparent;
        }
        .nav-table-item:hover {
            background: rgba(255, 255, 255, 0.04);
            color: var(--ahq-text-primary);
        }
        .nav-table-item.active {
            background: rgba(255, 181, 0, 0.12);
            border-color: rgba(255, 181, 0, 0.4);
            color: var(--ahq-primary);
            font-weight: 600;
        }
        .nav-table-item.highlight-chest {
            border: 1px dashed rgba(255, 181, 0, 0.5);
            background: rgba(255, 181, 0, 0.06);
        }
        .nav-table-item.highlight-chest.active {
            background: linear-gradient(90deg, rgba(255, 181, 0, 0.2) 0%, rgba(255, 69, 0, 0.1) 100%);
            border: 1px solid var(--ahq-primary);
            box-shadow: 0 0 12px rgba(255, 181, 0, 0.25);
        }

        /* ==============================================================
           MAIN CONTENT AREA
           ============================================================== */
        .workspace {
            padding: 1.75rem 2.25rem;
            overflow-y: auto;
            display: flex;
            flex-direction: column;
            gap: 1.5rem;
        }

        /* Top Banner Card */
        .ruleset-banner {
            background: var(--ahq-surface);
            border: 1px solid var(--ahq-border-subtle);
            border-radius: var(--ahq-radius-md);
            padding: 1.25rem 1.75rem;
            display: flex;
            align-items: center;
            justify-content: space-between;
            box-shadow: var(--ahq-shadow-card);
            position: relative;
            overflow: hidden;
        }
        .ruleset-banner::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 4px;
            height: 100%;
            background: var(--ahq-primary);
            box-shadow: 0 0 10px var(--ahq-primary);
        }

        .banner-title-box h1 {
            font-family: var(--ahq-font-display);
            font-size: 1.45rem;
            color: var(--ahq-primary);
            margin-bottom: 0.25rem;
            display: flex;
            align-items: center;
            gap: 0.75rem;
        }
        .banner-desc {
            font-size: 0.88rem;
            color: var(--ahq-text-secondary);
            max-width: 720px;
        }
        .banner-meta {
            display: flex;
            gap: 1rem;
            margin-top: 0.5rem;
            font-size: 0.78rem;
            color: var(--ahq-text-muted);
        }

        /* Table Editor Card */
        .editor-card {
            background: var(--ahq-surface);
            border: 1px solid var(--ahq-border-subtle);
            border-radius: var(--ahq-radius-md);
            box-shadow: var(--ahq-shadow-card);
            overflow: hidden;
            display: flex;
            flex-direction: column;
        }

        .editor-header {
            padding: 1.25rem 1.5rem;
            background: var(--ahq-surface-raised);
            border-bottom: 1px solid var(--ahq-divider);
            display: flex;
            align-items: center;
            justify-content: space-between;
            flex-wrap: wrap;
            gap: 1rem;
        }

        .table-heading-group {
            display: flex;
            align-items: center;
            gap: 1rem;
        }

        .table-title {
            font-family: var(--ahq-font-display);
            font-size: 1.2rem;
            font-weight: 700;
            color: var(--ahq-text-primary);
        }

        .editor-toolbar {
            display: flex;
            align-items: center;
            gap: 0.75rem;
        }

        /* Dice Range Visualizer Strip */
        .dice-strip-box {
            padding: 0.85rem 1.5rem;
            background: rgba(14, 16, 22, 0.6);
            border-bottom: 1px solid var(--ahq-divider);
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 1.5rem;
        }

        .dice-slots-container,
        .dice-slots {
            display: flex;
            flex-direction: row;
            align-items: center;
            gap: 0.35rem;
            flex-wrap: wrap;
        }

        .dice-slot {
            width: 32px;
            height: 32px;
            border-radius: var(--ahq-radius-sm);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 0.78rem;
            font-weight: 700;
            transition: all 0.15s;
            border: 1px solid transparent;
        }
        .dice-slot.covered {
            background: rgba(56, 142, 60, 0.2);
            border-color: rgba(56, 142, 60, 0.5);
            color: #a5d6a7;
        }
        .dice-slot.empty {
            background: rgba(211, 47, 47, 0.2);
            border-color: rgba(211, 47, 47, 0.6);
            color: #ef9a9a;
            animation: pulse-gap 2s infinite;
        }
        .dice-slot.overlap {
            background: rgba(245, 158, 11, 0.25);
            border-color: rgba(245, 158, 11, 0.7);
            color: #ffe082;
        }

        @keyframes pulse-gap {
            0% { opacity: 0.6; }
            50% { opacity: 1; }
            100% { opacity: 0.6; }
        }

        /* ==============================================================
           MATRIX DATA TABLE
           ============================================================== */
        .matrix-table {
            width: 100%;
            border-collapse: collapse;
            font-size: 0.85rem;
        }

        .matrix-table th {
            background: rgba(18, 20, 26, 0.9);
            color: var(--ahq-text-muted);
            font-family: var(--ahq-font-display);
            font-size: 0.72rem;
            text-transform: uppercase;
            letter-spacing: 0.08em;
            padding: 0.75rem 1rem;
            text-align: left;
            border-bottom: 1px solid var(--ahq-divider);
        }

        .matrix-table td {
            padding: 0.75rem 1rem;
            border-bottom: 1px solid rgba(255, 255, 255, 0.04);
            vertical-align: middle;
            transition: background 0.2s;
        }

        .matrix-table tr:hover td {
            background: rgba(255, 255, 255, 0.02);
        }

        /* Reorder Controls Cell */
        .reorder-cell {
            display: flex;
            align-items: center;
            gap: 0.3rem;
            color: var(--ahq-text-muted);
        }
        .order-badge {
            font-size: 0.75rem;
            font-weight: 700;
            color: var(--ahq-text-muted);
            width: 22px;
            text-align: center;
        }
        .btn-order {
            background: rgba(255, 255, 255, 0.05);
            border: 1px solid rgba(255, 255, 255, 0.12);
            color: var(--ahq-text-secondary);
            border-radius: 4px;
            width: 24px;
            height: 24px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            font-size: 0.7rem;
            transition: all 0.15s;
        }
        .btn-order:hover:not(:disabled) {
            background: var(--ahq-primary);
            color: #000;
            border-color: var(--ahq-primary);
        }
        .btn-order:disabled {
            opacity: 0.25;
            cursor: not-allowed;
        }

        /* Dice Picker Button */
        .dice-picker-btn {
            background: rgba(14, 17, 24, 0.95);
            border: 1px solid var(--ahq-border-subtle);
            border-radius: var(--ahq-radius-sm);
            color: var(--ahq-primary);
            font-weight: 700;
            font-size: 0.88rem;
            padding: 0.4rem 0.75rem;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 0.4rem;
            cursor: pointer;
            transition: all 0.2s;
            min-width: 90px;
        }
        .dice-picker-btn:hover {
            border-color: var(--ahq-primary);
            background: rgba(255, 181, 0, 0.12);
            box-shadow: 0 0 10px rgba(255, 181, 0, 0.3);
            transform: translateY(-1px);
        }

        .row-title-input {
            width: 100%;
            background: rgba(10, 12, 16, 0.7);
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: var(--ahq-radius-sm);
            color: var(--ahq-text-primary);
            padding: 0.4rem 0.6rem;
            font-size: 0.85rem;
        }
        .row-title-input:focus {
            border-color: var(--ahq-primary);
            outline: none;
        }

        .row-desc-input {
            width: 100%;
            background: rgba(10, 12, 16, 0.7);
            border: 1px solid rgba(255, 255, 255, 0.08);
            border-radius: var(--ahq-radius-sm);
            color: var(--ahq-text-secondary);
            padding: 0.35rem 0.5rem;
            font-size: 0.8rem;
        }

        /* Treasure Chest loot rows */
        .chest-gold-box {
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }

        .gold-input {
            width: 80px;
            background: rgba(10, 12, 16, 0.85);
            border: 1px solid rgba(255, 181, 0, 0.4);
            border-radius: var(--ahq-radius-sm);
            color: var(--ahq-primary);
            font-weight: 700;
            padding: 0.4rem 0.5rem;
            text-align: right;
        }

        .items-cell-container {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            flex-wrap: wrap;
            min-height: 38px;
        }

        .item-chip {
            display: inline-flex;
            align-items: center;
            gap: 0.35rem;
            padding: 0.25rem 0.55rem;
            background: rgba(30, 35, 48, 0.9);
            border: 1px solid rgba(255, 181, 0, 0.3);
            border-radius: var(--ahq-radius-sm);
            font-size: 0.78rem;
            color: var(--ahq-text-primary);
        }
        .item-chip-remove {
            cursor: pointer;
            color: var(--ahq-text-muted);
            margin-left: 0.25rem;
            font-weight: 700;
        }
        .item-chip-remove:hover {
            color: #ff6b6b;
        }

        .submatrix-badge {
            background: rgba(156, 39, 176, 0.2);
            border: 1px solid rgba(156, 39, 176, 0.5);
            color: #ce93d8;
            padding: 0.25rem 0.6rem;
            border-radius: var(--ahq-radius-sm);
            font-size: 0.75rem;
            font-weight: 600;
            display: inline-flex;
            align-items: center;
            gap: 0.3rem;
        }

        .editor-footer {
            padding: 1rem 1.5rem;
            background: var(--ahq-surface-raised);
            border-top: 1px solid var(--ahq-divider);
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        /* ==============================================================
           MODALS (Item Picker, Dice Picker, Create Ruleset)
           ============================================================== */
        .modal-backdrop {
            position: fixed;
            top: 0;
            left: 0;
            width: 100vw;
            height: 100vh;
            background: rgba(0, 0, 0, 0.75);
            backdrop-filter: blur(6px);
            z-index: 200;
            display: none;
            align-items: center;
            justify-content: center;
            padding: 1.5rem;
        }
        .modal-backdrop.show {
            display: flex;
        }

        .modal-card {
            background: var(--ahq-surface-modal);
            border: 1px solid var(--ahq-border-active);
            border-radius: var(--ahq-radius-lg);
            box-shadow: var(--ahq-shadow-modal);
            width: 100%;
            max-width: 820px;
            max-height: 85vh;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            animation: modal-appear 0.2s cubic-bezier(0.16, 1, 0.3, 1);
        }

        @keyframes modal-appear {
            from { opacity: 0; transform: scale(0.96) translateY(10px); }
            to { opacity: 1; transform: scale(1) translateY(0); }
        }

        .modal-header {
            padding: 1.25rem 1.75rem;
            border-bottom: 1px solid var(--ahq-border-subtle);
            background: var(--ahq-surface-raised);
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .modal-title {
            font-family: var(--ahq-font-display);
            font-size: 1.25rem;
            color: var(--ahq-primary);
            letter-spacing: 0.05em;
            display: flex;
            align-items: center;
            gap: 0.65rem;
        }

        .modal-body {
            padding: 1.5rem 1.75rem;
            overflow-y: auto;
            flex: 1;
            display: flex;
            flex-direction: column;
            gap: 1.25rem;
        }

        .modal-footer {
            padding: 1rem 1.75rem;
            background: var(--ahq-surface-raised);
            border-top: 1px solid var(--ahq-divider);
            display: flex;
            align-items: center;
            justify-content: flex-end;
            gap: 0.75rem;
        }

        /* ==============================================================
           DICE ROLL PICKER MODAL STYLES
           ============================================================== */
        .dice-picker-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(62px, 1fr));
            gap: 0.6rem;
            margin-top: 0.5rem;
        }

        .dice-choice-btn {
            height: 52px;
            background: rgba(25, 29, 39, 0.85);
            border: 1px solid rgba(255, 255, 255, 0.12);
            border-radius: var(--ahq-radius-sm);
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: all 0.15s;
            color: var(--ahq-text-primary);
            position: relative;
        }
        .dice-choice-btn:hover {
            border-color: var(--ahq-primary);
            background: rgba(255, 181, 0, 0.15);
            transform: translateY(-2px);
        }
        .dice-choice-btn.selected {
            background: linear-gradient(135deg, var(--ahq-primary) 0%, var(--ahq-primary-dark) 100%) !important;
            border-color: var(--ahq-primary-hover) !important;
            color: #000 !important;
            font-weight: 900;
            box-shadow: 0 0 12px rgba(255, 181, 0, 0.5);
        }
        .dice-choice-btn.in-range {
            background: rgba(255, 181, 0, 0.25);
            border-color: var(--ahq-primary);
            color: var(--ahq-gold-muted);
            font-weight: 700;
        }
        .dice-choice-btn.unassigned {
            border-color: rgba(56, 142, 60, 0.6);
            background: rgba(56, 142, 60, 0.1);
        }
        .dice-choice-num {
            font-size: 1.1rem;
            font-weight: 700;
            line-height: 1;
        }
        .dice-choice-sub {
            font-size: 0.65rem;
            color: var(--ahq-text-muted);
            margin-top: 2px;
        }
        .dice-choice-btn.selected .dice-choice-sub {
            color: #222;
            font-weight: 600;
        }

        .picker-tab-bar {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            border-bottom: 1px solid var(--ahq-divider);
            padding-bottom: 0.75rem;
        }

        /* Item Picker Grid */
        .catalog-filter-bar {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            flex-wrap: wrap;
        }

        .category-tab {
            padding: 0.35rem 0.75rem;
            border-radius: var(--ahq-radius-pill);
            background: rgba(255, 255, 255, 0.04);
            border: 1px solid rgba(255, 255, 255, 0.1);
            color: var(--ahq-text-secondary);
            font-size: 0.78rem;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.15s;
        }
        .category-tab:hover {
            background: rgba(255, 255, 255, 0.08);
            color: var(--ahq-text-primary);
        }
        .category-tab.active {
            background: rgba(255, 181, 0, 0.15);
            border-color: var(--ahq-primary);
            color: var(--ahq-primary);
        }

        .catalog-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
            gap: 0.85rem;
            margin-top: 0.5rem;
        }

        .catalog-item-card {
            background: rgba(25, 29, 39, 0.8);
            border: 1px solid rgba(255, 255, 255, 0.08);
            border-radius: var(--ahq-radius-sm);
            padding: 0.85rem;
            cursor: pointer;
            transition: all 0.2s;
            display: flex;
            flex-direction: column;
            gap: 0.4rem;
        }
        .catalog-item-card:hover {
            border-color: var(--ahq-primary);
            background: rgba(35, 41, 56, 0.95);
            transform: translateY(-2px);
            box-shadow: 0 4px 14px rgba(0,0,0,0.5);
        }

        .item-card-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
        }
        .item-card-name {
            font-weight: 700;
            color: var(--ahq-text-primary);
            font-size: 0.88rem;
        }
        .item-card-cost {
            font-size: 0.78rem;
            color: var(--ahq-primary);
            font-weight: 600;
        }
        .item-card-desc {
            font-size: 0.75rem;
            color: var(--ahq-text-muted);
            line-height: 1.35;
        }

        
        /* ==============================================================
           ENHANCED CONTROLS: DRAG & DROP, DICE COUNT, GOLD PICKER, GM SCREEN
           ============================================================== */
        
        /* Drag & Drop Rows */
        .drag-handle {
            cursor: grab;
            font-size: 1.15rem;
            color: var(--ahq-text-muted);
            opacity: 0.5;
            user-select: none;
            padding: 0 4px;
            transition: opacity 0.15s, color 0.15s;
        }
        .drag-handle:hover {
            opacity: 1;
            color: var(--ahq-primary);
        }
        .drag-handle:active {
            cursor: grabbing;
        }
        tr.matrix-row {
            transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
        }
        tr.is-dragging {
            opacity: 0.35 !important;
            background: rgba(255, 181, 0, 0.08) !important;
        }
        tr.drag-over-top {
            border-top: 3px solid var(--ahq-primary) !important;
            box-shadow: 0 -4px 10px rgba(255, 181, 0, 0.4);
        }
        tr.drag-over-bottom {
            border-bottom: 3px solid var(--ahq-primary) !important;
            box-shadow: 0 4px 10px rgba(255, 181, 0, 0.4);
        }

        /* Dice Count Selector */
        .dice-count-selector {
            display: inline-flex;
            align-items: center;
            gap: 0.5rem;
            background: rgba(14, 16, 22, 0.85);
            padding: 0.3rem 0.65rem;
            border-radius: var(--ahq-radius-sm);
            border: 1px solid var(--ahq-border-subtle);
        }
        .dice-count-label {
            font-size: 0.72rem;
            font-weight: 700;
            color: var(--ahq-gold-muted);
            text-transform: uppercase;
            letter-spacing: 0.06em;
            font-family: var(--ahq-font-display);
        }
        .dice-pill-group {
            display: flex;
            gap: 0.3rem;
        }
        .dice-pill {
            background: rgba(255, 255, 255, 0.04);
            border: 1px solid var(--ahq-border-subtle);
            color: var(--ahq-text-muted);
            padding: 0.22rem 0.6rem;
            border-radius: 4px;
            font-size: 0.75rem;
            font-weight: 700;
            cursor: pointer;
            transition: all 0.15s ease;
        }
        .dice-pill:hover {
            border-color: var(--ahq-primary);
            color: var(--ahq-primary);
        }
        .dice-pill.active {
            background: var(--ahq-primary);
            border-color: var(--ahq-primary);
            color: #000;
            box-shadow: 0 0 10px rgba(255, 181, 0, 0.4);
        }

        /* Gold Picker Trigger Button */
        .gold-picker-trigger-btn {
            background: rgba(255, 181, 0, 0.08);
            border: 1px solid rgba(255, 181, 0, 0.35);
            border-radius: var(--ahq-radius-sm);
            color: #ffd54f;
            padding: 0.35rem 0.65rem;
            font-size: 0.85rem;
            font-weight: 700;
            display: inline-flex;
            align-items: center;
            gap: 0.4rem;
            cursor: pointer;
            transition: all 0.2s ease;
        }
        .gold-picker-trigger-btn:hover {
            background: rgba(255, 181, 0, 0.2);
            border-color: var(--ahq-primary);
            box-shadow: 0 0 12px rgba(255, 181, 0, 0.3);
            transform: translateY(-1px);
        }
        .gold-coin-icon {
            font-size: 1rem;
        }
        .gold-unit-label {
            color: var(--ahq-gold-muted);
            font-size: 0.72rem;
            font-weight: 700;
        }
        .gold-edit-hint {
            font-size: 0.65rem;
            opacity: 0.6;
            margin-left: 0.2rem;
        }

        /* Gold Modal Styles */
        .gold-display-box {
            background: radial-gradient(circle, rgba(255, 181, 0, 0.15) 0%, rgba(14, 16, 22, 0.9) 100%);
            border: 2px solid var(--ahq-primary);
            border-radius: var(--ahq-radius-md);
            padding: 1.25rem;
            text-align: center;
            box-shadow: 0 0 25px rgba(255, 181, 0, 0.25);
        }
        .gold-display-amount {
            font-family: var(--ahq-font-display);
            font-size: 2.8rem;
            font-weight: 700;
            color: #ffd54f;
            text-shadow: 0 0 15px rgba(255, 181, 0, 0.5);
            letter-spacing: 0.05em;
        }
        .gold-display-sub {
            font-size: 0.78rem;
            text-transform: uppercase;
            letter-spacing: 0.1em;
            color: var(--ahq-text-muted);
            margin-top: 0.25rem;
        }
        @keyframes gold-glow {
            0% { transform: scale(0.96); filter: brightness(1.3); }
            100% { transform: scale(1); filter: brightness(1); }
        }

        .gold-steppers-grid {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 0.5rem;
        }
        .gold-step-btn {
            background: rgba(26, 31, 44, 0.85);
            border: 1px solid var(--ahq-border-subtle);
            border-radius: var(--ahq-radius-sm);
            color: var(--ahq-text-primary);
            padding: 0.55rem 0.5rem;
            font-weight: 700;
            font-size: 0.9rem;
            cursor: pointer;
            transition: all 0.15s ease;
            text-align: center;
        }
        .gold-step-btn.plus {
            color: #81c784;
            border-color: rgba(129, 199, 132, 0.4);
        }
        .gold-step-btn.plus:hover {
            background: rgba(129, 199, 132, 0.2);
            border-color: #81c784;
            box-shadow: 0 0 8px rgba(129, 199, 132, 0.3);
        }
        .gold-step-btn.minus {
            color: #e57373;
            border-color: rgba(229, 115, 115, 0.4);
        }
        .gold-step-btn.minus:hover {
            background: rgba(229, 115, 115, 0.2);
            border-color: #e57373;
            box-shadow: 0 0 8px rgba(229, 115, 115, 0.3);
        }

        .gold-presets-bar {
            display: flex;
            flex-wrap: wrap;
            gap: 0.45rem;
            justify-content: center;
        }
        .gold-preset-chip {
            background: rgba(255, 181, 0, 0.08);
            border: 1px solid rgba(255, 181, 0, 0.3);
            border-radius: 999px;
            color: var(--ahq-primary);
            padding: 0.35rem 0.8rem;
            font-size: 0.8rem;
            font-weight: 700;
            cursor: pointer;
            transition: all 0.15s ease;
        }
        .gold-preset-chip:hover {
            background: var(--ahq-primary);
            color: #000;
            box-shadow: 0 0 10px rgba(255, 181, 0, 0.35);
        }

        /* GM Screen Presentation */
        .gm-screen-parchment {
            background: #0d0c0a;
            border: 2px solid var(--ahq-primary);
            border-radius: var(--ahq-radius-md);
            padding: 1.5rem;
            box-shadow: inset 0 0 35px rgba(0, 0, 0, 0.9), 0 0 25px rgba(255, 181, 0, 0.2);
        }
        .gm-screen-header {
            text-align: center;
            border-bottom: 2px solid var(--ahq-primary);
            padding-bottom: 1rem;
            margin-bottom: 1.25rem;
        }
        .gm-screen-title {
            font-family: var(--ahq-font-display);
            font-size: 1.45rem;
            color: var(--ahq-primary);
            letter-spacing: 0.12em;
            text-transform: uppercase;
            margin: 0.3rem 0;
            text-shadow: 0 0 12px rgba(255, 181, 0, 0.4);
        }
        .gm-screen-sub {
            font-size: 0.85rem;
            color: var(--ahq-gold-muted);
            letter-spacing: 0.05em;
        }
        .gm-screen-table {
            width: 100%;
            border-collapse: collapse;
            font-size: 0.88rem;
        }
        .gm-screen-table th {
            background: rgba(255, 181, 0, 0.15);
            color: var(--ahq-primary);
            font-family: var(--ahq-font-display);
            padding: 0.65rem 0.85rem;
            border: 1px solid rgba(255, 181, 0, 0.3);
            text-align: left;
            font-size: 0.8rem;
            letter-spacing: 0.06em;
            text-transform: uppercase;
        }
        .gm-screen-table td {
            padding: 0.65rem 0.85rem;
            border: 1px solid rgba(255, 181, 0, 0.18);
            background: rgba(14, 16, 22, 0.7);
            color: #ded7c6;
            vertical-align: middle;
        }
        .gm-screen-table tr:nth-child(even) td {
            background: rgba(20, 24, 32, 0.75);
        }
        .gm-screen-roll-badge {
            font-weight: 700;
            font-family: var(--ahq-font-display);
            color: var(--ahq-primary);
            font-size: 1.05rem;
            text-shadow: 0 0 8px rgba(255, 181, 0, 0.3);
        }
        .gm-item-pill {
            display: inline-flex;
            align-items: center;
            gap: 0.3rem;
            background: rgba(255, 255, 255, 0.06);
            border: 1px solid rgba(255, 255, 255, 0.15);
            padding: 0.2rem 0.5rem;
            border-radius: 4px;
            font-size: 0.78rem;
            color: #fff;
            margin: 0.15rem 0.2rem 0.15rem 0;
        }
        .gm-item-pill.submatrix {
            background: rgba(156, 39, 176, 0.25);
            border-color: rgba(156, 39, 176, 0.5);
            color: #ce93d8;
        }
        .gm-action-pill {
            background: rgba(255, 181, 0, 0.1);
            border: 1px solid rgba(255, 181, 0, 0.25);
            padding: 0.2rem 0.55rem;
            border-radius: 4px;
            color: var(--ahq-gold-muted);
            font-size: 0.8rem;
        }

        /* Toast notifications */
        .toast-container {
            position: fixed;
            bottom: 2rem;
            right: 2rem;
            z-index: 300;
            display: flex;
            flex-direction: column;
            gap: 0.5rem;
            pointer-events: none;
        }

        .toast {
            background: rgba(20, 24, 32, 0.95);
            border: 1px solid var(--ahq-primary);
            border-radius: var(--ahq-radius-md);
            padding: 0.75rem 1.25rem;
            color: var(--ahq-text-primary);
            box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7);
            font-size: 0.88rem;
            display: flex;
            align-items: center;
            gap: 0.65rem;
            animation: toast-in 0.25s ease-out;
            pointer-events: auto;
        }
        @keyframes toast-in {
            from { transform: translateY(20px); opacity: 0; }
            to { transform: translateY(0); opacity: 1; }
        }