.hidden {
    display: none !important;
}

:root {
    --primary-color: var(--primary-color);
    /* Light Blue for dark mode */
    --accent-color: var(--primary-color);
    /* Switched from Cyan to Light Blue */
    --accent-light: #16242d;
    /* Dark Blue background instead of Dark Teal */
    --defense-silver: #b0bec5;
    --text-main: #e0e0e0;
    --text-muted: #9e9e9e;
    --bg-app: #121212;
    --card-bg: #1e1e1e;
    --input-bg: #2c2c2c;
    --border-color: #333;
    --border-radius: 12px;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.4);
    --font-heading: 'Cinzel', serif;
    --font-body: 'Lato', sans-serif;
    /* Magic Schools Colors (Muted/Earthy) */
    --school-abjuration: #90a4ae;
    /* Blue Grey */
    --school-conjuration: #a5d6a7;
    /* Green */
    --school-divination: #b39ddb;
    /* Deep Purple */
    --school-enchantment: #f48fb1;
    /* Pink */
    --school-evocation: #ef9a9a;
    /* Red (Muted) */
    --school-illusion: #ce93d8;
    /* Purple */
    --school-necromancy: #bcaaa4;
    /* Brownish */
    --school-transmutation: #ffe082;
    /* Amber */
    --school-universal: #eeeeee;
    /* Grey */
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-app);
    color: var(--text-main);
    margin: 0;
    -webkit-tap-highlight-color: transparent;
    /* Rimuove il flash azzurro predefinitivo dei browser mobili */
    padding: 10px 10px calc(54px + env(safe-area-inset-bottom, 0px)) 10px;
    /* Spazio per la nav ridotta */
    min-height: 100vh;
    box-sizing: border-box;
}


body.modal-open {
    overflow: hidden;
}

.app-container {
    max-width: 800px;
    margin: 0 auto;
    padding-top: 80px;
    /* Spazio per la Top Bar aumentato */
}

/* Fixed Top Bar */
.top-bar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 60px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 15px;
    box-sizing: border-box;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    z-index: 11000 !important;
}

.top-bar-saves {
    display: flex;
    gap: 10px;
    flex: 1;
    justify-content: center;
}

.save-btn {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    gap: 4px;
    align-items: center;
}

.save-btn span {
    color: var(--accent-color);
    font-size: 0.9rem;
}

.save-btn:active {
    background: var(--accent-light);
    transform: scale(0.95);
}

/* Sidebar Toggle & CD Button */
.sidebar-toggle-btn,
.cd-toggle-btn {
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.sidebar-toggle-btn:active,
.cd-toggle-btn:active {
    transform: scale(0.9);
    color: var(--accent-color);
}

/* Sidebar & Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 11400;
    backdrop-filter: blur(4px);
    transition: opacity 0.3s ease, visibility 0.3s ease;

    /* Default Hidden state */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100%;
    background: var(--bg-app);
    z-index: 11500;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s;
    border-right: 1px solid var(--border-color);
    box-shadow: 10px 0 25px rgba(0, 0, 0, 0.5);
    visibility: hidden;
}

.sidebar.open {
    transform: translateX(0);
    visibility: visible;
}

.sidebar-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 0;
}

.sidebar-header {
    padding: 25px 20px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h2 {
    font-family: var(--font-heading);
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin: 0;
}

.sidebar-actions {
    display: flex;
    gap: 10px;
}

.sidebar-action-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.sidebar-action-btn:hover {
    color: var(--accent-color);
}

.sidebar-scrollable {
    flex: 1;
    overflow-y: auto;
    padding: 10px 15px;
}

.sidebar-item {
    background: var(--card-bg);
    padding: 14px 18px;
    border-radius: 12px;
    margin-bottom: 8px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-item.active {
    border-color: var(--accent-color);
    background: var(--accent-light);
    box-shadow: inset 0 0 15px var(--primary-color-05);
}

.char-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.char-name {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    color: var(--text-main);
    letter-spacing: 1px;
}

.theme-trigger {
    width: 14px;
    height: 14px;
    background: var(--accent-color);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--accent-color);
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.2);
    transition: transform 0.2s;
}

.theme-trigger:hover {
    transform: scale(1.2);
}

/* Group Headers */
.party-group {
    margin-bottom: 20px;
}

.party-title {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0 0 8px 5px;
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 4px;
}

.theme-selector {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
    padding: 10px 0;
}

.color-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
}

.color-dot:hover {
    transform: scale(1.2);
    z-index: 2;
}

.color-dot.active {
    border-color: white;
    transform: scale(1.1);
    box-shadow: 0 0 10px currentColor;
}

.color-dot.active::after {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 10px;
    color: white;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.2);
}

.sidebar-footer p {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0 0 5px 0;
}

.version-tag {
    font-size: 0.65rem;
    color: var(--accent-color);
    font-weight: bold;
    opacity: 0.6;
}


.main-header {
    text-align: center;
    margin-bottom: 8px;
}

.main-header h1 {
    font-family: var(--font-heading);
    color: var(--primary-color);
    margin: 0;
    font-size: 1.2rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.subtitle {
    display: none;
}

/* Settings Panel */
.settings-panel {
    background: var(--card-bg);
    padding: 15px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    display: flex;
    gap: 15px;
    align-items: flex-end;
    margin-bottom: 20px;
    flex-wrap: wrap;
    border: 1px solid var(--border-color);
}

.setting-group {
    flex: 1;
    min-width: 140px;
}

.setting-group label {
    display: block;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: clamp(0.65rem, 3.2vw, 0.85rem); white-space: nowrap; gap: 8px;
    text-transform: uppercase;
}

.setting-group input {
    width: 100%;
    /* Full width for mobile friendliness */
    max-width: 80px;
    padding: 12px;
    /* Larger touch target */
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-radius: 8px;
    font-size: 1rem;
    font-family: var(--font-body);
    transition: border-color 0.3s;
}

.setting-group input:focus {
    border-color: var(--accent-color);
    outline: none;
}

/* Metamagic Settings */
.metamagic-settings-container {
    width: 100%;
    margin-top: 15px;
    border-top: 1px solid var(--border-color);
    padding-top: 15px;
}

.section-label {
    display: block;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text-muted);
    font-size: clamp(0.65rem, 3.2vw, 0.85rem); white-space: nowrap; gap: 8px;
    text-transform: uppercase;
}

.known-metamagic-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
}

.known-mm-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--input-bg);
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    font-size: 0.8rem;
    color: var(--text-main);
    cursor: pointer;
}

.known-mm-item input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-color);
}

.known-mm-item .mm-icon {
    color: var(--accent-color);
    font-size: 0.95rem;
}

.actions {
    width: 100%;
    margin-top: 10px;
}

.btn-secondary {
    width: 100%;
    /* Full width on mobile */
    padding: 12px;
    background: transparent;
    border: 1px solid var(--defense-silver);
    color: var(--defense-silver);
    font-weight: 700;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    font-size: 0.9rem;
}

.btn-secondary:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
    background: rgba(3, 218, 198, 0.1);
}

/* Operational Panel (Spells View) */
.operational-panel {
    background: var(--card-bg);
    padding: 15px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

.main-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
    width: 100%;
    align-items: stretch;
}

.main-actions #btn-new-day,
.main-actions .btn-primary-action,
.main-actions #reset-all,
.main-actions .btn-secondary-action {
    height: 38px !important;
    min-height: 38px !important;
    max-height: 38px !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 1 !important;
}

.main-actions #btn-new-day,
.main-actions .btn-primary-action {
    flex: 3;
    width: calc(75% - 4px);
    padding: 0 8px !important;
    font-size: clamp(0.74rem, 2.6vw, 0.88rem);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    gap: 6px;
    text-transform: uppercase;
    font-weight: bold;
    border-radius: 8px;
    background: var(--primary-color);
    color: #121212;
    border: 1px solid var(--primary-color) !important;
    cursor: pointer;
    transition: all 0.3s;
}

.main-actions #reset-all,
.main-actions .btn-secondary-action {
    flex: 1;
    width: calc(25% - 4px);
    padding: 0 4px !important;
    font-size: clamp(0.66rem, 2.2vw, 0.82rem);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    gap: 4px;
    text-transform: uppercase;
    font-weight: bold;
    border-radius: 8px;
    background: transparent;
    border: 1px solid #e57373 !important;
    color: #e57373;
    cursor: pointer;
    transition: all 0.3s;
}

.main-actions #reset-all:hover,
.main-actions .btn-secondary-action:hover {
    background: rgba(229, 115, 115, 0.1);
}

@media (max-width: 480px) {
    .main-actions {
        flex-direction: row !important;
        gap: 6px;
    }
}

.search-flex {
    display: flex;
    gap: 8px;
    position: relative;
    /* z-index removed to keep at home level */
}


.open-modal-btn {
    background: var(--accent-color);
    color: black;
    border: none;
    border-radius: 50%;
    width: 36px;
    /* Larger touch target */
    height: 36px;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background 0.2s;
    padding-bottom: 2px;
}

.open-modal-btn:hover {
    background: #4dd0e1;
}

/* Prepared Spells List */
.prepared-spells-list {
    padding: 10px 15px;
    min-height: 10px;
}

.prepared-spell-item {
    display: flex;
    align-items: center;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 12px 16px;
    margin-bottom: 12px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    transition: all 0.2s;
    position: relative;
    /* Bug 3 Fix */
}

.prepared-spell-item.used {
    background: #1a1a1a;
    border-left-color: #555;
    opacity: 0.6;
}

.prepared-spell-item.used .spell-name {
    text-decoration: line-through;
    color: var(--text-muted);
}

.spell-content {
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
    /* Prevent text overflow */
}

.spell-used-toggle {
    width: 20px;
    height: 20px;
    cursor: pointer;
    background: var(--input-bg);
    border: 1px solid var(--defense-silver);
    appearance: none;
    /* Custom checkbox style if needed, but standard is okay for now */
    border-radius: 3px;
    display: grid;
    place-content: center;
}

.spell-used-toggle::before {
    content: "";
    width: 10px;
    height: 10px;
    transform: scale(0);
    transition: 120ms transform ease-in-out;
    box-shadow: inset 1em 1em var(--accent-color);
    transform-origin: center;
    clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}

.spell-used-toggle:checked::before {
    transform: scale(1);
    background-color: var(--accent-color);
}

.spell-used-toggle:checked {
    border-color: var(--accent-color);
}


.spell-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
    /* Enable text truncation */
}

.spell-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.95rem;
}

.meta-tags {
    font-size: 0.75rem;
    color: #ffb74d;
    /* Orange lighten-2 */
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.prepared-spell-item .remove-spell {
    cursor: pointer;
    color: #e57373;
    /* Red lighten-2 */
    font-weight: bold;
    padding: 5px 10px;
    /* Larger area */
    opacity: 0.7;
    transition: opacity 0.2s;
    font-size: 1.4rem;
}

.prepared-spell-item .remove-spell:hover {
    opacity: 1;
}

/* Domain Slot Integration */
.domain-slot-container {
    margin-top: 12px;
    padding: 0;
    background: transparent;
    border: none;
}

.domain-fieldset {
    position: relative;
    border: 1px solid var(--accent-color);
    border-radius: var(--border-radius);
    margin: 15px 0 0 0;
    padding: 18px 10px 10px;
    /* Ridotto padding laterale */
    background: rgba(3, 218, 198, 0.03);
    transition: all 0.3s ease;
    box-sizing: border-box;
    width: 100%;
}

.domain-legend {
    position: absolute;
    top: 0;
    left: 10px;
    transform: translateY(-50%);
    background: var(--card-bg);
    padding: 0 8px;
    color: var(--accent-color);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.05rem;
    text-transform: uppercase;
}

.domain-spell-item {
    width: 100% !important;
    margin: 0 !important;
    background: var(--input-bg) !important;
    border: none !important;
    box-sizing: border-box !important;
    border-left: 3px solid var(--accent-color) !important;
}

.domain-full-action-btn {
    width: 100%;
    height: 44px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px dashed rgba(3, 218, 198, 0.3);
    color: var(--accent-color);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.domain-full-action-btn:hover {
    background: rgba(3, 218, 198, 0.1);
    border-color: var(--accent-color);
}

.domain-select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--input-bg);
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 0.95rem;
}

.domain-used-toggle {
    width: 20px;
    height: 20px;
    cursor: pointer;
    margin-left: auto;
    accent-color: var(--accent-color);
}

.domain-full-action-btn {
    width: 100%;
    min-height: 48px;
    /* Matches standard item height with padding */
    background: rgba(255, 255, 255, 0.03);
    border: 1px dashed rgba(3, 218, 198, 0.3);
    color: var(--accent-color);
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
    padding: 0;
    margin: 0;
}

.domain-full-action-btn:hover {
    background: rgba(3, 218, 198, 0.1);
    border-color: var(--accent-color);
    box-shadow: 0 0 10px rgba(3, 218, 198, 0.1);
}

/* Nuova Griglia Caratteristiche */
.stats-ability-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.ability-score-item {
    background: var(--input-bg);
    padding: 12px 8px;
    border-radius: 10px;
    text-align: center;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    position: relative;
    transition: all 0.3s ease;
}

.ability-score-item label {
    font-size: 0.7rem;
    font-weight: 900;
    color: var(--text-muted);
}

.ability-score-item input {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-main);
    text-align: center;
    font-size: 1.2rem;
    font-weight: bold;
    font-family: var(--font-body);
    padding: 0;
}

.ability-score-item input:focus {
    outline: none;
}

.ability-mod {
    font-size: 0.8rem;
    font-weight: bold;
    color: var(--accent-color);
    background: var(--primary-color-10);
    padding: 2px 8px;
    border-radius: 20px;
}

/* Evidenziazione stat chiave */
.ability-score-item.highlight-int {
    border-color: var(--school-divination);
}

.ability-score-item.highlight-wis {
    border-color: var(--primary-color);
}

.ability-score-item.highlight-cha {
    border-color: var(--school-enchantment);
}

/* Badge Livello nella Sidebar */
.lvl-badge {
    background: var(--accent-color);
    color: #121212;
    font-size: 0.7rem;
    font-weight: 900;
    padding: 2px 8px;
    border-radius: 6px;
    margin-top: 4px;
    display: inline-block;
}

/* Modale Progressione */
.progression-timeline {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 10px 0;
}

.level-row {
    display: flex;
    align-items: center;
    gap: 15px;
    background: var(--input-bg);
    padding: 10px 15px;
    border-radius: 10px;
    border-left: 4px solid var(--accent-color);
}

.level-num-circle {
    width: 30px;
    height: 30px;
    background: var(--accent-color);
    color: black;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 0.9rem;
}

.level-class-info {
    flex: 1;
}

.level-class-name {
    font-family: var(--font-heading);
    font-size: 1rem;
}

/* ==========================================================================
   Character Sheet - Stats (Vertical Rows)
   ========================================================================== */

.stats-ability-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.stat-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.03);
    padding: 10px 15px;
    border-radius: var(--border-radius);
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.2s ease;
}

.stat-row:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
}

.stat-label {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-muted);
    width: 45px;
}

.stat-inputs-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.stat-row input[type="number"] {
    width: 60px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-main);
    padding: 6px;
    text-align: center;
    font-weight: 700;
    font-size: 1rem;
}

.stat-mod {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    color: var(--accent-color);
    font-size: 1.1rem;
    min-width: 35px;
    text-align: center;
}

.stat-temp-input {
    width: 70px !important;
    font-size: 0.85rem !important;
    opacity: 0.7;
    border-style: dashed !important;
}

.stat-temp-input:focus {
    opacity: 1;
    border-style: solid !important;
}

.highlight-wis .stat-label {
    color: var(--primary-color);
}

.highlight-int .stat-label {
    color: #ffd740;
}

.highlight-cha .stat-label {
    color: #e040fb;
}

