html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

a, .btn-link {
    color: #006bb7;
}

.btn-primary {
    color: #fff;
    background-color: #1b6ec2;
    border-color: #1861ac;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

.content {
    padding-top: 1.1rem;
}

h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* Entry Renderer Tag Colors — per-theme CSS custom properties */

/* Dark Fantasy (default) */
.theme-dark-fantasy {
    --tag-default: #b0bec5;
    --tag-dice: #DAA520;
    --tag-dc: #ef5350;
    --tag-spell: #ce93d8;
    --tag-item: #4fc3f7;
    --tag-condition: #ef5350;
    --tag-skill: #81c784;
    --tag-creature: #ffb74d;
    --tag-action: #90a4ae;
    --tag-readaloud: #ce93d8;
    --tag-quote: #90a4ae;
}

/* Parchment (light theme) */
.theme-parchment {
    --tag-default: #5d4037;
    --tag-dice: #8B4513;
    --tag-dc: #c62828;
    --tag-spell: #7b1fa2;
    --tag-item: #0277bd;
    --tag-condition: #c62828;
    --tag-skill: #2e7d32;
    --tag-creature: #e65100;
    --tag-action: #546e7a;
    --tag-readaloud: #7b1fa2;
    --tag-quote: #546e7a;
}

/* Crimson Night */
.theme-crimson-night {
    --tag-default: #e0b0b0;
    --tag-dice: #ff6b6b;
    --tag-dc: #ff4444;
    --tag-spell: #e090c0;
    --tag-item: #80d0e0;
    --tag-condition: #ff4444;
    --tag-skill: #90c890;
    --tag-creature: #ffb070;
    --tag-action: #b0a0a0;
    --tag-readaloud: #e090c0;
    --tag-quote: #b0a0a0;
}

/* Forest Grove */
.theme-forest-grove {
    --tag-default: #a0c0a0;
    --tag-dice: #8bc34a;
    --tag-dc: #ff7043;
    --tag-spell: #b39ddb;
    --tag-item: #4dd0e1;
    --tag-condition: #ff7043;
    --tag-skill: #66bb6a;
    --tag-creature: #ffa726;
    --tag-action: #8aa88a;
    --tag-readaloud: #b39ddb;
    --tag-quote: #8aa88a;
}

/* Ocean Depths */
.theme-ocean-depths {
    --tag-default: #90c0d0;
    --tag-dice: #4dd0e1;
    --tag-dc: #ef5350;
    --tag-spell: #b39ddb;
    --tag-item: #80deea;
    --tag-condition: #ef5350;
    --tag-skill: #80cbc4;
    --tag-creature: #ffb74d;
    --tag-action: #80aab0;
    --tag-readaloud: #b39ddb;
    --tag-quote: #80aab0;
}

/* Entry Renderer Styles */
.entry-tag { color: var(--tag-default, #b0bec5); }
.entry-tag-bold { font-weight: bold; }
.entry-tag-italic { font-style: italic; }
.entry-tag-dice { color: var(--tag-dice, #DAA520); font-weight: 600; }
.entry-tag-dc { color: var(--tag-dc, #ef5350); font-weight: 600; }
.entry-tag-spell { color: var(--tag-spell, #ce93d8); cursor: help; border-bottom: 1px dotted var(--tag-spell, #ce93d8); }
.entry-tag-item { color: var(--tag-item, #4fc3f7); cursor: help; border-bottom: 1px dotted var(--tag-item, #4fc3f7); }
.entry-tag-condition { color: var(--tag-condition, #ef5350); cursor: help; border-bottom: 1px dotted var(--tag-condition, #ef5350); }
.entry-tag-skill { color: var(--tag-skill, #81c784); }
.entry-tag-creature { color: var(--tag-creature, #ffb74d); cursor: help; }
.entry-tag-action { color: var(--tag-action, #90a4ae); }

.entry-inset {
    border-left: 3px solid var(--mud-palette-primary);
    background: rgba(255,255,255,0.03);
    border-radius: 4px;
}

.entry-readaloud {
    border-left: 3px solid var(--tag-readaloud, #ce93d8);
    background: rgba(206,147,216,0.05);
    border-radius: 4px;
    font-style: italic;
}

.entry-quote {
    border-left: 3px solid var(--tag-quote, #90a4ae);
    font-style: italic;
}

.entry-quote-by {
    font-style: normal;
    color: var(--tag-quote, #90a4ae);
    font-size: 0.9em;
}

.entry-list { padding-left: 1.5rem; }
.entry-list li { margin-bottom: 0.25rem; }

.entry-table { overflow-x: auto; }
.entry-table table { width: 100%; border-collapse: collapse; }
.entry-table th, .entry-table td { padding: 4px 8px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.entry-table th { font-weight: 600; color: var(--mud-palette-primary); }
.entry-table-caption { font-size: 1.1em; }

/* Responsive Layout Improvements */

/* Tables: horizontal scroll on small screens */
.mud-table, .mud-simple-table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Character sheet stat boxes: constrain on small screens */
@media (max-width: 599px) {
    /* Compact header stats on mobile */
    .stat-box-row {
        gap: 0.5rem !important;
    }

    .stat-box-row > div {
        min-width: 50px;
    }

    /* Reduce padding on mobile */
    .mud-paper.pa-4 {
        padding: 12px !important;
    }

    /* Portrait: smaller on mobile */
    .mud-avatar.mud-avatar-large {
        width: 60px !important;
        height: 60px !important;
    }

    /* Compact tab text */
    .mud-tab {
        min-width: auto !important;
        padding: 6px 10px !important;
        font-size: 0.8rem !important;
    }

    /* Reduce font size in tables */
    .mud-simple-table td, .mud-simple-table th {
        font-size: 0.85rem;
        padding: 4px 6px;
    }
}

/* Medium screens: slightly more breathing room */
@media (min-width: 600px) and (max-width: 959px) {
    .mud-tab {
        min-width: auto !important;
        padding: 6px 14px !important;
    }
}

/* Character list cards: responsive portrait images */
.character-card-portrait {
    max-width: 100%;
    height: auto;
    object-fit: cover;
}

/* Click-to-roll interactive elements */
.clickable-roll {
    cursor: pointer;
    transition: background-color 0.15s ease;
    border-radius: 4px;
}
.clickable-roll:hover {
    background-color: rgba(var(--mud-palette-primary-rgb), 0.08);
}

/* Print-friendly character sheet */
@media print {
    /* Hide all UI chrome */
    .mud-drawer, .mud-appbar, .mud-fab,
    .mud-tabs-header, .mud-snackbar-provider,
    .no-print, .mud-dialog-provider,
    button, .mud-button, .mud-icon-button {
        display: none !important;
    }

    /* Reset layout */
    .mud-main-content {
        margin-left: 0 !important;
        padding: 8px !important;
    }

    .mud-layout {
        display: block !important;
    }

    /* Paper styling */
    .mud-paper {
        box-shadow: none !important;
        border: 1px solid #999;
        break-inside: avoid;
    }

    /* Force light colors for print */
    body, .mud-main-content, .mud-paper {
        background: white !important;
        color: black !important;
    }

    .mud-text-primary, .mud-typography {
        color: black !important;
    }

    .mud-text-secondary {
        color: #555 !important;
    }

    /* Character sheet specifics */
    .mud-tabs {
        border: none !important;
    }

    .mud-tab-panel {
        display: block !important;
        visibility: visible !important;
        padding: 0 !important;
    }

    /* Show all tab panels for print */
    .print-all-tabs .mud-tabs .mud-tab-panel {
        display: block !important;
    }

    /* Table styling */
    .mud-table, .mud-simple-table {
        border-collapse: collapse;
    }

    .mud-table td, .mud-table th,
    .mud-simple-table td, .mud-simple-table th {
        border: 1px solid #ccc !important;
        padding: 2px 6px !important;
        font-size: 10pt !important;
    }

    /* Chips */
    .mud-chip {
        border: 1px solid #999 !important;
        background: transparent !important;
        color: black !important;
        font-size: 9pt !important;
    }

    /* Compact spacing */
    .mud-grid-item {
        padding: 4px !important;
    }

    /* Page breaks */
    .print-page-break {
        page-break-before: always;
    }

    /* Font sizes */
    .mud-typography-h4 { font-size: 16pt !important; }
    .mud-typography-h5 { font-size: 14pt !important; }
    .mud-typography-h6 { font-size: 12pt !important; }
    .mud-typography-body1 { font-size: 10pt !important; }
    .mud-typography-body2 { font-size: 9pt !important; }
    .mud-typography-caption { font-size: 8pt !important; }

    /* Page setup */
    @page {
        margin: 0.5in;
        size: letter;
    }
}

/* ============================================================
   DDB-style character sheet (Phase 1: top banner + stats row)
   ============================================================ */

.dnd-banner {
    background: #1a1a1a;
    color: #f5f5f5;
    padding: 12px 24px;
    border-radius: 4px;
    margin-bottom: 16px;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    align-items: center;
    gap: 16px;
}

.dnd-banner-left {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.dnd-banner-center {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 16px;
    row-gap: 6px;
    justify-items: stretch;
    align-items: center;
    min-width: 0;
}

.dnd-banner-center > * {
    width: 100%;
}

.dnd-portrait-frame {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: #333;
    border: 2px solid #555;
}

.dnd-portrait-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.dnd-name {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.1;
    margin: 0;
    color: #f5f5f5;
    letter-spacing: 0.01em;
}

.dnd-subtitle {
    font-size: 0.85rem;
    color: #b0b0b0;
    margin-top: 2px;
}

.dnd-xp-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: #888;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-top: 4px;
}

.dnd-banner-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

/* The banner is always dark (#1a1a1a) regardless of theme. Force all
   inline buttons / icon buttons / menus to contrast against it so themes
   like Parchment don't render dark-on-dark and disappear. */
.dnd-banner .mud-button-root,
.dnd-banner .mud-icon-button,
.dnd-banner .mud-menu .mud-button-root {
    color: #f5f5f5 !important;
}
.dnd-banner .mud-button-outlined,
.dnd-banner .mud-icon-button-outlined {
    border-color: rgba(245, 245, 245, 0.45) !important;
}
.dnd-banner .mud-button-outlined:hover,
.dnd-banner .mud-icon-button-outlined:hover {
    border-color: #f5f5f5 !important;
    background: rgba(255, 255, 255, 0.08) !important;
}
.dnd-banner .mud-button-root .mud-icon-root,
.dnd-banner .mud-icon-button .mud-icon-root {
    color: inherit !important;
}
/* Filled / primary-color buttons keep their theme background but need
   readable text — pick light or dark text based on perceived brightness
   via a contrast variable. Filled buttons in the banner are e.g. Level Up
   (Warning) and Save (Primary); Mud already chooses readable text for
   those, so leave them alone — only override when no Color is set
   (Color.Default falls to white text via the rule above). */

.dnd-stat-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: stretch;
    margin-bottom: 16px;
    padding: 0 4px;
}

/* Ability score box (label / big number / mod pill hanging below) */
.dnd-ability-box {
    border: 1.5px solid var(--mud-palette-error, #c92a2a);
    border-radius: 4px;
    padding: 6px 14px 18px;
    text-align: center;
    background: var(--mud-palette-surface, #fff);
    position: relative;
    min-width: 88px;
    font-variant-numeric: tabular-nums;
    transition: background-color 0.15s ease;
}
.dnd-ability-box.clickable-roll:hover {
    background: rgba(var(--mud-palette-primary-rgb), 0.08);
}
.dnd-ability-box .label {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--mud-palette-text-secondary, #555);
}
.dnd-ability-box .score {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.1;
    margin-top: 2px;
}
.dnd-mod-pill {
    position: absolute;
    bottom: -13px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--mud-palette-surface, #fff);
    border: 1.5px solid var(--mud-palette-error, #c92a2a);
    border-radius: 14px;
    padding: 1px 14px;
    font-size: 0.95rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Generic small stat card (Proficiency, Speed) */
.dnd-stat-card {
    border: 1.5px solid var(--mud-palette-error, #c92a2a);
    border-radius: 4px;
    padding: 6px 12px;
    text-align: center;
    background: var(--mud-palette-surface, #fff);
    min-width: 100px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    transition: background-color 0.15s ease;
}
.dnd-stat-card.clickable-roll:hover {
    background: rgba(var(--mud-palette-primary-rgb), 0.08);
}
.dnd-stat-card .label {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--mud-palette-text-secondary, #555);
}
.dnd-stat-card .value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}
.dnd-stat-card .value-suffix {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--mud-palette-text-secondary, #777);
}
.dnd-stat-card .sublabel {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--mud-palette-text-secondary, #777);
    margin-top: 2px;
}

/* Heroic Inspiration — compact diamond with a tooltip-bound label */
.dnd-inspiration {
    border: 1.5px solid var(--mud-palette-error, #c92a2a);
    border-radius: 4px;
    padding: 6px 10px;
    text-align: center;
    background: var(--mud-palette-surface, #fff);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    min-width: 0;
}
.dnd-inspiration .icon {
    width: 16px;
    height: 16px;
    background: transparent;
    border: 1.5px solid var(--mud-palette-text-secondary, #888);
    transform: rotate(45deg);
    border-radius: 2px;
    margin-bottom: 2px;
}
.dnd-inspiration.active .icon {
    background: var(--mud-palette-warning, #d4a017);
    border-color: var(--mud-palette-warning, #d4a017);
}
.dnd-inspiration .sublabel {
    font-size: 0.55rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--mud-palette-text-secondary, #777);
    line-height: 1.1;
}

/* HP card — the big right-side one */
.dnd-hp-card {
    border: 1.5px solid var(--mud-palette-error, #c92a2a);
    border-radius: 4px;
    padding: 6px 14px;
    background: var(--mud-palette-surface, #fff);
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 320px;
}
.dnd-hp-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.dnd-hp-action-btn {
    border: 1px solid var(--mud-palette-error, #c92a2a);
    background: transparent;
    color: var(--mud-palette-error, #c92a2a);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 2px 10px;
    border-radius: 12px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}
.dnd-hp-action-btn.heal { color: var(--mud-palette-success, #4caf50); border-color: var(--mud-palette-success, #4caf50); }
.dnd-hp-action-btn:hover { background: rgba(var(--mud-palette-primary-rgb), 0.08); }

.dnd-hp-values {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-left: auto;
}
.dnd-hp-cell { display: flex; flex-direction: column; align-items: center; }
.dnd-hp-cell .label {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--mud-palette-text-secondary, #777);
}
.dnd-hp-cell .value {
    font-size: 1.7rem;
    font-weight: 700;
    line-height: 1.05;
    font-variant-numeric: tabular-nums;
}
.dnd-hp-slash {
    font-size: 1.7rem;
    color: var(--mud-palette-text-secondary, #888);
    align-self: center;
    padding: 0 2px;
}
.dnd-hp-card .sublabel {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--mud-palette-text-secondary, #777);
    margin-left: 8px;
    align-self: center;
}

/* ============================================================
   Phase 2: Three-column body
   ============================================================ */

/* Skills column — vertical scrollable list, DDB-style. */
.dnd-skills-card {
    border: 1.5px solid var(--mud-palette-error, #c92a2a);
    border-radius: 4px;
    background: var(--mud-palette-surface, #fff);
    overflow: hidden;
}
.dnd-skills-header {
    display: grid;
    grid-template-columns: 32px 36px 1fr 56px;
    gap: 4px;
    padding: 8px 12px 4px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--mud-palette-text-secondary, #777);
    border-bottom: 1px solid var(--mud-palette-divider);
}
.dnd-skill-row {
    display: grid;
    grid-template-columns: 32px 36px 1fr 56px;
    gap: 4px;
    align-items: center;
    padding: 6px 12px;
    cursor: pointer;
    transition: background-color 0.15s ease;
    border-bottom: 1px solid var(--mud-palette-divider);
}
.dnd-skill-row:last-child { border-bottom: none; }
.dnd-skill-row:hover { background: rgba(var(--mud-palette-primary-rgb), 0.06); }
.dnd-skill-prof {
    width: 14px; height: 14px; border-radius: 50%;
    border: 1.5px solid var(--mud-palette-text-secondary, #888);
    display: inline-block; margin: 0 auto;
}
.dnd-skill-prof.proficient {
    background: var(--mud-palette-text-primary, #1a1a1a);
    border-color: var(--mud-palette-text-primary, #1a1a1a);
}
.dnd-skill-prof.expertise {
    background: radial-gradient(circle, var(--mud-palette-warning, #d4a017) 40%, var(--mud-palette-text-primary, #1a1a1a) 42%);
    border-color: var(--mud-palette-warning, #d4a017);
}
.dnd-skill-ability {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--mud-palette-text-secondary, #888);
    text-transform: uppercase;
}
.dnd-skill-name { font-size: 0.95rem; }
.dnd-skill-bonus {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    text-align: right;
    font-size: 1rem;
}
.dnd-card-footer {
    text-align: center;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--mud-palette-text-secondary, #777);
    padding: 8px;
    border-top: 1px solid var(--mud-palette-divider);
    background: var(--mud-palette-surface, #fff);
}

/* Defenses card row at the top of the right column. */
.dnd-defenses-row {
    display: flex;
    gap: 12px;
    align-items: stretch;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.dnd-defenses-row .dnd-stat-card { min-width: 110px; }
.dnd-defenses-card {
    flex: 1 1 240px;
    border: 1.5px solid var(--mud-palette-error, #c92a2a);
    border-radius: 4px;
    background: var(--mud-palette-surface, #fff);
    padding: 10px 14px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 16px;
}
.dnd-defenses-card h4 {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--mud-palette-text-secondary, #555);
    margin: 0 0 4px;
}
.dnd-defenses-card .empty-msg {
    font-size: 0.8rem;
    color: var(--mud-palette-text-secondary, #888);
}

/* ============================================================
   Phase 3: Cartouche card styling
   ============================================================ */

/* Wraps a sidebar/middle-column section so it gets a section-title
   "footer" sitting on the bottom border, plus corner ornaments. */
.dnd-card {
    position: relative;
    border: 1.5px solid var(--mud-palette-error, #c92a2a);
    border-radius: 4px;
    background: var(--mud-palette-surface, #fff);
    padding: 14px 16px 28px;          /* extra bottom space for the title */
    margin-bottom: 18px;
}
.dnd-card.no-footer { padding-bottom: 14px; }

/* Centered uppercase section title overlapping the bottom border */
.dnd-card-title {
    position: absolute;
    left: 50%;
    bottom: -10px;
    transform: translateX(-50%);
    background: var(--mud-palette-surface, #fff);
    padding: 0 12px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--mud-palette-text-secondary, #555);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.dnd-card-title .gear {
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.15s ease;
}
.dnd-card-title .gear:hover { opacity: 1; }

/* Subtle corner ornaments — small inward tick marks on each corner */
.dnd-card::before,
.dnd-card::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    border: 1.5px solid var(--mud-palette-error, #c92a2a);
    pointer-events: none;
}
.dnd-card::before {
    top: -1.5px;
    left: -1.5px;
    border-right: none;
    border-bottom: none;
    border-top-left-radius: 4px;
}
.dnd-card::after {
    top: -1.5px;
    right: -1.5px;
    border-left: none;
    border-bottom: none;
    border-top-right-radius: 4px;
}

/* Bottom corners get matching ornaments via a wrapper hack — use
   a child element since we've used both pseudos for the top. */
.dnd-card-corners-bottom {
    position: absolute;
    inset: auto 0 -1.5px 0;
    height: 8px;
    pointer-events: none;
}
.dnd-card-corners-bottom::before,
.dnd-card-corners-bottom::after {
    content: '';
    position: absolute;
    bottom: 0;
    width: 8px;
    height: 8px;
    border: 1.5px solid var(--mud-palette-error, #c92a2a);
}
.dnd-card-corners-bottom::before {
    left: -1.5px;
    border-right: none;
    border-top: none;
    border-bottom-left-radius: 4px;
}
.dnd-card-corners-bottom::after {
    right: -1.5px;
    border-left: none;
    border-top: none;
    border-bottom-right-radius: 4px;
}

/* Global cartouche skin: red border on every card on the sheet, drop the
   default elevation shadow. Less invasive than rewriting every section. */
.character-sheet-skin .mud-paper.mud-elevation-4,
.character-sheet-skin .mud-paper.mud-elevation-2 {
    border: 1.5px solid var(--mud-palette-error, #c92a2a);
    box-shadow: none !important;
    background: var(--mud-palette-surface, #fff);
}
.character-sheet-skin .mud-paper.mud-elevation-6 {
    border: 2px solid var(--mud-palette-warning, #d4a017);
    box-shadow: none !important;
}
/* Sidebar/section h6 titles — uppercase + tracked + smaller, more like
   DDB's section labels than full headings. */
.character-sheet-skin .mud-paper > .mud-typography-h6:first-child {
    font-size: 0.85rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.08em !important;
    text-transform: uppercase !important;
    color: var(--mud-palette-text-secondary, #555) !important;
    margin-bottom: 10px !important;
}
/* Lift Skills card spacing to match the rest. */
.dnd-skills-card { margin-bottom: 18px; }