:root {
    --main-font: 'Libre Franklin', sans-serif;
    --color-black: #000000;
    --color-white: #ffffff;
    --color-secondary: #f4f4f4;
    --color-link: #007bff;
    --color-link-hover: #0056b3;
    --color-link-on-black: #99ccff;
    }
    
    * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    }
    
    body {
    font-family: var(--main-font);
    line-height: 1.4; /* Minimized vertical spacing */
    color: var(--color-black);
    background-color: var(--color-secondary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    }
    
    header {
    background: var(--color-black);
    color: var(--color-white);
    padding: 1rem 0;
    text-align: center;
    }
    
    header h1 {
    margin-bottom: 10px;
    }
    
    nav ul {
    padding: 0;
    list-style: none;
    }
    
    nav ul li {
    display: inline;
    margin: 0 10px;
    }
    
    nav a {
    color: var(--color-white);
    text-decoration: none;
    text-transform: uppercase;
    }
    
    nav a:hover {
    text-decoration: underline;
    }
    
    main {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 20px;
    flex: 1 0 auto;
    overflow-x: hidden;
    }
    
    p {
    margin: 0 0 0.8rem; /* Reduced space below paragraphs */
    }
    
    .paragraph-header {
    font-size: 1.5em;
    font-weight: bold;
    margin-bottom: 0.8rem;
    }
    
    ul {
    list-style: none;
    margin: 0;
    padding: 0 0 0 20px; /* Adjusted padding for bullets */
    }
    
    .paragraph_bullets ul {
    list-style: disc;
    }
    
    .paragraph_bullets li {
    margin-bottom: 0.8rem;
    }
    
    table {
    width: 100%;
    border-collapse: collapse;
    margin: 0; /* Removed vertical margins */
    }
        
    th, td {
    padding: 5px; /* Reduced padding for minimized space */
    text-align: left;
    border: 1px solid var(--color-black);
    }
    
    th {
    background-color: var(--color-secondary);
    }
    
    
    img {
    width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
    }
    
    figure {
    margin: 1rem 0; /* Reduced vertical space */
    text-align: center;
    }
    
    figcaption {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: var(--color-black);
    }
    
    .gallery {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    }
    
    .gallery img {
    width: 100%;
    max-width: 400px;
    height: auto;
    border-radius: 10px;
    transition: transform 0.2s;
    }
    
    .gallery img:hover {
    transform: scale(1.02);
    }
    
    footer {
    text-align: center;
    padding: 10px 0; /* Reduced padding */
    background: var(--color-black);
    color: var(--color-white);
    margin-top: auto;
    }
    
    .footer-content p {
    margin-bottom: 0.5rem;
    }
    
    .footer-content a {
    color: var(--color-link);
    text-decoration: none;
    }
    
    .footer-content a:hover {
    text-decoration: underline;
    color: var(--color-link-hover);
    }

    .footer-license-btn {
    display: inline-block;
    padding: 0.35rem 0.75rem;
    border: 1px solid var(--color-white);
    border-radius: 6px;
    color: var(--color-white) !important;
    text-decoration: none !important;
    font-weight: 700;
    }

    .footer-license-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--color-white) !important;
    text-decoration: none !important;
    }

    .nav-kofi {
    background: #F1641E;
    color: #fff !important;
    font-weight: 700;
    border-radius: 4px;
    padding: 0.2rem 0.6rem;
    }

    .nav-kofi:hover {
    background: #d4541a;
    color: #fff !important;
    }
    
    .download-section {
    margin: 1rem 0;
    text-align: center;
    }
    
    .download-section p {
    margin-bottom: 0.5rem;
    }
    
    .download-section a {
    padding: 10px;
    background-color: var(--color-link);
    color: white;
    text-decoration: none;
    border-radius: 5px;
    transition: background-color 0.3s;
    }
    
    .download-section a:hover {
    background-color: var(--color-link-hover);
    }
    
    .license-section {
    background-color: var(--color-black);
    color: var(--color-white);
    padding: 10px;
    margin-top: 1rem;
    text-align: left;
    }
    
    .license-section a {
    color: var(--color-link-on-black);
    text-decoration: none;
    }
    
    .license-section a:hover {
    text-decoration: underline;
    }
    
    .dungeon-entry img {
    display: block;
    max-width: 300px;
    border: 5px solid var(--color-black);
    margin: 0 0 0.8rem;
    }
    
    .dungeon-entry h3, .dungeon-entry p {
    margin: 0 0 0.8rem;
    }
    
    .dungeon-details h3, .dungeon-details p {
    margin: 0 0 0.8rem;
    }
    
    .hex-tiles-gallery .gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    padding: 0;
    }
    
    .hex-tiles-gallery .gallery a {
    display: block;
    text-align: center;
    }
    
    .hex-tiles-gallery .gallery img.hex-tile {
    width: 100%;
    height: auto;
    transition: transform 0.3s ease;
    border: 1px solid #ddd;
    padding: 5px;
    background-color: #fff;
    }
    
    .hex-tiles-gallery .gallery a:hover img.hex-tile {
    transform: scale(2);
    z-index: 10;
    }
    
.tokens-gallery .gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    padding: 0;
}

.tokens-gallery .gallery figure {
    margin: 0;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.tokens-gallery .gallery figcaption {
    margin-top: 0.25rem;
    font-size: 0.8rem;
}

.tokens-gallery .gallery a {
    display: block;
    text-align: center;
}

.tokens-gallery .gallery img.token {
    width: 100%;
    height: auto;
    max-width: 300px;
    border: 1px solid #ddd;
    padding: 5px;
    background-color: #fff;
    transition: transform 0.3s ease;
}

.tokens-gallery .gallery a:hover img.token {
    transform: scale(1.1);
}

/* ── Icon Gallery page ─────────────────────────────────── */
.ig-upload-section {
    margin-bottom: 1rem;
    max-width: 100%;
    overflow: hidden;
}

.ig-upload-section h2 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

.ig-upload-section p {
    font-size: 0.9rem;
    color: #555;
    margin-bottom: 0.75rem;
}

.ig-upload-area {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border: 2px dashed #ccc;
    border-radius: 8px;
    background: #fafafa;
    transition: border-color 0.15s, background 0.15s;
    box-sizing: border-box;
    max-width: 100%;
}

.ig-upload-area.ig-drag-over {
    border-color: #333;
    background: #f0f0f0;
}

.ig-upload-btn {
    padding: 0.5rem 1rem;
    background: #333;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 700;
    touch-action: manipulation;
}

.ig-upload-btn:hover {
    background: #555;
}

.ig-upload-hint {
    font-size: 0.85rem;
    color: #999;
}

.icon-gallery-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1rem 0;
    flex-wrap: wrap;
}

.icon-gallery-controls label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    white-space: nowrap;
}

.icon-gallery-controls input[type="range"] {
    width: 120px;
}

.icon-gallery-controls input[type="text"] {
    padding: 0.4rem 0.6rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.9rem;
    width: 200px;
}

.icon-gallery {
    --icon-card-size: 80px;
    max-width: 100%;
    overflow: hidden;
}

.icon-gallery-heading {
    margin: 1.5rem 0 0.5rem;
    font-size: 1.2rem;
}

.ig-artist-link {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px dashed #999;
}

.ig-artist-link:hover {
    border-bottom-color: #333;
}

.icon-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--icon-card-size), 1fr));
    gap: 12px;
}

.icon-gallery-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #f4f4f4;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 8px;
    text-decoration: none;
    color: #333;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}

.icon-gallery-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-color: #999;
}

.icon-gallery-icon {
    width: 100%;
    aspect-ratio: 1;
}

.icon-gallery-icon svg,
.icon-gallery-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.icon-gallery-label {
    margin-top: 4px;
    font-size: 0.75rem;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
}

.ig-tag-filters {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.ig-tag-btn {
    padding: 0.2rem 0.5rem;
    border: 1px solid #ccc;
    border-radius: 12px;
    background: #f4f4f4;
    cursor: pointer;
    font-size: 0.75rem;
    text-transform: capitalize;
    touch-action: manipulation;
}

.ig-tag-btn.active {
    background: #333;
    color: #fff;
    border-color: #333;
}

.ig-tag-btn:hover:not(.active) {
    border-color: #999;
    background: #e8e8e8;
}

.ig-card-tags {
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 2px;
}

.ig-card-tag {
    font-size: 0.6rem;
    padding: 1px 5px;
    background: #e0e0e0;
    border-radius: 8px;
    color: #555;
    text-transform: capitalize;
}

.ig-license-badge {
    font-size: 0.7rem;
    font-weight: 400;
    padding: 2px 6px;
    background: #e8f5e9;
    color: #2e7d32;
    border-radius: 8px;
    vertical-align: middle;
    text-decoration: none;
    cursor: pointer;
}

.ig-license-badge:hover {
    background: #c8e6c9;
}

.ig-placeholder {
    color: #999;
    font-style: italic;
    padding: 1rem 0;
    font-size: 0.9rem;
}

/* ── Token Maker Modal ── */
.ig-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ig-modal {
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    max-width: 640px;
    width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    box-sizing: border-box;
}

.ig-modal-close {
    position: absolute;
    top: 0.5rem;
    right: 0.75rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    line-height: 1;
}

.ig-modal h2 {
    margin: 0 0 1rem;
    font-size: 1.2rem;
}

.ig-modal-body {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
    min-width: 0;
}

.ig-modal-preview {
    flex: 0 0 200px;
    min-width: 0;
}

.ig-modal-preview canvas {
    width: 100%;
    max-width: 200px;
    height: auto;
    aspect-ratio: 1;
    border-radius: 8px;
    border: 1px solid #ddd;
    background: repeating-conic-gradient(#eee 0% 25%, #fff 0% 50%) 50% / 16px 16px;
}

.ig-modal-controls {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    overflow-y: auto;
}

.ig-control-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.ig-control-group label {
    font-size: 0.8rem;
    font-weight: 700;
    color: #555;
}

.ig-control-group input[type="color"] {
    width: 48px;
    height: 32px;
    padding: 2px;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
}

.ig-control-group select {
    padding: 0.3rem 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.85rem;
    width: 100px;
}

.ig-shape-btns {
    display: flex;
    gap: 4px;
}

.ig-shape-btn {
    padding: 0.3rem 0.6rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #f4f4f4;
    cursor: pointer;
    font-size: 0.8rem;
    touch-action: manipulation;
}

.ig-shape-btn.active {
    background: #333;
    color: #fff;
    border-color: #333;
}

.ig-preset-btns {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.ig-preset-btn {
    width: 32px;
    height: 32px;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f4f4f4;
    touch-action: manipulation;
}

.ig-preset-btn:hover {
    border-color: #666;
    background: #e8e8e8;
}

.ig-stroke-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.ig-stroke-row input[type="color"] {
    width: 36px;
    height: 28px;
    padding: 2px;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
}

.ig-stroke-row select {
    padding: 0.25rem 0.4rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.8rem;
}

.ig-nudge-row {
    display: flex;
    gap: 2px;
    justify-content: center;
}

.ig-nudge-btn {
    width: 32px;
    height: 32px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #f4f4f4;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    touch-action: manipulation;
}

.ig-nudge-btn:hover {
    border-color: #666;
    background: #e8e8e8;
}

.ig-nudge-reset {
    font-size: 0.6rem;
    font-weight: 700;
}

.ig-nudge-spacer {
    width: 32px;
}

.ig-download-btn {
    padding: 0.5rem 1rem;
    background: #333;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 700;
    touch-action: manipulation;
}

.ig-download-btn:hover {
    background: #555;
}

.ig-invert-btn,
.ig-download-svg-btn {
    background: #fff;
    color: #333;
    border: 1px solid #333;
}

.ig-invert-btn:hover,
.ig-download-svg-btn:hover {
    background: #f4f4f4;
}

@media (max-width: 560px) {
    .ig-modal-body {
        flex-direction: column;
        align-items: center;
    }
    .ig-modal-preview {
        flex: 0 0 auto;
    }
    .ig-modal-preview canvas {
        width: 160px;
        max-width: 160px;
        height: auto;
    }
}

/* ── Nav dropdowns ──────────────────────────────────────── */
.nav-dropdown {
    position: relative;
}

.nav-dropdown-toggle {
    cursor: pointer;
}

.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #000;
    list-style: none;
    padding: 0.4rem 0;
    margin: 0;
    min-width: 180px;
    z-index: 1000;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.nav-dropdown-menu li {
    display: block !important;
    margin: 0 !important;
}

.nav-dropdown-menu a {
    display: block;
    padding: 0.45rem 1rem;
    white-space: nowrap;
}

.nav-dropdown-menu a:hover {
    background: rgba(255, 255, 255, 0.12);
}

.nav-dropdown:hover > .nav-dropdown-menu {
    display: block;
}

.nav-dropdown.open > .nav-dropdown-menu {
    display: block;
}

/* ── Mobile nav ─────────────────────────────────────────── */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--color-white);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem 0.75rem;
}

@media (max-width: 768px) {
    .nav-toggle {
        display: block;
        margin: 0 auto;
    }

    nav ul {
        display: none;
        flex-direction: column;
        width: 100%;
        padding: 0;
    }

    nav ul.open {
        display: flex;
    }

    nav ul li {
        display: block;
        text-align: center;
        margin: 0;
        border-top: 1px solid #333;
    }

    nav ul li a {
        display: block;
        padding: 0.6rem 0;
    }

    .nav-dropdown-menu {
        position: static;
        transform: none;
        box-shadow: none;
        border-radius: 0;
        background: #111;
        min-width: 0;
    }

    .nav-dropdown:hover > .nav-dropdown-menu {
        display: none;
    }

    .nav-dropdown.open > .nav-dropdown-menu {
        display: block;
    }

    .nav-dropdown-menu a {
        padding: 0.5rem 0;
        font-size: 0.9em;
    }
}

/* ── Active nav link ─────────────────────────────────────── */
nav a.active {
    text-decoration: underline;
    font-weight: bold;
}

/* ── Homepage section cards ──────────────────────────────── */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.card {
    display: flex;
    flex-direction: column;
    background: var(--color-white);
    border: 1px solid #ccc;
    border-radius: 8px;
    overflow: hidden;
    text-decoration: none;
    color: var(--color-black);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.card img {
    width: 100%;
    height: 160px;
    object-fit: cover;
}

.card-img-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 93px);
    height: 186px;
    overflow: hidden;
    background: #fff;
}