/* Sidebar Level Action Badge */
.lvl-badge-btn {
    font-size: 0.75rem;
    padding: 3px 8px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    border-radius: 4px;
    transition: all 0.2s ease;
    cursor: default !important;
    /* Non più cliccabile come da richiesta */
}

.lvl-badge-btn:hover {
    transform: none;
}

.caster-level-tag {
    font-size: clamp(0.65rem, 3.2vw, 0.85rem); white-space: nowrap; gap: 8px;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    padding: 4px 10px;
    border-radius: 15px;
    border: 1px solid var(--border-color);
}

.caster-level-tag span {
    color: var(--accent-color);
    font-weight: bold;
}

.btn-add-level {
    width: 100%;
    padding: 12px;
    background: var(--primary-color-05);
    border: 2px dashed var(--accent-color);
    color: var(--accent-color);
    border-radius: 10px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 10px;
    transition: all 0.2s;
}

.btn-add-level:hover {
    background: var(--primary-color-15);
}


/* --- MODAL STYLES --- */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 12000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
    transition: z-index 0s;
    /* Instant update when stacked */
    /* 15 marginal, then 56px bottom nav */
    padding: 15px 15px calc(56px + env(safe-area-inset-bottom, 15px)) 15px;
    box-sizing: border-box;
}


.modal-overlay.hidden {
    display: none !important;
}


.modal-content {
    background: var(--card-bg);
    width: 100%;
    max-width: 600px;
    height: 85vh;
    /* Slightly taller on mobile */
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
    border: 1px solid var(--border-color);
}

.modal-header {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #252525;
}

.modal-header h2 {
    margin: 0;
    font-family: var(--font-heading);
    color: var(--primary-color);
    font-size: 1.2rem;
}

.modal-close_btn {
    background: none;
    border: none;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0 10px;
}

.modal-close_btn:hover {
    color: #e57373;
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--accent-color);
    color: #121212;
    padding: 10px 20px;
    border-radius: 30px;
    font-weight: bold;
    font-size: 0.9rem;
    z-index: 8000;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    pointer-events: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #121212;
}

::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
}

/* Inventory Tabs Switcher */
.inventory-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 15px;
    background: rgba(0, 0, 0, 0.2) !important;
    padding: 6px;
    border-radius: 8px;
}

.inv-tab {
    flex: 1 1 0px;
    min-width: 0;
    background: transparent;
    color: var(--text-muted);
    border: none;
    padding: 8px 4px;
    border-radius: 6px;
    font-family: 'Cinzel', serif;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Force Equipaggiamento to own its row (Full width stacked on top) */
.inv-tab[data-type="e"] {
    flex: 1 1 100%;
}

.inv-tab:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.inv-tab.active {
    background: var(--accent-color) !important;
    color: var(--bg-app) !important;
    font-weight: bold;
}

/* Custom PNG Icons Styling */
.nav-icon-img {
    width: 21px;
    /* RIDOTTO per combaciare con icone FontAwesome */
    height: 21px;
    object-fit: contain;
    /* Convert to gray #9e9e9e instead of pure white */
    filter: brightness(0) invert(62%);
    margin-bottom: 3px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.section-icon-img {
    width: 18px;
    /* Più piccola per allinearsi meglio */
    height: 18px;
    object-fit: contain;
    filter: brightness(0) saturate(100%) invert(86%) sepia(34%) saturate(750%) hue-rotate(170deg) brightness(101%) contrast(100%);
    vertical-align: middle;
    margin-right: 8px;
}

.nav-item.active .nav-icon-img {
    /* Colore Azzurro (--primary-color: #81d4fa) */
    filter: brightness(0) saturate(100%) invert(86%) sepia(34%) saturate(750%) hue-rotate(170deg) brightness(101%) contrast(100%);
}

/* Sticky top section inside modal content */
.modal-sticky-section {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 15px;
    flex: 0 0 auto;
    z-index: 10;
}

.metamagic-container {
    margin-bottom: 15px;
}

.mm-label {
    color: var(--text-muted);
    font-weight: bold;
    font-size: 0.9rem;
}

.metamagic-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.mm-option {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: clamp(0.65rem, 3.2vw, 0.85rem); white-space: nowrap; gap: 8px;
    background: var(--input-bg);
    padding: 8px 12px;
    border-radius: 20px;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.mm-option:hover {
    background: #333;
}

.mm-option input:checked+span {
    color: var(--accent-color);
    font-weight: bold;
}

/* Search bar inside modal */
.search-bar-container {
    display: flex;
    gap: 10px;
    align-items: center;
}

.spell-search {
    flex: 1;
    padding: 12px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    color: var(--text-main);
    font-family: var(--font-body);
}

.spell-search:focus {
    border-color: var(--accent-color);
    outline: none;
}

/* Scrollable List */
.modal-spell-list {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 15px;
    background: var(--card-bg);
}

.spell-grid {
    display: grid;
    grid-template-columns: 1fr;
    /* Single column default for mobile */
    gap: 10px;
}

.spell-selection-item {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--text-main);
    min-height: 54px;
    /* Uniform height for aesthetics */
    gap: 10px;
}

.spell-selection-item .spell-name {
    white-space: normal;
    line-height: 1.2;
    flex: 1;
    display: block;
    word-break: break-word;
}

.spell-selection-item:hover {
    border-color: var(--accent-color);
    background: rgba(3, 218, 198, 0.05);
}

.spell-selection-item span {
    font-weight: 500;
}

.spell-selection-item .plus-icon {
    font-weight: bold;
    color: var(--accent-color);
    font-size: 1.4rem;
}

.domain-highlight {
    color: var(--primary-color);
}

/* Favorite Styles */
.filter-favorite-btn {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-muted);
    padding: 10px 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 46px;
    /* Match search input height */
    box-sizing: border-box;
}

.filter-favorite-btn i {
    font-size: 1.2rem;
}

.filter-favorite-btn.active {
    border-color: #f1c40f;
    color: #f1c40f;
    background: rgba(241, 196, 15, 0.1);
    box-shadow: 0 0 10px rgba(241, 196, 15, 0.2);
}

.favorite-star {
    margin-right: 12px;
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.favorite-star:hover {
    transform: scale(1.2);
    color: rgba(241, 196, 15, 0.4);
}

.favorite-star.active {
    color: #f1c40f;
    text-shadow: 0 0 8px rgba(241, 196, 15, 0.5);
}

.spell-selection-item {
    padding-left: 8px !important;
    /* Adjust for star */
}

/* Domain Source Tags */
.source-tag-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 21px;
    height: 21px;
    border-radius: 3px;
    font-size: 0.8rem;
    font-weight: 900;
    margin-left: 10px;
    vertical-align: middle;
    line-height: 1;
    background-color: transparent;
    border: 2px solid currentColor;
}

.source-tag-icon.air {
    color: var(--primary-color);
}

.source-tag-icon.travel {
    color: #4fc3f7;
}

.source-air-text {
    color: var(--primary-color) !important;
}

.source-travel-text {
    color: #4fc3f7 !important;
}

/* --- ANIMATIONS --- */

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* --- SPELL DETAIL MODAL --- */
.detail-modal-content {
    background: #1e1e1e;
    border: 1px solid #333;
}

.detail-header {
    background: #2c2c2c;
    border-bottom: 2px solid #333;
}

.school-tag {
    font-size: 0.8rem;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 5px;
    display: inline-block;
}

.detail-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.2);
    margin-bottom: 15px;
    border-radius: 8px;
}

.stat-box {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.03);
    padding: 8px 10px;
    border-radius: 6px;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    width: 100%;
}

.stat-content {
    display: flex;
    align-items: center;
    width: 100%;
}

.stat-icon {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    width: 24px;
    margin-right: 8px;
}

.stat-value {
    font-size: 0.9rem;
    font-weight: bold;
    color: var(--text-main);
}

.detail-description-container {
    padding: 0 15px 15px;
}

.detail-description-container h3 {
    color: var(--primary-color);
    font-size: 1.1rem;
    border-bottom: 1px solid #333;
    padding-bottom: 5px;
    margin-top: 0;
}

.detail-description-container p {
    line-height: 1.6;
    color: #ccc;
    white-space: pre-wrap;
}

/* School Borders classes */
.school-border-Abjuration {
    border-left-color: var(--school-abjuration) !important;
}

.school-border-Conjuration {
    border-left-color: var(--school-conjuration) !important;
}

.school-border-Divination {
    border-left-color: var(--school-divination) !important;
}

.school-border-Enchantment {
    border-left-color: var(--school-enchantment) !important;
}

.school-border-Evocation {
    border-left-color: var(--school-evocation) !important;
}

.school-border-Illusion {
    border-left-color: var(--school-illusion) !important;
}

.school-border-Necromancy {
    border-left-color: var(--school-necromancy) !important;
}

.school-border-Transmutation {
    border-left-color: var(--school-transmutation) !important;
}

.school-border-Universal {
    border-left-color: var(--school-universal) !important;
}

/* Interactive/Clickable Name */
.spell-name-clickable {
    cursor: pointer;
    text-decoration: none;
    color: var(--text-main);
    transition: color 0.2s;
}

.spell-name-clickable:hover {
    color: var(--accent-color);
}

.spell-name-clickable.slots-info.full {
    color: var(--accent-color);
}

/* Orison Usage Controls (Next to Title) */
.orison-usage-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 4px;
    border-radius: 15px;
    margin-left: 10px;
}

.orison-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: var(--accent-color);
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: bold;
    transition: all 0.2s;
    line-height: 1;
}

.orison-btn:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.orison-count-display {
    font-size: 0.95rem;
    font-weight: bold;
    min-width: 40px;
    text-align: center;
}

/* Orison Premium Grid */
.prepared-orisons-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 15px;
}

.orison-card {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    /* Bug 3 Fix */
}

.orison-card:hover {
    border-color: var(--accent-color);
    background: rgba(255, 255, 255, 0.05);
}

.orison-name {
    flex: 1;
    font-size: 0.95rem;
    font-weight: 500;
}

/* Espansione area di click per la X delle orazioni (Surgical Fix) */
.orison-card .remove-spell {
    position: relative;
    cursor: pointer;
    z-index: 5;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.orison-card .remove-spell::after {
    content: '';
    position: absolute;
    top: -15px;
    bottom: -15px;
    left: -15px;
    right: -15px;
    /* Crea una "bolla" di click invisibile di 30px extra */
}

/* --- DRAG & DROP (Placeholder styles) --- */
.detail-sources-list {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
}

.source-btn {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    /* Match stat-box */
    padding: 10px 14px;
    border-radius: 6px;
    cursor: default;
    color: var(--text-main);
    /* Default White */
    font-size: 0.95rem;
    border: 1px solid transparent;
}

.source-btn.source-blue .source-text {
    color: #4fc3f7 !important;
    /* Blue text for special standard adds */
    font-weight: bold;
}

.source-text {
    flex: 1;
}

.source-add-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 1.2rem;
    line-height: 1;
    /* Center vertically */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-left: 10px;
    transition: background 0.2s;
    padding-bottom: 2px;
    /* Visual tweak */
}

.source-add-btn:hover {
    background: var(--primary-light);
}


/* Icon adjustments */
.stat-icon {
    width: 30px;
}

.source-add-btn i {
    font-size: 0.9em;
}



/* Grid Layout for Stats */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 1rem;
}

/* Icon Colors */
.stat-box:nth-child(1) .stat-icon i {
    color: #fbc02d;
}

/* Cast Time - Gold */
.stat-box:nth-child(2) .stat-icon i {
    color: #4fc3f7;
}

/* Components - Light Blue */
.stat-box:nth-child(3) .stat-icon i {
    color: #66bb6a;
}

/* Range - Green */
.stat-box:nth-child(4) .stat-icon i {
    color: #ab47bc;
}

/* Duration - Purple */
.stat-box:nth-child(5) .stat-icon i {
    color: #ef5350;
}

/* Save - Red */
.stat-box:nth-child(6) .stat-icon i {
    color: #ec407a;
}

/* SR - Pink */

/* Make stat boxes slightly more compact for grid */
/* .stat-box padding now handled by grid styles */



/* --- FIXED LAYOUT & COMPACT UI CONSOLIDATED --- */

/* 1. Modal Fixed Height & Scroll Structure */
.detail-modal-content {
    display: flex;
    flex-direction: column;
    height: 85vh;
    max-height: 800px;
    padding: 0;
    overflow: hidden;
}

.detail-header {
    flex-shrink: 0;
    padding: 15px 20px 5px 20px !important;
    /* Compact Padding */
}

.detail-header h2 {
    margin-bottom: 4px;
    font-size: 1.3rem;
}

/* 2. Stats Grid (Fixed Top) */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 0 20px 10px 20px !important;
    margin-bottom: 0;
    flex-shrink: 0;
}

.stat-box {
    padding: 6px 8px !important;
    /* Compact Box */
}

.stat-icon {
    width: 24px !important;
    font-size: 1rem !important;
}


.stat-label {
    font-size: 0.7rem !important;
    text-transform: uppercase;
    color: var(--text-muted);
}

.stat-value {
    font-size: 0.85rem !important;
    font-weight: 500;
}

/* Icon Colors */
.stat-box:nth-child(1) .stat-icon i {
    color: #fbc02d;
}

/* Time */
.stat-box:nth-child(2) .stat-icon i {
    color: #4fc3f7;
}

/* Comp */
.stat-box:nth-child(3) .stat-icon i {
    color: #66bb6a;
}

/* Range */
.stat-box:nth-child(4) .stat-icon i {
    color: #ab47bc;
}

/* Dur */
.stat-box:nth-child(5) .stat-icon i {
    color: #ef5350;
}

/* Save */
.stat-box:nth-child(6) .stat-icon i {
    color: #ec407a;
}

/* SR */

/* 3. Scrollable Body */
.detail-scroll-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.detail-scroll-area::-webkit-scrollbar {
    width: 6px;
}

.detail-scroll-area::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

/* 4. Sources Footer (Fixed Bottom) */
.detail-sources-list {
    flex-shrink: 0;
    display: grid !important;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 10px 20px 15px 20px !important;
    border-top: 1px solid var(--border-color);
    background: var(--card-bg);
    margin: 0;
}

.detail-sources-list.hidden,
#detail-sources-list.hidden {
    display: none !important;
}

/* Source Button Styling */
.source-btn {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    /* Push content apart */
    align-items: center;
    text-align: center;
    padding: 8px 6px !important;
    min-height: 85px;
    /* Fixed height for consistency */
}

.source-text {
    font-size: 0.75rem;
    line-height: 1.2;
    margin-bottom: 4px;
    /* Spacer */
}

.source-text i {
    display: block;
    font-size: 1.2rem;
    margin-bottom: 6px;
    color: var(--text-muted);
}

.source-btn.source-blue .source-text i {
    color: #4fc3f7;
}

.source-add-btn {
    width: 100%;
    margin-top: auto;
    /* Push to bottom */
    padding: 4px 0;
    font-size: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* [Step 527] Final Header Spacing Adjustment */
.detail-header {
    padding-bottom: 25px !important;
    /* Significant separation */
    margin-bottom: 5px;
    /* Physical gap */
    border-bottom: 1px solid var(--border-color);
}

.stats-grid {
    padding-top: 15px !important;
    /* Breathing room for top row stats */
    border-top: none;
    /* Avoid double borders if header has one */
}

/* Global Search Results Dropdown */
.global-search-container {
    position: relative;
    /* Anchor for absolute dropdown */
}

.search-results-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--card-bg);
    /* Use card background */
    border: 1px solid var(--accent-color);
    /* Highlight border */
    border-radius: 0 0 8px 8px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    /* Ensure on top */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.search-result-item {
    padding: 10px 15px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: rgba(3, 218, 198, 0.1);
}

.search-result-name {
    font-weight: bold;
    color: var(--primary-color);
}

.search-result-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}


/* Redundant Domain Section Removed and Consolidated Above */

