/* Basic Setup and CSS Variables for Theming */
:root {
    --bg-color: #1a1a1a;
    --panel-bg-color: #2c2c2c;
    --text-color: #e0e0e0;
    --text-secondary-color: #a0a0a0;
    --accent-color: #ffc107;
    --border-color: #444;
    --highlight-bg: #3a3a3a;
    --highlight-flash-bg: #ffe082; /* A lighter version of the accent color for the flash and hover */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    font-size: 14px;
    /* Prevent scrolling on the body itself */
    overflow: hidden;
}

/* --- Main App Structure --- */
#app-wrapper {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

#content-wrapper {
    flex-grow: 1;
    overflow: hidden; /* This is changed to allow inner content to scroll */
}

/* --- Top Header (Mobile Only) --- */
#app-header {
    display: none; /* Hidden on desktop by default now */
    justify-content: space-between;
    align-items: center;
    padding: 0 1rem;
    background-color: var(--panel-bg-color);
    border-bottom: 2px solid var(--border-color);
    flex-shrink: 0;
    height: 50px;
}

#app-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-color);
    margin: 0;
}

/* --- Search Bar & Suggestions Styles (Desktop) --- */
#search-container-desktop {
    display: flex;
    align-items: center;
    position: relative;
}
#search-icon-desktop {
    color: var(--text-secondary-color);
    cursor: pointer;
    transition: color 0.2s;
    order: 2; /* Icon to the right of the input */
}
#search-icon-desktop:hover {
    color: var(--accent-color);
}

/* New search bar logic to fix typing issue */
#search-bar-desktop {
    order: 1;
    padding: 6px 8px;
    border: 1px solid var(--border-color);
    background-color: var(--panel-bg-color);
    color: var(--text-color);
    outline: none;
    transition: all 0.3s ease-in-out;
    margin-right: 8px;
    font-size: 0.9rem;
    border-radius: 4px;
}

#search-bar-desktop.search-bar-collapsed {
    width: 0;
    padding-left: 0;
    padding-right: 0;
    opacity: 0;
    border-color: transparent;
    pointer-events: none;
}
#search-bar-desktop:not(.search-bar-collapsed) {
    width: 200px;
}

.search-hidden {
    display: none;
}

#search-suggestions-desktop {
    position: absolute;
    top: 110%;
    right: 0;
    width: 250px;
    background-color: var(--panel-bg-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    max-height: 50vh;
    overflow-y: auto;
    z-index: 200;
}
.suggestion-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color 0.2s;
}
.suggestion-item:last-child {
    border-bottom: none;
}
.suggestion-item:hover {
    background-color: var(--highlight-bg);
    color: var(--accent-color);
}
.suggestion-name {
    font-weight: bold;
}
.suggestion-type {
    color: var(--text-secondary-color);
    font-size: 0.85rem;
}


/* --- Views & Sub-Views --- */
.view {
    height: 100%;
    overflow: hidden;
}
.view-hidden {
    display: none;
}

.sub-view-container {
    display: flex;
    height: 100%;
}


/* --- Sidebars (Desktop/Tablet) --- */
#class-sidebar, #faction-sidebar, #school-sidebar, #artifacts-sidebar, #map-objects-sidebar, #taverntips-sidebar {
    width: 180px;
    background-color: var(--panel-bg-color);
    border-right: 2px solid var(--border-color);
    padding: 1rem;
    box-sizing: border-box;
    flex-shrink: 0;
    overflow-y: auto;
}

.faction-tab {
    margin-bottom: 10px;
}

.faction-tab-button {
    display: block;
    width: 100%;
    padding: 12px 10px;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    border-radius: 4px;
    text-align: left;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: bold;
    transition: background-color 0.2s;
}
.faction-tab-button:hover {
    background-color: var(--highlight-bg);
}
.faction-tab-button.active {
    background-color: var(--accent-color);
    color: #1a1a1a;
    border-color: var(--accent-color);
}

