/* Global CSS for D&D Project - Black & White Theme */

/* Font imports */
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&display=swap');

/* CSS Variables */
:root {
    --primary-bg: #000000;
    --secondary-bg: #0a0a0a;
    --tertiary-bg: #1a1a1a;
    --accent-bg: #2a2a2a;
    --primary-text: #ffffff;
    --secondary-text: #cccccc;
    --accent-text: #888888;
    --border-color: #333333;
    --hover-bg: #333333;
    --selected-bg: #444444;
    --grid-color: rgba(255, 255, 255, 0.1);
    --shadow-color: rgba(0, 0, 0, 0.8);
    --glow-color: rgba(255, 255, 255, 0.3);
}

/* Reset and base styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

::selection {
    background: var(--selected-bg);
    color: var(--primary-text);
}

::-moz-selection {
    background: var(--selected-bg);
    color: var(--primary-text);
}

body {
    font-family: 'Monolisa', 'Courier New', monospace;
    background: var(--primary-bg);
    color: var(--primary-text);
    min-height: 100vh;
    overflow-x: hidden;
    background-image: 
        linear-gradient(to top, transparent 0% 49%, var(--grid-color) 49% 51%, transparent 51%),
        linear-gradient(to right, transparent 0% 49%, var(--grid-color) 49% 51%, transparent 51%),
        repeating-radial-gradient(100rem 70% at 50% 50%, var(--secondary-bg) 0%, var(--primary-bg) 43%, var(--primary-bg) 100%);
    background-size: auto 25px, 25px auto, cover;
    background-blend-mode: overlay;
    line-height: 1.6;
}

/* Media elements scale to container width */
img, video, canvas, svg, iframe {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Typography */
@font-face {
    font-family: 'Protest Regular';
    src: url('protest_regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

h1 {
    font-family: 'Protest Regular', 'Monolisa', monospace, sans-serif;
    font-weight: normal;
    font-size: 2.5rem;
    text-shadow: 0 0 10px var(--glow-color);
    letter-spacing: 2px;
    margin-bottom: 1rem;
}

h2 {
    font-family: 'Monolisa', monospace;
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--primary-text);
    text-shadow: 0 0 5px var(--glow-color);
}

h3 {
    font-family: 'Monolisa', monospace;
    font-size: 1.2rem;
    font-weight: 500;
    margin-bottom: 0.8rem;
    color: var(--secondary-text);
}

p {
    margin-bottom: 1rem;
    color: var(--secondary-text);
}

/* Container and layout */
.container {
    width: 100%;
    margin: 0;
    background: var(--primary-bg);
    min-height: 100vh;
    box-shadow: 0 0 20px rgba(0,0,0,0.3);
    box-sizing: border-box;
}

.header {
    background: linear-gradient(135deg, var(--primary-bg) 0%, var(--tertiary-bg) 100%);
    color: var(--primary-text);
    padding: 2rem;
    text-align: center;
    border-bottom: 2px solid var(--border-color);
    position: relative;
    width: 100%;
}

/* Hamburger Menu */
.hamburger-menu {
    position: fixed;
    top: 2rem;
    right: 2rem;
    cursor: pointer;
    z-index: 1000;
    padding: 8px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid var(--border-color);
}

.hamburger-menu:hover {
    background: rgba(255, 255, 255, 0.1);
}

.hamburger-icon {
    width: 24px;
    height: 18px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
}

.hamburger-line {
    width: 100%;
    height: 2px;
    background: #ffffff;
    border-radius: 1px;
    transition: all 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transform-origin: center;
}

/* Removed hamburger to close animation */

/* Navigation Menu */
.nav-menu {
    position: fixed;
    top: 0;
    left: -320px;
    width: 300px;
    height: 100vh;
    background: var(--primary-bg);
    border-right: 2px solid var(--accent-color);
    box-shadow: 2px 0 20px rgba(0,0,0,0.3);
    transition: left 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: 999;
    padding-top: 80px;
    overflow-y: auto;
    overflow-x: hidden;
    /* Enhanced mobile scrolling */
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

.nav-menu.active {
    left: 0;
}

.nav-menu ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-menu li {
    border-bottom: 1px solid var(--border-color);
}

.nav-menu a {
    display: block;
    padding: 1rem 2rem;
    color: var(--primary-text);
    text-decoration: none;
    font-size: 1.1rem;
    transition: background-color 0.2s;
}

.nav-menu a:hover {
    background: var(--secondary-bg);
}

.nav-menu a.active {
    background: var(--accent-color);
    color: white;
}

.nav-menu .nav-section-header {
    color: var(--accent-text);
    font-size: 0.75rem;
    font-weight: bold;
    letter-spacing: 1px;
    padding: 1rem 2rem 0.5rem 2rem;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0;
    background: var(--secondary-bg);
}



/* Overlay */
.nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.6);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94), 
                visibility 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.nav-overlay.active {
    opacity: 1;
    visibility: visible;
}

.header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--glow-color), transparent);
}