/* Global Search Dropdown Refinement */
.search-results-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--accent-color);
    border-top: none;
    /* Flow seamlessly from search box */
    border-radius: 0 0 12px 12px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 9300;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    margin-top: 0;
    /* Align perfectly */

    /* Animation base */
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.global-search-container[data-search-active="true"] .search-results-dropdown {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.search-results-dropdown.hidden {
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
}

.search-result-item {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: rgba(3, 218, 198, 0.1);
}

/* Force Global Search Width */
#global-spell-search {
    width: 100% !important;
    max-width: 100% !important;
    display: block !important;
    box-sizing: border-box !important;
}


/* Force Global Search to full width */
.global-search-container {
    width: 100% !important;
    box-sizing: border-box;
    display: block;
    clear: both;
}


/* Info Icon in Modal Spell Selection */
.spell-selection-item .info-icon {
    color: var(--primary-color);
    font-size: 1.2rem;
    opacity: 0.7;
    transition: opacity 0.2s, color 0.2s;
    cursor: pointer;
    padding: 4px;
}

.spell-selection-item .info-icon:hover {
    opacity: 1;
    color: var(--accent-color);
}



/* Metamagic Icon Styling */
.known-mm-item .mm-icon {
    color: var(--accent-color);
    font-size: 0.95rem;
}

.mm-option .mm-icon {
    color: var(--accent-color);
    font-size: 0.9rem;
    margin-right: 4px;
}



/* Mobile Optimizations */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        max-width: 95%;
        height: 90vh;
        padding: 0;
    }

    .modal-header {
        padding: 12px;
    }

    .modal-header h2 {
        font-size: 1rem;
    }

    .modal-sticky-section {
        padding: 10px;
    }

    .spell-search {
        padding: 10px;
        font-size: 0.95rem;
    }

    .modal-spell-list {
        padding: 10px;
    }

    .spell-selection-item {
        padding: 8px 10px;
        font-size: clamp(0.65rem, 3.2vw, 0.85rem); white-space: nowrap; gap: 8px;
        min-height: 50px;
    }

    .spell-selection-item .spell-name {
        font-size: 0.82rem;
    }

    .spell-selection-item .info-icon {
        font-size: 1rem;
    }

    /* Detail Modal */
    .detail-modal-content {
        width: 95%;
        max-width: 95%;
    }

    .detail-header h2 {
        font-size: 1.1rem;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
        padding: 0 10px 10px 10px !important;
    }

    .stat-box {
        padding: 4px 6px !important;
    }

    .stat-icon {
        width: 20px !important;
        font-size: 0.9rem !important;
        margin-right: 6px;
    }

    .stat-label {
        font-size: 0.65rem !important;
    }

    .stat-value {
        font-size: 0.75rem !important;
        line-height: 1.2;
    }

    .detail-description-container {
        padding: 0 10px 10px;
    }

    .detail-description-container h3 {
        font-size: 1rem;
    }

    .detail-description-container p {
        font-size: 0.9rem;
    }

    /* Metamagic options in modal */
    .mm-option {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    /* Horizontal Alignment & Unified Spacing */
    .settings-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .level-header {
        padding: 10px;
    }

    .level-title {
        font-size: 1rem;
    }

    .slots-info {
        font-size: clamp(0.65rem, 3.2vw, 0.85rem); white-space: nowrap; gap: 8px;
    }

    .slot-tracker {
        padding: 8px 10px 4px;
        gap: 6px;
        justify-content: center;
        /* Center slots for better horizontal balance on small screens */
    }

    .slot-icon {
        width: 12px;
        height: 12px;
    }

    .prepared-spells-list {
        padding: 8px 10px;
    }

    .prepared-spell-item {
        padding: 8px;
    }

    .operational-panel {
        padding: 12px;
        margin-bottom: 15px;
    }

    .app-container {
        padding: 70px 5px 0 5px;
    }
}

/* Toast Notification */
/* Removed duplicate - handled at line 872 */

@media (max-width: 768px) {
    .toast {
        bottom: 20px;
        padding: 10px 20px;
        font-size: clamp(0.65rem, 3.2vw, 0.85rem); white-space: nowrap; gap: 8px;
        max-width: 90%;
    }
}

/* Spell Icons Container */
.spell-icons {
    display: flex;
    align-items: center;
    gap: 8px;
}

.spell-selection-item .remove-icon {
    color: #e57373;
    font-size: 1.1rem;
    opacity: 0.8;
    transition: opacity 0.2s, color 0.2s;
    cursor: pointer;
    padding: 4px;
}

.spell-selection-item .remove-icon:hover {
    opacity: 1;
    color: #ef5350;
}

.spell-count {
    color: var(--accent-color);
    font-weight: 600;
    font-size: clamp(0.65rem, 3.2vw, 0.85rem); white-space: nowrap; gap: 8px;
    margin-left: 4px;
}

/* Spell Icons Container */
.spell-icons {
    display: flex;
    align-items: center;
    gap: 8px;
}

.spell-selection-item .remove-icon {
    color: #e57373;
    font-size: 1.1rem;
    opacity: 0.8;
    transition: opacity 0.2s, color 0.2s;
    cursor: pointer;
    padding: 4px;
}

.spell-selection-item .remove-icon:hover {
    opacity: 1;
    color: #ef5350;
}

.spell-count {
    color: var(--accent-color);
    font-weight: 600;
    font-size: clamp(0.65rem, 3.2vw, 0.85rem); white-space: nowrap; gap: 8px;
    margin-left: 4px;
}

/* Spell Icons Container */
.spell-icons {
    display: flex;
    align-items: center;
    gap: 8px;
}

.spell-selection-item .remove-icon {
    color: #e57373;
    font-size: 1.1rem;
    opacity: 0.8;
    transition: opacity 0.2s, color 0.2s;
    cursor: pointer;
    padding: 4px;
}

.spell-selection-item .remove-icon:hover {
    opacity: 1;
    color: #ef5350;
}

.spell-count {
    color: var(--accent-color);
    font-weight: 600;
    font-size: clamp(0.65rem, 3.2vw, 0.85rem); white-space: nowrap; gap: 8px;
    margin-left: 4px;
}

/* Metamagic Modal Grid */
.metamagic-modal-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 15px;
}

.metamagic-modal-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--input-bg);
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s;
}

.metamagic-modal-item:hover {
    border-color: var(--accent-color);
    background: rgba(3, 218, 198, 0.05);
}

.metamagic-modal-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-color);
}

.metamagic-modal-item .mm-icon {
    color: var(--accent-color);
    font-size: 1rem;
}

.metamagic-modal-item .mm-name {
    flex: 1;
    font-size: 0.9rem;
    color: var(--text-main);
}

.metamagic-modal-item .info-icon {
    color: var(--primary-color);
    font-size: 1.1rem;
    opacity: 0.7;
    transition: opacity 0.2s;
    cursor: pointer;
    padding: 4px;
}

.metamagic-modal-item .info-icon:hover {
    opacity: 1;
    color: var(--accent-color);
}

/* Primary Button Style */
.btn-primary {
    width: 100%;
    padding: 12px;
    background: var(--accent-color);
    border: none;
    color: #121212;
    font-weight: 700;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.btn-primary:hover {
    filter: brightness(1.12);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--primary-color-30);
}

@media (max-width: 768px) {
    .metamagic-modal-grid {
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 10px;
    }

    .metamagic-modal-item {
        padding: 10px;
    }
}

/* ==========================================================================
   Prepared Spells Chips (Scrollable UX)
   ========================================================================== */
.modal-prepared-container {
    padding: 8px 15px;
    background: rgba(0, 0, 0, 0.4);
    border-bottom: 1px solid var(--border-color);
}

.modal-slots-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-size: clamp(0.65rem, 3.2vw, 0.85rem); white-space: nowrap; gap: 8px;
    color: var(--text-muted);
}

.modal-slots-count {
    font-weight: bold;
    color: var(--accent-color);
}

/* Horizontal scrollable container without scrollbars */
.modal-prepared-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    /* Smooth scroll for mobile */
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    /* Firefox */
}

/* Hide scrollbar for Chrome/Safari */
.modal-prepared-chips::-webkit-scrollbar {
    display: none;
}

/* Individual spell chip styling */
.spell-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(3, 218, 198, 0.15);
    /* Accent tint */
    border: 1px solid rgba(3, 218, 198, 0.3);
    color: var(--text-color);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: clamp(0.65rem, 3.2vw, 0.85rem); white-space: nowrap; gap: 8px;
    white-space: nowrap;
    /* Prevent wrapping */
    transition: background 0.2s, transform 0.1s;
}

.spell-chip.is-domain {
    background: rgba(255, 255, 255, 0.1);
    border: 1px dashed rgba(255, 255, 255, 0.3);
}

.spell-chip-name {
    font-weight: bold;
}

.spell-chip-meta {
    font-size: 0.75rem;
    color: #ffd54f;
    /* Highlight for metamagic tags */
    font-style: italic;
    opacity: 0.9;
}

.spell-chip-remove {
    cursor: pointer;
    color: #e57373;
    /* Red indicator */
    margin-left: 2px;
    padding: 2px 4px;
    /* Give it a better tap target */
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spell-chip-remove:hover {
    color: #ef5350;
    transform: scale(1.1);
}

/* When empty */
.modal-prepared-chips:empty::after {
    content: 'Nessun incantesimo preparato.';
    color: rgba(255, 255, 255, 0.3);
    font-size: clamp(0.65rem, 3.2vw, 0.85rem); white-space: nowrap; gap: 8px;
    font-style: italic;
    padding: 4px 0;
}

/* ==========================================================================
   Spell Detail Description Refinements (Tables & Links)
   ========================================================================== */

/* Tables inside description */
#detail-description table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#detail-description th,
#detail-description td {
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px 12px;
    text-align: left;
}

#detail-description tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

#detail-description tr.golarion-first-row {
    background: rgba(3, 218, 198, 0.1) !important;
    font-weight: bold;
    color: var(--accent-color);
}

/* Hyperlinks in description */
#detail-description a {
    color: #4db6ac;
    /* A soft teal/cyan that contrast well with dark bg */
    text-decoration: none;
    border-bottom: 1px dashed rgba(77, 182, 172, 0.4);
    transition: all 0.2s ease;
}

#detail-description a:hover {
    color: var(--accent-color);
    border-bottom: 1px solid var(--accent-color);
    background: rgba(3, 218, 198, 0.05);
}

/* Fix for bold stats often found in bad extractions */
#detail-description b {
    color: var(--accent-color);
    font-weight: 600;
}

/* ==========================================================================
   Bottom Navigation & View Switching
   ========================================================================== */

.app-view {
    display: none;
    animation: fadeIn 0.3s ease;
    min-height: calc(100vh - 150px);
    /* Previene il salto della nav su viste corte */
}

.app-view.active {
    display: block;
}

.placeholder-view {
    text-align: center;
    padding: 3rem 1rem;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    border: 1px dashed var(--border-color);
    color: var(--text-muted);
}

/* Reduced Height Bottom Nav */
.bottom-nav {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 52px;
    /* Altezza ridotta per mobile */
    background: rgba(18, 18, 18, 0.98);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 5000 !important;
    /* Stay above everything to allow switching */
    padding-bottom: env(safe-area-inset-bottom, 0px);
}


.bottom-nav::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
    background: var(--bg-app);
}

.nav-item {
    flex: 1;
    /* Divide lo spazio in modo identico per tutti i tasti */
    padding: 6px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    height: 100%;
    gap: 3px;
    user-select: none;
    position: relative;
    z-index: 1;
}

.nav-item.active {
    color: var(--accent-color);
}

.nav-item:active {
    scale: 0.94;
    /* Feedback tattico alla pressione */
}


.nav-item i {
    font-size: 1.25rem;
    /* Leggermente più grande per visibilità */
    transition: transform 0.2s ease;
}

.nav-item.active i,
.nav-item.active img {
    transform: translateY(-2px);
}

.nav-item span {
    font-size: 0.7rem;
    font-weight: 600;
}


/* Sheet View Styles */
.sheet-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sheet-section {
    background: var(--card-bg);
    padding: 18px;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.section-title {
    font-family: var(--font-heading);
    color: var(--primary-color);
    font-size: 1.1rem;
    margin: 0 0 15px 0;
    display: flex;
    align-items: center;
    /* Vertically center icon with text block */
    gap: 12px;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
    flex-wrap: nowrap;
    /* Don't wrap icon and text container */
}

.section-title-icon {
    flex-shrink: 0;
}

.section-title-text {
    flex: 1;
    white-space: normal;
    overflow-wrap: break-word;
    line-height: 1.2;
    transition: font-size 0.2s;
}

.section-title-text.is-wrapped {
    font-size: clamp(0.65rem, 3.2vw, 0.85rem);
    white-space: normal;
    line-height: 1.1;
    letter-spacing: 0.5px;
    display: block;
    max-width: 180px;
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    align-items: flex-end;
    /* Align inputs even if labels wrap */
}

.setting-group label {
    line-height: 1.2;
    min-height: 2.4em;
    /* Reserve space for 2 lines to keep inputs aligned */
    display: flex;
    align-items: flex-end;
}

.inventory-content {
    padding-bottom: 20px;
    /* Safe space to prevent nav interference */
}

.trait-box {
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.03);
    padding: 10px;
    border-radius: 8px;
    transition: background 0.2s;
}

.trait-box:hover {
    background: rgba(255, 255, 255, 0.06);
}

.checkbox-container {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer !important;
}

.checkbox-container input {
    cursor: pointer !important;
    width: 20px;
    height: 20px;
}

.trait-info {
    display: flex;
    flex-direction: column;
    pointer-events: none;
    /* Let the label handle click */
}

/* --- Global Search Backdrop & Clear --- */
.search-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(2px);
    z-index: 9100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.global-search-container[data-search-active="true"]~#global-search-backdrop,
.global-search-container[data-search-active="true"] .search-backdrop,
/* if nested */
#global-search-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

/* Since backdrop is at body root, we'll manage its 'active' class via JS for simplicity, 
   but we can also use a body class */
body.search-mode-active .search-backdrop {
    opacity: 1;
    pointer-events: auto;
}

.global-search-container {
    position: relative;
    z-index: 10;
}

.global-search-container[data-search-active="true"] {
    z-index: 9200;
}

.search-flex {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--card-bg);
    /* Ensure search box has bg to cover backdrop blur */
    border-radius: 8px;
    transition: all 0.2s;
}