.class-sub-tabs {
    padding-top: 8px;
    padding-left: 15px;
}
.class-sub-tabs.hidden {
    display: none;
}

.sidebar-button {
    display: block; width: 100%; padding: 10px; margin-bottom: 10px;
    background-color: var(--bg-color); border: 1px solid var(--border-color);
    color: var(--text-secondary-color); border-radius: 4px; text-align: left;
    cursor: pointer; font-size: 1rem; transition: background-color 0.2s, color 0.2s;
}
.sidebar-button:hover { background-color: var(--highlight-bg); }
.sidebar-button.active {
    background-color: var(--accent-color); color: #1a1a1a;
    font-weight: bold; border-color: var(--accent-color);
}
.sidebar-divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 1rem 0;
}

#class-sidebar .sidebar-button, #artifacts-sidebar .sidebar-button {
    margin-bottom: 6px;
    padding: 8px 10px;
    font-size: 0.95rem;
}


/* --- Main Content Areas --- */
#main-content, #creature-content, #spell-content, #artifacts-content, #map-objects-content, #taverntips-content {
    flex-grow: 1; 
    padding: 1.5rem; 
    overflow-y: auto;
}

.panel {
    background-color: var(--panel-bg-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 1rem;
}

.panel h2 {
    margin-top: 0; color: var(--accent-color); font-size: 1.1rem; text-align: center;
    border-bottom: 1px solid var(--border-color); padding-bottom: 0.5rem; margin-bottom: 0.25rem;
}

/* --- Tiered Responsive Layout for Heroes View --- */
.page-grid {
    display: grid;
    grid-template-columns: 220px 220px 1fr;
    gap: 1.5rem;
    grid-template-areas:
        "class-primary-skills magic-chance heroes"
        "movement-info skills-info heroes";
}
#class-primary-skills-panel { grid-area: class-primary-skills; }
#movement-panel { grid-area: movement-info; }
#magic-chance-panel { grid-area: magic-chance; }
#secondary-skills-panel { grid-area: skills-info; }
#heroes-panel { grid-area: heroes; }
/* --- End of Tiered Layout --- */


.info-table {
    width: 100%; border-collapse: collapse; font-size: 0.9rem;
}
.info-table td { padding: 5px 4px; }
.info-table td:last-child { text-align: right; font-weight: bold; }

.stats-grid-table {
    width: 100%; text-align: center; font-size: 0.9rem; border-collapse: collapse;
}
.stats-grid-table th, .stats-grid-table td { padding: 6px 2px; }
.stats-grid-table th {
    color: var(--text-secondary-color); font-weight: normal;
    border-bottom: 1px solid var(--border-color);
}
.stats-grid-table td:first-child {
    text-align: left; font-weight: bold; color: var(--text-secondary-color);
}

.magic-chance-grid {
    display: grid; grid-template-columns: repeat(4, 1fr); text-align: center;
    gap: 4px; margin-bottom: 1rem;
}
.magic-chance-grid div { font-size: 0.85rem; }
.magic-chance-grid .school-name { color: var(--text-secondary-color); }
.magic-chance-grid .school-chance { font-weight: bold; }
.guaranteed-skill-info {
    font-size: 0.9rem; text-align: center; margin-top: 0.5rem;
    padding-top: 0.5rem; border-top: 1px solid var(--border-color);
}
.guaranteed-skill-info div { margin-bottom: 4px; }

.movement-table {
    width: 100%; border-collapse: collapse; font-size: 0.9rem; margin-bottom: 1rem;
}
.movement-table th {
    color: var(--text-secondary-color); font-weight: normal; text-align: left;
    border-bottom: 1px solid var(--border-color); padding: 4px;
}
.movement-table td { padding: 4px; }
.movement-table td:last-child { text-align: right; }
.movement-links { text-align: center; margin-top: 1rem; }

.hero-table {
    width: 100%; border-collapse: collapse; font-size: 0.9rem;
}
.hero-table th, .hero-table td {
    padding: 6px 4px; text-align: left; border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}
.hero-table th { color: var(--text-secondary-color); font-weight: normal; }
.hero-table .hero-name-cell { display: flex; align-items: center; }
.hero-table .hero-portrait {
    width: 28px; height: 28px; border-radius: 50%;
    vertical-align: middle; margin-right: 8px;
}

/* --- REVISED: Harmonized Clickable Text Styles --- */
.info-table .clickable td:first-child,
.stats-grid-table th.clickable,
.magic-chance-grid .school-name.clickable,
.movement-table .clickable,
.movement-links .clickable,
.hero-table .clickable,
.creature-table .creature-name.clickable,
.creature-table span.clickable[data-special-name],
.spell-list-table .spell-name.clickable,
.panel-subtitle.clickable,
.artifacts-table .clickable td:first-child,
.map-objects-table .clickable td:first-child {
    /* Default state: subtle underline, inherits text color */
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 3px;
    transition: color 0.2s ease-in-out;
}

.info-table .clickable:hover td:first-child,
.stats-grid-table th.clickable:hover,
.magic-chance-grid .school-name.clickable:hover,
.movement-table .clickable:hover,
.movement-links .clickable:hover,
.hero-table .clickable:hover,
.creature-table .creature-name.clickable:hover,
.creature-table span.clickable[data-special-name]:hover,
.spell-list-table .spell-name.clickable:hover,
.panel-subtitle.clickable:hover,
.artifacts-table .clickable:hover td:first-child,
.map-objects-table .clickable:hover td:first-child {
    /* Hover state: changes color, removes underline */
    color: var(--accent-color);
    text-decoration: none;
}


/* --- Creatures View Specific Styles --- */
.creature-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.creature-table th, .creature-table td {
    padding: 8px 5px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
    vertical-align: middle;
}
.creature-table th {
    color: var(--text-secondary-color);
    font-weight: normal;
    position: sticky;
    top: 0;
    background-color: var(--panel-bg-color);
}
.creature-table .upgraded-row td {
    background-color: var(--highlight-bg);
}
.creature-table .creature-name {
    font-weight: bold;
}
.placeholder-panel {
    padding: 3rem;
    text-align: center;
    color: var(--text-secondary-color);
}

.native-terrain-info {
    text-align: center;
    color: var(--text-secondary-color);
    margin: -0.5rem 0 1rem 0;
    font-size: 0.9rem;
}

/* --- Spells View Specific Styles --- */
#spell-content .panel h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    font-size: 1rem;
    color: var(--text-secondary-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.25rem;
}
#spell-content .panel h3:first-of-type {
    margin-top: 0;
}
.spell-list-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.spell-list-table th, .spell-list-table td {
    padding: 8px 5px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
    vertical-align: top;
}
.spell-list-table th {
    color: var(--text-secondary-color);
    font-weight: normal;
}
.spell-list-table .spell-name {
    font-weight: bold;
}
.spell-list-table td:nth-child(1) { width: 20%; }
.spell-list-table td:nth-child(2) { width: 10%; }
.spell-list-table td:nth-child(3) { width: 15%; }
.spell-list-table td:nth-child(4) { width: 55%; }