.header h1 {
    margin-bottom: 0.5rem;
}

.header p {
    font-size: 1.1rem;
    opacity: 0.8;
    color: var(--secondary-text);
}

.main-content {
    display: grid;
    /* Strict two-column layout to prevent over-shrinking */
    grid-template-columns: repeat(2, minmax(420px, 1fr));
    justify-items: stretch; /* ensure items fill available track width */
    grid-template-areas:
        "character character"
        "memory link"
        "mutators abilities"
        "mechanics mechanics";
    gap: 2rem;
    padding: 2rem;
    background: var(--secondary-bg);
    width: 100%; /* allow grid to use full screen width */
    margin: 0; /* no centering cap; fill available width */
}

/* One-column fallback on narrow screens */
@media (max-width: 920px) {
    .main-content {
        grid-template-columns: 1fr;
        grid-template-areas:
            "character"
            "memory"
            "link"
            "mutators"
            "abilities"
            "mechanics";
    }
}

/* Removed mobile-specific media queries; adopt fluid responsive defaults */

/* All grids below use auto-fit/minmax for fluid responsiveness without breakpoints */
/* Stats grid used across pages */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* Ensure common card blocks never exceed container width */
.monster-card,
.mutator-card,
.invocation-card,
.stat-box,
.ability-score,
.slot,
.derived-stats,
.attributes-grid,
.data-table {
    width: 100%;
    max-width: 100%;
}

/* Section styles */
.section {
    background: var(--tertiary-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    box-sizing: border-box; /* ensure padding does not cause overflow */
    position: relative;
    align-self: stretch; /* stretch section to fill grid area */
    transition: all 0.3s ease;
}

.section:hover {
    border-color: var(--glow-color);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.1);
}

.section h2 {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
}

/* Character info section */
.character-info {
    grid-area: character;
    grid-column: 1 / -1; /* force full-width across both columns */
    background: linear-gradient(135deg, var(--tertiary-bg) 0%, var(--accent-bg) 100%);
}

.mechanics-info { grid-area: mechanics; }
.memory-slots { grid-area: memory; }
.link-stats { grid-area: link; }
.mutators-section { grid-area: mutators; }
.abilities-section { grid-area: abilities; }

.char-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.stat-box {
    background: var(--primary-bg);
    border: 1px solid var(--border-color);
    padding: 1rem;
    border-radius: 6px;
    text-align: center;
    transition: all 0.3s ease;
}

.stat-box:hover {
    border-color: var(--glow-color);
    background: var(--secondary-bg);
}

.stat-label {
    font-size: 0.9rem;
    color: var(--accent-text);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--primary-text);
}

/* Memory slots */
.memory-slots {
    background: var(--tertiary-bg);
}