.global-search-container[data-search-active="true"] .search-flex {
    border-radius: 8px 8px 0 0;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.search-clear-btn {
    position: absolute;
    right: 64px;
    z-index: 5;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.global-search-container[data-search-active="true"] .search-clear-btn {
    opacity: 1;
    pointer-events: auto;
}

.trait-name {
    font-weight: bold;
    color: var(--accent-color);
    font-size: 1rem;
}

.trait-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ==========================================================================
   Inventory Styles
   ========================================================================== */
.inventory-section {
    margin-bottom: 20px;
}

.section-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.section-header-row .section-title {
    margin: 0;
    border-bottom: none;
    padding-bottom: 0;
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-header-row .section-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    align-items: center;
}

.btn-add-item {
    background: var(--accent-color);
    color: #000;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all 0.2s;
}

.btn-add-item:hover {
    transform: scale(1.1);
    background: #4dd0e1;
}

/* Inventory Item Layout */
.inventory-items-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.inventory-item {
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 12px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.inventory-item.to-sell {
    border-left: 4px solid #c35214;
    background: rgba(195, 82, 20, 0.05);
}

.item-main {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.item-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.item-name {
    font-weight: 700;
    color: var(--text-main);
    font-size: 1rem;
}

.sell-badge {
    font-size: 0.6rem;
    font-weight: 800;
    background: var(--accent-color);
    color: #121212;
    padding: 1px 5px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.item-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.item-val-display {
    font-weight: 800;
    color: var(--text-muted);
    background: #252525;
    padding: 3px 8px;
    border-radius: 6px;
    border: 1px solid #333;
    font-size: 0.75rem;
    line-height: 1;
    display: inline-block;
}

.item-sale-badge {
    background: rgba(195, 82, 20, 0.1);
    color: #ff8a65;
    padding: 3px 8px;
    border-radius: 6px;
    border: 1px solid rgba(195, 82, 20, 0.2);
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1;
    display: inline-block;
}

.sell-star-block {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    border: 1px solid #333;
    color: #444;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.sell-star-block.active {
    background: rgba(195, 82, 20, 0.15);
    border-color: #c35214;
    color: #c35214;
    box-shadow: inset 0 0 10px rgba(195, 82, 20, 0.1);
}

.sell-star-block i {
    font-size: 1.1rem;
}

.item-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #2a2a2a;
    padding-top: 8px;
}

.item-qty-control {
    display: flex;
    align-items: center;
    background: #252525;
    border-radius: 8px;
    padding: 2px;
    border: 1px solid #333;
}

.qty-btn {
    background: none;
    border: none;
    color: var(--text-main);
    width: 26px;
    height: 26px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    border-radius: 4px;
}

.qty-btn:hover {
    background: rgba(255, 255, 255, 0.05);
}

.qty-display {
    min-width: 25px;
    text-align: center;
    font-weight: 800;
    font-size: 0.9rem;
}

.item-tools {
    display: flex;
    gap: 15px;
    align-items: center;
}

.action-icon {
    font-size: 1.1rem;
    cursor: pointer;
    color: #666;
    transition: all 0.2s ease;
}

.action-icon:hover {
    color: var(--text-main);
    transform: scale(1.1);
}

.sell-btn.active {
    color: var(--accent-color);
}

.transfer-btn:hover {
    color: var(--primary-color);
}

.remove-item-btn:hover {
    color: #ff5252;
}

@media (max-width: 480px) {
    .inventory-item {
        padding: 10px;
    }

    .item-name {
        font-size: 0.9rem;
    }

    .item-tools {
        gap: 12px;
    }
}

.coins-layout {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 15px 0;
    padding: 10px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 12px;
}

.coins-column {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
}

.coin-control {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 2px;
    transition: all 0.2s;
    overflow: hidden;
}

.coin-control:hover {
    border-color: var(--accent-light);
}

.coin-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 60px;
}

.coin-info i {
    font-size: 1rem;
    margin-bottom: 2px;
}

.fas.fa-coins.cp,
.coin-info i.cp {
    color: #cd7f32;
}

.fas.fa-coins.sp,
.coin-info i.sp {
    color: #c0c0c0;
}

.fas.fa-coins.gp,
.coin-info i.gp {
    color: #ffd700;
}

.fas.fa-coins.pp,
.coin-info i.pp {
    color: #e5e4e2;
}

.coin-value {
    font-weight: bold;
    font-size: 1.1rem;
    line-height: 1;
}

.coin-info label {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: bold;
}

.coin-btn {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: var(--text-main);
    width: 32px;
    height: 38px;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.coin-btn.minus {
    color: #e57373;
    border-right: 1px solid var(--border-color);
}

.coin-btn.plus {
    color: var(--accent-color);
    border-left: 1px solid var(--border-color);
}

.coin-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.coin-btn:active {
    scale: 0.9;
}

.coins-total-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, #2a2a2a, #1a1a1a);
    padding: 15px 10px;
    border-radius: 50%;
    width: 100px;
    height: 100px;
    border: 2px solid var(--accent-color);
    box-shadow: 0 0 15px rgba(3, 218, 198, 0.1);
    flex-shrink: 0;
}

.coins-total-display .total-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    letter-spacing: 1px;
    text-align: center;
    line-height: 1.2;
}

.coins-total-display .total-amount {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--accent-color);
    font-family: var(--font-heading);
}

.coins-total-display .total-unit {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
}

/* Modal Specific */
.coin-modal-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.coin-modal-display i {
    font-size: 3rem;
}

.coin-modal-display span {
    font-size: 1.2rem;
    font-weight: bold;
    text-transform: uppercase;
}

@media (max-width: 480px) {
    .coins-layout {
        gap: 4px;
        padding: 8px 4px;
        justify-content: center;
    }

    .coins-column {
        gap: 8px;
        flex: 1;
        min-width: 0;
    }

    .coins-total-display {
        width: 75px;
        height: 75px;
        padding: 5px;
        border-width: 1.5px;
    }

    .coins-total-display .total-amount {
        font-size: 1rem;
    }

    .coins-total-display .total-label {
        font-size: 0.45rem;
        transform: scale(0.9);
    }

    .coin-control {
        padding: 1px;
        border-radius: 6px;
    }

    .coin-info {
        min-width: 40px;
    }

    .coin-value {
        font-size: 0.9rem;
    }

    .coin-info label {
        font-size: 0.55rem;
    }

    .coin-btn {
        width: 26px;
        height: 34px;
        font-size: 1rem;
    }
}

@media (max-width: 380px) {
    .coins-total-display {
        width: 65px;
        height: 65px;
    }

    .coins-total-display .total-amount {
        font-size: 0.9rem;
    }

    .coin-info {
        min-width: 35px;
    }
}

.btn-metamagic-manager {
    width: 100%;
    padding: 12px;
    background: var(--accent-light);
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-transform: uppercase;
}

/* Redefine Spell Blocks specifically */
.spell-level-block {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.level-header {
    padding: 12px 15px;
    background: #222;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.slots-info {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    white-space: nowrap;
}

.slots-count {
    color: var(--accent-color);
    font-size: clamp(0.65rem, 3.2vw, 0.85rem); white-space: nowrap; gap: 8px;
}

.level-title {
    margin: 0;
    font-size: 1.1rem;
    font-family: var(--font-heading);
    color: var(--primary-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Mobile Optimizations for Horizontal Overflow */
@media (max-width: 480px) {
    .main-header h1 {
        font-size: 1.5rem;
    }

    .level-header,
    .section-header-row {
        padding: 10px 12px;
    }

    .header-left,
    .section-title {
        gap: 10px;
        min-width: 0;
        flex: 1;
        white-space: normal;
        overflow: visible;
        word-break: break-word;
    }

    .section-title {
        font-size: 0.95rem;
        align-items: center;
    }

    .section-title-icon {
        font-size: 1.1rem;
    }

    .header-right,
    .btn-add-item {
        gap: 8px;
        flex-shrink: 0;
    }

    .slots-info {
        font-size: 0.75rem;
    }

    .nav-item span {
        font-size: 0.68rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        padding: 0 2px;
        width: 100%;
        text-align: center;
    }
}

@media (max-width: 360px) {
    .nav-item span {
        font-size: 0.62rem;
        letter-spacing: -0.3px;
    }

    .header-left {
        gap: 6px;
    }

    .header-right {
        gap: 5px;
    }
}

.orison-usage-controls {
    display: flex;
    align-items: center;
    background: #141414;
    border-radius: 20px;
    padding: 2px;
    border: 1px solid #333;
    scale: 0.9;
    transform-origin: left center;
}

.orison-btn {
    background: var(--accent-color);
    border: none;
    color: #121212;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.1rem;
    line-height: 1;
}

.orison-count-display {
    padding: 0 10px;
    font-size: 0.9rem;
    font-weight: bold;
    color: var(--text-main);
    min-width: 45px;
    text-align: center;
}

/* ==========================================================================
   Slot Tracker Icons
   ========================================================================== */
/* Obsolescent: These are overwritten below in the inline slots section, 
   but we clear them here so they don't fight. */

/* Toast Notifications */
/* Removed duplicate - handled at line 872 */

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #121212;
}

::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
}

/* ==========================================================================
   Premium Item Modal Styles
   ========================================================================== */
.item-modal-premium {
    background: rgba(30, 30, 30, 0.95) !important;
    backdrop-filter: blur(12px);
    border: 1px solid rgba(129, 212, 250, 0.2) !important;
    max-width: 500px !important;
    height: auto !important;
    max-height: 95vh !important;
    display: flex;
    flex-direction: column;
}

.item-modal-premium .modal-body {
    padding: 0 !important;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.item-form-container {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.form-section {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.form-section:last-of-type {
    border-bottom: none;
}

.form-section.centered {
    display: flex;
    justify-content: center;
    border-bottom: none;
    margin-bottom: 0;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-bottom: 10px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--accent-color);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
    min-height: 14px;
    display: block;
}

.form-group input,
.form-group select,
.form-group textarea {
    background: rgba(44, 44, 44, 0.6);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-radius: 8px;
    padding: 12px;
    font-family: var(--font-body);
    font-size: 1rem;
    transition: all 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--accent-color);
    background: rgba(44, 44, 44, 0.9);
    box-shadow: 0 0 10px var(--primary-color-10);
    outline: none;
}

.form-row-responsive {
    display: flex;
    gap: 15px;
}

.value-currency-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.flex-1 {
    flex: 1;
    min-width: 0;
}

.flex-2 {
    flex: 2;
    min-width: 0;
}

.flex-3 {
    flex: 3;
    min-width: 0;
}

/* Premium Toggle Switch */
.premium-toggle-label {
    width: 100%;
    cursor: pointer;
}

.premium-toggle-label input {
    display: none;
}

.toggle-track {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 0 10px;
    border-radius: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 42px;
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
}

.toggle-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.toggle-thumb {
    width: 32px;
    height: 32px;
    background: #333;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    z-index: 2;
}

.toggle-text {
    flex: 1;
    font-weight: 800;
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    transition: all 0.3s ease;
    text-align: center;
    z-index: 1;
}

.premium-toggle-label input:checked + .toggle-track:not(.dual-switch) {
    flex-direction: row-reverse;
}

/* Dual Switch (Phone Settings Style) */
.toggle-track.dual-switch {
    display: flex;
    position: relative;
    background: rgba(0, 0, 0, 0.4);
    padding: 3px;
    border-radius: 10px;
    gap: 0;
    border: 1px solid var(--border-color);
}

.toggle-selection-bg {
    position: absolute;
    top: 3px;
    left: 3px;
    width: calc(50% - 3px);
    height: calc(100% - 6px);
    background: var(--accent-color);
    border-radius: 7px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.premium-toggle-label input:checked + .toggle-track.dual-switch .toggle-selection-bg {
    transform: translateX(100%);
}

.toggle-option {
    flex: 1;
    z-index: 2;
    text-align: center;
    font-size: 0.6rem;
    font-weight: 900;
    color: var(--text-muted);
    transition: all 0.3s;
    line-height: 1.1;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.premium-toggle-label input:not(:checked) + .toggle-track.dual-switch .toggle-option.opt-1,
.premium-toggle-label input:checked + .toggle-track.dual-switch .toggle-option.opt-2 {
    color: #121212;
}

/* Specific override for Sell toggle to keep icon on left and increase height */
.premium-toggle-label.sell-toggle .toggle-track {
    min-height: 70px;
}

.premium-toggle-label.sell-toggle input:checked + .toggle-track {
    flex-direction: row !important;
}

.toggle-text-main {
    font-weight: 800;
    font-size: clamp(0.7rem, 3.2vw, 0.85rem);
    color: var(--text-muted);
    letter-spacing: 1px;
    line-height: 1.2;
}

.toggle-text-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    opacity: 0.7;
    margin-top: 2px;
}

.sell-toggle .toggle-text-main {
    font-size: clamp(0.7rem, 3.5vw, 0.9rem);
    line-height: 1.1;
    margin-bottom: 4px;
}

.sell-toggle .toggle-text-sub {
    font-size: clamp(0.65rem, 3vw, 0.85rem);
    white-space: nowrap;
    margin-top: 2px;
}

.sell-toggle .sell-label {
    color: white !important;
    opacity: 0.9;
    margin-right: 4px;
}

.premium-toggle-label input:checked+.toggle-track:not(.dual-switch) {
    background: rgba(195, 82, 20, 0.08);
    border-color: #c35214;
    box-shadow: 0 0 15px rgba(195, 82, 20, 0.1);
}

.premium-toggle-label input:checked+.toggle-track .toggle-thumb {
    background: #c35214;
    color: white;
    box-shadow: 0 0 10px rgba(195, 82, 20, 0.3);
}

.premium-toggle-label input:checked + .toggle-track .toggle-text-main {
    color: #c35214;
}

.sell-toggle .toggle-text-sub {
    color: #e65100 !important;
    opacity: 1;
}

/* Icon and Text Swapping Logic */
.premium-toggle-label .daily-icon,
.premium-toggle-label .daily-text {
    display: none;
}

.premium-toggle-label input:checked + .toggle-track .daily-icon,
.premium-toggle-label input:checked + .toggle-track .daily-text {
    display: inline-block;
}

.premium-toggle-label input:checked + .toggle-track .limited-icon,
.premium-toggle-label input:checked + .toggle-track .limited-text {
    display: none;
}

.premium-toggle-label input:not(:checked) + .toggle-track .daily-icon,
.premium-toggle-label input:not(:checked) + .toggle-track .daily-text {
    display: none;
}

.premium-toggle-label input:not(:checked) + .toggle-track .limited-icon,
.premium-toggle-label input:not(:checked) + .toggle-track .limited-text {
    display: inline-block;
}

.premium-toggle-label input:checked+.toggle-track .toggle-text-sub {
    color: rgba(195, 82, 20, 0.8);
}

/* Modal Footer Actions */
.modal-footer-actions {
    padding: 15px 20px 20px;
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.btn-premium-action {
    width: 100%;
    padding: 16px;
    background: var(--accent-color);
    color: #000;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1rem;
    font-family: 'Cinzel', serif;
    letter-spacing: 1px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn-premium-action:hover {
    transform: translateY(-3px);
    background: #4dd0e1;
    box-shadow: 0 8px 20px var(--primary-color-30);
}

.btn-premium-action:active {
    transform: translateY(0);
}

/* Tablet & Mobile Adjustments */
@media (max-width: 480px) {
    .form-row-responsive {
        flex-direction: column;
        gap: 0;
    }

    .item-form-container {
        padding: 15px;
    }

    .item-modal-premium {
        width: 100% !important;
        margin: 0 10px;
    }

    .form-group {
        margin-bottom: 20px;
    }
}



/* Sell All Button in Sell List Modal */
.sell-all-footer {
    display: flex;
    flex-direction: column;
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--card-bg);
}

.sell-all-value {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 12px;
    font-weight: bold;
    font-size: 1rem;
    color: #fbc02d;
    text-align: center;
    gap: 4px;
}

#sell-all-total-value {
    font-size: 1.3rem;
    color: #fff;
}

.btn-sell-all {
    background: linear-gradient(135deg, #c35214, #e65100);
    color: white;
    border: none;
    padding: 14px;
    border-radius: 8px;
    font-weight: 700;
    font-family: 'Cinzel', serif;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    letter-spacing: 1px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.btn-sell-all:hover {
    background: linear-gradient(135deg, #e65100, #ff6d00);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(195, 82, 20, 0.5);
}

.btn-sell-all i {
    font-size: 1.1rem;
}

/* Coin Update Modal Styles */
.coin-update-modal-content {
    max-width: 320px !important;
    height: auto !important;
}

.coin-update-body {
    padding: 15px 20px 25px !important;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.coin-modal-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
}

.coin-modal-display i {
    font-size: 3.5rem;
    color: var(--accent-color);
}

.coin-modal-display span {
    font-family: 'Cinzel', serif;
    font-size: 1.2rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 1px;
}

.coin-input-group {
    width: 100%;
    margin-bottom: 25px;
    text-align: center;
}

.coin-input-group label {
    display: block;
    margin-bottom: 10px;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.coin-input-group input {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 0;
    color: #fff;
    font-size: 1.8rem;
    text-align: center;
    font-family: 'Cinzel', serif;
    font-weight: 700;
    box-sizing: border-box;
}

/* Responsive Header Fix */
@media (max-width: 480px) {
    .main-header {
        flex-wrap: nowrap;
        justify-content: space-between;
        align-items: center;
    }
}

/* Undo Button Styles */
.btn-undo {
    background: transparent;
    border: 1.5px solid var(--accent-color);
    color: var(--accent-color);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    padding: 0;
    flex-shrink: 0;
}

.btn-undo:hover:not(.disabled) {
    background: var(--primary-color-10);
    transform: rotate(-30deg) scale(1.1);
}

.btn-undo.disabled {
    cursor: default;
    pointer-events: none;
    opacity: 0.25;
    filter: grayscale(1);
    border-color: var(--text-muted);
    color: var(--text-muted);
}

.known-mm-grid.hidden {
    display: none;
}


/* --- NUOVI STILI PER SLOT INLINEA E VETRO --- */
.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.slot-tracker {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    min-height: auto;
    margin: 8px 15px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 8px;
}

.slot-icon {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-block;
    flex-shrink: 0;
}

.slot-icon.full {
    background: var(--primary-color);
    border: none;
}

.slot-icon.empty {
    background: rgba(255, 255, 255, 0.1);
    border: none;
}

.slot-icon.used {
    background: rgba(0, 0, 0, 0.4);
    border: none;
}

.slot-icon.warning {
    background: linear-gradient(135deg, rgba(231, 76, 60, 0.85), rgba(231, 76, 60, 0.45)) !important;
    border: 1.5px solid #fff !important;
    box-shadow: 0 0 12px rgba(231, 76, 60, 0.5) !important;
    backdrop-filter: blur(2px);
    color: #fff;
}

.orison-card.empty-dashed {
    border: 1.5px dashed rgba(255, 255, 255, 0.15) !important;
    background: transparent !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    color: rgba(255, 255, 255, 0.3) !important;
    cursor: default;
    border-radius: 10px;
    box-sizing: border-box;
    padding: 12px 15px;
}

.orison-card.empty-dashed:hover {
    background: rgba(255, 255, 255, 0.02) !important;
}

.prepared-spell-item.spontaneous-depleted {
    opacity: 0.45;
    filter: grayscale(0.5);
}/* Fix Quantity Badge Position (Flow-based, Top Left) */
.item-card-qty-row {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 8px;
    width: 100%;
}

.item-card-qty-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 2px 8px;
    border-radius: 6px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.3);
}

.qty-mini-btn {
    background: none;
    border: none;
    color: var(--accent-color);
    font-size: 0.8rem;
    cursor: pointer;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.qty-mini-val {
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--text-main);
    min-width: 24px;
    text-align: center;
}

/* --- PREMIUM WAND SWIPE (EXACT SPELL CLONE) --- */
.wand-swipe-container {
    position: relative;
    width: 100%;
    height: 42px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    overflow: hidden;
    margin: 4px 0;
}

.item-swipe-handle {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 45px;
    background: linear-gradient(90deg, var(--primary-color-20), var(--primary-color-10));
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    z-index: 10;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.item-swipe-handle i {
    font-size: 0.65rem;
    color: var(--text-muted);
    opacity: 0.6;
}

.wand-swipe-content {
    position: absolute;
    inset: 0;
    padding-left: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 5;
}

.wand-charges-text {
    font-family: var(--font-heading);
    font-size: clamp(0.65rem, 3.2vw, 0.85rem); white-space: nowrap; gap: 8px;
    font-weight: bold;
    color: var(--text-main);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.swipe-handle {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 45px;
    background: linear-gradient(90deg, var(--primary-color-20), var(--primary-color-10));
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: grab;
    z-index: 10;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), background 0.2s;
    touch-action: pan-y;
    /* Previene swipe orizzontale del browser */
}

.swipe-handle:active {
    cursor: grabbing;
    background: var(--primary-color-40);
}

.swipe-handle::after {
    content: '';
    position: absolute;
    right: -8px;
    top: 0;
    bottom: 0;
    width: 8px;
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.15), transparent);
    pointer-events: none;
}

.swipe-icon {
    font-size: 1rem;
    color: var(--accent-color);
    text-shadow: 0 0 10px var(--accent-color);
    pointer-events: none;
}

.swipe-arrow {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: -1px;
    opacity: 0.6;
    pointer-events: none;
}

.prepared-spell-item .spell-content {
    padding-left: 55px;
    /* Spazio per l'handle iniziale */
    flex: 1;
    transition: opacity 0.3s;
}


/* Quando sbarrato (Prepared Engine) */
.prepared-spell-item.used .spell-name {
    text-decoration: line-through;
    opacity: 0.5;
}



.slots-label {
    font-size: 0.7rem;
    color: var(--primary-color);
    opacity: 0.7;
    text-transform: uppercase;
    font-weight: normal;
    display: flex;
    align-items: center;
}

@keyframes mana-glow-pulse {
    0% {
        background-color: #800000;
        box-shadow: 0 0 2px #800020;
    }

    50% {
        background-color: #ff0000;
        box-shadow: 0 0 12px #800020;
    }

    100% {
        background-color: #800000;
        box-shadow: 0 0 2px #800020;
    }
}

.slot-icon.full.metamagic-pulse {
    animation: mana-glow-pulse 2s infinite ease-in-out !important;
    border-color: #800000 !important;
}

/* Orison Card Metamagic Pulse */
.orison-card.metamagic-pulse {
    animation: orison-glow-pulse 2s infinite ease-in-out !important;
    border: 1.5px solid #800000 !important;
    cursor: pointer;
    position: relative;
}

.orison-card.metamagic-pulse:hover {
    background: rgba(128, 0, 0, 0.15) !important;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(128, 0, 0, 0.3) !important;
}

@keyframes orison-glow-pulse {
    0% {
        border-color: #800000;
        box-shadow: 0 0 5px rgba(128, 0, 0, 0.2);
    }

    50% {
        border-color: #ff0000;
        box-shadow: 0 0 15px rgba(255, 0, 0, 0.4);
    }

    100% {
        border-color: #800000;
        box-shadow: 0 0 5px rgba(128, 0, 0, 0.2);
    }
}

/* Metamagic Tags Theme-Friendly */
.metamagic-tag {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-size: 0.8rem;
    padding: 6px 12px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.metamagic-tag.active {
    background: var(--primary-color-20) !important;
    border-color: var(--accent-color) !important;
    box-shadow: 0 0 10px var(--primary-color-10);
}

.metamagic-tag:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

/* --- COLLAPSIBLE SPELL LEVELS --- */
.spell-level-block {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.level-header {
    position: relative;
}

.collapse-toggle-btn {
    position: relative;
    display: inline-flex;
    background: rgba(255, 255, 255, 0.03);
    border: 1.5px solid var(--primary-color-20);
    color: var(--primary-color);
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 5;
    font-size: 0.75rem;
    padding: 0;
    outline: none !important;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.collapse-toggle-btn i {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-block;
}

.collapse-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--primary-color);
    border-color: var(--primary-color-20);
}

.collapse-toggle-btn:focus,
.collapse-toggle-btn:active {
    background: rgba(255, 255, 255, 0.03);
    border-color: var(--primary-color-20);
    box-shadow: none !important;
    outline: none !important;
}

.spell-level-block.collapsed .level-content {
    max-height: 0;
    overflow: hidden;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
    pointer-events: none;
    margin-top: 0;
}

.level-content {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 2000px;
    opacity: 1;
}

.spell-level-block.collapsed .collapse-toggle-btn i {
    transform: rotate(180deg);
}

.spell-level-block.collapsed {
    margin-bottom: 5px;
    opacity: 0.8;
}

/* Refined Metamagic Border Pulse (Cantrips & Leveled Spells) */
.orison-card.metamagic-pulse,
.prepared-spell-item.metamagic-pulse {
    animation: orison-glow-pulse 2s infinite ease-in-out !important;
    border: 1.5px solid #800000 !important;
    position: relative;
    z-index: 10;
}

.orison-card.metamagic-pulse {
    cursor: pointer;
}

/* Red Glow for Metamagic Labels */
.meta-tags {
    color: #b30000 !important;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

.spell-chip-meta {
    color: #ff3c3c !important;
    text-shadow: 0 0 5px rgba(255, 0, 0, 0.5), 0 0 10px rgba(255, 0, 0, 0.3);
    font-weight: bold;
    letter-spacing: 0.5px;
}



.toast.error {
    background: #872323;
    /* Dark crimson for error messages */
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* --- MODAL SELECTION & CONFIRM FOOTER --- */
.modal-footer {
    flex-shrink: 0;
    padding: 12px 20px;
    background: rgba(30, 30, 30, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
    z-index: 100;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.3);
}

.modal-confirm-btn {
    width: 100%;
    max-width: 400px;
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--accent-color), #2980b9);
    color: white;
    border: none;
    border-radius: 8px;
    font-family: 'Cinzel', serif;
    font-size: 0.95rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.modal-confirm-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.4);
    filter: brightness(1.1);
}

.spell-selection-item.selected {
    background: rgba(52, 152, 219, 0.2) !important;
    border-left: 4px solid var(--accent-color) !important;
    box-shadow: inset 0 0 10px rgba(52, 152, 219, 0.2);
    transform: translateX(4px);
}


/* ==========================================================================
   Compact Character Modal & Theme Picker
   ========================================================================== */

.name-theme-container .setting-group label {
    min-height: auto !important;
    margin-bottom: 6px;
}

.current-theme-dot {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--accent-color);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.current-theme-dot:hover {
    transform: scale(1.1);
    border-color: #fff;
    box-shadow: 0 0 15px var(--accent-color);
}

.theme-selector-popover {
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: all;
}

.theme-selector-popover.hidden {
    display: none;
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
}

.theme-selector-popover .color-dot {
    width: 25px;
    height: 25px;
    margin: 0;
}

.btn-secondary-action {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 12px;
    border-radius: 10px;
    font-family: 'Cinzel', serif;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.btn-secondary-action:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent-color);
    color: var(--accent-color);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

#char-progression-modal .modal-content {
    border: 1px solid var(--accent-color);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
}

#char-progression-modal .progression-timeline {
    max-height: 40vh;
    overflow-y: auto;
    padding-right: 8px;
    margin-top: 10px;
}

#char-progression-modal .progression-timeline::-webkit-scrollbar {
    width: 4px;
}

#char-progression-modal .progression-timeline::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

/* ==========================================================================
   Inventory - Paginated Horizontal Pager
   ========================================================================== */

.inventory-sections-wrapper {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-bottom: 20px;
    gap: 0;
    width: 100%;
}

.inventory-sections-wrapper::-webkit-scrollbar {
    display: none;
}

.inventory-category-page {
    flex: 0 0 100%;
    scroll-snap-align: center;
    padding: 0 10px;
    animation: fadeIn 0.4s ease-out;
    display: flex;
    flex-direction: column;
}

.inventory-category-title {
    font-family: 'Cinzel', serif;
    font-size: 1.1rem;
    color: var(--accent-color);
    margin: 15px 0;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    text-transform: uppercase;
    letter-spacing: 2px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(var(--accent-rgb), 0.2);
}

/* Category Rubrica Tabs (Vertical Right) */
.category-tabs-container {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    gap: 2px;
    margin-bottom: 0;
    padding: 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-behavior: smooth;
    align-items: stretch;
    background: rgba(0, 0, 0, 0.2);
    width: 50px;
    flex-shrink: 0;
    border-left: 1px solid rgba(var(--accent-rgb), 0.2);
}

.category-tabs-container::-webkit-scrollbar {
    display: none;
}

.category-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px 0;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border: none;
    border-right: 3px solid transparent;
    transition: all 0.2s ease;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.category-tab .tab-label {
    display: none;
}

.category-tab:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.category-tab.active {
    background: rgba(var(--accent-rgb), 0.1);
    color: var(--accent-color);
    border-right: 3px solid var(--accent-color);
}


/* Vertical List within Category Page */
.inventory-items-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 10px;
    max-height: calc(100vh - 250px);
    overflow-y: auto;
    scrollbar-width: thin;
}

/* Inventory Horizontal Pager */
.inventory-sections-wrapper {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -ms-overflow-style: none;
    width: 100%;
    scroll-behavior: smooth;
    gap: 0;
}

.inventory-sections-wrapper::-webkit-scrollbar {
    display: none;
}

.inventory-category-page {
    flex: 0 0 100%;
    min-width: 100%;
    scroll-snap-align: start;
    padding: 0 5px;
    box-sizing: border-box;
}

.inventory-category-title {
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    color: var(--accent-color);
    margin: 15px 0 10px 0;
    display: flex;
    align-items: center;
    gap: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.inventory-item-card {
    background: rgba(30, 30, 40, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-left: 4px solid var(--accent-color);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
    transition: all 0.3s ease;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    width: 100%;
    box-sizing: border-box;
}

.inventory-item-card:hover {
    background: rgba(30, 30, 40, 0.6);
    border-color: rgba(var(--accent-rgb), 0.5);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
}

.item-card-header {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
}

.item-card-prefix {
    font-size: 0.7rem;
    color: var(--accent-color);
    text-transform: uppercase;
    font-weight: 800;
    letter-spacing: 1px;
    opacity: 0.8;
}

.item-card-name {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    color: var(--text-main);
    font-weight: bold;
    line-height: 1.2;
}

.item-card-name.clickable-spell {
    cursor: pointer;
    transition: color 0.2s;
    text-decoration: underline dotted rgba(255, 255, 255, 0.2);
}

.item-card-name.clickable-spell:hover {
    color: var(--accent-color);
}

.item-card-meta {
    display: flex;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
    align-items: center;
}

.item-card-center-space {
    padding: 15px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    border: 1px dashed rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
}

.feature-placeholder {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.8rem;
    opacity: 0.5;
}

.item-card-footer {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.item-card-tools {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    width: 100%;
}

.card-tool-btn {
    aspect-ratio: 1 / 1;
    width: 100%;
    max-height: 40px;
    min-width: 0;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.item-card-stats-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.item-card-counter {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.3);
    padding: 6px 12px;
    border-radius: 20px;
    flex: 1;
    justify-content: center;
}

.card-qty-btn {
    background: none;
    border: none;
    color: var(--accent-color);
    font-size: 1.1rem;
    cursor: pointer;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.1s, transform 0.1s;
}

.card-qty-btn:active {
    opacity: 0.7;
    transform: scale(0.9);
}

.card-qty-val {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-main);
    min-width: 25px;
    text-align: center;
}

.item-card-value {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    flex: 1;
}

.val-display {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    color: var(--accent-color);
    font-size: clamp(0.7rem, 2.5vw, 0.9rem);
    white-space: nowrap;
}

.sale-display {
    font-size: clamp(0.5rem, 1.8vw, 0.65rem);
    color: var(--text-muted);
    font-style: italic;
    opacity: 0.8;
    white-space: nowrap;
}

.item-card-uses {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(var(--accent-rgb), 0.05);
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid rgba(var(--accent-rgb), 0.1);
    justify-content: center;
}

.uses-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 4px;
}

.uses-counter {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.4);
    padding: 4px 10px;
    border-radius: 15px;
}

.card-use-btn {
    background: none;
    border: none;
    color: var(--accent-color);
    font-size: 1rem;
    cursor: pointer;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.card-use-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.uses-val {
    font-weight: bold;
    font-size: 1rem;
    color: var(--text-main);
    min-width: 40px;
    text-align: center;
}

.daily-icon {
    color: #fbc02d;
    /* Gold for sun */
    font-size: 1rem;
    margin-left: 5px;
    filter: drop-shadow(0 0 4px rgba(251, 192, 45, 0.4));
}

@media (max-width: 600px) {
    .inventory-item-card {
        padding: 14px;
        gap: 10px;
    }

    .item-card-name {
        font-size: 1rem;
    }

    .card-tool-btn {
        max-height: 36px;
    }
}



.card-cat-weapon,
.weapon-card,
.card-cat-potion,
.potion-card,
.card-cat-scroll,
.scroll-card,
.card-cat-wand,
.wand-card,
.card-cat-wondrous,
.wondrous-card {
    border-left: 4px solid var(--accent-color) !important;
}

/* Custom Simple Sword Icon (Since FA Free lacks one) */
.fa-custom-sword {
    display: inline-block;
    width: 1em;
    height: 1em;
    background-color: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'%3E%3Cpath d='M505.7 13.9c-17.5-17.5-46-17.5-63.5 0L190.5 265.6l-46.4-46.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l46.4 46.4L13.9 442.2c-18.5 18.5-18.5 48.6 0 67.1s48.6 18.5 67.1 0l131.3-131.3 46.4 46.4c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3l-46.4-46.4 251.7-251.7c17.5-17.5 17.5-46 0-63.5l-3.6-3.7z'/%3E%3C/svg%3E") no-repeat center;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'%3E%3Cpath d='M505.7 13.9c-17.5-17.5-46-17.5-63.5 0L190.5 265.6l-46.4-46.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l46.4 46.4L13.9 442.2c-18.5 18.5-18.5 48.6 0 67.1s48.6 18.5 67.1 0l131.3-131.3 46.4 46.4c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3l-46.4-46.4 251.7-251.7c17.5-17.5 17.5-46 0-63.5l-3.6-3.7z'/%3E%3C/svg%3E") no-repeat center;
    -webkit-mask-size: contain;
    mask-size: contain;
    vertical-align: -0.15em;
}

.magic-prefix {
    font-size: 0.7rem;
    color: var(--accent-color);
    text-transform: uppercase;
    font-weight: 900;
    letter-spacing: 1px;
    margin-bottom: -2px;
    opacity: 0.8;
}

.weapon-icon {
    color: var(--accent-color);
    margin-right: 8px;
    font-size: 1.1rem;
    filter: drop-shadow(0 0 5px rgba(var(--accent-rgb), 0.4));
}


/* Redesigned Inventory Modal Styles */
.form-section-premium {
    padding: 2px 0;
    width: 100%;
    box-sizing: border-box;
}

.section-separator {
    height: 1px;
    background: linear-gradient(to right, transparent, var(--border-color), transparent);
    margin: 8px 0;
    opacity: 0.3;
}

.modal-grid-row .form-group input,
.modal-grid-row .form-group select,
.custom-select-trigger,
.toggle-track {
    width: 100%;
    height: 42px !important;
    box-sizing: border-box !important;
    padding: 0 12px;
}

.modal-grid-row {
    display: grid;
    gap: 12px;
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 5px;
    align-items: flex-start;
}

.form-row-equal {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    width: 100%;
    box-sizing: border-box;
}

.form-row-responsive {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.form-row-responsive.no-wrap {
    flex-wrap: nowrap !important;
    justify-content: space-between;
}

.variable-row {
    display: flex;
    gap: 15px;
    margin-bottom: 12px;
}

.variable-row>div {
    flex: 1;
}

.placeholder-text {
    padding: 20px;
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.1);
}

#item-sell-value {
    color: var(--accent-color);
    font-weight: bold;
    text-shadow: 0 0 5px rgba(var(--accent-rgb), 0.3);
}

.form-group label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 14px;
}

.form-row-equal .form-group {
    min-width: 0;
    /* Allow grid items to shrink below their content size */
}


.form-row-equal .form-group input {
    width: 100%;
    box-sizing: border-box;
}

.form-group.full-width {
    width: 100%;
}

.form-group input, 
.form-group select, 
.form-group textarea {
    width: 100%;
    box-sizing: border-box;
}

/* Removed redundant row classes in favor of modal-grid-row utility */

.grid-80-20 {
    grid-template-columns: 8fr 2fr;
}

.grid-20-80 {
    grid-template-columns: 2fr 8fr;
}

.grid-3-col {
    grid-template-columns: 1fr 1fr 1fr;
}

.grid-2-col {
    grid-template-columns: 1fr 1fr;
}

.modal-grid-row .form-group {
    min-width: 0;
    width: 100%;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

/* --- Special Abilities Section --- */
.skills-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 10px;
}

.btn-add-full-width {
    width: 100%;
    padding: 12px;
    background: var(--card-bg);
    border: 1px dashed var(--accent-color);
    color: var(--accent-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.btn-add-full-width:hover {
    background: rgba(3, 218, 198, 0.05);
    border-style: solid;
}

.special-abilities-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sa-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: var(--shadow);
    transition: transform 0.2s;
}

.sa-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.sa-title {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    color: var(--accent-color);
    margin: 0;
    font-weight: bold;
}

.sa-edit-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    padding: 5px;
    transition: color 0.2s;
}

.sa-edit-btn:hover {
    color: var(--accent-color);
}

.sa-desc-link {
    font-size: clamp(0.65rem, 3.2vw, 0.85rem); white-space: nowrap; gap: 8px;
    color: var(--accent-color);
    cursor: pointer;
    font-weight: bold;
    display: inline-block;
    padding: 2px 6px;
    background: rgba(3, 218, 198, 0.1);
    border-radius: 4px;
    width: fit-content;
}

.sa-desc-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-right: 5px;
}