/* --- Artifacts View Specific Styles --- */
.artifacts-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.artifacts-table th, .artifacts-table td {
    padding: 8px 6px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
    vertical-align: top;
}
.artifacts-table th {
    color: var(--text-secondary-color);
    font-weight: normal;
    position: sticky;
    top: 0;
    background-color: var(--panel-bg-color);
}
.artifacts-table .clickable:hover {
    background-color: var(--highlight-bg);
    cursor: pointer;
}
.artifacts-table td:first-child {
    font-weight: bold;
}


/* --- Map Objects View Specific Styles --- */
.panel-subtitle {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary-color);
    text-align: center;
    margin-top: 0;
    margin-bottom: 1rem;
}

.map-objects-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.map-objects-table th, .map-objects-table td {
    padding: 8px 6px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
    vertical-align: top;
}
.map-objects-table th {
    color: var(--text-secondary-color);
    font-weight: normal;
    position: sticky;
    top: 0;
    background-color: var(--panel-bg-color);
}
.map-objects-table .clickable:hover {
    background-color: var(--highlight-bg);
}
.map-objects-table td:nth-child(1) { width: 15%; font-weight: bold; } /* Name */
.map-objects-table td:nth-child(2) { width: 20%; } /* Guards */
.map-objects-table td:nth-child(3) { width: 65%; } /* Rewards */