.card-img-grid img {
    width: 100%;
    height: 93px;
    object-fit: contain;
    padding: 4px;
    background: #fff;
}

.card-body {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    flex: 1;
    padding: 1rem;
}

.card-body h2 {
    font-size: 1.1rem;
    margin-bottom: 0.4rem;
}

.card-body p {
    font-size: 0.9rem;
    color: #444;
    margin: 0;
}

.card .initiative-card-img {
    display: block;
    width: calc(100% - 2rem);
    height: 160px;
    margin: 1rem auto 0;
    border-radius: 6px;
    object-fit: contain;
    object-position: center;
    background: #fff;
}

.card .maps-card-img {
    height: 210px;
    object-fit: cover;
    object-position: center top;
}

/* ── Maps gallery ────────────────────────────────────────── */
.maps-gallery {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.map-group {
    background: var(--color-white);
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 1rem;
}

.map-group h2 {
    font-size: 1.1rem;
    margin-bottom: 0.2rem;
}

.map-meta {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 0.75rem;
}

.map-variants {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.map-card {
    flex: 1 1 160px;
    max-width: 200px;
    text-decoration: none;
    color: var(--color-black);
    border: 1px solid #ddd;
    border-radius: 6px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.map-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.map-card img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    display: block;
    margin: 0;
}

.map-variant-label {
    display: block;
    padding: 0.3rem 0.5rem;
    font-size: 0.8rem;
    text-align: center;
    background: #f5f5f5;
    border-top: 1px solid #ddd;
}

/* ── Campaign page styles (shared) ──────────────────────── */
hr {
    border: none;
    border-top: 2px solid var(--color-black);
    margin: 1.5rem 0;
}

.section-subheader {
    font-size: 1.1em;
    font-weight: bold;
    margin-bottom: 0.5rem;
    margin-top: 1rem;
}

.stat-table {
    width: auto;
    margin: 0 0 0.8rem;
}

.stat-table th, .stat-table td {
    text-align: center;
    padding: 4px 12px;
}

.char-card {
    background: var(--color-white);
    border: 1px solid #ccc;
    padding: 15px;
    margin-bottom: 1rem;
}

.char-card .char-name {
    font-size: 1.2em;
    font-weight: bold;
    margin-bottom: 0.4rem;
}

.char-card .char-subtitle {
    font-style: italic;
    margin-bottom: 0.6rem;
    color: #444;
}

.npc-entry {
    margin-bottom: 1rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid #ddd;
}

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

.npc-name {
    font-weight: bold;
}

.npc-title {
    font-style: italic;
    color: #444;
}

.loot-table {
    width: auto;
}

.commitments-done {
    text-decoration: line-through;
    color: #888;
}

.section-divider {
    border-top: 1px solid #ccc;
    margin: 1rem 0;
}

/* ── Etsy shop banner ───────────────────────────────────── */
.etsy-banner {
    background: var(--color-black);
    color: var(--color-white);
    padding: 2rem;
    margin-top: 2rem;
    border-radius: 8px;
}

.etsy-banner-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.etsy-banner-header h2 {
    font-size: 1.6rem;
    margin-bottom: 0.5rem;
    color: var(--color-white);
}

.etsy-banner-header p {
    color: #ccc;
    max-width: 620px;
    margin: 0 auto;
}

.etsy-products {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.etsy-product {
    background: #222;
    border-radius: 6px;
    overflow: hidden;
    padding: 1rem;
}

.etsy-product-photo {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 4px;
    margin-bottom: 0.75rem;
    display: block;
}

.etsy-product a {
    color: var(--color-link-on-black);
}

.etsy-product h3 {
    font-size: 1rem;
    margin-bottom: 0.35rem;
    color: var(--color-white);
}

.etsy-product p {
    font-size: 0.85rem;
    color: #bbb;
    margin: 0;
}

.etsy-cta {
    text-align: center;
}

.etsy-cta a {
    display: inline-block;
    background: #F1641E;
    color: white;
    text-decoration: none;
    padding: 0.75rem 2.5rem;
    border-radius: 4px;
    font-weight: bold;
    font-size: 1rem;
    letter-spacing: 0.02em;
    transition: background 0.2s;
}

.etsy-cta a:hover {
    background: #d4541a;
}

@media (max-width: 600px) {
    .etsy-products {
        grid-template-columns: 1fr;
    }
}

/* ── Etsy Mini Banner ──────────────────────────────────── */
.etsy-mini-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--color-black);
    color: var(--color-white);
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
    transition: background 0.2s;
}

.etsy-mini-banner:hover {
    background: #1a1a1a;
}

.etsy-mini-images {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.etsy-mini-images img {
    width: 52px;
    height: 52px;
    object-fit: cover;
    border-radius: 4px;
}

.etsy-mini-text {
    flex: 1;
    font-size: 0.9rem;
    font-weight: bold;
    color: var(--color-white);
}

.etsy-mini-cta {
    flex-shrink: 0;
    background: #F1641E;
    color: white;
    font-size: 0.85rem;
    font-weight: bold;
    padding: 0.3rem 0.75rem;
    border-radius: 4px;
    white-space: nowrap;
}

/* ── Dice Roller ───────────────────────────────────────── */
.dice-roller {
    max-width: 600px;
    margin: 0 auto;
    overflow-x: hidden;
}

.dice-roller h2 {
    text-align: center;
    margin-bottom: 1rem;
}

.dice-expression {
    background: var(--color-white);
    border: 2px solid var(--color-black);
    border-radius: 6px;
    padding: 0.75rem 1rem;
    min-height: 2.8rem;
    font-size: 1.25rem;
    text-align: center;
    margin-bottom: 1rem;
}

.expression-placeholder {
    color: #999;
    font-style: italic;
}

.expression-text {
    font-weight: bold;
}

.mode-tag {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: bold;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    margin-left: 0.5rem;
    vertical-align: middle;
}

.adv-tag {
    background: #6ecba0;
    color: #fff;
}

.dis-tag {
    background: #c62828;
    color: #fff;
}

.crit-tag {
    background: #e65100;
    color: #fff;
    transition: opacity 0.5s ease;
}

.crit-tag-fading {
    opacity: 0;
}

.dice-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: 1fr;
    gap: 0.35rem;
    margin-bottom: 0.5rem;
}

.die-btn {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    padding: 0.1rem 0.15rem;
    background: var(--color-white);
    border: 2px solid #ccc;
    border-radius: 6px;
    cursor: pointer;
    touch-action: manipulation;
    transition: transform 0.1s, border-color 0.2s;
    font-family: var(--main-font);
    font-weight: bold;
    font-size: 0.75rem;
}

.die-btn img {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.die-btn:hover {
    border-color: var(--color-black);
    transform: scale(1.05);
}

.die-btn:active {
    transform: scale(0.95);
}

@media (max-width: 480px) {
    .dice-buttons {
        gap: 0.25rem;
        margin-bottom: 0.35rem;
    }
    .die-btn {
        padding: 0.1rem 0.05rem;
        gap: 0.1rem;
        font-size: 0.65rem;
    }
    .die-btn img {
        width: 32px;
        height: 32px;
    }
    .d100-btn img {
        width: 24px;
        height: 42px;
    }
    .dhf-btn svg {
        width: 24px;
        height: 42px;
    }
}

.d100-btn {
    flex-direction: row;
    gap: 2px;
}

.d100-btn img {
    width: 24px;
    height: 42px;
}

.dhf-btn {
    flex-direction: row;
    align-items: center;
    gap: 6px;
}

.dhf-icons {
    display: flex;
    flex-direction: row;
    gap: 2px;
}

.dhf-btn svg {
    display: block;
    width: 24px;
    height: 42px;
}

.dhf-label {
    font-size: 0.9rem;
    font-weight: bold;
    white-space: nowrap;
}

.hope-fear-msg {
    font-weight: bold;
    font-size: 1.1rem;
    margin-top: 0.25rem;
    text-align: center;
}

.hope-msg {
    color: #1565c0;
}

.fear-msg {
    color: #6a1b9a;
}

.critical-msg {
    color: #e65100;
    font-size: 1.3rem;
}

.dice-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
    width: 100%;
}

.dice-controls .ctrl-btn {
    flex: 1;
}

.ctrl-btn {
    padding: 0.5rem 1rem;
    border: 2px solid #ccc;
    border-radius: 6px;
    background: var(--color-white);
    cursor: pointer;
    font-family: var(--main-font);
    font-weight: bold;
    font-size: 0.9rem;
    touch-action: manipulation;
    transition: background 0.2s, border-color 0.2s;
}

.ctrl-btn:hover {
    border-color: var(--color-black);
}

.toggle-btn.active {
    color: #fff;
}

.toggle-btn#btn-adv.active {
    background: #6ecba0;
    border-color: #6ecba0;
}

.toggle-btn#btn-dis.active {
    background: #c62828;
    border-color: #c62828;
}

.toggle-btn#btn-crit.active {
    background: #e65100;
    border-color: #e65100;
}

.clear-btn {
    background: #eee;
}

.roll-label {
    position: absolute;
    bottom: 0px;
    left: 2px;
    right: 0;
    text-align: left;
    font-weight: bold;
    color: #fff;
    font-size: 1.28rem;
    pointer-events: none;
}

.roll-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    background: var(--color-black);
    color: var(--color-white);
    border: 2px solid var(--color-black);
    border-radius: 8px;
    padding: 0.5rem;
    cursor: pointer;
    touch-action: manipulation;
    transition: background 0.2s, border-color 0.2s;
}

.roll-btn:hover {
    background: #333;
    border-color: #333;
}

.roll-btn:active {
    transform: scale(0.97);
}

.roll-icon {
    width: 80px;
    height: 80px;
}

.dice-result {
    text-align: center;
    margin-bottom: 1.5rem;
    min-height: 1rem;
    border-radius: 6px;
    transition: background 0.3s;
}

/* Critical failure: min possible roll — red background, white text */
.dice-result.result-crit-fail {
    background: #c62828;
}
.dice-result.result-crit-fail .result-total,
.dice-result.result-crit-fail .result-breakdown {
    color: #fff;
}

/* Below average (> 10% of max below avg) — red text */
.dice-result.result-low .result-total {
    color: #c62828;
}

/* Above average (> 10% of max above avg) — green text */
.dice-result.result-high .result-total {
    color: #6ecba0;
}

/* Critical success: max possible roll — green background, white text */
.dice-result.result-crit-success {
    background: #6ecba0;
}
.dice-result.result-crit-success .result-total,
.dice-result.result-crit-success .result-breakdown {
    color: #fff;
}

.result-total {
    font-size: 3rem;
    font-weight: bold;
    line-height: 1.2;
}

.result-breakdown {
    font-size: 0.9rem;
    color: #555;
    margin-top: 0.25rem;
    word-break: break-word;
    overflow-wrap: break-word;
}

.result-animate .result-total {
    animation: pop 0.3s ease-out;
}

@keyframes pop {
    0% { transform: scale(0.8); opacity: 0.5; }
    60% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

.dice-history h3 {
    margin-bottom: 0.5rem;
}

.history-log {
    background: var(--color-white);
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 0.75rem;
    max-height: 300px;
    overflow-y: auto;
}

.history-empty {
    color: #999;
    font-style: italic;
    text-align: center;
}

.history-entry {
    padding: 0.35rem 0;
    border-bottom: 1px solid #eee;
    font-size: 0.85rem;
    overflow-wrap: break-word;
    word-break: break-word;
}

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

.history-time {
    color: #999;
    font-size: 0.8rem;
}

.history-expr {
    font-weight: bold;
}

.history-arrow {
    color: #999;
}

.history-breakdown {
    color: #555;
    word-break: break-word;
    overflow-wrap: break-word;
}

.history-total {
    color: var(--color-black);
}

/* ── Formula input ──────────────────────────────────────── */
.formula-row {
    margin-bottom: 1rem;
}

.formula-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 2px solid #ccc;
    border-radius: 6px;
    font-family: var(--main-font);
    font-size: 0.95rem;
    box-sizing: border-box;
}

.formula-input:focus {
    outline: none;
    border-color: var(--color-black);
}

/* ── Dice action area (action row above Roll icon) ───────── */
.dice-action-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.dice-action-row {
    display: flex;
    gap: 0.5rem;
    width: 100%;
}

.dice-action-row .ctrl-btn {
    flex: 1;
}

.clear-btn {
    background: #c62828;
    color: #fff;
    border-color: #c62828;
}

.clear-btn:hover {
    background: #b71c1c;
    border-color: #b71c1c;
}

.clear-btn-outline {
    background: transparent;
    color: #c62828;
    border-color: #c62828;
}

.clear-btn-outline:hover {
    background: #ffebee;
    border-color: #b71c1c;
    color: #b71c1c;
}

.save-btn {
    background: #1565c0;
    color: #fff;
    border-color: #1565c0;
}

.save-btn:hover {
    background: #0d47a1;
    border-color: #0d47a1;
}