.sa-uses-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 5px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.sa-checkbox {
    width: 22px;
    height: 22px;
    cursor: pointer;
    appearance: none;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.sa-checkbox:checked {
    background: var(--accent-color);
    border-color: var(--accent-color);
}

.sa-checkbox:checked::after {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 12px;
    color: #121212;
}

.sa-at-will-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-style: italic;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-danger-action {
    background: transparent;
    border: 1px solid #e57373;
    color: #e57373;
    padding: 10px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-danger-action:hover {
    background: rgba(229, 115, 115, 0.1);
}

.sa-desc-text-small {
    color: var(--text-muted);
    font-size: clamp(0.65rem, 3.2vw, 0.85rem);
    white-space: normal;
    line-height: 1.5;
    margin: 6px 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.modifier-row {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.2);
    padding: 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.modifier-row .form-group {
    margin-bottom: 0;
    flex: 1;
}

.modifier-row .modifier-label {
    font-family: 'Cinzel', serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-color);
    padding: 0 5px;
    height: 100%;
    display: flex;
    align-items: center;
}

.modifier-row select,
.modifier-row input {
    margin: 0;
    width: 100%;
}

.category-tabs-horizontal {
    display: flex;
    flex-direction: row;
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(var(--accent-rgb), 0.2);
    margin-bottom: 15px;
    border-radius: 12px 12px 0 0;
    overflow: hidden;
}

.category-tabs-horizontal .category-tab {
    flex: 1;
    padding: 12px 5px;
    font-size: 1.1rem;
    border-right: none;
    border-bottom: 3px solid transparent;
    flex-direction: column;
    gap: 4px;
    height: auto;
}

.category-tabs-horizontal .category-tab .tab-label {
    display: block;
    font-size: 0.6rem;
    text-transform: uppercase;
    font-family: 'Cinzel', serif;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.category-tabs-horizontal .category-tab.active {
    background: rgba(var(--accent-rgb), 0.15);
    color: var(--accent-color);
    border-bottom: 3px solid var(--accent-color);
    border-right: none;
}

.inventory-category-header-premium {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(90deg, rgba(var(--accent-rgb), 0.15) 0%, transparent 100%);
    border-left: 4px solid var(--accent-color);
    margin: 10px 5px 15px 5px;
    border-radius: 4px;
    box-shadow: -4px 0 12px rgba(0, 0, 0, 0.2);
}

.inventory-category-header-premium .cat-label {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    color: var(--accent-color);
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.inventory-category-header-premium .cat-count {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: bold;
    letter-spacing: 1.5px;
    opacity: 0.8;
}

/* Refinement for horizontal tabs on small screens */
@media (max-width: 600px) {
    .category-tabs-horizontal .category-tab {
        padding: 10px 0;
        font-size: 1.2rem;
    }

    .inventory-category-header-premium {
        padding: 10px 12px;
    }

    .inventory-category-header-premium .cat-label {
        font-size: clamp(0.65rem, 3.2vw, 0.85rem); white-space: nowrap; gap: 8px;
    }
}

/* --- CUSTOM PREMIUM SELECT --- */
.custom-select-container {
    position: relative;
    width: 100%;
}

.custom-select-container select {
    display: none;
    /* Hide native select */
}

.custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    height: 42px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-main);
    font-size: 0.95rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
}

.custom-select-trigger:hover {
    border-color: var(--accent-color);
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.custom-select-container.open .custom-select-trigger {
    border-color: var(--accent-color);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.trigger-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.trigger-content i {
    color: var(--accent-color);
    font-size: 1rem;
    filter: drop-shadow(0 0 5px rgba(var(--accent-rgb), 0.4));
}

.custom-select-trigger .chevron {
    font-size: 0.8rem;
    opacity: 0.6;
    transition: transform 0.3s ease;
}

.custom-select-container.open .chevron {
    transform: rotate(180deg);
}

.custom-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #1e1e26;
    border: 1px solid var(--accent-color);
    border-top: none;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
    z-index: 1000;
    max-height: 350px;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    scrollbar-width: thin;
}

.custom-select-container.open .custom-options {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.custom-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.custom-option:last-child {
    border-bottom: none;
}

.custom-option:hover {
    background: rgba(var(--accent-rgb), 0.15);
    color: var(--accent-color);
    padding-left: 20px;
}

.custom-option.selected {
    background: rgba(var(--accent-rgb), 0.1);
    color: var(--accent-color);
    font-weight: bold;
}

.custom-option i {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
    color: var(--accent-color);
    opacity: 0.8;
}

.custom-option:hover i {
    opacity: 1;
    transform: scale(1.1);
}
/* --- INVENTORY FINAL LAYOUT FIXES --- */

.item-card-qty-row {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 6px;
    padding-left: 2px;
}

.item-card-qty-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
}

.qty-mini-btn {
    background: none;
    border: none;
    color: var(--accent-color);
    font-size: 0.75rem;
    cursor: pointer;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qty-mini-val {
    font-size: 0.75rem;
    font-weight: bold;
    color: var(--text-main);
    min-width: 20px;
    text-align: center;
}

/* WAND SWIPE - SPELL CLONE */
.wand-swipe-container {
    position: relative;
    width: 100%;
    height: 40px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    overflow: hidden;
    margin: 4px 0;
}

.item-swipe-handle {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 38px;
    background: linear-gradient(90deg, var(--primary-color-20), var(--primary-color-10));
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    z-index: 10;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.item-swipe-handle i {
    font-size: 0.6rem;
    color: var(--text-muted);
}

.wand-swipe-content {
    position: absolute;
    inset: 0;
    padding-left: 48px; /* 38px handle + 10px spacing */
    display: flex;
    align-items: center;
    justify-content: flex-start;
    pointer-events: none;
    z-index: 5;
}

.wand-charges-text {
    font-family: var(--font-heading);
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--text-main);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Footer value split - Responsive Scaling */
.item-card-value-split {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    font-size: clamp(0.7rem, 3.2vw, 0.85rem);
    white-space: nowrap;
    gap: 8px;
}

.val-left { 
    color: var(--text-main);
    opacity: 0.8;
}

.val-right { 
    color: #e65100 !important;
    font-weight: 800;
}


/* Orison Card with Swipe Handle (Metamagic) */
.orison-card.with-swipe {
    padding-left: 48px;
}

.orison-card .swipe-handle {
    width: 38px;
    border-radius: 9px 0 0 9px;
}

.orison-card .swipe-handle .swipe-icon {
    font-size: 0.85rem;
}

.orison-card .swipe-handle .swipe-arrow {
    font-size: 0.55rem;
}


/* Spell Badges in Special Abilities & Descriptions */
.sa-spell-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    margin: 2px 4px 2px 0;
    vertical-align: middle;
    border: 1px solid var(--primary-color);
    background: rgba(255, 255, 255, 0.06);
    color: var(--primary-color);
    transition: all 0.2s ease;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.sa-spell-badge:hover {
    background: var(--primary-color);
    color: #121212;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

.sa-spell-badge i {
    font-size: 0.7rem;
}

.sa-card-badges-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 4px 0 6px 0;
}


/* Autocomplete Dropdown for [[ Spell references */
.spell-autocomplete-dropdown {
    position: absolute;
    top: calc(100% - 2px);
    left: 0;
    right: 0;
    background: #1a1a1a;
    border: 1.5px solid var(--primary-color);
    border-radius: 8px;
    max-height: 220px;
    overflow-y: auto;
    z-index: 10000;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7);
}

.spell-autocomplete-dropdown.hidden {
    display: none !important;
}

.autocomplete-item {
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    transition: background 0.15s ease;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover {
    background: rgba(255, 255, 255, 0.12);
}

.autocomplete-item-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.autocomplete-item-left i {
    color: var(--primary-color);
    font-size: 0.85rem;
    flex-shrink: 0;
}

.autocomplete-item-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.autocomplete-item-school {
    font-size: 0.75rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.autocomplete-hint {
    padding: 10px 14px;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
}

.search-result-item.highlighted {
    background: rgba(3, 218, 198, 0.25) !important;
    border-left: 3px solid var(--accent-color);
}

/* Top Bar Inventory Button */
.top-bar-inv-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--accent-color);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.2s ease;
}

.top-bar-inv-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--accent-color);
    transform: scale(1.05);
}

.top-bar-inv-btn:active {
    transform: scale(0.95);
}

/* ==========================================================================
   Character Inventory Modal (Bottom Sheet & Accordion Items)
   ========================================================================== */

.char-inv-modal-content {
    max-width: 650px;
    width: 95%;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    padding: 0 !important;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
}

@media (max-width: 768px) {
    #char-inventory-modal.modal-overlay {
        align-items: flex-end !important;
        padding: 0 !important;
    }

    .char-inv-modal-content {
        max-width: 100% !important;
        width: 100% !important;
        max-height: 90vh !important;
        height: 90vh;
        border-radius: 20px 20px 0 0 !important;
        border-bottom: none !important;
        transform: translateY(0);
        animation: slideUpSheet 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    }
}

@keyframes slideUpSheet {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.char-inv-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.char-inv-header-title h2 {
    margin: 0;
    font-family: 'Cinzel', serif;
    font-size: 1.15rem;
    color: var(--accent-color);
}

/* Tabs: Segmented control */
.char-inv-tabs {
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    padding: 6px;
    gap: 6px;
    border-bottom: 1px solid var(--border-color);
}

.char-inv-tab-btn {
    flex: 1;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    font-family: 'Cinzel', serif;
    font-size: 0.85rem;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.char-inv-tab-btn.active {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent-color);
    color: var(--accent-color);
    font-weight: 700;
}

.char-inv-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Compact Coins HUD */
.char-inv-coins-hud {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 8px 12px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.char-coins-strip {
    display: flex;
    gap: 10px;
    align-items: center;
}

.char-coin-chip {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.85rem;
    cursor: pointer;
    user-select: none;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.15s, transform 0.1s;
}

.char-coin-chip:hover {
    background: rgba(255, 255, 255, 0.08);
}

.char-coin-chip:active {
    transform: scale(0.96);
}

.coin-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.coin-dot.cp { background: #b87333; }
.coin-dot.sp { background: #c0c0c0; }
.coin-dot.gp { background: #ffd700; }
.coin-dot.pp { background: #e5e4e2; }

.char-coin-chip label {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: bold;
}

.char-coin-val {
    font-weight: bold;
    color: var(--text-main);
}

.char-coins-total {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.coins-total-amount {
    color: #ffd700;
    font-size: 0.95rem;
}

/* Category Filter Chips */
.char-inv-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.char-inv-category-chips {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: thin;
}

.char-inv-category-chips::-webkit-scrollbar {
    height: 4px;
}

.inv-cat-chip {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 5px 12px;
    border-radius: 14px;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
}

.inv-cat-chip.active {
    background: var(--accent-color);
    color: #121212;
    border-color: var(--accent-color);
    font-weight: bold;
}

.char-inv-action-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Items List & Accordion Card Styling */
.char-inv-items-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-bottom: 20px;
}

.char-inv-card {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.char-inv-card.expanded {
    border-color: var(--accent-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.char-inv-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    cursor: pointer;
    gap: 10px;
    user-select: none;
}

.char-inv-card-main {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.char-inv-card-icon {
    font-size: 1rem;
    color: var(--accent-color);
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.char-inv-card-title-group {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.char-inv-card-name {
    font-weight: bold;
    font-size: 0.9rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.char-inv-card-subtitle {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.char-inv-card-quick-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.char-inv-stepper {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}

.char-inv-stepper-btn {
    background: transparent;
    border: none;
    color: var(--text-main);
    width: 24px;
    height: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

.char-inv-stepper-btn:active {
    background: rgba(255, 255, 255, 0.1);
}

.char-inv-stepper-val {
    min-width: 24px;
    text-align: center;
    font-size: 0.8rem;
    font-weight: bold;
    color: var(--accent-color);
    padding: 0 4px;
}

.char-inv-card-chevron {
    color: var(--text-muted);
    font-size: 0.75rem;
    transition: transform 0.2s ease;
    margin-left: 4px;
}

.char-inv-card.expanded .char-inv-card-chevron {
    transform: rotate(180deg);
}

.char-inv-card-details {
    display: none;
    padding: 10px 12px 12px 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(0, 0, 0, 0.15);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.char-inv-card.expanded .char-inv-card-details {
    display: block;
}

.char-inv-meta-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px 12px;
    margin-bottom: 8px;
    font-size: 0.75rem;
}

.char-inv-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed var(--border-color);
}

/* Char Column Header (Replaces big centered GRIMORIO) */
.char-column-header {
    margin-bottom: 12px;
    padding: 0 4px;
}

.char-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.char-header-left {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.char-header-left .char-current-name {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--accent-color);
    line-height: 1.2;
}

.char-header-left .subtitle {
    margin: 2px 0 0 0;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.col-inv-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--accent-color);
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.15rem;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.col-inv-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--accent-color);
    transform: scale(1.05);
}

.col-inv-btn:active {
    transform: scale(0.95);
}

/* Hide scrollbar on category chips */
.char-inv-category-chips {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

.char-inv-category-chips::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

/* Compact Responsive Buttons in Char Inv Modal */
.char-inv-tabs {
    padding: 4px;
    gap: 4px;
}

.char-inv-tab-btn {
    font-size: clamp(0.72rem, 3vw, 0.85rem) !important;
    padding: 6px 8px !important;
    white-space: nowrap;
}

.char-inv-action-row button {
    font-size: clamp(0.7rem, 2.8vw, 0.82rem) !important;
    padding: 8px 10px !important;
    white-space: nowrap;
}

/* Coin chip click feedback (for add/subtract/convert) */
.char-coin-chip {
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    transition: background 0.15s ease;
}

.char-coin-chip:hover {
    background: rgba(255, 255, 255, 0.08);
}

/* ==========================================================================
   Compact Adaptable Modals (Mobile Bottom-Sheet & Desktop Polish)
   ========================================================================== */

.item-modal-premium {
    background: rgba(26, 26, 26, 0.98) !important;
    backdrop-filter: blur(14px);
    border: 1px solid rgba(129, 212, 250, 0.25) !important;
    max-width: 480px !important;
    height: auto !important;
    max-height: 88vh !important;
    display: flex;
    flex-direction: column;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    overflow: hidden;
}

.item-modal-premium .modal-header {
    padding: 12px 16px !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.item-modal-premium .modal-header h2 {
    font-size: 1.05rem !important;
    margin: 0;
    color: var(--accent-color);
}

.item-modal-premium .modal-body {
    padding: 0 !important;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
}

.item-form-container {
    padding: 14px 16px;
    overflow-y: auto;
    overscroll-behavior: contain;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.form-section-premium {
    padding: 0;
    width: 100%;
    box-sizing: border-box;
}

.form-group {
    margin-bottom: 6px;
}

.form-group label {
    font-size: 0.72rem !important;
    font-weight: 700 !important;
    color: var(--accent-color) !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 3px !important;
}

.form-group input,
.form-group select,
.form-group textarea {
    background: rgba(36, 36, 36, 0.7) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    color: var(--text-main) !important;
    border-radius: 8px !important;
    padding: 8px 10px !important;
    font-size: 0.9rem !important;
    box-sizing: border-box;
}

.form-group textarea {
    resize: vertical;
    min-height: 48px;
    max-height: 90px;
}

.modal-grid-row {
    display: grid;
    gap: 8px;
}

.grid-80-20 {
    grid-template-columns: 3.5fr 1.2fr;
}

.item-compact-stats-row {
    grid-template-columns: 1.2fr 1.5fr 1fr;
    gap: 8px;
}

/* Compact Sell Row & Switch */
.compact-sell-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 6px 10px;
    margin-top: 4px;
    gap: 10px;
}

.compact-switch-label {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.compact-switch-label input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.compact-slider {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 22px;
    background-color: rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.compact-slider::before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: #eee;
    border-radius: 50%;
    transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.compact-switch-label input:checked + .compact-slider {
    background-color: #c35214;
    box-shadow: 0 0 10px rgba(195, 82, 20, 0.4);
}

.compact-switch-label input:checked + .compact-slider::before {
    transform: translateX(16px);
    background-color: #fff;
}

.compact-switch-text {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.compact-switch-label input:checked ~ .compact-switch-text {
    color: #ff8a50;
}

.compact-sell-feedback {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.8rem;
    background: rgba(0, 0, 0, 0.35);
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.compact-sell-label {
    color: var(--text-muted);
    font-size: 0.72rem;
    text-transform: uppercase;
}

.compact-sell-amount {
    color: #ffb74d;
    font-weight: 800;
}

/* Modal Sticky Footer Actions */
.modal-footer-actions {
    padding: 10px 16px 14px !important;
    background: rgba(18, 18, 18, 0.95);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    position: sticky;
    bottom: 0;
    z-index: 5;
}

.btn-premium-action {
    width: 100%;
    padding: 10px !important;
    font-size: 0.9rem !important;
    font-weight: 800 !important;
    border-radius: 8px !important;
    letter-spacing: 1px !important;
}

/* Mobile Bottom-Sheet Transformation */
@media (max-width: 600px) {
    #add-item-modal.modal-overlay {
        align-items: flex-end !important;
        padding: 0 !important;
    }

    #add-item-modal .item-modal-premium {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        max-height: 85vh !important;
        border-radius: 20px 20px 0 0 !important;
        border-bottom: none !important;
        margin: 0 !important;
        animation: slideUpBottomSheet 0.25s ease-out;
    }

    .item-form-container {
        padding: 12px 14px;
        gap: 8px;
    }

    .form-group label {
        font-size: 0.7rem !important;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 7px 9px !important;
        font-size: 0.85rem !important;
    }
}

/* 4-Card Category Grid for Item Modal */
.item-cat-cards-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    width: 100%;
    margin-top: 4px;
}

.item-cat-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 6px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    cursor: pointer;
    transition: all 0.18s ease;
    user-select: none;
}

.item-cat-card i {
    font-size: 1rem;
    color: var(--text-muted);
    transition: color 0.18s ease;
}

.item-cat-card span {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.item-cat-card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(129, 212, 250, 0.4);
}

.item-cat-card.active {
    background: rgba(129, 212, 250, 0.12) !important;
    border-color: var(--accent-color) !important;
    box-shadow: 0 0 10px rgba(129, 212, 250, 0.25);
}

.item-cat-card.active i {
    color: var(--accent-color);
}

.item-cat-card.active span {
    color: #fff;
}

/* Coin Modal Form Elements Harmonization */
#char-coin-action-modal input[type="text"],
#char-coin-action-modal input[type="number"],
#char-coin-action-modal select {
    background: rgba(36, 36, 36, 0.7) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    color: var(--text-main) !important;
    border-radius: 8px !important;
    padding: 8px 10px !important;
    font-size: 0.95rem !important;
    box-sizing: border-box !important;
    transition: all 0.2s ease;
}

#char-coin-action-modal input:focus,
#char-coin-action-modal select:focus {
    border-color: var(--accent-color) !important;
    background: rgba(44, 44, 44, 0.95) !important;
    box-shadow: 0 0 10px rgba(129, 212, 250, 0.2) !important;
    outline: none;
}

/* ==========================================================================
   Compact Coin Modal & Stepper Styling
   ========================================================================== */
.char-coin-compact-modal {
    max-width: 330px !important;
    padding: 12px 14px 16px !important;
    border-radius: 14px !important;
    background: rgba(24, 24, 28, 0.98) !important;
    backdrop-filter: blur(14px);
    border: 1px solid rgba(129, 212, 250, 0.25) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
}

.compact-modal-header {
    margin-bottom: 8px !important;
    padding-bottom: 6px !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.compact-modal-header h3 {
    margin: 0;
    font-family: 'Cinzel', serif;
    font-size: 0.95rem !important;
    color: var(--accent-color);
}

.coin-action-tabs-row {
    display: flex;
    gap: 4px;
    background: rgba(0, 0, 0, 0.35);
    padding: 3px;
    border-radius: 8px;
    margin-bottom: 10px;
}

.coin-action-tab-btn {
    flex: 1;
    padding: 5px 4px !important;
    font-size: 0.75rem !important;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.coin-action-tab-btn.active {
    background: rgba(255, 255, 255, 0.1) !important;
    color: var(--accent-color) !important;
    font-weight: bold;
}

.coin-compact-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.coin-cur-status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.coin-cur-status-row strong {
    color: var(--accent-color);
    font-size: 0.85rem;
}

.coin-main-input {
    width: 100% !important;
    font-size: 1.15rem !important;
    font-weight: bold !important;
    text-align: center !important;
    height: 38px !important;
    padding: 4px 8px !important;
}

.coin-convert-prompt {
    font-size: 0.78rem;
    color: var(--text-secondary);
    text-align: center;
}

.coin-convert-prompt strong {
    color: var(--accent-color);
}

.coin-convert-preview-badge {
    text-align: center;
    font-size: 0.82rem;
    color: var(--accent-color);
    padding: 5px 8px;
    background: rgba(0, 0, 0, 0.35);
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.compact-confirm-btn {
    width: 100% !important;
    margin-top: 12px !important;
    padding: 8px !important;
    font-size: 0.88rem !important;
    font-weight: bold !important;
}

/* Modal Qty Stepper in Item Modal */
.modal-qty-stepper {
    display: inline-flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    overflow: hidden;
}

.modal-qty-stepper .char-inv-stepper-btn {
    width: 24px;
    height: 26px;
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: var(--accent-color);
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
}

.modal-qty-stepper .char-inv-stepper-btn:hover {
    background: rgba(255, 255, 255, 0.12);
}

.modal-qty-stepper input:focus {
    background: rgba(255, 255, 255, 0.1) !important;
    outline: none;
}


/* Rimuovi freccette su input numerici (Chrome, Safari, Edge, Opera) */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    -webkit-appearance: none !important;
    margin: 0 !important;
}

/* Rimuovi freccette su input numerici (Firefox) */
input[type="number"] {
    -moz-appearance: textfield !important;
}


/* Custom Category Cards Edit/Delete actions */
.item-cat-card.is-custom {
    position: relative;
    padding-top: 10px;
}

.cat-card-tools {
    position: absolute;
    top: 2px;
    right: 2px;
    display: flex;
    gap: 3px;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.item-cat-card.is-custom:hover .cat-card-tools {
    opacity: 1;
}

.cat-tool-btn {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.55rem;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.5);
    color: var(--text-muted);
    border: none;
    transition: all 0.15s ease;
}

.cat-tool-btn:hover {
    transform: scale(1.2);
}

.cat-tool-btn.edit:hover {
    color: var(--accent-color);
}

.cat-tool-btn.del:hover {
    color: #ff5252;
}


/* Card Zaino contrassegnata Da Vendere */
.char-inv-card.to-sell {
    /* Bordo rimosso su richiesta: meno invadente */
}

.char-inv-card.to-sell .char-inv-card-icon {
    color: #c35214 !important;
    text-shadow: 0 0 8px rgba(195, 82, 20, 0.4);
}

/* Manage Categories Modal Styles */
#manage-categories-modal .modal-content {
    height: auto !important;
    max-height: 85vh !important;
    width: 90% !important;
    max-width: 400px !important;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

#manage-cat-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 2px;
}

#manage-cat-list::-webkit-scrollbar {
    width: 4px;
}
#manage-cat-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

/* Footer layout: 90% input, 10% '+' button */
#manage-categories-modal .manage-cat-footer {
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
}

#new-cat-input {
    flex: 1 1 90% !important;
    width: calc(90% - 8px) !important;
    min-width: 0 !important;
    height: 38px !important;
    box-sizing: border-box !important;
    padding: 0 12px !important;
    background: rgba(0, 0, 0, 0.4) !important;
    border: 1px solid rgba(255, 255, 255, 0.18) !important;
    border-radius: 8px !important;
    color: #fff !important;
    font-size: 0.85rem !important;
    outline: none !important;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#new-cat-input:focus {
    border-color: var(--accent-color) !important;
    box-shadow: 0 0 8px rgba(129, 212, 250, 0.25) !important;
}

#btn-create-new-cat {
    flex: 0 0 10% !important;
    width: 10% !important;
    min-width: 38px !important;
    height: 38px !important;
    padding: 0 !important;
    margin: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 8px !important;
    background: var(--accent-color) !important;
    color: #121212 !important;
    border: none !important;
    font-size: 1rem !important;
    cursor: pointer !important;
    box-sizing: border-box !important;
    flex-shrink: 0 !important;
    transition: all 0.2s ease !important;
}

#btn-create-new-cat:hover {
    filter: brightness(1.15) !important;
    transform: scale(1.05) !important;
}

/* Category row action buttons & alignment */
.manage-cat-action-btn {
    width: 28px;
    height: 28px;
    min-width: 28px;
    padding: 0;
    margin: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    box-sizing: border-box;
    flex-shrink: 0;
    line-height: 1;
    transition: all 0.2s ease;
}

.manage-cat-action-btn i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    pointer-events: none;
}

.manage-cat-action-btn.edit-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-main);
}
.manage-cat-action-btn.edit-btn:hover {
    color: var(--accent-color);
    border-color: var(--accent-color);
    background: rgba(129, 212, 250, 0.12);
}

.manage-cat-action-btn.del-btn {
    background: rgba(255, 82, 82, 0.08);
    border: 1px solid rgba(255, 82, 82, 0.3);
    color: #ff5252;
}
.manage-cat-action-btn.del-btn:hover {
    background: rgba(255, 82, 82, 0.22);
    border-color: #ff5252;
}

/* Modalità conferma eliminazione: si espande in larghezza con testo visibile */
.manage-cat-action-btn.del-confirm {
    width: auto !important;
    min-width: 78px !important;
    padding: 0 8px !important;
    gap: 5px !important;
    background: rgba(255, 82, 82, 0.25) !important;
    border-color: #ff5252 !important;
    color: #ff5252 !important;
    font-size: 0.74rem !important;
    font-weight: 600 !important;
    white-space: nowrap !important;
}

.manage-cat-action-btn.del-confirm i {
    font-size: 0.75rem !important;
}

.manage-cat-action-btn.save-edit-btn {
    background: var(--accent-color);
    color: #121212;
    border: none;
}
.manage-cat-action-btn.save-edit-btn:hover {
    filter: brightness(1.2);
    transform: scale(1.05);
}

.manage-cat-action-btn.cancel-edit-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-muted);
}
.manage-cat-action-btn.cancel-edit-btn:hover {
    color: #ff5252;
    border-color: rgba(255, 82, 82, 0.5);
    background: rgba(255, 82, 82, 0.15);
}


/* Shared Inventory Specific Enhancements */
#view-shared-inventory .inventory-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 10px 14px 40px 14px;
}

/* Sell List Modal Premium Enhancements */
.sell-modal-premium {
    width: 90% !important;
    max-width: 480px !important;
    border-radius: 14px !important;
    background: rgba(22, 22, 26, 0.98) !important;
    border: 1px solid rgba(195, 82, 20, 0.35) !important;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7) !important;
    backdrop-filter: blur(14px) !important;
}

.sell-modal-premium .sell-item-row {
    transition: background 0.2s;
}

.sell-modal-premium .sell-item-row:hover {
    background: rgba(255, 255, 255, 0.06) !important;
}

/* ==========================================================================
   LOBBY & TABLE MANAGEMENT (FASE 6.1)
   ========================================================================== */

/* Sidebar Lobby Entry */
.sidebar-lobby-section {
    padding: 12px 15px;
    border-top: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.15);
}