.rewards-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.rewards-list li {
    margin-bottom: 4px;
}
.rewards-list li:last-child {
    margin-bottom: 0;
}
.reward-label {
    font-weight: bold;
    color: var(--text-secondary-color);
    display: inline-block;
    width: 80px;
}

/* --- Tavern Tips View Specific Styles --- */
#taverntips-content .panel h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    font-size: 1rem;
    color: var(--text-secondary-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.25rem;
}
#taverntips-content .panel h3:first-of-type {
    margin-top: 0;
}
.keybinds-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.keybinds-table th, .keybinds-table td {
    padding: 8px 6px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
    vertical-align: top;
}
.keybinds-table th {
    color: var(--text-secondary-color);
    font-weight: normal;
}
.keybinds-table td:first-child {
    font-weight: bold;
    width: 25%;
}

/* --- Highlight for Scrolled-to Item --- */
@keyframes highlight-fade {
    from { background-color: var(--highlight-flash-bg); }
    to { background-color: transparent; }
}
.highlight-flash {
    animation: highlight-fade 1.5s ease-in-out;
}


/* --- Modal Styling --- */
#modal.modal-hidden, #search-modal-mobile.modal-hidden { 
    display: none; 
}

#modal {
    position: fixed; z-index: 100; left: 0; top: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.7); display: flex; align-items: center; justify-content: center;
    padding: 1rem; box-sizing: border-box;
}
#modal-content {
    background-color: var(--panel-bg-color); padding: 20px; border-radius: 4px; width: 100%;
    max-width: 600px; max-height: 90vh; overflow-y: auto; position: relative;
    border: 1px solid var(--border-color);
}
#modal-close {
    position: absolute; top: 0; right: 0; font-size: 2rem; border: none;
    background: none; color: var(--text-secondary-color); cursor: pointer;
    width: 44px; height: 44px; line-height: 44px; text-align: center;
}
#modal-body h3 { color: var(--accent-color); margin-top: 0; }
#modal-body h4 { color: var(--accent-color); margin-bottom: 0.5rem; }
#modal-body p, #modal-body li { line-height: 1.6; }
#modal-body ul { padding-left: 20px; margin-top: 0.5rem; }
#modal-body .hota-details summary {
    cursor: pointer;
    font-weight: bold;
    color: var(--accent-color);
    margin-top: 1rem;
    outline: none;
}
#modal-body .hota-details summary::marker {
    color: var(--accent-color);
}
#modal-body .hota-details .details-content {
    padding-left: 1.5rem;
    margin-top: 0.5rem;
    border-left: 2px solid var(--border-color);
}
#modal-body .modal-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}
#modal-body .modal-table th, #modal-body .modal-table td {
    border: 1px solid var(--border-color);
    padding: 6px 8px;
    text-align: left;
}
#modal-body .modal-table th {
    background-color: var(--highlight-bg);
}
#modal-body img.battlefield-image {
    display: block;
    max-width: 100%;
    margin: 0 auto 1rem auto;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

/* ==========================================================================
   NAVIGATION STYLES (DESKTOP FIRST, THEN MOBILE OVERRIDE)
   ========================================================================== */