.explode-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    background: transparent;
    border-color: #555;
    color: #888;
    padding: 0.25rem 0.75rem 0.25rem 0.4rem;
    cursor: not-allowed;
}

.explode-icon {
    width: 2em;
    height: 2em;
    flex-shrink: 0;
}

.explode-label {
    display: none;
    font-weight: bold;
}

.explode-btn:not(:disabled) {
    color: #e65100;
    border-color: #e65100;
    background: transparent;
    cursor: pointer;
}

.explode-btn:not(:disabled) .explode-label {
    display: inline;
}

.explode-btn:not(:disabled):hover {
    color: #bf360c;
    border-color: #bf360c;
}

/* ── Saved rolls ─────────────────────────────────────────── */
.saved-rolls {
    margin-bottom: 1rem;
}

.saved-rolls h3 {
    margin-bottom: 0.5rem;
}

.saved-rolls-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.saved-roll-wrap {
    display: inline-flex;
    align-items: stretch;
    border: 2px solid var(--color-black);
    border-radius: 6px;
    overflow: hidden;
}

.saved-roll-btn {
    padding: 0.4rem 0.75rem;
    background: var(--color-black);
    color: var(--color-white);
    border: none;
    cursor: pointer;
    font-family: var(--main-font);
    font-weight: bold;
    font-size: 0.85rem;
}

.saved-roll-btn:hover {
    background: #333;
}

.saved-roll-del {
    padding: 0.4rem 0.5rem;
    background: var(--color-black);
    border: none;
    border-left: 1px solid #444;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--color-white);
}

.saved-roll-del:hover {
    background: #c62828;
    color: var(--color-white);
}

/* ── Oracle d20 ──────────────────────────────────────────── */
.oracle-roller {
    max-width: 600px;
    margin: 0 auto;
    padding-top: 1rem;
}

.oracle-roller h2 {
    text-align: center;
    margin-bottom: 0.4rem;
}

.oracle-description {
    text-align: center;
    color: #555;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.oracle-buttons {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

.oracle-d20-btn {
    width: 100px;
    height: 100px;
    padding: 0.75rem;
}

.oracle-d20-btn img {
    width: 60px;
    height: 60px;
}

.oracle-result {
    text-align: center;
    min-height: 5rem;
    margin-bottom: 1.5rem;
}

.oracle-roll-num {
    font-size: 3rem;
    font-weight: bold;
    line-height: 1.2;
}

.oracle-answer {
    font-size: 1.75rem;
    font-weight: bold;
    margin-top: 0.25rem;
    padding: 0.25rem 1rem;
    display: inline-block;
    border-radius: 6px;
}

.oracle-yes {
    background: #e8f5e9;
    color: #6ecba0;
}

.oracle-no {
    background: #ffebee;
    color: #c62828;
}

.oracle-maybe {
    background: #e3f2fd;
    color: #1565c0;
}

.oracle-history {
    margin-bottom: 1.5rem;
}

.oracle-history h3 {
    margin-bottom: 0.5rem;
}

.oracle-history-answer {
    font-size: 0.85rem;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    vertical-align: middle;
}

.oracle-table {
    margin-top: 0.5rem;
}

.oracle-table table {
    width: 100%;
    max-width: 320px;
    margin: 0 auto;
}

/* ── Roll Statistics ─────────────────────────────────────── */
.roll-stats {
    max-width: 600px;
    margin: 0 auto;
    padding-top: 0.5rem;
}

.roll-stats h3 {
    margin-bottom: 0.75rem;
}

.stats-table-wrap {
    margin-bottom: 1.25rem;
    overflow-x: auto;
}

.stats-label {
    font-weight: bold;
    font-size: 0.85rem;
    margin-bottom: 0.3rem;
    color: #555;
}

.stats-table {
    border-collapse: collapse;
    width: 100%;
}

.stats-table th,
.stats-table td {
    min-width: 1.8rem;
    text-align: center;
    padding: 3px 4px;
    border: 1px solid #ccc;
    font-size: 0.8rem;
}

.stats-table thead th {
    background: #f0f0f0;
    font-weight: bold;
}

.stats-high {
    background: #fff9c4;
    font-weight: bold;
}

/* ── Initiative Tracker ──────────────────────────────── */
.initiative-tracker {
    max-width: 600px;
    margin: 0 auto;
}

.initiative-tracker button,
.initiative-tracker input,
.initiative-tracker select,
.initiative-tracker [data-action],
.initiative-tracker .init-counter-clickable {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

.init-topbar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.round-display {
    font-size: 1.25rem;
}

/* ── Form ── */
.init-add-form {
    background: var(--color-white);
    border: 2px solid #ccc;
    border-radius: 6px;
    padding: 0.75rem;
    margin-bottom: 1rem;
}

.init-form-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
}

.init-form-row:last-child {
    margin-bottom: 0;
}

.init-input {
    flex: 1;
    padding: 0.4rem 0.5rem;
    border: 2px solid #ccc;
    border-radius: 4px;
    font-family: var(--main-font);
    font-size: 0.9rem;
}

.init-input:focus {
    border-color: var(--color-black);
    outline: none;
}

.init-input-sm {
    flex: 0 0 5rem;
    max-width: 5rem;
}

.init-input-xs {
    flex: 0 0 4rem;
    max-width: 4rem;
    text-transform: uppercase;
    font-weight: bold;
    text-align: center;
}



/* ── Buttons ── */
.init-btn {
    padding: 0.4rem 1rem;
    border: none;
    border-radius: 4px;
    background: var(--color-black);
    color: var(--color-white);
    font-family: var(--main-font);
    font-weight: bold;
    font-size: 0.9rem;
    cursor: pointer;
    touch-action: manipulation;
}

.init-btn:hover {
    opacity: 0.85;
}

.init-btn-primary {
    background: var(--color-black);
    color: var(--color-white);
    width: 100%;
}

.init-btn-primary:hover {
    opacity: 0.85;
}

.init-btn-add-quick {
    background: #6ecba0;
    color: var(--color-white);
}

.init-btn-warning {
    background: #e65100;
    color: var(--color-white);
}

.init-btn-danger {
    background: #c62828;
    color: var(--color-white);
    grid-column: 1 / -1;
}

.init-btn-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.85rem;
}

.init-btn-icon {
    background: none;
    border: 1px solid #ccc;
    border-radius: 4px;
    width: 1.6rem;
    height: 1.6rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    touch-action: manipulation;
    transition: background 0.15s;
    font-family: var(--main-font);
    padding: 0;
}

.init-btn-icon:hover {
    background: #eee;
}

.init-card-actions {
    position: absolute;
    top: 0.4rem;
    right: 0.4rem;
    display: flex;
    gap: 0.3rem;
    align-items: center;
}

.init-btn-card {
    background: var(--color-black);
    color: var(--color-white);
    border: none;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: bold;
    font-family: var(--main-font);
    padding: 0 0.4rem;
    height: 1.6rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
}

.init-btn-card:hover {
    background: #333;
}

.init-btn-card-collapse {
    font-size: 0.7rem;
    width: 1.6rem;
    justify-content: center;
    padding: 0;
    background: none;
    border: 1px solid #ccc;
    color: #888;
}

.init-btn-card-collapse:hover {
    background: #eee;
    color: #333;
}

.init-btn-card-remove {
    font-size: 1.1rem;
    width: 1.6rem;
    justify-content: center;
    padding: 0;
    background: none;
    border: 1px solid #c62828;
    color: #c62828;
}

.init-btn-card-remove:hover {
    background: #c62828;
    color: #fff;
}

.init-btn-remove-sm {
    width: 1.2rem;
    height: 1.2rem;
    font-size: 0.8rem;
    color: #999;
    border-color: #ddd;
}

.init-btn-remove-sm:hover {
    color: #c62828;
    border-color: #c62828;
}

.init-btn-link {
    background: none;
    border: none;
    color: var(--color-link);
    cursor: pointer;
    font-family: var(--main-font);
    font-size: 0.8rem;
    padding: 0.2rem 0;
    touch-action: manipulation;
}

.init-btn-link:hover {
    color: var(--color-link-hover);
    text-decoration: underline;
}

/* ── Combatant list ── */
.init-list {
    margin-bottom: 1rem;
}

.init-empty {
    text-align: center;
    color: #999;
    font-style: italic;
    padding: 2rem 0;
}

.init-row {
    background: var(--color-white);
    border: 2px solid #ccc;
    border-radius: 6px;
    padding: 2.9rem 0.8rem 0.7rem 0.4rem;
    margin-bottom: 0.5rem;
    transition: border-color 0.2s, box-shadow 0.2s, opacity 0.2s;
    position: relative;
}

.init-row-active {
    border-left: 4px solid #6ecba0;
    background: #f1f8e9;
}

.init-row-dragging {
    opacity: 0.4;
}

.init-row-dragover {
    border-top: 3px solid var(--color-link);
}

.init-row-ghost {
    position: fixed;
    z-index: 1000;
    pointer-events: none;
    opacity: 0.8;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.init-row-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding-left: 0.25rem;
}

.init-row-collapsed {
    padding-top: 2.9rem;
    padding-bottom: 0.6rem;
    padding-left: 0.4rem;
    padding-right: 0.4rem;
}

.init-row-collapsed .init-row-header {
    gap: 0.2rem;
    align-items: center;
}

.init-drag-handle {
    cursor: grab;
    color: #999;
    font-size: 1.2rem;
    line-height: 1;
    user-select: none;
    position: absolute;
    top: 0.3rem;
    left: 0.4rem;
    padding: 0 0.2rem;
}

.init-drag-handle:active {
    cursor: grabbing;
}