.btn-sidebar-lobby {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.18), rgba(20, 20, 20, 0.8));
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
    padding: 11px 16px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.88rem;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.btn-sidebar-lobby:hover {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.3), rgba(30, 30, 30, 0.9));
    border-color: #fff;
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(212, 175, 55, 0.25);
}

/* Modal Tabs */
.lobby-tabs-nav {
    display: flex;
    gap: clamp(2px, 1vw, 6px);
    background: rgba(0, 0, 0, 0.4);
    padding: clamp(2px, 1vw, 4px);
    border-radius: 10px;
    margin-bottom: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    width: 100%;
    box-sizing: border-box;
}

.lobby-tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: clamp(6px, 1.5vw, 8px) clamp(3px, 1vw, 8px);
    border-radius: 7px;
    font-size: clamp(0.66rem, 2.2vw, 0.8rem);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(3px, 0.8vw, 6px);
    white-space: nowrap;
    min-width: 0;
    line-height: 1.2;
}

@media (max-width: 420px) {
    .lobby-tabs-nav {
        gap: 2px;
        padding: 2px;
    }
    .lobby-tab-btn {
        padding: 6px 2px;
        font-size: 0.65rem;
        gap: 3px;
    }
    .lobby-tab-btn i {
        font-size: 0.72rem;
    }
}