/* --- Desktop Navigation (Single Top Bar) --- */
#main-nav {
    order: -1; /* Places nav before content wrapper on desktop */
    display: flex;
    align-items: center;
    background-color: var(--panel-bg-color);
    border-bottom: 2px solid var(--border-color);
    flex-shrink: 0;
    height: 50px;
    padding: 0 1rem;
}

#app-title-nav {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-color);
    margin-right: 2rem;
}

.nav-buttons-wrapper {
    display: flex;
    flex-grow: 1;
}

.nav-button {
    padding: 12px 15px;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary-color);
    background-color: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}
.nav-button:hover {
    background-color: var(--highlight-bg);
}
.nav-button.active {
    color: var(--accent-color);
    border-bottom-color: var(--accent-color);
}
.nav-button svg {
    display: none; /* Hide icons on desktop by default */
}

/* Hide mobile-specific text on desktop */
.nav-button .mobile-nav-text {
    display: none;
}
.nav-button .desktop-nav-text {
    display: inline;
}

#search-button-mobile {
    display: none; /* Hide mobile search button on desktop */
}


/* ==========================================================================
   MOBILE OVERHAUL (Applies to screens smaller than 768px)
   ========================================================================== */
@media (max-width: 768px) {
    /* --- Global Mobile Adjustments --- */
    body {
        font-size: 13px;
    }
    #main-content, #creature-content, #spell-content, #artifacts-content, #map-objects-content, #taverntips-content {
        padding: 0.75rem;
    }

    #app-header {
        display: flex; /* Show the original header on mobile */
        height: 44px;
        padding: 0 0.75rem;
    }

    /* --- Bottom Navigation Bar --- */
    #main-nav {
        order: 1; /* Places nav after content wrapper on mobile */
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 60px;
        border-top: 1px solid var(--border-color);
        border-bottom: none;
        z-index: 100;
        justify-content: space-around;
        padding: 0;
    }

    #app-title-nav {
        display: none; /* Hide the nav bar title on mobile */
    }

    .nav-buttons-wrapper {
        display: contents; /* Let buttons be direct flex children of nav on mobile */
    }

    #content-wrapper {
        padding-bottom: 110px; /* 60px for nav + 50px for dropdown bar */
    }

    .nav-button {
        flex-direction: column;
        padding: 4px 0;
        font-size: 0.7rem;
        font-weight: 400;
        border-bottom: none;
        border-top: 3px solid transparent;
        flex-grow: 1;
        max-width: 80px; /* Prevent buttons from becoming too wide */
    }
    .nav-button.active {
        border-bottom-color: transparent;
        border-top-color: var(--accent-color);
    }
    .nav-button svg {
        display: block; /* Show icons on mobile */
        width: 24px;
        height: 24px;
        margin-bottom: 2px;
    }
    .nav-button span {
        display: block;
    }

    /* Swap text visibility */
    .nav-button .desktop-nav-text {
        display: none;
    }
    .nav-button .mobile-nav-text {
        display: block;
    }

    #search-container-desktop {
        display: none; /* Hide desktop search container on mobile */
    }
    #search-button-mobile {
        display: flex; /* Show the mobile search button */
    }

    /* --- Mobile Layout Structure --- */
    .sub-view-container {
        flex-direction: column;
        height: 100%;
    }

    /* Hide the original sidebars on mobile, they are replaced by the custom dropdown */
    #class-sidebar, #faction-sidebar, #school-sidebar, #artifacts-sidebar, #map-objects-sidebar, #taverntips-sidebar {
       display: none;
    }

    .page-grid {
        display: block; /* Disable grid/flex for mobile */
    }

    /* --- Mobile Dropdown Navigation --- */
    #mobile-dropdown-container {
        position: fixed;
        bottom: 60px; /* Positioned just above the main nav bar */
        left: 0;
        right: 0;
        z-index: 100;
        background-color: var(--panel-bg-color);
        border-top: 2px solid var(--border-color);
        padding: 0.5rem 0;
    }

    .custom-select-container {
        position: relative;
        width: 90%;
        max-width: 400px;
        margin: 0 auto; /* Center the container */
    }

    .custom-select-button {
        width: 100%;
        padding: 10px;
        background-color: var(--bg-color);
        color: var(--text-color);
        border: 1px solid var(--border-color);
        border-radius: 4px;
        font-size: 1rem;
        text-align: center;
        cursor: pointer;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .custom-select-arrow {
        transition: transform 0.2s;
    }

    .custom-select-arrow.up {
        transform: rotate(180deg);
    }

    .custom-select-options {
        position: fixed;
        bottom: 115px; /* (60px nav bar + ~55px dropdown bar) */
        left: 50%;
        transform: translateX(-50%);
        width: fit-content; /* Make width adapt to content */
        min-width: 60vw;   /* Ensure it's not too narrow */
        background-color: var(--panel-bg-color);
        border: 1px solid var(--accent-color);
        border-radius: 4px;
        z-index: 300;
        max-height: 40vh;
        overflow-y: auto;
        box-shadow: 0 -4px 15px rgba(0,0,0,0.5);
    }

    .custom-select-options.hidden {
        display: none;
    }

    .custom-select-optgroup {
        padding: 10px 24px;
        font-weight: bold;
        color: var(--accent-color);
        background-color: var(--bg-color);
        border-bottom: 1px solid var(--border-color);
        position: sticky;
        top: 0;
        text-align: center;
    }

    .custom-select-option {
        padding: 12px 24px;
        cursor: pointer;
        border-bottom: 1px solid var(--border-color);
        text-align: center;
    }
    .custom-select-option:last-child {
        border-bottom: none;
    }
    .custom-select-option:hover {
        background-color: var(--highlight-bg);
        color: var(--accent-color);
    }

    /* Hide desktop sidebar elements */
    .faction-tab, .sidebar-button, .sidebar-divider {
        display: none;
    }

    /* --- Mobile Clickable Text --- */
    .mobile-card .clickable, 
    .mobile-accordion .clickable, 
    .movement-links .clickable {
        color: inherit;
        font-weight: inherit;
        text-decoration: underline;
        text-decoration-style: dotted;
        text-underline-offset: 3px;
    }


    /* --- Mobile Accordion --- */
    .mobile-accordion details {
        background-color: var(--panel-bg-color);
        border: 1px solid var(--border-color);
        border-radius: 4px;
        margin-bottom: 0.75rem;
    }
    .mobile-accordion summary {
        padding: 1rem; /* Increased padding for larger touch target */
        font-weight: bold;
        cursor: pointer;
        /* color: var(--accent-color); */ /* Removed for consistency */
        font-size: 1rem;
        list-style: none; /* Remove default marker */
        position: relative;
        text-decoration: underline;
        text-decoration-style: dotted;
        text-underline-offset: 3px;
    }
    .mobile-accordion summary::-webkit-details-marker {
        display: none; /* For Chrome/Safari */
    }
    .mobile-accordion summary::after { /* Custom arrow */
        content: '▶';
        position: absolute;
        right: 15px;
        top: 50%;
        transform: translateY(-50%) rotate(0deg);
        transition: transform 0.2s;
        font-size: 0.8em;
        text-decoration: none; /* Ensure arrow is not underlined */
    }
    .mobile-accordion details[open] > summary::after {
        transform: translateY(-50%) rotate(90deg);
    }
    .mobile-accordion .panel-content {
        padding: 0 1rem 1rem 1rem;
        border-top: 1px solid var(--border-color);
    }

    /* --- Mobile Card Layouts --- */
    .mobile-card-list {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }
    .mobile-card {
        background-color: var(--panel-bg-color);
        border: 1px solid var(--border-color);
        border-radius: 4px;
        padding: 0.75rem;
        cursor: pointer;
        transition: background-color 0.2s;
    }
    .mobile-card:hover {
        background-color: var(--highlight-bg);
    }
    .card-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 0.5rem;
    }
    .card-title {
        font-size: 1.1rem;
        font-weight: bold;
        color: var(--text-color);
        text-decoration: underline;
        text-decoration-style: dotted;
        text-underline-offset: 3px;
    }
    .card-subtitle {
        font-size: 0.8rem;
        color: var(--text-secondary-color);
    }
    .card-body {
        font-size: 0.9rem;
        line-height: 1.5;
    }
    .card-body p {
        margin: 0;
    }
    .card-body .label {
        font-weight: bold;
        color: var(--text-secondary-color);
    }

    /* Creature Card Specifics */
    .creature-card.upgraded {
        background-color: var(--highlight-bg);
    }
    .creature-card .card-stats {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
        font-size: 0.85rem;
    }
    .creature-card .stat-item {
        display: flex;
        justify-content: space-between;
    }
    .creature-card .stat-value {
        font-weight: bold;
    }
    .creature-card .card-special {
        margin-top: 0.5rem;
        padding-top: 0.5rem;
        border-top: 1px solid var(--border-color);
        font-size: 0.85rem;
    }

    /* Hero Card Specifics */
    .hero-card .card-header {
        align-items: flex-start;
    }
    .hero-card {
        background-color: var(--bg-color);
    }
    .hero-card .hero-info {
        display: flex;
        align-items: center;
    }
    .hero-card .hero-portrait {
        width: 32px;
        height: 32px;
        border-radius: 50%;
        margin-right: 0.5rem;
    }
    .hero-card .hero-name {
        font-size: 1.1rem;
        font-weight: bold;
        text-decoration: underline;
        text-decoration-style: dotted;
        text-underline-offset: 3px;
    }
    .hero-card .hero-specialty {
        font-size: 0.8rem;
        color: var(--text-secondary-color);
    }
    .hero-card .hero-details {
        font-size: 0.85rem;
    }

    /* Spell/Artifact/Map Object Card Specifics */
    .spell-card .card-header, .artifact-card .card-header, .map-object-card .card-header {
        border-bottom: 1px solid var(--border-color);
        padding-bottom: 0.5rem;
    }
    .map-object-card .rewards-list {
        font-size: 0.85rem;
        margin-top: 0.5rem;
    }

    /* Hide Desktop Tables on Mobile */
    .hero-table, .creature-table, .spell-list-table, .artifacts-table, .map-objects-table {
        display: none;
    }

    /* --- Mobile Search Modal --- */
    #search-modal-mobile {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0,0,0,0.7); /* Dim the background */
        z-index: 250;
        display: flex;
        flex-direction: column;
        justify-content: flex-end; /* Align content to the bottom */
        padding-bottom: env(safe-area-inset-bottom);
    }
    #search-modal-mobile.modal-hidden {
        display: none;
    }
    #search-modal-content {
        display: flex;
        flex-direction: column-reverse; /* Reverses visual order */
        width: 100%;
        background-color: var(--bg-color);
        max-height: 70vh; /* Limit the height */
    }
    #search-modal-header {
        display: flex;
        align-items: center;
        padding: 0.5rem;
        border-top: 1px solid var(--border-color); /* Border on top now */
        border-bottom: none;
        flex-shrink: 0;
    }
    #search-bar-mobile {
        flex-grow: 1;
        padding: 0.75rem;
        font-size: 1rem;
        background-color: var(--panel-bg-color);
        border: 1px solid var(--border-color);
        border-radius: 4px;
        color: var(--text-color);
        outline: none;
    }
    #search-modal-close {
        background: none;
        border: none;
        color: var(--text-secondary-color);
        font-size: 2rem;
        cursor: pointer;
        width: 44px;
        height: 44px;
        line-height: 44px;
        text-align: center;
    }
    #search-suggestions-mobile {
        overflow-y: auto;
    }
}