.init-name {
    font-weight: bold;
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.init-init-val {
    font-size: 1.5rem;
    font-weight: bold;
    font-style: italic;
    color: #333;
    position: absolute;
    bottom: 0.4rem;
    right: 0.5rem;
}


.init-hp {
    font-size: 0.85rem;
    color: #333;
    flex: 0 0 auto;
    margin-left: 0.3rem;
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
}

.init-icon {
    width: 22px;
    height: 22px;
    vertical-align: middle;
    flex-shrink: 0;
}


.init-combatant-icon-wrap {
    flex-shrink: 0;
    width: 2em;
    height: 2em;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.init-combatant-icon-wrap:hover {
    outline: 2px solid #888;
}

.init-combatant-icon-wrap,
.icon-picker-btn,
.icon-picker-option,
.icon-popup-option {
    touch-action: manipulation;
}

.init-combatant-icon {
    width: 100%;
    height: 100%;
    border-radius: 4px;
    display: block;
}

.icon-colored {
    mix-blend-mode: screen;
}

/* ── Color picker (shared) ── */
.icon-color-picker {
    display: flex;
    align-items: center;
    gap: 3px;
    flex: 0 0 auto;
}

.icon-color-swatch {
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
    touch-action: manipulation;
}

.icon-color-swatch:hover {
    border-color: #888;
}

.icon-color-swatch.active {
    border-color: #fff;
    outline: 2px solid #333;
}

/* ── Icon/color popup (shared) ── */
.icon-popup {
    z-index: 200;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
    padding: 8px;
    width: 14rem;
}

.icon-popup-label {
    font-size: 0.7rem;
    font-weight: bold;
    color: #666;
    text-transform: uppercase;
    margin: 4px 0 2px;
}

.icon-popup-color-row {
    display: flex;
    gap: 4px;
    margin-bottom: 6px;
}

.icon-popup-sections,
.icon-picker-dropdown {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.icon-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.icon-section-label {
    font-size: 0.7rem;
    font-weight: bold;
    color: #666;
    text-transform: uppercase;
}

.icon-section-grid,
.icon-popup-grid {
    display: grid;
    grid-template-columns: repeat(5, 2.2rem);
    gap: 4px;
}

.icon-popup-option {
    width: 2.2rem;
    height: 2.2rem;
    border: 2px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    padding: 2px;
    background: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-popup-option:hover {
    border-color: #555;
    background: #f0f0f0;
}

.icon-popup-option.active {
    border-color: #2255cc;
    background: #e8eef8;
}

.icon-popup-option img {
    width: 100%;
    height: 100%;
}

.icon-picker {
    position: relative;
    flex: 0 0 auto;
}

.icon-picker-btn {
    width: 2.5rem;
    height: 2.5rem;
    border: 2px solid #ccc;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
}

.icon-picker-btn:hover {
    border-color: #888;
}

.icon-picker-btn img {
    width: 100%;
    height: 100%;
    border-radius: 3px;
}

.icon-picker-placeholder {
    font-size: 0.65rem;
    color: #999;
}

/* Shared font selector — reusable across apps */
.icon-font-select {
    padding: 2px 4px;
    border: 1px solid #555;
    border-radius: 3px;
    background: #222;
    color: #eee;
    font-family: var(--main-font);
    font-size: 0.7rem;
    cursor: pointer;
}

.icon-font-select:focus {
    outline: 1px solid #6ecba0;
    border-color: #6ecba0;
}

/* Shared number pill — capsule badge for icon-based markers (used by map prepper, initiative, etc.) */
.icon-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    font-weight: 700;
    font-family: var(--main-font);
    text-align: center;
    box-sizing: border-box;
    border: 4px solid #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

.icon-picker-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 100;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    padding: 6px;
    margin-top: 4px;
    min-width: 14rem;
    max-height: 300px;
    overflow-y: auto;
}

.icon-picker-dropdown.open {
    display: flex;
}

.icon-picker-option {
    width: 2.2rem;
    height: 2.2rem;
    border: 2px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    padding: 2px;
    background: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-picker-option:hover {
    border-color: #555;
    background: #f0f0f0;
}

.icon-picker-option img {
    width: 100%;
    height: 100%;
}

.icon-picker-option.no-icon {
    font-size: 0.6rem;
    color: #999;
}

/* ── HP / Damage counters ── */
.init-row-counters {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.4rem;
    padding-left: 0.25rem;
    margin-top: 0.4rem;
    margin-top: 0.3rem;
    align-items: center;
}

.init-counter {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    font-size: 0.85rem;
}

.init-counter-hp {
    color: #333;
}

.init-counter-label {
    font-weight: bold;
    font-size: 0.95rem;
}

.init-counter-label-initmod {
    font-weight: normal;
    font-style: italic;
    font-size: 0.75rem;
}

.init-counter-val {
    font-weight: bold;
    font-size: 0.95rem;
    min-width: 1.5rem;
    text-align: center;
}


.init-counter-clickable {
    cursor: pointer;
    border-bottom: 1px dashed #aaa;
    touch-action: manipulation;
}

.init-counter-clickable:hover {
    border-bottom-color: #333;
}

/* ── Notes ── */
.init-row-notes {
    font-size: 0.8rem;
    color: #666;
    font-style: italic;
    margin-top: 0.4rem;
    margin-top: 0.25rem;
    padding-left: 0.25rem;
}

/* ── Status chips ── */
.init-row-statuses {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-top: 0.4rem;
    margin-top: 0.3rem;
    padding-left: 0.25rem;
}

.init-status-chip {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: bold;
    font-family: monospace;
    padding: 0.15rem 0.35rem;
    border-radius: 3px;
    background: #e8eaf6;
    color: #283593;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
    letter-spacing: 0.03em;
}

.init-status-chip:hover {
    background: #c62828;
    color: #fff;
}

.init-status-chip-preview {
    cursor: pointer;
}

.init-status-chip-preview:hover {
    background: #e8eaf6;
    color: #283593;
}

.init-editable {
    cursor: pointer;
    border-bottom: 1px dashed #aaa;
}

.init-editable:hover {
    border-bottom-color: #333;
}

/* ── Resources ── */
.init-row-resources {
    margin-top: 0.4rem;
    padding-left: 0.25rem;
}

.init-resource {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin-bottom: 0.2rem;
    font-size: 0.8rem;
}

.init-resource-name {
    font-weight: bold;
    min-width: 0;
    white-space: nowrap;
}

.init-resource-val {
    min-width: 1.5rem;
    text-align: center;
    font-weight: bold;
}

/* ── Action buttons row ── */
.init-row-actions {
    display: flex;
    gap: 0.3rem;
    align-items: center;
    margin-top: 0.4rem;
    margin-top: 0.3rem;
    padding-left: 0.25rem;
}

.init-row-actions .init-btn-card-action,
.init-row-actions .init-status-select-styled {
    min-width: 5rem;
    text-align: center;
}

.init-status-select-styled {
    background: var(--color-black);
    color: var(--color-white);
    border: none;
    border-radius: 4px;
    font-family: var(--main-font);
    font-weight: bold;
    font-size: 0.6rem;
    padding: 0 0.3rem;
    height: 1.3rem;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

/* ── Dice formulas on combatant cards ── */
.init-row-dice {
    margin-top: 0.4rem;
    padding-left: 0.25rem;
}

.init-dice-saved {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.4rem;
}

.init-dice-wrap {
    display: inline-flex;
    align-items: stretch;
    border: 2px solid var(--color-black);
    border-radius: 6px;
    overflow: hidden;
}

.init-dice-roll-btn {
    padding: 0.3rem 0.6rem;
    background: var(--color-black);
    color: var(--color-white);
    border: none;
    cursor: pointer;
    font-family: var(--main-font);
    font-weight: bold;
    font-size: 0.8rem;
}

.init-dice-roll-btn:hover {
    background: #333;
}

.init-dice-del {
    padding: 0.3rem 0.4rem;
    background: var(--color-black);
    border: none;
    border-left: 1px solid #444;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--color-white);
}

.init-dice-del:hover {
    background: #c62828;
    color: var(--color-white);
}

.init-dice-roll-icon-btn {
    background: var(--color-black);
    color: var(--color-white);
    border: none;
    border-radius: 4px;
    width: 1.7rem;
    height: 1.5rem;
    padding: 0.2rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.init-dice-roll-icon-btn:hover {
    background: #333;
}

.init-dice-roll-icon-btn.init-btn-rolled {
    background: #6ecba0;
    color: var(--color-white);
}

.init-dice-roll-icon-btn svg {
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.init-dice-save-icon-btn {
    background: var(--color-black);
    color: var(--color-white);
    border: none;
    border-radius: 4px;
    width: 2rem;
    height: 1.5rem;
    padding: 0.15rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.init-dice-save-icon-btn:hover {
    background: #333;
}

.init-dice-save-icon-btn.init-btn-saved {
    background: #6ecba0;
    color: var(--color-white);
}

.init-dice-save-icon-btn img {
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.init-dice-toggle-btn {
    background: var(--color-white);
    border: 2px solid #ccc;
    border-radius: 4px;
    height: 1.5rem;
    padding: 0 0.4rem;
    cursor: pointer;
    font-family: var(--main-font);
    font-weight: bold;
    font-size: 0.7rem;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    touch-action: manipulation;
}

.init-dice-toggle-btn.ghosted {
    opacity: 0.3;
    pointer-events: none;
}

.init-dice-adv-btn {
    color: #6ecba0;
    border-color: #6ecba0;
}

.init-dice-adv-btn:hover {
    background: #e8f5e9;
}

.init-dice-adv-btn.active {
    background: #6ecba0;
    border-color: #6ecba0;
    color: #fff;
}

.init-dice-dis-btn {
    color: #c62828;
    border-color: #c62828;
}

.init-dice-dis-btn:hover {
    background: #ffebee;
}

.init-dice-dis-btn.active {
    background: #c62828;
    border-color: #c62828;
    color: #fff;
}

.init-dice-crit-btn {
    color: #e65100;
    border-color: #e65100;
}

.init-dice-crit-btn:hover {
    background: #fff3e0;
}

.init-dice-crit-btn.active {
    background: #e65100;
    border-color: #e65100;
    color: #fff;
}

/* ── Dice Picker Modal ── */
.dice-picker {
    width: 18rem;
    text-align: center;
    position: relative;
}

.dice-picker-close {
    position: absolute;
    top: 0.4rem;
    right: 0.4rem;
    background: none;
    border: 1px solid #c62828;
    border-radius: 4px;
    color: #c62828;
    font-size: 1.2rem;
    width: 1.6rem;
    height: 1.6rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.dice-picker-close:hover {
    background: #c62828;
    color: #fff;
}

.dice-picker-display {
    font-size: 1.1rem;
    font-weight: bold;
    font-family: var(--main-font);
    padding: 0.5rem;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    border: 2px solid #ccc;
    border-radius: 6px;
    min-height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dice-picker-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.4rem;
    margin-bottom: 0.6rem;
}

.dice-picker-die {
    padding: 0.6rem;
    background: var(--color-black);
    color: var(--color-white);
    border: none;
    border-radius: 6px;
    font-family: var(--main-font);
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
    touch-action: manipulation;
}

.dice-picker-die:hover {
    background: #333;
}

.dice-picker-die:active {
    background: #555;
}

.dice-picker-mods {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.4rem;
    margin-bottom: 0.75rem;
}

.dice-picker-mod {
    padding: 0.5rem;
    background: var(--color-white);
    color: var(--color-black);
    border: 2px solid #ccc;
    border-radius: 6px;
    font-family: var(--main-font);
    font-weight: bold;
    font-size: 0.9rem;
    cursor: pointer;
    touch-action: manipulation;
}

.dice-picker-mod:hover {
    border-color: var(--color-black);
}

.dice-picker-mod:active {
    background: #eee;
}

.dice-picker-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
}

.dice-picker-actions .init-btn {
    width: 100%;
}

/* Prevent iOS zoom on dice picker buttons */
@media (max-width: 480px) {
    .dice-picker-die,
    .dice-picker-mod {
        font-size: 16px;
    }
}

.init-dice-set-btn {
    background: var(--color-black);
    color: var(--color-white);
    border: none;
    border-radius: 4px;
    width: 2rem;
    height: 1.5rem;
    padding: 0.15rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.init-dice-set-btn:hover {
    background: #333;
}

.init-dice-set-btn img {
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.init-dice-input-row {
    display: flex;
    gap: 0.3rem;
    align-items: center;
}

.init-dice-input {
    max-width: 8rem;
    font-size: 0.8rem;
    padding: 0.2rem 0.4rem;
}

.init-dice-result {
    margin-top: 0.3rem;
    padding: 0.3rem 0.5rem;
    border-radius: 4px;
    background: #f5f5f5;
    font-family: var(--main-font);
    font-size: 0.85rem;
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.init-dice-result-total {
    font-weight: bold;
    font-size: 1.1rem;
}

.init-dice-result-breakdown {
    color: #666;
    font-size: 0.8rem;
}

.init-dice-result.result-crit-fail {
    background: #c62828;
    color: #fff;
}

.init-dice-result.result-crit-fail .init-dice-result-breakdown {
    color: rgba(255,255,255,0.8);
}

.init-dice-result.result-low {
    color: #c62828;
}

.init-dice-result.result-high {
    color: #6ecba0;
}

.init-dice-result.result-crit-success {
    background: #6ecba0;
    color: #fff;
}

.init-dice-result.result-crit-success .init-dice-result-breakdown {
    color: rgba(255,255,255,0.8);
}

/* ── Turn controls ── */
.init-turn-controls {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.init-turn-controls .init-btn {
    flex: 1;
    max-width: 10rem;
}

/* ── Bench (minimized combatants) ── */
.init-bench {
    margin-bottom: 1.5rem;
}

.init-bench-title {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #888;
    margin: 0 0 0.4rem 0;
}

.init-bench-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.init-bench-wrap {
    display: inline-flex;
    align-items: stretch;
    border: 2px solid var(--color-black);
    border-radius: 6px;
    overflow: hidden;
}

.init-bench-restore {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.4rem 0.75rem;
    background: var(--color-black);
    color: var(--color-white);
    border: none;
    cursor: pointer;
    font-family: var(--main-font);
    font-weight: bold;
    font-size: 0.85rem;
}

.init-bench-restore:hover {
    background: #333;
}

.init-bench-maximize {
    padding: 0.4rem 0.4rem;
    background: var(--color-black);
    border: none;
    border-left: 1px solid #444;
    cursor: pointer;
    font-size: 0.7rem;
    color: var(--color-white);
}

.init-bench-maximize:hover {
    background: #6ecba0;
    color: var(--color-white);
}

.init-bench-del {
    padding: 0.4rem 0.5rem;
    background: var(--color-black);
    border: none;
    border-left: 1px solid #444;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--color-white);
}

.init-bench-del:hover {
    background: #c62828;
    color: var(--color-white);
}

.init-btn-card-icon {
    padding: 0.15rem;
    width: 1.6rem;
}

.init-btn-card-icon img {
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.init-header-stat {
    font-size: 0.8rem;
    font-weight: bold;
    font-style: italic;
    color: #888;
    white-space: nowrap;
}

.init-btn-card-action {
    font-size: 0.6rem;
    padding: 0 0.3rem;
    height: 1.3rem;
}

.init-btn-card.init-btn-saved {
    background: #6ecba0;
    color: var(--color-white);
}

.init-row-collapsed .init-init-val {
    display: none;
}

.init-collapsed-stat {
    font-size: 0.95rem;
    font-weight: bold;
    padding: 0;
    border-radius: 3px;
    white-space: nowrap;
}

.init-collapsed-icon {
    width: 22px;
    height: 22px;
    margin-left: 0.15rem;
    margin-right: -0.1rem;
    vertical-align: middle;
}

.init-collapsed-hp {
    color: #000;
}


.init-collapsed-init {
    color: #555;
    font-style: italic;
    margin-left: auto;
}

/* ── Saved NPC rows ── */
.init-saved-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid #eee;
}

.init-saved-row:last-child {
    border-bottom: none;
}

.init-saved-name {
    font-weight: bold;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.init-saved-search-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.init-saved-search-row .init-input {
    flex: 1;
    min-width: 150px;
}

.init-saved-search-row .init-select {
    font-size: 0.8rem;
    padding: 0.3rem 0.4rem;
    border-radius: 4px;
    border: 1px solid #ccc;
    background: #fff;
    min-height: 36px;
}

/* ── Multi-select dropdown ── */
.init-multiselect {
    position: relative;
    flex: 1;
    min-width: 100px;
}

.init-multiselect-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.3rem 0.5rem;
    font-size: 0.8rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
    color: #333;
    cursor: pointer;
    min-height: 36px;
    text-align: left;
}

.init-multiselect-btn::after {
    content: '\25BC';
    font-size: 0.6rem;
    margin-left: 0.4rem;
    color: #999;
}

.init-multiselect-btn.active {
    border-color: #6ecba0;
}

.init-multiselect-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    background: #fff;
    border: 1px solid #ccc;
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.init-multiselect.open .init-multiselect-dropdown {
    display: block;
}

.init-multiselect-item {
    display: flex;
    align-items: center;
    padding: 0.3rem 0.5rem;
    font-size: 0.8rem;
    cursor: pointer;
    color: #333;
}

.init-multiselect-item:hover {
    background: #f0f0f0;
}

.init-multiselect-item input[type="checkbox"] {
    margin-right: 0.4rem;
    cursor: pointer;
}

.init-multiselect-clear {
    display: block;
    width: 100%;
    padding: 0.3rem 0.5rem;
    font-size: 0.75rem;
    color: #999;
    cursor: pointer;
    border: none;
    background: none;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.init-multiselect-clear:hover {
    color: #c62828;
    background: #fef0f0;
}

.init-btn-add-circle {
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 4px;
    border: none;
    background: #6ecba0;
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
    position: relative;
}

.init-btn-add-circle::before,
.init-btn-add-circle::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    background: #fff;
    transform: translate(-50%, -50%);
}

.init-btn-add-circle::before {
    width: 0.6rem;
    height: 2px;
}

.init-btn-add-circle::after {
    width: 2px;
    height: 0.6rem;
}

.init-btn-add-circle:hover {
    background: #5ab78c;
}

.init-btn-load-more {
    display: block;
    width: 100%;
    padding: 0.5rem;
    margin-top: 0.4rem;
    font-size: 0.75rem;
    color: #666;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    text-align: center;
}

.init-btn-load-more:hover {
    background: #e0e0e0;
    color: #333;
}

.init-btn-statblock-sm {
    width: 1.4rem;
    height: 1.4rem;
    padding: 0.15rem;
    flex-shrink: 0;
    min-height: 0;
}

.init-saved-source {
    font-size: 0.6rem;
    color: #999;
    font-style: italic;
    white-space: nowrap;
}

.init-saved-stat {
    font-size: 0.55rem;
    color: #666;
    white-space: nowrap;
}

.init-saved-count {
    font-size: 0.75rem;
    color: #999;
    padding: 0.25rem 0;
}

/* ── Stat Block Modal ── */
.init-statblock-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
}

.init-statblock-content {
    max-height: 70vh;
    overflow-y: auto;
    font-size: 0.85rem;
    line-height: 1.5;
    padding: 0.5rem 0;
}

.init-statblock-content h1 {
    font-size: 1.3rem;
    margin: 0 0 0.25rem 0;
    color: #8b0000;
}

.init-statblock-content h2,
.init-statblock-content h3 {
    font-size: 1rem;
    margin: 0.75rem 0 0.25rem 0;
    color: #8b0000;
    border-bottom: 1px solid #ddd;
    padding-bottom: 0.15rem;
}

.init-statblock-content hr {
    border: none;
    border-top: 1px solid #ddd;
    margin: 0.4rem 0;
}

.init-statblock-content br {
    display: none;
}

.init-statblock-content p {
    margin: 0.3rem 0;
}

.init-statblock-content ul {
    list-style: none;
    padding-left: 0;
    margin: 0.2rem 0;
}

.init-statblock-content ul li {
    margin: 0.2rem 0;
}

.init-statblock-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.4rem 0;
    text-align: center;
    font-size: 0.8rem;
}

.init-statblock-content table th {
    font-weight: bold;
    color: #8b0000;
    padding: 0.2rem 0.4rem;
    border-bottom: 1px solid #ddd;
}

.init-statblock-content table td {
    padding: 0.2rem 0.4rem;
}

.init-statblock-content strong {
    font-weight: bold;
}

.init-statblock-content em {
    font-style: italic;
}

.init-btn-statblock {
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
    color: #8b0000;
    border: 1px solid #8b0000;
    border-radius: 3px;
    background: transparent;
    cursor: pointer;
    min-height: 0;
}

.init-btn-statblock:hover {
    background: #8b0000;
    color: #fff;
}

/* ── Instructions ── */
.init-instructions {
    font-size: 0.85rem;
    line-height: 1.5;
}

.init-instructions h4 {
    margin: 0.75rem 0 0.25rem;
    font-size: 0.9rem;
}

.init-instructions h4:first-child {
    margin-top: 0.25rem;
}

.init-instructions ul {
    margin: 0;
    padding-left: 1.2rem;
}

.init-instructions li {
    margin-bottom: 0.25rem;
}

.init-instructions code {
    background: #eee;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-size: 0.8rem;
}

/* ── Status pool table ── */
.init-status-pool {
    margin-top: 0.3rem;
    margin-bottom: 0.3rem;
}

.init-status-pool summary {
    font-weight: bold;
    cursor: pointer;
    padding: 0.25rem 0;
    user-select: none;
}

.init-tag-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

.init-tag-table th,
.init-tag-table td {
    text-align: left;
    padding: 0.3rem 0.5rem;
    border: 1px solid #ccc;
    font-size: 0.85rem;
}

.init-tag-table th {
    background: var(--color-secondary);
    font-weight: bold;
}

.init-tag-table td:last-child {
    width: 2rem;
    text-align: center;
}

.init-tag-add-row {
    margin-top: 0.5rem;
}

/* ── Modal ── */
.init-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
}

.init-modal {
    background: #fff;
    border-radius: 8px;
    padding: 1.2rem;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
    width: 16rem;
    position: relative;
}

.init-modal-wide {
    width: 22rem;
    max-height: 80vh;
    overflow-y: auto;
}

.init-modal-title {
    font-weight: bold;
    font-size: 1rem;
    margin-bottom: 0.75rem;
}

.init-modal label {
    font-size: 0.85rem;
    font-weight: bold;
    flex: 0 0 auto;
}

.init-modal-current {
    text-align: center;
    font-size: 1.4rem;
    font-weight: bold;
    margin-bottom: 0.75rem;
}

.init-modal-compact {
    width: 14rem;
}

.init-modal-compact input[type="number"]::-webkit-inner-spin-button,
.init-modal-compact input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.init-modal-compact input[type="number"] {
    -moz-appearance: textfield;
}

.init-modal-adjust-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.3rem;
    margin-bottom: 0.4rem;
}

.init-modal-btn-reduce {
    background: #c62828;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 0.5rem 0.8rem;
    font-size: 1.4rem;
    font-weight: bold;
    font-family: var(--main-font);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

.init-modal-btn-reduce:hover {
    background: #a11;
}

.init-modal-btn-add {
    background: #6ecba0;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 0.5rem 0.8rem;
    font-size: 1.4rem;
    font-weight: bold;
    font-family: var(--main-font);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

.init-modal-btn-add:hover {
    background: #5ab78c;
}

.init-modal-quick-row {
    display: flex;
    justify-content: center;
    gap: 0.3rem;
    margin-bottom: 0.5rem;
}

.init-modal-quick-btn {
    background: var(--color-black);
    color: var(--color-white);
    border: none;
    border-radius: 4px;
    padding: 0.3rem 0.5rem;
    font-family: var(--main-font);
    font-weight: bold;
    font-size: 0.8rem;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.init-modal-quick-btn:hover {
    background: #333;
}

.init-modal-override-btn {
    width: 100%;
    padding: 0.35rem;
    background: var(--color-white);
    color: #888;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: var(--main-font);
    font-weight: bold;
    font-size: 0.75rem;
    cursor: pointer;
    touch-action: manipulation;
    margin-top: 0.3rem;
}

.init-modal-override-btn:hover {
    border-color: #888;
    color: #333;
}

.init-modal-section-label {
    font-size: 0.7rem;
    font-weight: bold;
    color: #666;
    text-transform: uppercase;
    margin: 0.5rem 0 0.25rem;
}

/* ── Responsive ── */
@media (max-width: 480px) {
    .initiative-tracker {
        padding: 0 0.25rem;
    }

    /* Form: stack rows and let inputs breathe */
    .init-form-row {
        flex-wrap: wrap;
    }

    .init-input-sm {
        flex: 1 1 3.5rem;
        max-width: none;
        min-width: 3rem;
    }

    .init-input-xs {
        flex: 0 0 3.5rem;
        max-width: 3.5rem;
    }

    /* Prevent iOS zoom on input focus (requires >= 16px) */
    .init-input,
    .init-input-sm,
    .init-input-xs {
        font-size: 16px;
    }

    /* Color picker: wrap if needed */
    .icon-color-picker {
        gap: 2px;
    }

    .icon-color-swatch {
        width: 1.2rem;
        height: 1.2rem;
    }

    /* Combatant row header */
    .init-row-header {
        flex-wrap: wrap;
    }

    .init-name {
        flex: 0 1 auto;
        min-width: 0;
    }

    .init-init-val {
        font-size: 1.2rem;
    }

    /* Counters */
    .init-row-counters {
        padding-left: 0.3rem;
        gap: 0.3rem;
    }

    .init-counter {
        font-size: 0.75rem;
        gap: 0.1rem;
    }

    /* Row padding adjustments */

    /* Icon popup: constrain to viewport */
    .icon-popup {
        position: fixed !important;
        left: 50% !important;
        top: 50% !important;
        transform: translate(-50%, -50%);
        max-width: calc(100vw - 2rem);
        max-height: calc(100vh - 4rem);
        overflow-y: auto;
    }

    /* Icon picker dropdown: don't overflow right edge */
    .icon-picker-dropdown {
        left: auto;
        right: 0;
        max-width: calc(100vw - 2rem);
    }

    /* Turn controls full width */
    .init-turn-controls {
        gap: 0.5rem;
    }

    .init-turn-controls .init-btn {
        flex: 1;
    }
}

/* ══════════════════════════════════════════════════════════════════════════ */
/* Monster Catalogue                                                        */
/* ══════════════════════════════════════════════════════════════════════════ */

.catalogue button,
.catalogue input,
.catalogue select,
.catalogue [data-action],
.catalogue .sb-roll-btn {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

.catalogue {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 1rem 2rem;
}

.catalogue h2 {
    margin: 1.5rem 0 0.75rem;
    font-size: 1.2rem;
}

/* ── Filters ── */

.catalogue-filters {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.catalogue-filters .init-input {
    width: 100%;
    box-sizing: border-box;
    font-size: 16px;
}

.catalogue-filter-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.catalogue-filter-row .init-multiselect {
    flex: 1;
    min-width: 100px;
}

/* ── Browse results ── */

.catalogue-result-count {
    font-size: 0.8rem;
    color: #888;
    margin-bottom: 0.5rem;
}

.catalogue-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid #eee;
}

.catalogue-row:last-child {
    border-bottom: none;
}

.catalogue-row-name {
    font-weight: bold;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.catalogue-row-source {
    font-size: 0.65rem;
    color: #888;
    margin-left: auto;
    flex-shrink: 0;
}

.catalogue-row-stat {
    font-size: 0.65rem;
    font-weight: bold;
    color: #555;
    flex-shrink: 0;
    margin-left: 0.3rem;
}

.catalogue-load-more {
    width: 100%;
    margin-top: 0.5rem;
}

/* ── Stable cards ── */

.catalogue-stable-count {
    font-weight: normal;
    font-size: 0.85rem;
    color: #888;
}

.catalogue-card {
    background: #fff;
    border: 2px solid #ddd;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    overflow: hidden;
    transition: border-color 0.15s;
}

.catalogue-card:hover {
    border-color: #aaa;
}

.catalogue-card-expanded {
    border-color: #222;
}

.catalogue-card-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.5rem;
    cursor: pointer;
    user-select: none;
}

.catalogue-card-name {
    font-weight: bold;
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex: 1;
}

.catalogue-card-stat {
    font-size: 0.75rem;
    font-weight: bold;
    color: #555;
    flex-shrink: 0;
}

.catalogue-card-cr {
    font-size: 0.65rem;
    font-weight: bold;
    color: #888;
    flex-shrink: 0;
    margin-left: 0.3rem;
}

.catalogue-card-actions {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    flex-shrink: 0;
    margin-left: auto;
}

.catalogue-card-statblock {
    padding: 0.75rem 1rem;
    border-top: 1px solid #eee;
}

/* ── Rollable dice buttons in stable stat blocks ── */

.sb-roll-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.8rem;
    height: 1.4rem;
    padding: 0;
    margin: 0.15rem 0 0.15rem 0.2rem;
    border: none;
    border-radius: 3px;
    background: #222;
    cursor: pointer;
    vertical-align: middle;
    flex-shrink: 0;
}

.sb-roll-btn:hover {
    background: #555;
}

.sb-roll-icon {
    width: 1rem;
    height: 1rem;
    pointer-events: none;
    filter: invert(1);
}

.sb-roll-result {
    font-weight: 700;
    font-size: 0.85em;
    margin-left: 0.2rem;
    vertical-align: middle;
}

.sb-roll-result.result-crit-success { color: #6ecba0; }
.sb-roll-result.result-high { color: #6ecba0; }
.sb-roll-result.result-low { color: #c62828; }
.sb-roll-result.result-crit-fail { color: #c62828; }

/* ── Roll result display in top bar of stat blocks ── */

.sb-roll-display {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    border-top: 1px solid #ddd;
    background: #f8f8f8;
    font-size: 0.85rem;
    justify-content: space-between;
    align-items: center;
}

.sb-roll-display-result {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.3rem;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85rem;
    flex: 1;
}

.sb-roll-display-formula {
    color: #888;
    font-size: 0.78rem;
    font-family: monospace;
}

.sb-roll-display-total {
    font-weight: bold;
    font-size: 1.2rem;
}

.sb-roll-display-breakdown {
    color: #555;
    font-size: 0.82rem;
}

.sb-roll-display-result.result-crit-success {
    background: #6ecba0;
    color: #fff;
}
.sb-roll-display-result.result-crit-success .sb-roll-display-breakdown,
.sb-roll-display-result.result-crit-success .sb-roll-display-formula { color: rgba(255,255,255,0.8); }

.sb-roll-display-result.result-high { color: #6ecba0; }
.sb-roll-display-result.result-low  { color: #c62828; }

.sb-roll-display-result.result-crit-fail {
    background: #c62828;
    color: #fff;
}
.sb-roll-display-result.result-crit-fail .sb-roll-display-breakdown,
.sb-roll-display-result.result-crit-fail .sb-roll-display-formula { color: rgba(255,255,255,0.8); }

.sb-roll-display-modes {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
    margin-left: 0.5rem;
}

.sb-mode-btn {
    padding: 0.2rem 0.45rem;
    border: 2px solid #ccc;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    font-family: var(--main-font);
    font-weight: bold;
    font-size: 0.7rem;
    transition: background 0.15s, border-color 0.15s;
}

.sb-mode-btn:hover { border-color: #888; }

.sb-mode-btn[data-mode="adv"].active {
    background: #6ecba0;
    border-color: #6ecba0;
    color: #fff;
}

.sb-mode-btn[data-mode="dis"].active {
    background: #c62828;
    border-color: #c62828;
    color: #fff;
}

.sb-mode-btn[data-mode="crit"].active {
    background: #e65100;
    border-color: #e65100;
    color: #fff;
}

/* ── Map Browser ── */

.mb-main {
    max-width: none;
    padding: 12px;
    flex: 1 0 auto;
}

.mb-controls-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.mb-filter {
    text-align: center;
}

.mb-toolbar {
    display: flex;
    gap: 6px;
    align-items: center;
}

.mb-toolbar-btn {
    font-family: var(--main-font);
    font-size: 0.85rem;
    padding: 0.3rem 0.65rem;
    border: 2px solid var(--color-black);
    border-radius: 6px;
    background: var(--color-white);
    color: var(--color-black);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.mb-toolbar-btn.active,
.mb-toolbar-btn:hover {
    background: var(--color-black);
    color: var(--color-white);
}

.mb-source-btn {
    font-family: var(--main-font);
    font-size: 0.9rem;
    padding: 0.35rem 0.75rem;
    margin: 0 4px;
    border: 2px solid var(--color-black);
    border-radius: 6px;
    background: var(--color-white);
    color: var(--color-black);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.mb-source-btn.active,
.mb-source-btn:hover {
    background: var(--color-black);
    color: var(--color-white);
}

.mb-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--mb-thumb-size, 120px), 1fr));
    gap: 6px;
    background: #1a1a1a;
    padding: 8px;
    border-radius: 8px;
}

.mb-size-slider-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--main-font);
    font-size: 0.8rem;
    color: var(--color-black);
}

.mb-size-slider-wrap input[type="range"] {
    width: 120px;
    cursor: pointer;
}

.mb-thumb-wrap {
    position: relative;
    overflow: visible;
    border-radius: 4px;
}

.mb-thumb {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, z-index 0s;
    position: relative;
    z-index: 1;
}

.mb-thumb:hover {
    transform: scale(var(--mb-hover-scale, 1.6));
    z-index: 10;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.7);
}

.mb-thumb-wrap.mb-pinned {
    outline: 3px solid #f5c518;
    outline-offset: -3px;
    border-radius: 4px;
}

.mb-thumb-wrap.mb-pinned::after {
    content: '\2605';
    position: absolute;
    top: 4px;
    right: 6px;
    color: #f5c518;
    font-size: 1.2rem;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    z-index: 2;
    pointer-events: none;
}

/* ── Map Viewer (shared overlay) ── */

.mv-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 1000;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.mv-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 20px 0;
    flex-shrink: 0;
}

.mv-info {
    color: rgba(255, 255, 255, 0.75);
    font-family: var(--main-font);
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.mv-close {
    font-size: 2.5rem;
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    line-height: 1;
    z-index: 1010;
    flex-shrink: 0;
    margin-left: 12px;
}

.mv-close:hover {
    color: #ccc;
}

.mv-body {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    flex: 1;
    min-height: 0;
    padding: 10px 20px 10px;
}

.mv-img-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    overflow: hidden;
}

.mv-img {
    max-width: 100%;
    max-height: 80vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 4px;
}

.mv-nav {
    font-size: 3rem;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    padding: 0 18px;
    line-height: 1;
    flex-shrink: 0;
    user-select: none;
}

.mv-nav:hover {
    color: #fff;
}

.mv-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 10px 20px;
    flex-wrap: wrap;
}

.mv-counter {
    color: rgba(255, 255, 255, 0.6);
    font-family: var(--main-font);
    font-size: 0.9rem;
}

.mv-downloads {
    display: flex;
    gap: 8px;
}

.mv-dl-btn {
    font-family: var(--main-font);
    font-size: 0.85rem;
    padding: 0.35rem 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 6px;
    background: transparent;
    color: #fff;
    cursor: pointer;
    transition: background 0.15s;
}

.mv-dl-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.mv-pin-btn {
    font-family: var(--main-font);
    font-size: 0.85rem;
    padding: 0.35rem 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 6px;
    background: transparent;
    color: #fff;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.mv-pin-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.mv-pin-btn.mv-pinned {
    border-color: #f5c518;
    color: #f5c518;
}

.mv-attribution {
    color: rgba(255, 255, 255, 0.5);
    font-family: var(--main-font);
    font-size: 0.8rem;
    text-align: center;
    padding: 4px 20px 12px;
}

/* ── Map Prepper ── */

.mp-main {
    max-width: none;
    padding: 12px;
    width: 100%;
    display: flex;
    flex-direction: column;
    flex: 1 0 auto;
    flex: 1;
    min-height: 0;
}

.mp-selection-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 10px;
    padding: 10px;
    background: var(--color-white);
    border: 1px solid #ccc;
    border-radius: 6px;
}

.mp-picker-divider {
    width: 1px;
    height: 40px;
    background: #ccc;
}

.mp-picker-section {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.mp-picker-label {
    font-family: var(--main-font);
    font-size: 0.85rem;
    font-weight: 700;
    white-space: nowrap;
}

.mp-pinned-picker {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    flex: 1;
    min-width: 0;
    padding: 4px 0;
}

.mp-picker-thumb {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 4px;
    cursor: pointer;
    border: 2px solid transparent;
    flex-shrink: 0;
    transition: border-color 0.15s;
}

.mp-picker-thumb:hover {
    border-color: var(--color-black);
}

.mp-no-pinned {
    font-family: var(--main-font);
    font-size: 0.8rem;
    color: #888;
    font-style: italic;
}

.mp-btn {
    font-family: var(--main-font);
    font-size: 0.85rem;
    padding: 0.3rem 0.5rem;
    border: 2px solid var(--color-black);
    border-radius: 6px;
    background: var(--color-white);
    color: var(--color-black);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.mp-btn:hover {
    background: var(--color-black);
    color: var(--color-white);
}

.mp-btn.active {
    background: var(--color-black);
    color: var(--color-white);
}

.mp-btn-inverted {
    background: #F1641E;
    border-color: #F1641E;
    color: var(--color-black);
}

.mp-btn-inverted:hover {
    background: var(--color-black);
    border-color: var(--color-black);
    color: var(--color-white);
}

.mp-btn-accent {
    border-color: #6ecba0;
    background: #6ecba0;
    color: #000;
}

.mp-btn-accent:hover {
    background: var(--color-black);
    color: var(--color-white);
    border-color: var(--color-black);
}

.mp-toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.mp-placeholder {
    font-family: var(--main-font);
    font-size: 1rem;
    color: #888;
    text-align: center;
    padding: 80px 20px;
    background: #1a1a1a;
    border-radius: 8px;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mp-workspace {
    display: flex;
    flex: 1;
    min-height: 0;
    gap: 0;
}

.mp-canvas {
    position: relative;
    overflow: hidden;
    background: #1a1a1a;
    border-radius: 8px;
    flex: 1;
    min-width: 0;
    min-height: 0;
    touch-action: none;
}

.mp-canvas.mp-panning {
    cursor: grab;
}

.mp-canvas.mp-panning-active {
    cursor: grabbing;
}

.mp-canvas.mp-panning .mp-pin,
.mp-canvas.mp-panning .mp-notecard-header {
    pointer-events: none;
}

.mp-inner {
    position: absolute;
    transform-origin: 0 0;
}

.mp-map-img {
    display: block;
    max-width: none;
    width: auto;
    height: auto;
    position: relative;
    z-index: 1;
}

.mp-svg {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 2;
    overflow: visible;
}

.mp-minimap {
    border-radius: 4px;
    display: none;
}

.mp-minimap-panel {
    position: absolute;
    bottom: 40px;
    right: 10px;
    z-index: 20;
    background: rgba(30, 30, 30, 0.95);
    border: 1px solid #555;
    border-radius: 6px;
    display: none;
    flex-direction: column;
    gap: 0;
    padding: 0;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}

.mp-minimap-panel-header {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 6px;
    border-bottom: 1px solid #444;
}

.mp-minimap-panel-label {
    font-family: var(--main-font);
    font-size: 0.65rem;
    font-weight: 700;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.mp-minimap-panel .mp-minimap {
    display: block;
    border-radius: 0 0 5px 5px;
}

.mp-pin-layer {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 3;
    overflow: visible;
    pointer-events: none;
}

/* Pin marker — counter-scaled to stay constant screen size */
.mp-pin {
    pointer-events: auto;
    position: absolute;
    cursor: grab;
    transform: translate(-50%, -50%) scale(var(--mp-pin-counter-scale, 1));
    transform-origin: center center;
    z-index: 4;
}

/* Default (non-icon) pin marker — pill shape via .icon-pill */
.mp-pin:not(.mp-pin-icon) {
    min-width: 48px;
    height: 28px;
    padding: 0 6px;
    white-space: nowrap;
}

/* Small dot when label is hidden */
.mp-pin.mp-pin-dot {
    min-width: 24px;
    width: 24px;
    height: 24px !important;
    padding: 0;
    border-width: 3px;
}

.mp-pin:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.6);
}

.mp-pin:active {
    cursor: grabbing;
}

.mp-pin-delete {
    display: none;
    position: absolute;
    top: -8px;
    right: -8px;
    width: 16px;
    height: 16px;
    background: #333;
    color: #fff;
    border-radius: 50%;
    font-size: 11px;
    line-height: 16px;
    text-align: center;
    cursor: pointer;
}

.mp-pin:hover .mp-pin-delete {
    display: block;
}

.mp-canvas.mp-preview-mode .mp-pin-delete {
    display: none !important;
}

/* Icon pin marker — rounded square with padding around icon */
.mp-pin.mp-pin-icon {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    padding: 2px;
    border-width: 4px;
}

.mp-pin-icon-img {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 2px;
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-mode: luminance;
    mask-mode: luminance;
}

/* Number pill below icon pins — positioned beneath marker, width matches icon */
.mp-pin-pill {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: -26px;
    min-width: calc(100% + 12px);   /* at least as wide as icon outer */
    width: max-content;
    padding: 0 8px;
    height: 24px;
    font-size: 13px;
    line-height: 1;
    white-space: nowrap;
    pointer-events: none;
}

/* Notecard — counter-scaled to stay readable at any zoom */
/* Notecard — dark theme matching site aesthetic */
.mp-notecard {
    position: absolute;
    pointer-events: auto;
    background: var(--color-black);
    color: var(--color-white);
    font-family: var(--main-font);
    font-size: 0.8rem;
    border: 2px solid #666;
    border-radius: 6px;
    min-width: 150px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
    z-index: 5;
    transform: scale(var(--mp-card-counter-scale, 1));
    transform-origin: top left;
    display: flex;
    flex-direction: column;
}

/* Edit mode: card must be wide enough for header buttons */
.mp-notecard:not(.mp-notecard-preview):not(.mp-notecard-title) {
    min-width: min-content;
}

.mp-notecard-resize {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 14px;
    height: 14px;
    cursor: nwse-resize;
    z-index: 10;
    border-right: 2px solid #666;
    border-bottom: 2px solid #666;
    border-radius: 0 0 4px 0;
}

.mp-notecard-resize:hover {
    border-right-color: #aaa;
    border-bottom-color: #aaa;
}

.mp-notecard-header {
    position: relative;
    display: flex;
    align-items: center;
    gap: 4px 5px;
    padding: 36px 10px 6px 10px;
    background: #1a1a1a;
    border-bottom: 1px solid #444;
    border-radius: 4px 4px 0 0;
    cursor: grab;
    user-select: none;
}

.mp-notecard-header-actions {
    position: absolute;
    top: 5px;
    right: 6px;
    display: flex;
    gap: 4px;
    z-index: 1;
}

.mp-notecard-header:active {
    cursor: grabbing;
}

.mp-notecard-grip {
    font-size: 1.1rem;
    color: #666;
    line-height: 1;
    flex-shrink: 0;
    cursor: grab;
    padding-right: 2px;
}

.mp-notecard-grip:active {
    cursor: grabbing;
    color: #aaa;
}

.mp-notecard-label {
    font-family: var(--main-font);
    font-size: 0.8rem;
    font-weight: 700;
    flex: 1;
    color: var(--color-white);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mp-notecard-label-input {
    font-family: inherit;
    font-size: inherit;
    font-weight: 700;
    flex: 1;
    min-width: 0;
    color: var(--color-white);
    background: transparent;
    border: none;
    border-bottom: 1px solid transparent;
    outline: none;
    padding: 0;
}

.mp-notecard-label-input:focus {
    border-bottom-color: #666;
}

.mp-notecard-btn {
    font-family: var(--main-font);
    font-size: 0.75rem;
    padding: 2px 6px;
    border: 1px solid #666;
    border-radius: 4px;
    background: transparent;
    color: var(--color-white);
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.mp-notecard-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.mp-notecard-dup-btn {
    width: 24px;
    min-width: 24px;
    height: 22px;
    padding: 0;
    position: relative;
    background: #000;
    flex-shrink: 0;
}

.mp-notecard-dup-btn::after {
    content: '';
    display: block;
    width: 14px;
    height: 14px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #fff;
    -webkit-mask-image: url('icons/utility/copy.svg');
    mask-image: url('icons/utility/copy.svg');
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
}

.mp-notecard-dup-btn:hover {
    background: #333;
}

/* Lock button on card header */
.mp-notecard-lock-btn {
    font-size: 0.7rem;
    padding: 0 2px;
    line-height: 1;
}

.mp-notecard-lock-btn.active {
    background: #444;
}

/* Lock indicator on layout mode cards */
/* Hide overlay button on layout cards — visible on hover */
.mp-notecard-hide-overlay {
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 0.6rem;
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    opacity: 0;
    padding: 2px;
    line-height: 1;
    transition: opacity 0.15s;
    z-index: 1;
}

.mp-notecard:hover .mp-notecard-hide-overlay {
    opacity: 0.6;
}

.mp-notecard-hide-overlay:hover {
    opacity: 1 !important;
}

.mp-notecard-expand-overlay {
    right: 18px;
}

.mp-notecard-lock-indicator {
    position: absolute;
    top: 4px;
    right: 20px;
    font-size: 0.6rem;
    opacity: 0.6;
    pointer-events: none;
}

.mp-color-row {
    display: flex;
    gap: 4px;
    padding: 5px 10px;
    border-bottom: 1px solid #444;
    align-items: center;
}

.mp-color-tab {
    font-family: var(--main-font);
    font-size: 0.6rem;
    font-weight: 700;
    padding: 1px 5px;
    border: 1px solid #555;
    border-radius: 3px;
    background: transparent;
    color: #888;
    cursor: pointer;
    line-height: 1.4;
}

.mp-color-tab:hover {
    color: #ccc;
    border-color: #888;
}

.mp-color-tab-active {
    background: #555;
    color: #fff;
    border-color: #777;
}

.mp-color-swatch {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.1s;
    flex-shrink: 0;
}

.mp-color-swatch.mp-color-light {
    box-shadow: 0 0 0 1px #666;
}

.mp-color-swatch:hover {
    border-color: rgba(255, 255, 255, 0.6);
}

.mp-color-swatch.mp-color-active {
    border-color: var(--color-white);
    box-shadow: 0 0 0 1px #000 inset;
}

.mp-weight-row {
    display: flex;
    gap: 6px;
    padding: 4px 10px;
    border-bottom: 1px solid #444;
    align-items: center;
}

.mp-weight-label {
    font-family: var(--main-font);
    font-size: 0.7rem;
    color: #fff;
    margin-right: 2px;
}

.mp-weight-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 20px;
    cursor: pointer;
    border: 1px solid transparent;
    border-radius: 3px;
    transition: border-color 0.1s;
}

.mp-weight-btn:hover {
    border-color: #666;
}

.mp-weight-btn.mp-weight-active {
    border-color: var(--color-white);
}

.mp-weight-sample {
    width: 100%;
    border-radius: 1px;
}

/* Icon picker row on pin cards */
.mp-icon-row {
    display: flex;
    gap: 6px;
    padding: 4px 10px;
    border-bottom: 1px solid #444;
    align-items: center;
}

.mp-icon-row .icon-picker {
    flex: 0 0 auto;
}

.mp-icon-picker-btn {
    width: 1.8rem;
    height: 1.8rem;
    background: #333;
    border-color: #555;
}

.mp-icon-picker-btn:hover {
    border-color: #888;
}

.mp-icon-picker-btn img {
    filter: invert(1);
}

.mp-icon-picker-num {
    font-family: var(--main-font);
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
}

.mp-icon-color-row {
    display: flex;
    gap: 3px;
    align-items: center;
}

.mp-icon-color-row .icon-color-swatch {
    width: 1.1rem;
    height: 1.1rem;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
}

.mp-icon-color-row .icon-color-swatch:hover {
    border-color: #888;
}

.mp-icon-color-row .icon-color-swatch.active {
    border-color: #fff;
    outline: 1px solid #555;
}

/* Dark theme overrides for icon picker dropdown in map prepper */
.mp-icon-dropdown-portal {
    position: fixed;
    z-index: 9999;
    background: #2a2a2a;
    border: 1px solid #555;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    padding: 6px;
    max-height: 300px;
    overflow-y: scroll;
    display: none;
}

.mp-icon-dropdown-portal.open {
    display: block;
}

.mp-icon-dropdown-portal > * {
    margin-bottom: 6px;
}

.mp-icon-dropdown-portal::-webkit-scrollbar {
    width: 4px;
}

.mp-icon-dropdown-portal::-webkit-scrollbar-track {
    background: transparent;
}

.mp-icon-dropdown-portal::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 2px;
}

.mp-icon-dropdown-portal::-webkit-scrollbar-thumb:hover {
    background: #777;
}

.mp-icon-dropdown-portal .icon-picker-option img {
    filter: invert(1);
}

.mp-icon-dropdown-portal .icon-picker-option {
    border-color: transparent;
}

.mp-icon-dropdown-portal .icon-picker-option:hover {
    border-color: #888;
    background: #444;
}

.mp-icon-dropdown-portal .icon-picker-option.active {
    border-color: #4fc3f7;
    background: #333;
}

.mp-icon-dropdown-portal .icon-picker-option.no-icon {
    font-size: 0.55rem;
    color: #aaa;
}

.mp-icon-dropdown-portal .icon-section-label {
    color: #aaa;
}

/* Name row — full-width input below header */
.mp-notecard-name-row {
    display: flex;
    padding: 4px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.15);
}

.mp-notecard-name-row .mp-notecard-label-input {
    flex: 1;
    min-width: 8em;
    width: auto;
}

/* Collapsible tool panel — hidden by default, shown via toggle */
.mp-tool-toggle {
    width: 100%;
    border: none;
    border-bottom: 1px solid rgba(255,255,255,0.15);
    padding: 3px 10px;
    font-size: 0.7rem;
    cursor: pointer;
    text-align: left;
}

.mp-card-tools {
    display: none;
}

.mp-card-tools-open {
    display: block;
}

.mp-notecard-body {
    padding: 8px 10px;
    font-family: inherit;
    font-size: inherit;
    line-height: 1.5;
    color: var(--color-white);
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.mp-notecard-body::-webkit-scrollbar {
    width: 4px;
}

.mp-notecard-body::-webkit-scrollbar-track {
    background: transparent;
}

.mp-notecard-body::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 2px;
}

.mp-notecard-body::-webkit-scrollbar-thumb:hover {
    background: #777;
}

.mp-notecard-body h3,
.mp-notecard-body h4,
.mp-notecard-body h5,
.mp-notecard-body h6 {
    margin: 0.3em 0;
    font-size: 0.9rem;
    color: var(--color-white);
}

.mp-notecard-body p {
    margin: 0 0 0.4em;
}

.mp-notecard-body ul {
    padding-left: 16px;
    list-style: disc;
    margin: 0 0 0.4em;
}

.mp-notecard-body li {
    margin-bottom: 0.2em;
}

.mp-notecard-body a {
    color: var(--color-link-on-black);
}

.mp-fmt-bar {
    display: flex;
    gap: 3px;
    padding: 4px 0;
    flex-wrap: wrap;
    border-bottom: 1px solid #444;
    margin-bottom: 6px;
}

.mp-fmt-btn {
    font-family: var(--main-font);
    font-size: 0.7rem;
    padding: 2px 6px;
    border: 1px solid #555;
    border-radius: 3px;
    background: #222;
    color: #ccc;
    cursor: pointer;
    line-height: 1.2;
}

.mp-fmt-btn:hover {
    background: #444;
    color: #fff;
}

.mp-fmt-bold {
    font-weight: 700;
}

.mp-fmt-italic {
    font-style: italic;
}

.mp-fmt-underline {
    text-decoration: underline;
}

.mp-fmt-strike {
    text-decoration: line-through;
}

.mp-fmt-select {
    font-family: var(--main-font);
    font-size: 0.7rem;
    padding: 2px 4px;
    border: 1px solid #555;
    border-radius: 3px;
    background: #222;
    color: #ccc;
    cursor: pointer;
}

.mp-fmt-select:hover {
    background: #444;
}

.mp-notecard-textarea {
    width: 100%;
    min-height: 100px;
    border: none;
    outline: none;
    resize: none;
    font-family: inherit;
    font-size: inherit;
    line-height: 1.5;
    background: transparent;
    color: var(--color-white);
    overflow-y: auto;
    flex: 1;
}

.mp-notecard-textarea::-webkit-scrollbar {
    width: 4px;
}

.mp-notecard-textarea::-webkit-scrollbar-track {
    background: transparent;
}

.mp-notecard-textarea::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 2px;
}

.mp-notecard-textarea::-webkit-scrollbar-thumb:hover {
    background: #777;
}

.mp-notecard-textarea::placeholder {
    color: #888;
}

.mp-notecard-empty {
    color: #888;
    font-style: italic;
    cursor: pointer;
}

.mp-notecard-empty:hover {
    color: #aaa;
}

/* Markdown text size classes */
.md-text-S { font-size: 0.7rem; }
.md-text-M { font-size: 0.85rem; }
.md-text-L { font-size: 1rem; }
.md-text-XL { font-size: 1.2rem; }

/* Preview / pretty mode notecard */
.mp-notecard-preview {
    cursor: grab;
}

.mp-notecard-preview:active {
    cursor: grabbing;
}

.mp-notecard-preview-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
    font-size: 0.7rem;
    font-weight: 700;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 5px 10px 0;
}

/* Title-only card: vertically center the label row */
.mp-notecard-title-only {
    display: flex;
    align-items: center;
    min-height: 36px;
}

/* Pin number badge on notecard header */
/* Pin label badge on notecard headers — uses .icon-pill base, overrides size */
.mp-notecard-pin-num {
    min-width: 3em;
    height: 1.6em;
    padding: 0 0.4em;
    border-width: 2px;
    font-size: 0.75rem;
    line-height: 1;
    margin-right: 4px;
    flex-shrink: 0;
}

/* Selected card outline */
.mp-notecard-selected, .mp-pin-selected {
    outline: 2px solid #4fc3f7;
    outline-offset: 2px;
}

/* Align / Distribute floating toolbar */
.mp-align-toolbar {
    position: absolute;
    bottom: 10px;
    right: 10px;
    left: auto;
    z-index: 25;
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 4px 8px;
    background: rgba(30, 30, 30, 0.95);
    border: 1px solid #555;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.mp-align-btn {
    font-size: 0.85rem;
    width: 28px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #555;
    border-radius: 4px;
    background: transparent;
    color: #ccc;
    cursor: pointer;
    transition: background 0.1s, color 0.1s;
    padding: 0;
}

.mp-align-btn:hover:not(:disabled) {
    background: #444;
    color: #fff;
}

.mp-align-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

.mp-align-sep {
    width: 1px;
    height: 20px;
    background: #555;
    margin: 0 3px;
}

.mp-align-toggle {
    display: inline-flex;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.2);
}
.mp-align-toggle-seg {
    background: transparent;
    color: rgba(255,255,255,0.5);
    border: none;
    padding: 2px 8px;
    font-size: 0.7rem;
    cursor: pointer;
    white-space: nowrap;
}
.mp-align-toggle-seg.active {
    background: rgba(255,255,255,0.15);
    color: #fff;
}
.mp-align-toggle-seg:hover:not(.active) {
    background: rgba(255,255,255,0.08);
}

/* Line context popup */
.mp-svg .mp-line-hit { pointer-events: stroke; }
.mp-curve-handle {
    position: absolute;
    transform: translate(-50%, -50%) scale(var(--mp-pin-counter-scale, 1));
    background: #6ecba0;
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: grab;
    z-index: 20;
    pointer-events: auto;
    box-shadow: 0 1px 4px rgba(0,0,0,0.5);
}
.mp-curve-handle:hover {
    background: #8fd8b6;
}
.mp-curve-handle:active {
    cursor: grabbing;
}

.mp-line-popup {
    position: fixed;
    z-index: 10000;
    background: rgba(30, 30, 30, 0.95);
    border: 1px solid #555;
    border-radius: 6px;
    padding: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}
.mp-btn-small {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 0.75rem;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
}
.mp-btn-small:hover {
    background: rgba(255,255,255,0.2);
}

/* Auto Arrange dropdown menu */
.mp-arrange-dropdown {
    z-index: 10000;
    background: rgba(30, 30, 30, 0.97);
    border: 1px solid #555;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.6);
    padding: 4px 0;
    min-width: 200px;
}

.mp-arrange-option {
    display: block;
    width: 100%;
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: #ccc;
    font-size: 0.85rem;
    text-align: left;
    cursor: pointer;
    transition: background 0.1s, color 0.1s;
}

.mp-arrange-option:hover {
    background: #444;
    color: #fff;
}

/* Floating toolbar drag grip */
.mp-float-grip {
    font-size: 1rem;
    color: #666;
    cursor: grab;
    line-height: 1;
    flex-shrink: 0;
    padding: 0 2px;
    user-select: none;
}

.mp-float-grip:active {
    cursor: grabbing;
    color: #aaa;
}

/* Card scale floating control */
.mp-card-scale-toolbar {
    position: absolute;
    bottom: 10px;
    left: 10px;
    z-index: 25;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: rgba(30, 30, 30, 0.95);
    border: 1px solid #555;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.mp-card-scale-label {
    font-family: var(--main-font);
    font-size: 0.7rem;
    color: #888;
    margin-right: 2px;
    white-space: nowrap;
}

.mp-card-scale-value,
.mp-pin-scale-value,
.mp-zoom-value {
    font-family: var(--main-font);
    font-size: 0.75rem;
    color: #ccc;
    min-width: 36px;
    text-align: center;
}

/* ── View Zoom Slider (vertical, left edge) ───────────────── */

.mp-view-zoom-slider {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 25;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 4px;
    background: rgba(30, 30, 30, 0.95);
    border: 1px solid #555;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.mp-view-zoom-label {
    font-family: var(--main-font);
    font-size: 0.65rem;
    color: #888;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.mp-view-zoom-track {
    width: 6px;
    height: 120px;
    background: #444;
    border-radius: 3px;
    position: relative;
    cursor: pointer;
}

.mp-view-zoom-thumb {
    position: absolute;
    left: 50%;
    width: 14px;
    height: 10px;
    background: rgba(255, 255, 255, 0.35);
    border-radius: 3px;
    transform: translate(-50%, -50%);
    cursor: grab;
    pointer-events: none;
}

.mp-view-zoom-pct {
    font-family: var(--main-font);
    font-size: 0.65rem;
    color: #ccc;
    white-space: nowrap;
}

.mp-view-zoom-slider .mp-align-btn {
    width: 22px;
    height: 22px;
    font-size: 0.8rem;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mp-view-zoom-reset {
    font-size: 0.7rem !important;
}

/* ── Pan Scrollbars ───────────────────────────────────────── */

.mp-pan-bar {
    position: absolute;
    z-index: 24;
    transition: opacity 0.2s;
}

.mp-pan-bar-h {
    top: 0;
    left: 40px;
    right: 10px;
    height: 8px;
    cursor: grab;
}

.mp-pan-bar-v {
    right: 0;
    top: 10px;
    bottom: 50px;
    width: 8px;
    cursor: grab;
}

.mp-pan-thumb {
    position: absolute;
    background: rgba(255, 255, 255, 0.35);
    border-radius: 4px;
    transition: background 0.15s;
}

.mp-pan-bar:hover .mp-pan-thumb,
.mp-pan-bar:active .mp-pan-thumb {
    background: rgba(255, 255, 255, 0.55);
}

.mp-pan-bar-h .mp-pan-thumb {
    top: 1px;
    height: 6px;
    min-width: 20px;
}

.mp-pan-bar-v .mp-pan-thumb {
    left: 1px;
    width: 6px;
    min-height: 20px;
}

/* ── Crop Tool ────────────────────────────────────────────── */

.mp-crop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 20;
    background: rgba(0, 0, 0, 0.55);
    pointer-events: none;
}

.mp-crop-bright {
    position: absolute;
    outline: 2px dashed #fff;
    outline-offset: -1px;
    background: transparent;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
    cursor: move;
    pointer-events: auto;
    box-sizing: border-box;
}

.mp-crop-handle {
    position: absolute;
    width: 22px;
    height: 22px;
    background: #fff;
    border: 3px solid #333;
    border-radius: 3px;
    transform: translate(-50%, -50%) scale(var(--mp-crop-handle-scale, 1));
    transform-origin: center center;
    z-index: 21;
    pointer-events: auto;
    box-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

.mp-crop-handle:hover {
    background: #6ecba0;
    border-color: #333;
}

.mp-crop-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

.mp-crop-grid-line {
    position: absolute;
    pointer-events: none;
}

.mp-crop-grid-v {
    width: 1px;
    top: 0;
    background: rgba(255, 255, 255, 0.35);
}

.mp-crop-grid-h {
    height: 1px;
    left: 0;
    background: rgba(255, 255, 255, 0.35);
}

/* Crop control panel — matches card scale toolbar pattern */
.mp-crop-control {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 25;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(30, 30, 30, 0.95);
    border: 1px solid #555;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.5);
    white-space: nowrap;
}

.mp-border-panel {
    top: auto;
    bottom: 60px;
}

.mp-crop-label {
    font-family: var(--main-font);
    font-size: 0.8rem;
    font-weight: 700;
    color: #ccc;
}

.mp-crop-sq-label {
    font-family: var(--main-font);
    font-size: 0.7rem;
    color: #888;
}

.mp-crop-sq-input {
    width: 50px;
    padding: 2px 4px;
    border: 1px solid #555;
    border-radius: 3px;
    background: #222;
    color: #eee;
    font-family: var(--main-font);
    font-size: 0.75rem;
    text-align: center;
}

.mp-crop-sq-input:focus {
    outline: 1px solid #6ecba0;
    border-color: #6ecba0;
}

.mp-crop-dims {
    font-family: var(--main-font);
    font-size: 0.75rem;
    color: #aaa;
}

/* ── Confirm Dialog ────────────────────────────────────── */

.mp-confirm-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
}

.mp-confirm-dialog {
    background: #1e1e1e;
    color: #fff;
    border: 1px solid #555;
    border-radius: 8px;
    padding: 20px 24px;
    min-width: 280px;
    max-width: 360px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.6);
    text-align: center;
}

.mp-confirm-message {
    font-family: var(--main-font);
    font-size: 0.9rem;
    color: #ddd;
    margin: 0 0 16px;
    line-height: 1.4;
}

.mp-confirm-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.mp-confirm-buttons .mp-btn {
    min-width: 80px;
}

/* Export dialog */
.mp-export-dialog {
    max-width: 320px;
    text-align: left;
}
.mp-export-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.mp-export-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.mp-export-label {
    font-family: var(--main-font);
    font-size: 0.85rem;
    color: #bbb;
    min-width: 90px;
    text-align: right;
}
.mp-export-select {
    flex: 1;
    background: #2a2a2a;
    color: #ddd;
    border: 1px solid #555;
    border-radius: 4px;
    padding: 4px 8px;
    font-family: var(--main-font);
    font-size: 0.85rem;
}
.mp-export-select:focus {
    outline: 1px solid #6ecba0;
    border-color: #6ecba0;
}

/* Title card — squared corners, no border, no shadow, border-box sizing */
.mp-notecard-title {
    border: none;
    border-radius: 0;
    box-sizing: border-box;
    box-shadow: none;
    font-size: 1.3rem;
}

.mp-notecard-title.mp-notecard-preview {
    border: none;
    border-radius: 0;
    border-left: none;
    cursor: grab;
}

.mp-notecard-title-label {
    font-family: inherit;
    font-size: inherit;
    font-weight: 700;
    padding: 10px 10px 8px;
    text-align: center;
}

.mp-title-header {
    justify-content: center;
    background: transparent;
    border-bottom: 1px solid rgba(255,255,255,0.15);
    border-radius: 0;
}

.mp-title-input {
    font-size: inherit;
    text-align: center;
    flex: 1;
}

/* Title card anchor position controls */
.mp-title-anchor-row {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.mp-title-anchor-label {
    font-family: var(--main-font);
    font-size: 0.65rem;
    color: #888;
    margin-right: 2px;
}

.mp-title-anchor-btn {
    font-family: var(--main-font);
    font-size: 0.65rem;
    padding: 2px 6px;
    border: 1px solid #555;
    border-radius: 3px;
    background: transparent;
    color: #aaa;
    cursor: pointer;
}

.mp-title-anchor-btn:hover {
    background: #444;
    color: #fff;
}

.mp-title-anchor-btn.active {
    background: #6ecba0;
    color: #000;
    border-color: #6ecba0;
}

.mp-title-delete-btn {
    color: #e53935;
    border-color: #e53935;
}

.mp-title-delete-btn:hover {
    background: #e53935;
    color: #fff;
}

.mp-title-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.15);
    flex-wrap: wrap;
}

.mp-title-ctrl-label {
    font-family: var(--main-font);
    font-size: 0.7rem;
    color: #fff;
    white-space: nowrap;
}

.mp-ctrl-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.mp-ctrl-toggle:hover {
    color: #6ecba0;
}

.mp-title-color-input {
    width: 24px;
    height: 20px;
    border: 1px solid #555;
    border-radius: 3px;
    background: none;
    cursor: pointer;
    padding: 0;
}

.mp-title-color-input::-webkit-color-swatch-wrapper {
    padding: 1px;
}

.mp-title-color-input::-webkit-color-swatch {
    border: none;
    border-radius: 2px;
}

/* Color swatch button with checkerboard for transparency */
.mp-color-swatch {
    width: 24px;
    height: 20px;
    border: 1px solid #555;
    border-radius: 3px;
    cursor: pointer;
    padding: 0;
    background-image:
        linear-gradient(45deg, #444 25%, transparent 25%),
        linear-gradient(-45deg, #444 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #444 75%),
        linear-gradient(-45deg, transparent 75%, #444 75%);
    background-size: 8px 8px;
    background-position: 0 0, 0 4px, 4px -4px, -4px 0px;
    position: relative;
}

/* Color popover */
.mp-color-popover {
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 9999;
}

.mp-color-popover-input {
    width: 100%;
    height: 32px;
    border: 1px solid #555;
    border-radius: 3px;
    background: none;
    cursor: pointer;
    padding: 0;
}

.mp-color-popover-input::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.mp-color-popover-input::-webkit-color-swatch {
    border: none;
    border-radius: 2px;
}

.mp-color-popover-opacity {
    display: flex;
    gap: 2px;
}

.mp-color-popover-opacity .mp-arrange-option {
    flex: 1;
    font-size: 0.65rem;
    padding: 2px 4px;
}

/* ── Template dropdown additions (reuses .mp-arrange-dropdown) ── */

.mp-template-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
}

.mp-template-row:hover {
    background: rgba(255,255,255,0.08);
}

.mp-template-swatch {
    width: 18px;
    height: 18px;
    border-radius: 3px;
    border: 2px solid #333;
    flex-shrink: 0;
}

.mp-template-name {
    flex: 1;
    min-width: 0;
    background: none;
    border: none;
    color: #ccc;
    font-family: var(--main-font);
    font-size: 0.85rem;
    text-align: left;
    cursor: pointer;
    padding: 4px 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mp-template-name:hover {
    color: #6ecba0;
}

.mp-opacity-btn-group {
    display: inline-flex;
    gap: 2px;
}

.mp-opacity-btn {
    background: #444;
    color: #ccc;
    border: 1px solid #666;
    border-radius: 3px;
    padding: 1px 5px;
    font-size: 11px;
    cursor: pointer;
    line-height: 1.4;
}

.mp-opacity-btn:hover {
    background: #555;
}

.mp-opacity-btn.active {
    background: #6ecba0;
    color: #000;
    border-color: #6ecba0;
}

/* ── Notes View panel ── */

.mp-notes-panel {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 400px;
    height: 50%;
    min-height: 200px;
    z-index: 25;
    display: flex;
    flex-direction: column;
    background: rgba(30, 30, 30, 0.95);
    border: 1px solid #555;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
    resize: both;
    overflow: hidden;
}

.mp-notes-panel-header {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 8px;
    background: transparent;
    border-bottom: 1px solid #444;
}

.mp-notes-panel-title {
    font-family: var(--main-font);
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--color-white);
    flex: 1;
}

.mp-notes-textarea {
    flex: 1;
    resize: none;
    background: #1a1a1a;
    color: var(--color-white);
    border: none;
    padding: 12px;
    font-family: monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    outline: none;
    overflow-y: auto;
}

.mp-notes-textarea::-webkit-scrollbar {
    width: 4px;
}

.mp-notes-textarea::-webkit-scrollbar-track {
    background: transparent;
}

.mp-notes-textarea::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 2px;
}

.mp-notes-textarea::-webkit-scrollbar-thumb:hover {
    background: #777;
}

.mp-notes-textarea::placeholder {
    color: #666;
    font-style: italic;
}

/* ── Map Prepper mobile ── */

@media (max-width: 600px) {
    .mp-selection-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 8px;
    }

    .mp-picker-divider {
        width: 100%;
        height: 1px;
    }

    .mp-picker-section {
        flex-direction: column;
        align-items: flex-start;
    }

    .mp-toolbar {
        gap: 4px;
    }

    .mp-btn {
        font-size: 0.75rem;
        padding: 0.3rem 0.5rem;
    }

    .mp-minimap {
        width: 120px !important;
    }

    .mp-notecard {
        min-width: 170px;
        max-width: 260px;
    }

    .mp-color-swatch {
        width: 22px;
        height: 22px;
    }

    .mp-weight-btn {
        width: 32px;
        height: 24px;
    }

    .mp-notes-panel {
        width: 280px;
        height: 40%;
    }
}


/* ── GM campaign page styles (used by campaign-FRR2026-gm.html only) ── */

.dm-secret {
    background: #2a1a1a;
    color: #e0d0d0;
    border-left: 4px solid #c44;
    padding: 0.8em 1em;
    margin: 0.6em 0;
    border-radius: 4px;
}

.dm-secret::before {
    content: "\1F512  DM ONLY";
    display: block;
    font-weight: 700;
    color: #c44;
    font-size: 0.75em;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.4em;
}

.dm-secret p {
    margin: 0.3em 0;
}

.dm-claude {
    background: #1a1a2a;
    color: #d0d0e0;
    border-left: 4px solid #66c;
    padding: 0.8em 1em;
    margin: 0.6em 0;
    border-radius: 4px;
}

.dm-claude::before {
    content: "\1F4A1  CLAUDE SUGGESTION";
    display: block;
    font-weight: 700;
    color: #66c;
    font-size: 0.75em;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.4em;
}

.dm-claude p {
    margin: 0.3em 0;
}

.dm-analysis {
    background: #2a1a1a;
    color: #e0d0d0;
    border-left: 4px solid #c44;
    padding: 0.8em 1em;
    margin: 0.6em 0;
    border-radius: 4px;
}

.dm-analysis::before {
    content: "\1F50D  DM ANALYSIS";
    display: block;
    font-weight: 700;
    color: #c44;
    font-size: 0.75em;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.4em;
}

.dm-analysis p {
    margin: 0.3em 0;
}

.trust-tag {
    display: inline-block;
    background: #1a3a1a;
    color: #6c6;
    padding: 0.1em 0.5em;
    border-radius: 3px;
    font-size: 0.75em;
    font-weight: 700;
    margin-left: 0.3em;
}