.lobby-tab-btn.active {
    background: var(--accent-color);
    color: #000;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(212, 175, 55, 0.3);
}

/* Panels */
.lobby-panel {
    display: none;
}

.lobby-panel.active {
    display: block;
}

/* Active Party Card */
.lobby-active-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 18px 16px;
    text-align: center;
    margin-bottom: 10px;
}

.lobby-party-title {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    color: var(--text-main);
    margin: 0 0 6px 0;
}

.lobby-badges-row-center {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.lobby-status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: rgba(46, 204, 113, 0.15);
    border: 1px solid rgba(46, 204, 113, 0.4);
    color: #2ecc71;
    font-size: 0.72rem;
    height: 24px;
    padding: 0 10px;
    border-radius: 20px;
    font-weight: 700;
    line-height: 1;
    box-sizing: border-box;
    margin: 0;
}

.lobby-code-box {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px dashed var(--accent-color);
    border-radius: 10px;
    padding: 10px 16px;
    margin-bottom: 16px;
}

.lobby-code-text {
    font-family: monospace;
    font-size: 1.5rem;
    letter-spacing: 3px;
    font-weight: 800;
    color: var(--accent-color);
}

/* QR Code Display */
.lobby-qr-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 16px 0 10px 0;
}

.lobby-qr-frame {
    background: #ffffff;
    padding: 12px;
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-width: 170px;
    min-height: 170px;
}