/* Monster Filters */
.monster-filters {
    background: var(--secondary-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.monster-filters h3 {
    margin: 0 0 1rem 0;
    color: var(--primary-text);
    font-size: 1.1rem;
}

/* Mutator Filters */
.mutator-filters {
    background: var(--secondary-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.mutator-filters h3 {
    margin: 0 0 1rem 0;
    color: var(--primary-text);
    font-size: 1.1rem;
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    min-width: 120px;
}

.filter-group label {
    color: var(--secondary-text);
    font-size: 0.9rem;
    margin-bottom: 0.3rem;
    font-weight: 500;
}

.filter-group select,
.filter-group input {
    background: var(--primary-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.5rem;
    color: var(--primary-text);
    font-size: 0.9rem;
}

.filter-group select:focus,
.filter-group input:focus {
    outline: none;
    border-color: var(--accent-text);
    box-shadow: 0 0 0 2px rgba(139, 69, 19, 0.2);
}

#clearFilters,
#clearMutatorFilters,
.clear-filters-btn {
    padding: 0.5rem 1rem;
    background: var(--accent-text);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s;
    height: 38px; /* Match the height of select elements */
    margin: 1rem 0;
    display: block;
    width: fit-content;
}

#clearFilters:hover,
#clearMutatorFilters:hover,
.clear-filters-btn:hover {
    background: #a0522d;
}

/* Save button styling */
.save-section {
    text-align: center;
    margin: 2rem 0;
}

.save-button {
    padding: 1rem 2rem;
    background: linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: bold;
    font-family: 'Monolisa', monospace;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    text-transform: uppercase;
    letter-spacing: 1px;
    min-width: 200px;
}

.save-button:hover {
    background: linear-gradient(135deg, #333333 0%, #1a1a1a 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.save-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.slot {
    background: var(--primary-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
    transition: all 0.3s ease;
}

.slot:hover {
    border-color: var(--glow-color);
    background: var(--secondary-bg);
}

.slot h3 {
    color: var(--primary-text);
    margin-bottom: 0.8rem;
}

/* Form elements */
.slot-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
    margin-bottom: 0.8rem;
}

.monster-search {
    background: var(--primary-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.5rem;
    color: var(--primary-text);
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.monster-search:focus {
    outline: none;
    border-color: var(--accent-text);
    box-shadow: 0 0 0 2px rgba(139, 69, 19, 0.2);
}

.monster-search::placeholder {
    color: var(--accent-text);
    opacity: 0.7;
}

.monster-select {
    background: var(--primary-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.5rem;
    color: var(--primary-text);
    font-family: 'Monolisa', monospace;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.monster-select:focus {
    outline: none;
    border-color: var(--glow-color);
    box-shadow: 0 0 5px rgba(255, 255, 255, 0.2);
}

.monster-select option {
    background: var(--primary-bg);
    color: var(--primary-text);
}

.monster-info {
    background: var(--secondary-bg);
    border: 1px solid var(--border-color);
    padding: 0.8rem;
    border-radius: 4px;
    margin-top: 0.8rem;
    font-size: 0.85rem;
    color: var(--secondary-text);
}

/* Stats grid */
.stats-grid {
    display: grid;
    /* Fluid columns that wrap naturally and avoid overflow on mobile */
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.ability-score {
    background: var(--primary-bg);
    border: 1px solid var(--border-color);
    padding: 1rem;
    border-radius: 6px;
    text-align: center;
    transition: all 0.3s ease;
}

.ability-score:hover {
    border-color: var(--glow-color);
    background: var(--secondary-bg);
}

.ability-name {
    font-weight: bold;
    color: var(--primary-text);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.ability-value {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--primary-text);
}

.ability-modifier {
    font-size: 0.9rem;
    color: var(--accent-text);
}

/* Derived stats */
.derived-stats {
    background: var(--primary-bg);
    border: 1px solid var(--border-color);
    padding: 1rem;
    border-radius: 6px;
}

.derived-stat {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
    color: var(--secondary-text);
}

.derived-stat:last-child {
    border-bottom: none;
}

.derived-stat strong {
    color: var(--primary-text);
}

/* Attributes table */
.attributes-grid {
    background: var(--primary-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}

.attribute-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 1rem;
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--border-color);
    align-items: center;
}

.attribute-row:last-child {
    border-bottom: none;
}

.header-row {
    background: var(--tertiary-bg);
    font-weight: bold;
    color: var(--primary-text);
    border-bottom: 2px solid var(--border-color);
}

.attr-name {
    font-weight: 500;
    color: var(--secondary-text);
}

.attr-score, .attr-modifier, .attr-save {
    text-align: center;
    font-weight: bold;
    color: var(--primary-text);
}

/* Abilities section */
.ability-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--primary-bg);
}

.ability-list::-webkit-scrollbar {
    width: 8px;
}

.ability-list::-webkit-scrollbar-track {
    background: var(--secondary-bg);
}

.ability-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.ability-list::-webkit-scrollbar-thumb:hover {
    background: var(--glow-color);
}

.ability-item {
    background: var(--secondary-bg);
    padding: 0.8rem;
    margin: 0.5rem;
    border-radius: 4px;
    border-left: 3px solid var(--border-color);
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: all 0.2s ease;
    color: var(--secondary-text);
}

.ability-item:hover {
    background: var(--hover-bg);
    border-left-color: var(--glow-color);
    color: var(--primary-text);
}

.ability-item.selected {
    background: var(--selected-bg);
    border-left-color: var(--primary-text);
    color: var(--primary-text);
}

.ability-checkbox {
    margin-right: 0.8rem;
    display: flex;
    align-items: center;
}

.ability-checkbox input[type="checkbox"] {
    margin: 0;
    margin-right: 0.5rem;
    accent-color: var(--primary-text);
}

.ability-text {
    flex: 1;
}

.ability-source-header {
    font-weight: bold;
    color: var(--primary-text);
    margin: 1rem 0.5rem 0.5rem 0.5rem;
    padding: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    background: var(--tertiary-bg);
}

.ability-limit-message {
    background: var(--tertiary-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.8rem;
    margin: 0.5rem;
    font-size: 0.8rem;
    color: var(--accent-text);
    text-align: center;
    font-style: italic;
}

/* Type counter and pure form bonus */
.type-counter {
    background: var(--primary-bg);
    border: 1px solid var(--border-color);
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}

.type-item {
    display: flex;
    justify-content: space-between;
    padding: 0.3rem 0;
    color: var(--secondary-text);
}

.pure-form-bonus {
    background: linear-gradient(135deg, var(--tertiary-bg) 0%, var(--accent-bg) 100%);
    border: 1px solid var(--border-color);
    color: var(--primary-text);
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1.5rem;
    text-align: center;
    font-weight: bold;
}

/* Feats and Mutators sections */
.feats-list, .mutators-list {
    background: var(--primary-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    max-height: 500px;
    overflow-y: auto;
    padding: 0.5rem;
}

.feat-item, .mutator-item {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.feat-item:last-child, .mutator-item:last-child {
    border-bottom: none;
}

.feat-name, .mutator-name {
    font-weight: bold;
    color: var(--primary-text);
    margin-bottom: 0.8rem;
    font-size: 1.1rem;
    text-shadow: 0 0 3px var(--glow-color);
}

.feat-description, .mutator-description {
    font-size: 0.9rem;
    color: var(--secondary-text);
    line-height: 1.4;
    margin-bottom: 0.5rem;
}

.feat-prerequisite {
    color: var(--secondary-text);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    font-style: italic;
}

.feat-benefits {
    margin-top: 0.5rem;
}

.feat-benefit {
    color: var(--secondary-text);
    font-size: 0.9rem;
    line-height: 1.4;
    margin-bottom: 0.25rem;
    padding-left: 0.5rem;
}

.mutator-description {
    font-style: italic;
}

.mutator-prerequisite {
    color: var(--secondary-text);
    font-size: 0.9rem;
    margin-bottom: 0.8rem;
    font-style: italic;
    padding: 0.5rem;
    background: var(--tertiary-bg);
    border-radius: 4px;
    border-left: 3px solid var(--accent-text);
}

.mutator-benefits {
    margin-top: 0.5rem;
}

.mutator-benefit {
    color: var(--secondary-text);
    font-size: 0.9rem;
    line-height: 1.4;
    margin-bottom: 0.25rem;
    padding-left: 0.5rem;
}

.mutator-selection-info {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--tertiary-bg);
    border-radius: 6px;
    border-left: 4px solid var(--accent-text);
}

.mutator-selection-info h4 {
    margin: 0 0 0.5rem 0;
    color: var(--primary-text);
    font-size: 1rem;
}

.selection-details {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.selection-details div {
    color: var(--secondary-text);
    font-size: 0.9rem;
}

.selection-details strong {
    color: var(--primary-text);
}

/* Mutator selection styling */
.mutator-item {
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: all 0.3s ease;
    background: var(--secondary-bg);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.mutator-item:hover {
    background: var(--hover-bg);
    border-color: var(--glow-color);
}

.mutator-item.selected {
    background: var(--selected-bg);
    border-color: var(--primary-text);
    border-width: 2px;
}

.mutator-item.expanded {
    border-color: var(--glow-color);
}

.mutator-item.prerequisite-unmet {
    opacity: 0.6;
    background: var(--tertiary-bg);
}

.mutator-item.prerequisite-unmet:hover {
    background: var(--tertiary-bg);
    border-color: var(--border-color);
}

.mutator-header {
    display: flex;
    align-items: flex-start;
    cursor: pointer;
    width: 100%;
}

.mutator-checkbox {
    margin-right: 1rem;
    margin-top: 0.2rem;
    display: flex;
    align-items: center;
    cursor: pointer;
}

.mutator-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-text);
}

.mutator-checkbox input[type="checkbox"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.prerequisite-warning {
    color: #ff6b6b;
    font-size: 0.85rem;
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: rgba(255, 107, 107, 0.1);
    border-radius: 4px;
    border-left: 3px solid #ff6b6b;
}

.mutator-basic-info {
    flex: 1;
}

.mutator-dropdown-btn {
    margin-left: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 30px;
    border-radius: 4px;
    background: var(--tertiary-bg);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.mutator-dropdown-btn:hover {
    background: var(--hover-bg);
    border-color: var(--glow-color);
}

.dropdown-arrow {
    font-size: 12px;
    color: var(--accent-text);
    transition: transform 0.2s ease;
}

.mutator-details {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
    }
    to {
        opacity: 1;
        max-height: 500px;
    }
}

.mutator-details h4 {
    color: var(--primary-text);
    font-size: 1rem;
    margin: 1rem 0 0.5rem 0;
    font-weight: bold;
}

.mutator-details h4:first-child {
    margin-top: 0;
}

.mutator-mechanics,
.mutator-notes {
    margin-top: 1rem;
}

.mutator-mechanics-text,
.mutator-notes-text {
    color: var(--secondary-text);
    font-size: 0.9rem;
    line-height: 1.4;
    padding: 0.5rem;
    background: var(--tertiary-bg);
    border-radius: 4px;
    border-left: 3px solid var(--glow-color);
}

.mutator-limit-message {
    text-align: center;
    padding: 1.5rem;
    background: var(--tertiary-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--accent-text);
    font-style: italic;
    margin-top: 1rem;
}

.mutator-table {
    margin: 1rem 0;
    overflow-x: auto;
}

.mutator-table table {
    width: 100%;
    border-collapse: collapse;
    background: var(--secondary-bg);
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.mutator-table th,
.mutator-table td {
    padding: 0.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    color: var(--primary-text);
    font-size: 0.9rem;
}

.mutator-table th {
    background: var(--tertiary-bg);
    font-weight: bold;
    color: var(--accent-text);
}

.mutator-table tr:last-child td {
    border-bottom: none;
}

/* Loading state */
.loading {
    text-align: center;
    padding: 3rem;
    font-size: 1.2rem;
    color: var(--accent-text);
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        width: 100%;
        margin: 0;
        box-shadow: none;
    }
    
    .header {
        padding: 1.5rem 1rem;
        width: 100%;
        box-sizing: border-box;
    }
    
    .main-content {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        padding: 1.5rem 1rem;
        width: 100%;
        box-sizing: border-box;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .attribute-row {
        grid-template-columns: 1fr;
        gap: 0.5rem;
        text-align: center;
        font-size: 0.9rem;
        padding: 0.5rem;
    }

    .header-row {
        display: none;
    }

    .attribute-row:not(.header-row) {
        background: var(--tertiary-bg);
        margin-bottom: 0.8rem;
        border-radius: 4px;
        border: 1px solid var(--border-color);
    }

    .attr-name {
        font-weight: bold;
        color: var(--primary-text);
        border-bottom: 1px solid var(--border-color);
        padding-bottom: 0.5rem;
        margin-bottom: 0.5rem;
        font-size: 0.85rem;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    h1 {
        font-size: 2rem;
    }

    .char-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .section h3 {
        font-size: 1.2rem;
        line-height: 1.3;
    }
    
    .character-info p {
        font-size: 0.9rem;
        line-height: 1.4;
        word-wrap: break-word;
    }
    
    .memory-slots {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .slot {
        min-width: auto;
        width: 100%;
    }
}

/* Text wrapping and positioning improvements */
.section p, .section div {
    line-height: 1.4;
    margin-bottom: 0.75rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.character-info p {
    line-height: 1.4;
    margin-bottom: 0.5rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Advanced/Debug Table */
.advanced-table {
    background: var(--tertiary-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
}

.advanced-table h4 {
    color: var(--primary-text);
    margin-bottom: 1rem;
    font-family: 'Monolisa', monospace;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.advanced-table h4:hover {
    color: var(--accent-color);
}

.advanced-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.advanced-content.show {
    display: block;
}

.advanced-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.advanced-item {
    background: var(--secondary-bg);
    padding: 0.75rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.advanced-item strong {
    color: var(--primary-text);
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

.advanced-item span {
    color: var(--secondary-text);
    font-family: 'Monolisa', monospace;
    font-size: 0.85rem;
}

.toggle-icon {
    transition: transform 0.3s ease;
}

.toggle-icon.rotated {
    transform: rotate(90deg);
}

@media (max-width: 768px) {
    /* Make the Save Canvas Fragment button full width on mobile */
    .save-button {
        width: 100%;
        display: block;
    }
    .section {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        justify-self: stretch;
    }
    .advanced-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .advanced-item {
        padding: 0.5rem;
    }
    
    .advanced-item strong {
        font-size: 0.85rem;
    }
    
    .advanced-item span {
        font-size: 0.8rem;
    }
}

/* Ensure specific sections fill full width on small and mid-size screens */
@media (max-width: 1080px) {
    .link-stats,
    .save-section,
    .advanced-table {
        grid-column: 1 / -1; /* span full grid width to avoid right gap */
        width: 100%;
        box-sizing: border-box;
        justify-self: stretch;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 1rem 0.75rem;
        width: 100%;
        box-sizing: border-box;
    }

    .main-content {
        padding: 1rem 0.75rem;
        width: 100%;
        box-sizing: border-box;
    }

    h1 {
        font-size: 1.6rem;
        letter-spacing: 1px;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .char-stats {
        grid-template-columns: 1fr;
    }
}

/* Mechanics Section */
.mechanics-info {
    background: var(--secondary-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    grid-column: 1 / -1; /* Full width like character-info */
}

.mechanics-info h2 {
    color: var(--primary-text);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: 'Monolisa', monospace;
}

.mechanics-info h2:hover {
    color: var(--accent-color);
}

.toggle-arrow {
    font-size: 0.8rem;
    transition: transform 0.3s ease;
}

.mechanics-content {
    margin-top: 1rem;
}

.mechanics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.mechanics-category {
    background: var(--tertiary-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1rem;
}

.mechanics-category h3 {
    color: var(--accent-color);
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
    font-family: 'Monolisa', monospace;
}

.mechanics-category ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.mechanics-category li {
    margin-bottom: 0.75rem;
    padding: 0.5rem;
    background: var(--secondary-bg);
    border-radius: 4px;
    border-left: 3px solid var(--accent-color);
    line-height: 1.4;
}

.mechanics-category li strong {
    color: var(--primary-text);
}

/* Mechanics Divider */
.mechanics-divider {
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent-color), transparent);
    margin: 2rem 0;
    border-radius: 1px;
}

/* Inline Feats Section */
.feats-section-inline {
    margin-top: 1rem;
}

.feats-section-inline h3 {
    color: var(--accent-color);
    margin-bottom: 1rem;
    font-size: 1.2rem;
    font-family: 'Monolisa', monospace;
}

/* Base Abilities Section */
.base-abilities {
    margin: 1.5rem 0;
    background: var(--tertiary-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1rem;
}

.base-abilities h3 {
    color: var(--accent-color);
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
    font-family: 'Monolisa', monospace;
}

.base-ability-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.base-ability-item {
    padding: 0.5rem;
    background: var(--secondary-bg);
    border-radius: 4px;
    border-left: 3px solid var(--accent-color);
}

.base-ability-item strong {
    color: var(--primary-text);
}

/* Saving Throws Toggle */
.saving-throws-toggle {
    margin: 1.5rem 0;
    background: var(--tertiary-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1rem;
}

.saving-throws-toggle h3 {
    color: var(--primary-text);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: 'Monolisa', monospace;
    cursor: pointer;
}

.saving-throws-toggle h3:hover {
    color: var(--accent-color);
}

.saving-throws-content {
    margin-top: 1rem;
}

/* Responsive adjustments for new sections */
@media (max-width: 768px) {
    .mechanics-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .mechanics-category {
        padding: 0.75rem;
    }
    
    .mechanics-category h3 {
        font-size: 1rem;
    }
    
    .base-abilities, .saving-throws-toggle {
        margin: 1rem 0;
        padding: 0.75rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}


/* Animation utilities */
@keyframes fadeIn {
    from { 
        opacity: 0; 
        transform: translateY(20px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

@keyframes glow {
    0%, 100% { 
        box-shadow: 0 0 5px var(--glow-color); 
    }
    50% { 
        box-shadow: 0 0 15px var(--glow-color); 
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

.glow-effect {
    animation: glow 2s ease-in-out infinite;
}

/* Additional utility classes */
.text-center {
    text-align: center;
}

.text-uppercase {
    text-transform: uppercase;
}

.font-bold {
    font-weight: bold;
}

.font-italic {
    font-style: italic;
}

/* Padding utilities */
.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }
.p-4 { padding: 2rem; }

.m-1 { margin: 0.5rem; }
.m-2 { margin: 1rem; }
.m-3 { margin: 1.5rem; }
.m-4 { margin: 2rem; }

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

.modal-content {
    background: var(--primary-bg);
    margin: 5% auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.3s ease-out;
}

.large-modal {
    max-width: 800px;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--secondary-bg);
    border-radius: 8px 8px 0 0;
}

.modal-header h2 {
    margin: 0;
    color: var(--primary-text);
    font-family: 'Monolisa', monospace;
    font-size: 1.3rem;
}

.close {
    color: var(--secondary-text);
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    transition: color 0.3s ease;
}

.close:hover {
    color: var(--primary-text);
}

.modal-body {
    padding: 1.5rem;
    color: var(--primary-text);
}

.modal-body p {
    margin-bottom: 1rem;
    line-height: 1.5;
}

.modal-body input[type="text"] {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--secondary-bg);
    color: var(--primary-text);
    font-family: 'Monolisa', monospace;
    font-size: 1rem;
    margin-bottom: 1rem;
    transition: border-color 0.3s ease;
}

.modal-body input[type="text"]:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 5px rgba(255, 255, 255, 0.2);
}

.save-slots-info {
    background: var(--tertiary-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 1rem;
    margin-top: 1rem;
}

.save-note {
    font-size: 0.9rem;
    color: var(--secondary-text);
    margin-bottom: 0;
}

.delete-warning {
    color: #ff6b6b;
    font-weight: bold;
    margin-bottom: 0;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    background: var(--secondary-bg);
    border-radius: 0 0 8px 8px;
}

.modal-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Monolisa', monospace;
    font-weight: bold;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.3s ease;
    min-width: 100px;
}

.cancel-btn {
    background: var(--tertiary-bg);
    color: var(--secondary-text);
    border: 1px solid var(--border-color);
}

.cancel-btn:hover {
    background: var(--secondary-bg);
    color: var(--primary-text);
}

.save-btn {
    background: linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%);
    color: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.save-btn:hover {
    background: linear-gradient(135deg, #333333 0%, #1a1a1a 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.delete-btn {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
    color: white;
    box-shadow: 0 2px 10px rgba(255, 107, 107, 0.3);
}

.delete-btn:hover {
    background: linear-gradient(135deg, #ff5252 0%, #e53935 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
}

/* Saved Sheets List */
.saved-sheets-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.saved-sheet-item {
    background: var(--secondary-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1rem;
    transition: all 0.3s ease;
}

.saved-sheet-item:hover {
    border-color: var(--accent-color);
    background: var(--tertiary-bg);
}

.saved-sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.saved-sheet-name {
    font-weight: bold;
    color: var(--primary-text);
    font-size: 1.1rem;
    font-family: 'Monolisa', monospace;
}

.saved-sheet-date {
    color: var(--secondary-text);
    font-size: 0.9rem;
}

.saved-sheet-summary {
    color: var(--secondary-text);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    line-height: 1.4;
}

.saved-sheet-actions {
    display: flex;
    gap: 0.5rem;
}

.sheet-action-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Monolisa', monospace;
    font-size: 0.8rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.3s ease;
}

.view-btn {
    background: linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%);
    color: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.view-btn:hover {
    background: linear-gradient(135deg, #333333 0%, #1a1a1a 100%);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

.delete-sheet-btn {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
    color: white;
    box-shadow: 0 2px 5px rgba(255, 107, 107, 0.2);
}

.delete-sheet-btn:hover {
    background: linear-gradient(135deg, #ff5252 0%, #e53935 100%);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(255, 107, 107, 0.3);
}

.no-saved-sheets {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--secondary-text);
}

.no-saved-sheets p {
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

/* Server-only fragment styles */
.saved-sheet-item.server-only {
    border-left: 4px solid #ffa726;
    background: linear-gradient(135deg, var(--secondary-bg) 0%, rgba(255, 167, 38, 0.05) 100%);
}

.server-only-badge {
    background: linear-gradient(135deg, #ffa726 0%, #ff9800 100%);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: bold;
    margin-left: 0.5rem;
    display: inline-block;
    box-shadow: 0 1px 3px rgba(255, 167, 38, 0.3);
}

.sheet-action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #666 !important;
    transform: none !important;
    box-shadow: none !important;
}

.sheet-action-btn:disabled:hover {
    background: #666 !important;
    transform: none !important;
    box-shadow: none !important;
}

/* Mobile navbar enhancements */
@media (max-width: 768px) {
    .nav-menu {
        width: 280px;
        left: -300px;
        /* Ensure proper scrolling on mobile */
        overscroll-behavior: contain;
        touch-action: pan-y;
    }
    
    .nav-menu ul {
        padding-bottom: 4rem; /* Extra padding to avoid phone bottom bar */
    }
    
    .nav-menu a {
        padding: 1.2rem 1.5rem; /* Larger touch targets */
        font-size: 1rem;
    }
    
    .nav-menu .nav-section-header {
        padding: 1rem 1.5rem 0.5rem 1.5rem;
        font-size: 0.7rem;
    }
}

@media (max-width: 480px) {
    .nav-menu {
        width: 260px;
        left: -280px;
    }
    
    .nav-menu ul {
        padding-bottom: 5rem; /* Even more padding for smaller screens */
    }
    
    .nav-menu a {
        padding: 1rem 1.2rem;
        font-size: 0.95rem;
    }
}

/* Responsive modal adjustments */
@media (max-width: 768px) {
    .modal-content {
        margin: 10% auto;
        width: 95%;
    }
    
    .modal-header, .modal-body, .modal-footer {
        padding: 1rem;
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .modal-btn {
        width: 100%;
    }
    
    .saved-sheet-actions {
        flex-direction: column;
    }
    
    .sheet-action-btn {
        width: 100%;
        padding: 0.75rem;
    }
}

/* Abilities & Mutators grids for consistent responsive behavior */
.abilities-grid,
.mutators-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.ability-card,
.mutator-card,
.memory-slot {
    background: var(--primary-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1rem;
}

.ability-name,
.mutator-name,
.memory-header {
    font-weight: bold;
    color: var(--accent-color);
    margin-bottom: 0.5rem;
}

@media (max-width: 920px) {
    .main-content {
        padding: 1rem;
        gap: 1rem;
    }
    .section {
        padding: 1rem;
    }
    .filter-row {
        gap: 0.75rem;
    }
    .filter-group {
        flex: 1 1 160px; /* allow filters to wrap into two columns on mobile */
    }
}