.lobby-qr-frame img,
.lobby-qr-frame canvas {
    display: block;
    max-width: 100%;
}

.lobby-qr-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 10px;
    text-align: center;
    max-width: 270px;
    line-height: 1.35;
}

/* Separator */
.lobby-separator {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.75rem;
    margin: 16px 0;
}

.lobby-separator::before,
.lobby-separator::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border-color);
}

.lobby-separator span {
    padding: 0 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* QR Scanner Box */
.lobby-scanner-container {
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    max-width: 100%;
    margin-top: 10px;
    border: 1px solid var(--border-color);
}

.lobby-scanner-video {
    width: 100%;
    max-height: 240px;
    object-fit: cover;
    display: block;
}

.lobby-scanner-overlay {
    position: absolute;
    inset: 15%;
    border: 2px solid var(--accent-color);
    border-radius: 10px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45);
    pointer-events: none;
}

/* Saved Tables List & Disconnect View */
.lobby-saved-tables-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

.lobby-saved-table-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: all 0.2s ease;
}

.lobby-saved-table-card:hover {
    border-color: rgba(212, 175, 55, 0.5);
    background: rgba(255, 255, 255, 0.06);
}

.lobby-saved-table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.lobby-saved-table-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-main);
}

.lobby-saved-badges-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.lobby-badge {
    font-size: 0.72rem;
    height: 24px;
    padding: 0 10px;
    border-radius: 20px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    line-height: 1;
    box-sizing: border-box;
    margin: 0;
}

.lobby-badge.owner {
    background: rgba(212, 175, 55, 0.15);
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
}

.lobby-badge.participant {
    background: rgba(52, 152, 219, 0.15);
    border: 1px solid #3498db;
    color: #3498db;
}

.lobby-badge.active-status {
    background: rgba(46, 204, 113, 0.15);
    border: 1px solid #2ecc71;
    color: #2ecc71;
}

.lobby-badge.closed-status {
    background: rgba(231, 76, 60, 0.15);
    border: 1px solid #e74c3c;
    color: #e74c3c;
}

.lobby-saved-actions {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    width: 100%;
    align-items: stretch;
    box-sizing: border-box;
}

.lobby-saved-actions .btn-connect-table {
    flex: 0 0 calc(90% - 3px);
    width: calc(90% - 3px);
    padding: clamp(6px, 1.5vw, 8px) clamp(8px, 2vw, 12px);
    font-size: clamp(0.72rem, 2.4vw, 0.82rem);
    height: auto;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
    margin: 0;
}

.lobby-saved-actions .btn-delete-table {
    flex: 0 0 calc(10% - 3px);
    width: calc(10% - 3px);
    min-width: 32px;
    background: rgba(255, 82, 82, 0.15) !important;
    border: 1px solid rgba(255, 82, 82, 0.4) !important;
    color: #ff5252 !important;
    padding: clamp(6px, 1.5vw, 8px) 0;
    font-size: clamp(0.72rem, 2.4vw, 0.82rem);
    height: auto;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    cursor: pointer;
    box-sizing: border-box;
    margin: 0;
    transition: all 0.2s ease;
}

.lobby-saved-actions .btn-delete-table:hover {
    background: rgba(255, 82, 82, 0.25) !important;
    border-color: #ff5252 !important;
}

@media (max-width: 420px) {
    .lobby-saved-actions {
        gap: 4px;
    }
    .lobby-saved-actions .btn-connect-table {
        flex: 0 0 calc(90% - 2px);
        width: calc(90% - 2px);
        padding: 6px 6px;
        font-size: 0.72rem;
    }
    .lobby-saved-actions .btn-delete-table {
        flex: 0 0 calc(10% - 2px);
        width: calc(10% - 2px);
        min-width: 30px;
        padding: 6px 0;
        font-size: 0.72rem;
    }
}

.lobby-footer-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
}

.lobby-footer-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 14px;
    height: 42px;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
    box-sizing: border-box;
    line-height: 1;
}

.lobby-footer-btn.btn-share {
    background: var(--accent-color);
    border: 1px solid var(--accent-color);
    color: #121212;
}

.lobby-footer-btn.btn-share:hover {
    background: #4dd0e1;
    border-color: #4dd0e1;
    box-shadow: 0 4px 10px rgba(3, 218, 198, 0.3);
}

.lobby-footer-btn.btn-disconnect {
    background: rgba(231, 76, 60, 0.12);
    border: 1px solid rgba(231, 76, 60, 0.4);
    color: #ff6b6b;
}

.lobby-footer-btn.btn-disconnect:hover {
    background: rgba(231, 76, 60, 0.25);
    border-color: #ff5252;
    color: #fff;
    box-shadow: 0 4px 10px rgba(231, 76, 60, 0.25);
}

/* Table Characters & Assignment Section */
.lobby-table-characters-section {
    text-align: left;
    margin: 16px 0;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.lobby-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.lobby-section-title {
    font-size: 0.86rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.lobby-table-char-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 220px;
    overflow-y: auto;
}

.lobby-table-char-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 8px;
    padding: 8px 12px;
    gap: 10px;
    transition: border-color 0.2s ease;
}

.lobby-table-char-item:hover {
    border-color: rgba(212, 175, 55, 0.3);
}

.lobby-table-char-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.lobby-table-char-name {
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lobby-table-char-class {
    font-size: 0.74rem;
    color: var(--text-muted);
}

.lobby-table-char-assign-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.lobby-assign-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.lobby-assign-select {
    background: rgba(20, 20, 20, 0.9);
    border: 1px solid var(--border-color);
    color: var(--accent-color);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.lobby-assign-select:focus {
    border-color: var(--accent-color);
}

.lobby-assigned-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-muted);
    font-size: 0.74rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 6px;
}

.lobby-remove-char-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    transition: color 0.2s, background 0.2s;
}

.lobby-remove-char-btn:hover {
    color: #ff5252;
    background: rgba(255, 82, 82, 0.15);
}

/* Select Characters Modal */
.lobby-select-chars-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 320px;
    overflow-y: auto;
}

.lobby-select-char-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    user-select: none;
}

.lobby-select-char-row:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(212, 175, 55, 0.35);
}

.lobby-select-char-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.lobby-select-char-name {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-main);
}

.lobby-select-char-meta {
    font-size: 0.74rem;
    color: var(--text-muted);
}

.lobby-select-char-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--accent-color);
}

/* Coin Toggle Switch & Split Styles */
.char-coin-compact-modal.expanded {
    max-height: 90vh !important;
    overflow-y: auto !important;
}

.coin-switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    margin: 0;
}

.coin-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.coin-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(255, 255, 255, 0.2);
    transition: 0.2s;
    border-radius: 20px;
}

.coin-slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.2s;
    border-radius: 50%;
}

.coin-switch input:checked + .coin-slider {
    background-color: var(--accent-color);
}

.coin-switch input:checked + .coin-slider:before {
    transform: translateX(16px);
    background-color: #000;
}

.coin-split-chars-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 130px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.35);
    padding: 6px 8px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.coin-split-char-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    padding: 4px 6px;
    cursor: pointer;
    border-radius: 4px;
    color: var(--text-main);
    transition: background 0.15s;
}

.coin-split-char-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.coin-split-char-item input[type="checkbox"] {
    accent-color: var(--accent-color);
    cursor: pointer;
}

/* Coins Overview Modal & Select Styles */
.char-coin-overview-modal {
    max-width: 340px !important;
    padding: 14px 16px 18px !important;
    border-radius: 14px !important;
    background: rgba(22, 22, 26, 0.98) !important;
    backdrop-filter: blur(14px);
    border: 1px solid rgba(129, 212, 250, 0.25) !important;
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.7);
}

.coins-overview-total-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    margin-bottom: 12px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.coins-overview-rows {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 14px;
}

.coin-overview-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.coin-overview-card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent-color);
    transform: translateY(-1px);
}

.coin-overview-card-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.coin-overview-card-labels {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.coin-overview-code {
    font-size: 0.92rem;
    color: var(--accent-color);
    font-weight: 700;
}

.coin-overview-name {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.coin-overview-card-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.coin-overview-amount {
    font-size: 1.05rem;
    font-weight: 700;
    font-family: monospace;
    color: #fff;
}

.coin-overview-chevron {
    font-size: 0.75rem;
    color: var(--text-muted);
    transition: transform 0.2s;
}

.coin-overview-card:hover .coin-overview-chevron {
    transform: translateX(2px);
    color: var(--accent-color);
}

/* Styled Transfer Select */
#transfer-dest-select,
.app-styled-select {
    width: 100%;
    background: rgba(24, 24, 28, 0.95) !important;
    border: 1px solid rgba(129, 212, 250, 0.3) !important;
    color: var(--accent-color) !important;
    padding: 10px 12px !important;
    border-radius: 8px !important;
    font-size: 0.88rem !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    outline: none !important;
    box-sizing: border-box !important;
    transition: border-color 0.2s;
}

#transfer-dest-select:focus,
.app-styled-select:focus {
    border-color: var(--accent-color) !important;
    box-shadow: 0 0 10px rgba(129, 212, 250, 0.25) !important;
}

#transfer-dest-select option,
.app-styled-select option {
    background: #18181c !important;
    color: #e0e0e0 !important;
    padding: 8px !important;
}

/* Scoped Coin Split Row */
.coin-split-char-row {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 7px 10px !important;
    border-radius: 6px !important;
    background: rgba(255, 255, 255, 0.04) !important;
    cursor: pointer !important;
    margin-bottom: 4px !important;
    border: 1px solid rgba(255, 255, 255, 0.05) !important;
    transition: background 0.15s;
}

.coin-split-char-row:hover {
    background: rgba(255, 255, 255, 0.08) !important;
}

.coin-split-char-info {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    color: #e0e0e0 !important;
    font-size: 0.84rem !important;
    font-weight: 600 !important;
    text-transform: none !important;
    letter-spacing: normal !important;
}

.coin-split-char-cb {
    width: 18px !important;
    height: 18px !important;
    padding: 0 !important;
    margin: 0 !important;
    accent-color: var(--accent-color) !important;
    cursor: pointer !important;
}

/* Synchronized Compact Modal Proportions */
.char-coin-compact-modal,
.char-coin-overview-modal {
    width: 90% !important;
    max-width: 330px !important;
    height: auto !important;
    max-height: 90vh !important;
    overflow-y: auto !important;
    box-sizing: border-box !important;
    padding: 12px 14px 16px !important;
    border-radius: 14px !important;
    background: rgba(24, 24, 28, 0.98) !important;
    backdrop-filter: blur(14px);
    border: 1px solid rgba(129, 212, 250, 0.25) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
}

.char-coin-compact-modal.expanded {
    width: 90% !important;
    max-width: 330px !important;
    height: auto !important;
    max-height: 90vh !important;
    overflow-y: auto !important;
}

.coin-split-participants-title {
    font-size: 0.75rem !important;
    font-weight: 700 !important;
    color: var(--accent-color) !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    margin-bottom: 6px !important;
    font-family: var(--font-header, 'Cinzel', serif) !important;
}

.coin-split-chars-list {
    display: flex !important;
    flex-direction: column !important;
    gap: 4px !important;
    max-height: 140px !important;
    overflow-y: auto !important;
    padding-right: 2px !important;
}

.coin-split-char-row {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    padding: 6px 10px !important;
    border-radius: 6px !important;
    background: rgba(255, 255, 255, 0.05) !important;
    cursor: pointer !important;
    margin-bottom: 3px !important;
    border: 1px solid rgba(255, 255, 255, 0.07) !important;
    transition: background 0.15s, border-color 0.15s;
    user-select: none !important;
}

.coin-split-char-row:hover {
    background: rgba(255, 255, 255, 0.09) !important;
    border-color: rgba(129, 212, 250, 0.3) !important;
}

.coin-split-char-cb {
    width: 17px !important;
    min-width: 17px !important;
    height: 17px !important;
    margin: 0 10px 0 0 !important;
    padding: 0 !important;
    accent-color: var(--accent-color) !important;
    cursor: pointer !important;
    display: inline-block !important;
}

.coin-split-char-name {
    color: #f0f0f0 !important;
    font-size: 0.88rem !important;
    font-weight: 600 !important;
    text-transform: none !important;
    font-family: var(--font-body, 'Lato', sans-serif) !important;
    letter-spacing: normal !important;
    flex: 1 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}

/* Button "Tutto" below split amount input */
.coin-split-all-btn {
    width: 100% !important;
    padding: 7px 10px !important;
    font-size: 0.8rem !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    border-radius: 6px !important;
    background: rgba(129, 212, 250, 0.12) !important;
    border: 1px solid rgba(129, 212, 250, 0.35) !important;
    color: var(--accent-color) !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    text-align: center !important;
    box-sizing: border-box !important;
    display: block !important;
}

.coin-split-all-btn:hover {
    background: rgba(129, 212, 250, 0.22) !important;
    border-color: var(--accent-color) !important;
}
