.zgm-screen {
    --zgm-bg: #0a0a0a;
    --zgm-surface: #131313;
    --zgm-surface-low: #1c1b1b;
    --zgm-surface-high: #2a2a2a;
    --zgm-surface-highest: #353534;
    --zgm-gold: #b8860b;
    --zgm-gold-bright: #f7bd48;
    --zgm-crimson: #8b0000;
    --zgm-crimson-bright: #b52619;
    --zgm-parchment: #f5f5dc;
    --zgm-muted: #e3beb8;
    --zgm-border: #5a403c;
    --zgm-error: #ffb4ab;
    color: var(--zgm-parchment);
    margin: 0 auto;
    max-width: 1200px;
    padding: 0 1rem 3rem;
}

.zgm-screen *,
.zgm-dialog * {
    box-sizing: border-box;
}

.zgm-screen button,
.zgm-screen input,
.zgm-screen select,
.zgm-screen textarea,
.zgm-dialog button,
.zgm-dialog input,
.zgm-dialog select,
.zgm-dialog textarea {
    border-radius: 0;
}

.zgm-hero,
.zgm-toolbar,
.zgm-panel,
.zgm-dialog-frame {
    background:
        linear-gradient(135deg, rgba(184, 134, 11, 0.08), transparent 34%),
        linear-gradient(180deg, var(--zgm-surface), var(--zgm-bg));
    border: 1px solid var(--zgm-border);
    box-shadow:
        inset 0 0 0 1px rgba(184, 134, 11, 0.18),
        0 0 48px rgba(0, 0, 0, 0.48);
}

.zgm-hero {
    align-items: flex-end;
    border-width: 3px;
    display: flex;
    gap: 2rem;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding: clamp(1.25rem, 4vw, 2.5rem);
}

.zgm-hero h1,
.zgm-panel h2,
.zgm-dialog h2 {
    color: var(--zgm-parchment);
    font-family: "Noto Serif", Georgia, serif;
    line-height: 1.05;
    margin: 0;
}

.zgm-hero h1 {
    font-size: clamp(2rem, 6vw, 4rem);
    letter-spacing: -0.04em;
}

.zgm-hero p:not(.zgm-kicker) {
    color: var(--zgm-muted);
    font-family: "Source Serif 4", Georgia, serif;
    font-size: 1.08rem;
    line-height: 1.65;
    margin: 1rem 0 0;
    max-width: 760px;
}

.zgm-kicker {
    color: var(--zgm-gold-bright);
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    margin: 0 0 0.45rem;
    text-transform: uppercase;
}

.zgm-hero-status {
    align-items: center;
    color: var(--zgm-muted);
    display: inline-flex;
    flex: 0 0 auto;
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.7rem;
    gap: 0.55rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.zgm-status-light {
    background: var(--zgm-gold-bright);
    box-shadow: 0 0 12px rgba(247, 189, 72, 0.65);
    display: inline-block;
    height: 0.65rem;
    width: 0.65rem;
}

.zgm-hero-status[data-state="dirty"] .zgm-status-light {
    background: var(--zgm-crimson-bright);
    box-shadow: 0 0 12px rgba(181, 38, 25, 0.75);
}

.zgm-toolbar {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    margin-bottom: 1rem;
    padding: 0.85rem;
    position: sticky;
    top: 0;
    z-index: 20;
}

.zgm-button,
.zgm-icon-button,
.zgm-drag-handle {
    cursor: pointer;
    font-family: "JetBrains Mono", Consolas, monospace;
    font-weight: 700;
    text-transform: uppercase;
}

.zgm-button {
    background: linear-gradient(180deg, var(--zgm-gold-bright), var(--zgm-gold));
    border: 1px solid #412d00;
    clip-path: polygon(0.65rem 0, 100% 0, 100% calc(100% - 0.65rem), calc(100% - 0.65rem) 100%, 0 100%, 0 0.65rem);
    color: #271900;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    min-height: 2.5rem;
    padding: 0.7rem 0.9rem;
}

.zgm-button:hover,
.zgm-button:focus-visible,
.zgm-icon-button:hover,
.zgm-icon-button:focus-visible,
.zgm-drag-handle:hover,
.zgm-drag-handle:focus-visible {
    box-shadow: 0 0 0 2px rgba(181, 38, 25, 0.72);
    outline: none;
}

.zgm-button:disabled,
.zgm-icon-button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.zgm-button-secondary {
    background: linear-gradient(180deg, var(--zgm-surface-highest), #201f1f);
    border-color: var(--zgm-border);
    color: var(--zgm-parchment);
}

.zgm-button-danger {
    background: linear-gradient(180deg, var(--zgm-crimson-bright), var(--zgm-crimson));
    border-color: #410000;
    color: var(--zgm-parchment);
}

.zgm-dashboard {
    --zgm-masonry-row: 8px;
    align-items: start;
    display: grid;
    grid-auto-flow: row;
    grid-auto-rows: var(--zgm-masonry-row);
    grid-template-columns: repeat(12, minmax(0, 1fr));
    column-gap: 1rem;
    row-gap: 1rem;
}

.zgm-panel {
    align-self: start;
    container-type: inline-size;
    display: flex;
    flex-direction: column;
    grid-column: span 6;
    min-width: 0;
    position: relative;
    transition: border-color 140ms ease, opacity 140ms ease, transform 140ms ease;
}

.zgm-panel[data-panel-size="quarter"] {
    grid-column: span 3;
}

.zgm-panel[data-panel-size="compact"] {
    grid-column: span 4;
}

.zgm-panel[data-panel-size="standard"] {
    grid-column: span 6;
}

.zgm-panel[data-panel-size="two-thirds"] {
    grid-column: span 8;
}

.zgm-panel[data-panel-size="three-quarters"] {
    grid-column: span 9;
}

.zgm-panel[data-panel-size="wide"] {
    grid-column: 1 / -1;
}

.zgm-dashboard[data-layout-mode="single"] .zgm-panel,
.zgm-dashboard[data-layout-mode="single"] .zgm-panel[data-panel-size="quarter"],
.zgm-dashboard[data-layout-mode="single"] .zgm-panel[data-panel-size="compact"],
.zgm-dashboard[data-layout-mode="single"] .zgm-panel[data-panel-size="standard"],
.zgm-dashboard[data-layout-mode="single"] .zgm-panel[data-panel-size="two-thirds"],
.zgm-dashboard[data-layout-mode="single"] .zgm-panel[data-panel-size="three-quarters"],
.zgm-dashboard[data-layout-mode="single"] .zgm-panel[data-panel-size="wide"] {
    grid-column: 1 / -1;
}

.zgm-panel.is-dragging {
    opacity: 0.35;
}

.zgm-panel.is-drag-target {
    border-color: var(--zgm-gold-bright);
    transform: translateY(3px);
}

.zgm-panel[data-collapsed="true"] .zgm-panel-body {
    display: none;
}

.zgm-panel-header {
    align-items: center;
    border-bottom: 1px solid var(--zgm-border);
    cursor: grab;
    display: grid;
    gap: 0.75rem;
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 0.85rem;
    user-select: none;
}

.zgm-panel-heading {
    align-items: center;
    display: flex;
    gap: 0.55rem;
    min-width: 0;
}

.zgm-panel-title-icon {
    color: var(--zgm-gold-bright);
    flex: 0 0 auto;
    font-size: 1.45rem;
    line-height: 1;
}

.zgm-panel h2 {
    color: var(--zgm-crimson-bright);
    font-size: clamp(1.25rem, 2.5vw, 1.65rem);
    overflow-wrap: anywhere;
}

.zgm-panel-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    justify-content: flex-end;
}

.zgm-icon-button,
.zgm-drag-handle {
    align-items: center;
    background: var(--zgm-surface-high);
    border: 1px solid var(--zgm-border);
    color: var(--zgm-parchment);
    display: inline-flex;
    font-size: 0.85rem;
    height: 2rem;
    justify-content: center;
    padding: 0;
    width: 2rem;
}

.zgm-drag-handle {
    color: var(--zgm-gold-bright);
    cursor: grab;
    font-size: 1.15rem;
}

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

.zgm-panel-header:active {
    cursor: grabbing;
}

.zgm-panel-actions {
    cursor: default;
}

.zgm-icon-button .material-symbols-outlined {
    font-size: 1.15rem;
}

.zgm-icon-button-danger {
    background: var(--zgm-crimson);
}

.zgm-panel.is-resizing {
    border-color: var(--zgm-gold-bright);
    box-shadow:
        inset 0 0 0 1px rgba(247, 189, 72, 0.36),
        0 0 22px rgba(247, 189, 72, 0.18);
    transition: none;
}

.zgm-panel-resize-handle {
    position: absolute;
    z-index: 9;
    touch-action: none;
}

.zgm-panel-resize-handle::after {
    background: transparent;
    content: "";
    position: absolute;
    transition: background 120ms ease, box-shadow 120ms ease;
}

.zgm-panel-resize-handle-left,
.zgm-panel-resize-handle-right {
    bottom: 0;
    cursor: ew-resize;
    top: 0;
    width: 0.55rem;
}

.zgm-panel-resize-handle-left {
    left: -0.28rem;
}

.zgm-panel-resize-handle-right {
    right: -0.28rem;
}

.zgm-panel-resize-handle-left::after,
.zgm-panel-resize-handle-right::after {
    bottom: 0.4rem;
    top: 0.4rem;
    width: 2px;
}

.zgm-panel-resize-handle-left::after {
    left: calc(50% - 1px);
}

.zgm-panel-resize-handle-right::after {
    right: calc(50% - 1px);
}

.zgm-panel-resize-handle-bottom {
    bottom: -0.28rem;
    cursor: ns-resize;
    height: 0.55rem;
    left: 0;
    right: 0;
}

.zgm-panel-resize-handle-bottom::after {
    bottom: calc(50% - 1px);
    height: 2px;
    left: 0.4rem;
    right: 0.4rem;
}

.zgm-panel-resize-handle:hover::after,
.zgm-panel-resize-handle:focus-visible::after,
.zgm-panel.is-resizing .zgm-panel-resize-handle::after {
    background: var(--zgm-gold-bright);
    box-shadow: 0 0 8px rgba(247, 189, 72, 0.72);
}

.zgm-panel-resize-handle:focus-visible {
    outline: 1px solid var(--zgm-gold-bright);
    outline-offset: -1px;
}

.zgm-panel[data-collapsed="true"] .zgm-panel-resize-handle-bottom,
.zgm-panel.is-dock-flyout-panel .zgm-panel-resize-handle,
.zgm-dashboard[data-layout-mode="single"] .zgm-panel-resize-handle-left,
.zgm-dashboard[data-layout-mode="single"] .zgm-panel-resize-handle-right {
    display: none;
}

body.zgm-panel-resizing-horizontal,
body.zgm-panel-resizing-horizontal * {
    cursor: ew-resize !important;
    user-select: none !important;
}

body.zgm-panel-resizing-vertical,
body.zgm-panel-resizing-vertical * {
    cursor: ns-resize !important;
    user-select: none !important;
}

.zgm-panel-body {
    flex: 1 1 auto;
    min-height: 0;
    padding: 1rem;
}

.zgm-field {
    color: var(--zgm-muted);
    display: grid;
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.68rem;
    gap: 0.35rem;
    letter-spacing: 0.07em;
    min-width: 0;
    text-transform: uppercase;
}

.zgm-field input,
.zgm-field select,
.zgm-field textarea,
.zgm-monster-table input,
.zgm-monster-table textarea {
    background: var(--zgm-bg);
    border: 0;
    border-bottom: 1px solid var(--zgm-gold);
    color: var(--zgm-parchment);
    font-family: "Source Serif 4", Georgia, serif;
    font-size: 1rem;
    line-height: 1.4;
    min-width: 0;
    padding: 0.6rem 0.55rem;
    width: 100%;
}

.zgm-field input:focus,
.zgm-field select:focus,
.zgm-field textarea:focus,
.zgm-monster-table input:focus,
.zgm-monster-table textarea:focus {
    border-bottom-color: var(--zgm-gold-bright);
    box-shadow: 0 2px 0 var(--zgm-crimson-bright);
    outline: none;
}

.zgm-field textarea,
.zgm-monster-table textarea {
    resize: vertical;
}

.zgm-field input[type="color"] {
    cursor: pointer;
    height: 2.7rem;
    padding: 0.2rem;
}

.zgm-field-grid {
    display: grid;
    gap: 0.85rem;
}

.zgm-field-grid-two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.zgm-field-grid-stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin: 1rem 0;
}

.zgm-field-grid-dice {
    align-items: end;
    grid-template-columns: minmax(0, 1fr) minmax(85px, 0.3fr) auto;
}

.zgm-button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
}

.zgm-check-row {
    align-items: flex-start;
    color: var(--zgm-muted);
    cursor: pointer;
    display: flex;
    font-family: "Source Serif 4", Georgia, serif;
    gap: 0.55rem;
    line-height: 1.4;
    margin-top: 0.85rem;
}

.zgm-check-row input {
    accent-color: var(--zgm-crimson);
    margin-top: 0.25rem;
}

.zgm-treasure-stage {
    align-items: stretch;
    display: grid;
    gap: 0.85rem;
    grid-template-columns: minmax(105px, 0.72fr) minmax(130px, 1fr);
}

.zgm-card-stack,
.zgm-card-result {
    background: #0e0e0e;
    border: 1px solid var(--zgm-surface-high);
    margin: 0;
    min-width: 0;
    padding: 0.65rem;
    text-align: center;
}

.zgm-card-stack {
    color: var(--zgm-gold-bright);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.7rem;
    gap: 0.45rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.zgm-card-stack:hover,
.zgm-card-stack:focus-visible {
    border-color: var(--zgm-gold);
    outline: 2px solid rgba(184, 134, 11, 0.32);
    outline-offset: 2px;
}

.zgm-card-stack img,
.zgm-card-result img {
    display: block;
    height: auto;
    margin: 0 auto;
    max-height: 270px;
    max-width: 100%;
    object-fit: contain;
}

.zgm-card-result figcaption {
    color: var(--zgm-muted);
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.7rem;
    letter-spacing: 0.04em;
    margin-top: 0.55rem;
    text-transform: uppercase;
}

.zgm-card-result figcaption[data-card-type="hazard"] {
    color: var(--zgm-error);
}

.zgm-card-result figcaption[data-card-type="treasure"] {
    color: var(--zgm-gold-bright);
}

.zgm-meter {
    margin: 0.85rem 0;
}

.zgm-meter > span {
    color: var(--zgm-muted);
    display: block;
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.68rem;
    letter-spacing: 0.07em;
    margin-bottom: 0.4rem;
    text-transform: uppercase;
}

.zgm-meter-track {
    background: var(--zgm-bg);
    border: 1px solid var(--zgm-border);
    height: 0.7rem;
    overflow: hidden;
}

.zgm-meter-track span {
    background: linear-gradient(90deg, var(--zgm-crimson), var(--zgm-gold));
    display: block;
    height: 100%;
    transition: width 160ms ease;
}

.zgm-stat-grid {
    display: grid;
    gap: 0.65rem;
    margin: 0.85rem 0;
}

.zgm-stat-grid-three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.zgm-stat-grid div {
    background: rgba(0, 0, 0, 0.24);
    border: 1px solid var(--zgm-surface-high);
    padding: 0.55rem;
}

.zgm-stat-grid dt {
    color: var(--zgm-muted);
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.62rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.zgm-stat-grid dd {
    color: var(--zgm-parchment);
    font-family: "Noto Serif", Georgia, serif;
    font-size: 1.45rem;
    line-height: 1;
    margin: 0.3rem 0 0;
}

.zgm-details {
    border-top: 1px solid var(--zgm-border);
    margin-top: 0.9rem;
    padding-top: 0.75rem;
}

.zgm-details summary {
    color: var(--zgm-gold-bright);
    cursor: pointer;
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.zgm-history {
    display: grid;
    gap: 0.45rem;
    list-style: none;
    margin: 0.75rem 0 0;
    padding: 0;
}

.zgm-history li {
    border-left: 3px solid var(--zgm-gold);
    color: var(--zgm-muted);
    font-family: "Source Serif 4", Georgia, serif;
    padding: 0.45rem 0.55rem;
}

.zgm-history li[data-card-type="hazard"] {
    border-left-color: var(--zgm-crimson-bright);
}

.zgm-dice-results {
    align-items: center;
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid var(--zgm-surface-high);
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    justify-content: center;
    margin-top: 0.85rem;
    min-height: 7.2rem;
    padding: 0.85rem;
}

.zgm-die-result {
    align-items: center;
    border: 2px solid #000;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25), 0 6px 12px rgba(0, 0, 0, 0.35);
    border-radius: 1em;
    display: inline-flex;
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.7rem;
    font-weight: 700;
    height: 4.5rem;
    justify-content: center;
    line-height: 1.05;
    overflow-wrap: anywhere;
    padding: 0.35rem;
    text-align: center;
    width: 4.5rem;
}

.zgm-die-result > .zgm-dice-face-icon-single {
    display: block;
    height: 78%;
    object-fit: contain;
    width: 78%;
}

.zgm-dice-icon-stack {
    display: block;
    height: 92%;
    position: relative;
    width: 92%;
}

.zgm-dice-icon-stack .zgm-dice-face-icon {
    display: block;
    height: 70%;
    object-fit: contain;
    position: absolute;
    width: 70%;
}

.zgm-dice-icon-stack .is-upper-left {
    left: 0;
    top: 0;
}

.zgm-dice-icon-stack .is-lower-right {
    bottom: 0;
    right: 0;
}

.zgm-dice-pips {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: repeat(3, minmax(0, 1fr));
    height: 82%;
    width: 82%;
}

.zgm-die-pip {
    align-self: center;
    aspect-ratio: 1;
    background: currentColor;
    border-radius: 50%;
    justify-self: center;
    width: 48%;
}

.zgm-die-pip-1 { grid-column: 1; grid-row: 1; }
.zgm-die-pip-3 { grid-column: 3; grid-row: 1; }
.zgm-die-pip-4 { grid-column: 1; grid-row: 2; }
.zgm-die-pip-5 { grid-column: 2; grid-row: 2; }
.zgm-die-pip-6 { grid-column: 3; grid-row: 2; }
.zgm-die-pip-7 { grid-column: 1; grid-row: 3; }
.zgm-die-pip-9 { grid-column: 3; grid-row: 3; }

.zgm-dice-summary {
    color: var(--zgm-muted);
    font-family: "Source Serif 4", Georgia, serif;
    margin-top: 0.65rem;
    text-align: center;
}

.zgm-dice-editor,
.zgm-rule-form {
    display: grid;
    gap: 0.85rem;
    margin-top: 0.85rem;
}

.zgm-face-list {
    display: grid;
    gap: 0.5rem;
}

.zgm-face-row {
    align-items: end;
    display: grid;
    gap: 0.5rem;
    grid-template-columns: minmax(0, 1fr) auto;
}

.zgm-help-text,
.zgm-empty-copy,
.zgm-empty-dashboard {
    color: var(--zgm-muted);
    font-family: "Source Serif 4", Georgia, serif;
    font-style: italic;
    line-height: 1.5;
}

.zgm-help-text {
    font-size: 0.88rem;
    margin: 0;
}

.zgm-template-field {
    margin-bottom: 0.85rem;
}

.zgm-field-note {
    color: var(--zgm-muted);
    font-family: "Source Serif 4", Georgia, serif;
    font-size: 0.75rem;
    font-style: italic;
    letter-spacing: 0;
    text-transform: none;
}

.zgm-vital-grid {
    display: grid;
    gap: 0.85rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 1rem;
}

.zgm-vital {
    border: 1px solid var(--zgm-border);
    display: grid;
    gap: 0.65rem;
    grid-template-columns: minmax(0, 1fr);
    margin: 0;
    min-width: 0;
    padding: 0.7rem;
    text-align: center;
}

.zgm-vital legend {
    color: var(--zgm-gold-bright);
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.68rem;
    letter-spacing: 0.07em;
    padding: 0 0.35rem;
    text-transform: uppercase;
}

.zgm-vital-controls {
    align-items: center;
    display: grid;
    gap: 0.55rem;
    grid-template-columns: auto minmax(2.5rem, 1fr) auto;
    min-width: 0;
}

.zgm-vital button,
.zgm-round-counter button {
    background: var(--zgm-surface-high);
    border: 1px solid var(--zgm-border);
    color: var(--zgm-parchment);
    cursor: pointer;
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 1.1rem;
    height: 2.2rem;
    width: 2.2rem;
}

.zgm-vital output,
.zgm-round-counter output {
    color: var(--zgm-parchment);
    font-family: "Noto Serif", Georgia, serif;
    font-size: 2rem;
    font-weight: 700;
}

.zgm-vital-max {
    align-items: center;
    color: var(--zgm-muted);
    display: flex;
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.62rem;
    gap: 0.35rem;
    justify-content: center;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.zgm-vital input {
    background: var(--zgm-bg);
    border: 0;
    border-bottom: 1px solid var(--zgm-gold);
    color: var(--zgm-parchment);
    padding: 0.3rem;
    text-align: center;
    width: 4.5rem;
}

.zgm-monster-form {
    display: grid;
    gap: 0.85rem;
    margin-bottom: 0.85rem;
}

.zgm-monster-identity-row,
.zgm-monster-stat-row {
    display: grid;
    gap: 0.65rem;
    min-width: 0;
}

.zgm-monster-identity-row {
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
}

.zgm-monster-stat-row {
    align-items: end;
    gap: 0.45rem;
    grid-template-columns: repeat(5, minmax(0, 1fr)) minmax(6.75rem, auto);
}

.zgm-monster-stat-row input {
    padding-inline: 0.3rem;
    text-align: center;
}

.zgm-monster-stat-row .zgm-button {
    min-width: 6.75rem;
    padding-inline: 0.55rem;
}

.zgm-table-wrap {
    overflow-x: auto;
}

.zgm-monster-table {
    border-collapse: collapse;
    min-width: 1040px;
    width: 100%;
}

.zgm-monster-table th,
.zgm-monster-table td {
    border: 1px solid var(--zgm-surface-high);
    padding: 0.45rem;
    text-align: left;
    vertical-align: top;
}

.zgm-monster-table th {
    background: var(--zgm-surface-low);
    color: var(--zgm-gold-bright);
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.63rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.zgm-monster-table input[type="number"] {
    min-width: 3.7rem;
    text-align: center;
}

.zgm-monster-table textarea {
    min-width: 10rem;
    resize: vertical;
}

.zgm-rule-panel-actions {
    display: flex;
    justify-content: flex-start;
    margin-top: 0.75rem;
}

.zgm-rule-panel-actions .zgm-button {
    min-height: 2.15rem;
    padding-block: 0.5rem;
}

.zgm-rule-results {
    display: grid;
    gap: 0.55rem;
    margin-top: 0.75rem;
}

.zgm-rule-results.is-scrollable {
    max-height: var(--zgm-rule-results-max-height, 27rem);
    overflow-y: auto;
    overscroll-behavior: auto;
    padding-right: 0.35rem;
    scrollbar-color: var(--zgm-gold) var(--zgm-bg);
    scrollbar-gutter: stable;
    scrollbar-width: thin;
}

.zgm-rule-results.is-scrollable::-webkit-scrollbar {
    width: 0.55rem;
}

.zgm-rule-results.is-scrollable::-webkit-scrollbar-track {
    background: var(--zgm-bg);
    border-left: 1px solid var(--zgm-surface-high);
}

.zgm-rule-results.is-scrollable::-webkit-scrollbar-thumb {
    background: var(--zgm-gold);
    border: 1px solid #412d00;
}

.zgm-rule-card {
    background: rgba(0, 0, 0, 0.24);
    border: 1px solid var(--zgm-surface-high);
    border-left: 3px solid var(--zgm-gold);
    padding: 0.55rem;
}

.zgm-rule-preview {
    display: grid;
    width: 100%;
    gap: 0.45rem;
    padding: 0.2rem;
    color: inherit;
    background: transparent;
    border: 0;
    cursor: pointer;
    text-align: left;
}

.zgm-rule-preview:hover,
.zgm-rule-preview:focus-visible {
    background: rgba(184, 134, 11, 0.08);
    box-shadow: inset 0 0 0 1px rgba(247, 189, 72, 0.32);
    outline: none;
}

.zgm-rule-preview-heading {
    display: grid;
    gap: 0.12rem;
}

.zgm-rule-card h3 {
    color: var(--zgm-parchment);
    font-family: "Noto Serif", Georgia, serif;
    font-size: 1rem;
    line-height: 1.25;
    margin: 0;
}

.zgm-rule-category {
    color: var(--zgm-gold-bright);
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.6rem;
    letter-spacing: 0.065em;
    margin: 0;
    text-transform: uppercase;
}

.zgm-rule-snippet {
    display: -webkit-box;
    overflow: hidden;
    margin: 0;
    color: var(--zgm-muted);
    font-family: "Source Serif 4", Georgia, serif;
    font-size: 0.9rem;
    line-height: 1.4;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}

.zgm-rule-open-label {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    width: fit-content;
    color: var(--zgm-gold-bright);
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.zgm-rule-open-label .material-symbols-outlined {
    font-size: 0.95rem;
}

.zgm-rule-card-actions {
    justify-content: flex-end;
    margin-top: 0.45rem;
    padding-top: 0.45rem;
    border-top: 1px solid var(--zgm-surface-high);
}

.zgm-rule-card-actions .zgm-button {
    min-height: 2rem;
    padding: 0.42rem 0.6rem;
    font-size: 0.6rem;
}

.zgm-round-counter {
    align-items: center;
    background: rgba(0, 0, 0, 0.24);
    border: 1px solid var(--zgm-border);
    display: grid;
    gap: 0.65rem;
    grid-template-columns: minmax(0, 1fr) auto auto auto;
    margin: 0.85rem 0;
    padding: 0.75rem;
}

.zgm-round-counter > span {
    color: var(--zgm-gold-bright);
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.zgm-empty-dashboard {
    border: 1px dashed var(--zgm-border);
    margin: 0;
    padding: 2rem;
    text-align: center;
}

.zgm-dialog {
    background: transparent;
    border: 0;
    color: var(--zgm-parchment);
    max-height: 88vh;
    max-width: 940px;
    padding: 0;
    width: calc(100% - 2rem);
}

.zgm-dialog::backdrop {
    background: rgba(0, 0, 0, 0.82);
}

.zgm-dialog-frame {
    max-height: 88vh;
    overflow: auto;
    padding: 1rem;
}

.zgm-dialog-header {
    align-items: flex-start;
    border-bottom: 1px solid var(--zgm-border);
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.85rem;
}

.zgm-dialog h2 {
    color: var(--zgm-crimson-bright);
    font-size: clamp(1.4rem, 3vw, 2rem);
}

.zgm-help-dialog-copy {
    display: grid;
    gap: 0.8rem;
    padding: 1rem;
    color: var(--zgm-muted);
    font-family: "Source Serif 4", Georgia, serif;
    line-height: 1.6;
}

.zgm-help-dialog-copy p {
    margin: 0;
}

.zgm-panel-library-grid {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.zgm-panel-choice {
    background: var(--zgm-surface-low);
    border: 1px solid var(--zgm-border);
    color: var(--zgm-parchment);
    cursor: pointer;
    display: grid;
    gap: 0.4rem;
    padding: 0.9rem;
    text-align: left;
}

.zgm-panel-choice:hover,
.zgm-panel-choice:focus-visible {
    border-color: var(--zgm-gold-bright);
    box-shadow: inset 0 0 0 1px var(--zgm-gold);
    outline: none;
}

.zgm-panel-choice:disabled,
.zgm-panel-choice.is-unavailable {
    background: var(--zgm-bg);
    border-color: var(--zgm-surface-high);
    box-shadow: none;
    cursor: not-allowed;
    filter: grayscale(1);
    opacity: 0.42;
}

.zgm-panel-choice:disabled strong,
.zgm-panel-choice:disabled span,
.zgm-panel-choice.is-unavailable strong,
.zgm-panel-choice.is-unavailable span {
    color: var(--zgm-muted);
}

.zgm-panel-choice strong {
    color: var(--zgm-gold-bright);
    font-family: "Noto Serif", Georgia, serif;
    font-size: 1.1rem;
}

.zgm-panel-choice span {
    color: var(--zgm-muted);
    font-family: "Source Serif 4", Georgia, serif;
    line-height: 1.45;
}

.zgm-screen .visually-hidden,
.zgm-dialog .visually-hidden {
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    height: 1px;
    overflow: hidden;
    position: absolute;
    white-space: nowrap;
    width: 1px;
}

@media (max-width: 960px) {
    .zgm-dashboard {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }

    .zgm-panel[data-panel-size="quarter"] {
        grid-column: span 2;
    }

    .zgm-panel[data-panel-size="compact"],
    .zgm-panel[data-panel-size="standard"] {
        grid-column: span 3;
    }

    .zgm-panel[data-panel-size="two-thirds"] {
        grid-column: span 4;
    }

    .zgm-panel[data-panel-size="three-quarters"] {
        grid-column: span 5;
    }

    .zgm-panel[data-panel-size="wide"] {
        grid-column: 1 / -1;
    }

}

@media (max-width: 700px) {
    .zgm-screen {
        padding-inline: 0.75rem;
    }

    .zgm-hero {
        align-items: flex-start;
        flex-direction: column;
    }

    .zgm-toolbar {
        position: static;
    }

    .zgm-toolbar .zgm-button {
        flex: 1 1 calc(50% - 0.65rem);
    }

    .zgm-dashboard {
        grid-template-columns: 1fr;
    }

    .zgm-panel,
    .zgm-panel[data-panel-size="quarter"],
    .zgm-panel[data-panel-size="compact"],
    .zgm-panel[data-panel-size="standard"],
    .zgm-panel[data-panel-size="two-thirds"],
    .zgm-panel[data-panel-size="three-quarters"],
    .zgm-panel[data-panel-size="wide"] {
        grid-column: 1;
    }

    .zgm-panel-header {
        align-items: start;
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .zgm-panel-actions {
        grid-column: 1 / -1;
        justify-content: flex-start;
    }

    .zgm-field-grid-two,
    .zgm-field-grid-dice,
    .zgm-panel-library-grid {
        grid-template-columns: 1fr;
    }

    .zgm-treasure-stage {
        grid-template-columns: 1fr;
    }

    .zgm-panel-resize-handle-left,
    .zgm-panel-resize-handle-right {
        display: none;
    }

}

@media (max-width: 480px) {
    .zgm-toolbar .zgm-button,
    .zgm-button-row .zgm-button {
        flex-basis: 100%;
        width: 100%;
    }

    .zgm-stat-grid-three {
        grid-template-columns: 1fr;
    }

    .zgm-round-counter {
        grid-template-columns: 1fr auto auto auto;
    }
}

.zgm-dashboard[data-layout-mode="masonry"] .zgm-panel:is([data-panel-size="compact"], [data-panel-size="quarter"]) .zgm-hero-identity-grid,
.zgm-dashboard[data-layout-mode="masonry"] .zgm-panel:is([data-panel-size="compact"], [data-panel-size="quarter"]) .zgm-monster-identity-row {
    grid-template-columns: minmax(0, 1fr);
}

.zgm-dashboard[data-layout-mode="masonry"] .zgm-panel:is([data-panel-size="compact"], [data-panel-size="quarter"]) .zgm-vital-grid {
    gap: 0.55rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.zgm-dashboard[data-layout-mode="masonry"] .zgm-panel:is([data-panel-size="compact"], [data-panel-size="quarter"]) .zgm-vital {
    padding: 0.55rem;
}

.zgm-dashboard[data-layout-mode="masonry"] .zgm-panel:is([data-panel-size="compact"], [data-panel-size="quarter"]) .zgm-vital-controls {
    gap: 0.35rem;
    grid-template-columns: 2rem minmax(1.75rem, 1fr) 2rem;
}

.zgm-dashboard[data-layout-mode="masonry"] .zgm-panel:is([data-panel-size="compact"], [data-panel-size="quarter"]) .zgm-vital button {
    height: 2rem;
    width: 2rem;
}

.zgm-dashboard[data-layout-mode="masonry"] .zgm-panel:is([data-panel-size="compact"], [data-panel-size="quarter"]) .zgm-vital output {
    font-size: 1.6rem;
}

.zgm-dashboard[data-layout-mode="masonry"] .zgm-panel:is([data-panel-size="compact"], [data-panel-size="quarter"]) .zgm-vital input {
    width: 3.5rem;
}

.zgm-dashboard[data-layout-mode="masonry"] .zgm-panel:is([data-panel-size="compact"], [data-panel-size="quarter"]) .zgm-monster-stat-row .zgm-field {
    font-size: 0.58rem;
    letter-spacing: 0.03em;
}

@container (max-width: 520px) {
    .zgm-hero-identity-grid,
    .zgm-monster-identity-row {
        grid-template-columns: minmax(0, 1fr);
    }

    .zgm-vital-grid {
        gap: 0.55rem;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .zgm-vital {
        padding: 0.55rem;
    }

    .zgm-vital-controls {
        gap: 0.35rem;
        grid-template-columns: 2rem minmax(1.75rem, 1fr) 2rem;
    }

    .zgm-vital button {
        height: 2rem;
        width: 2rem;
    }

    .zgm-vital output {
        font-size: 1.6rem;
    }

    .zgm-vital input {
        width: 3.5rem;
    }
}

@container (max-width: 360px) {
    .zgm-monster-stat-row {
        gap: 0.3rem;
        grid-template-columns: repeat(5, minmax(0, 1fr)) minmax(5.9rem, auto);
    }

    .zgm-monster-stat-row .zgm-field {
        font-size: 0.52rem;
        letter-spacing: 0;
    }

    .zgm-monster-stat-row .zgm-button {
        min-width: 5.9rem;
        padding-inline: 0.35rem;
    }
}

.zgm-body-points-cell {
    align-items: center;
    display: grid;
    gap: 0.3rem;
    grid-template-columns: minmax(3.7rem, 1fr) auto minmax(3.7rem, 1fr);
}

.zgm-body-points-cell span {
    color: var(--zgm-muted);
    font-family: "JetBrains Mono", Consolas, monospace;
    text-align: center;
}

/* =========================================================
   Dedicated low-profile application shell
   ========================================================= */
:root {
    --zgm-bg: #0a0a0a;
    --zgm-surface: #131313;
    --zgm-surface-low: #1c1b1b;
    --zgm-surface-high: #2a2a2a;
    --zgm-surface-highest: #353534;
    --zgm-gold: #b8860b;
    --zgm-gold-bright: #f7bd48;
    --zgm-crimson: #8b0000;
    --zgm-crimson-bright: #b52619;
    --zgm-parchment: #f5f5dc;
    --zgm-muted: #e3beb8;
    --zgm-border: #5a403c;
    --zgm-error: #ffb4ab;
    --zgm-header-height: 4rem;
}

html {
    min-height: 100%;
    background: var(--zgm-bg);
}

.zgm-app-body {
    min-height: 100dvh;
    margin: 0;
    color: var(--zgm-parchment);
    background:
        radial-gradient(circle at 15% 0%, rgba(139, 0, 0, 0.14), transparent 30rem),
        linear-gradient(180deg, #151414 0%, var(--zgm-surface) 38%, var(--zgm-bg) 100%);
    font-family: "Source Serif 4", Georgia, serif;
    display: flex;
    flex-direction: column;
}

.zgm-app-body::before {
    position: fixed;
    z-index: -1;
    inset: 0;
    background-image: repeating-linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.009) 0,
        rgba(255, 255, 255, 0.009) 1px,
        transparent 1px,
        transparent 5px
    );
    content: "";
    pointer-events: none;
}

.zgm-app-body *,
.zgm-app-body *::before,
.zgm-app-body *::after {
    box-sizing: border-box;
    /* border-radius: 0 !important; */
}

.zgm-app-body ::selection {
    color: #fff;
    background: var(--zgm-crimson);
}

.zgm-app-body a:focus-visible,
.zgm-app-body button:focus-visible,
.zgm-app-body input:focus-visible,
.zgm-app-body select:focus-visible,
.zgm-app-body textarea:focus-visible {
    outline: 2px solid var(--zgm-gold-bright);
    outline-offset: 2px;
}

.zgm-app-body .material-symbols-outlined {
    font-variation-settings: "FILL" 0, "wght" 500, "GRAD" 0, "opsz" 20;
    font-size: 1.15rem;
    line-height: 1;
}

.zgm-skip-link {
    position: fixed;
    z-index: 3000;
    top: -5rem;
    left: 0.75rem;
    padding: 0.65rem 0.85rem;
    color: var(--zgm-parchment);
    background: var(--zgm-crimson);
    border: 1px solid var(--zgm-gold);
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    text-decoration: none;
    text-transform: uppercase;
}

.zgm-skip-link:focus {
    top: 0.75rem;
}

.zgm-app-header {
    position: sticky;
    z-index: 1000;
    top: 0;
    display: grid;
    min-height: var(--zgm-header-height);
    grid-template-columns: minmax(17rem, auto) minmax(10rem, 1fr) auto;
    align-items: center;
    gap: 0.75rem 1rem;
    padding: 0.45rem clamp(0.75rem, 1.5vw, 1.25rem);
    background:
        radial-gradient(circle at 40% 100%, rgba(139, 0, 0, 0.2), transparent 25rem),
        linear-gradient(180deg, rgba(31, 28, 27, 0.99), rgba(12, 12, 12, 0.99));
    border-top: 1px solid rgba(247, 189, 72, 0.18);
    border-bottom: 2px solid var(--zgm-border);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.82), inset 0 -1px 0 rgba(247, 189, 72, 0.12);
}

.zgm-app-header::after {
    position: absolute;
    right: 0;
    bottom: 0.25rem;
    left: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(184, 134, 11, 0.55), rgba(139, 0, 0, 0.4), rgba(184, 134, 11, 0.55), transparent);
    content: "";
    pointer-events: none;
}

.zgm-app-brand-group,
.zgm-app-controls,
.zgm-app-save-state,
.zgm-app-footer,
.zgm-app-footer-identity,
.zgm-app-footer-links,
.zgm-header-button,
.zgm-header-icon-button {
    display: flex;
    align-items: center;
}

.zgm-app-brand-group {
    min-width: 0;
    gap: 0.75rem;
}

.zgm-app-logo-link {
    display: flex;
    width: 2.9rem;
    height: 2.9rem;
    flex: 0 0 2.9rem;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    text-decoration: none;
}

.zgm-app-logo {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* filter: drop-shadow(0 6px 9px rgba(0, 0, 0, 0.88)); */
}

.zgm-app-title-group {
    display: grid;
    min-width: 0;
    line-height: 1;
}


.zgm-app-title {
    overflow: hidden;
    color: var(--zgm-parchment);
    font-family: "Noto Serif", Georgia, serif;
    font-size: clamp(1rem, 1.55vw, 1.35rem);
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.zgm-app-save-state {
    min-width: 0;
    justify-content: flex-end;
    gap: 0.5rem;
    color: var(--zgm-muted);
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.62rem;
    letter-spacing: 0.04em;
    text-align: right;
    text-transform: uppercase;
}

.zgm-app-save-state .zgm-status-light {
    flex: 0 0 auto;
}

.zgm-app-save-state[data-state="dirty"] {
    color: var(--zgm-error);
}

.zgm-app-save-state[data-state="dirty"] .zgm-status-light {
    background: var(--zgm-crimson-bright);
    box-shadow: 0 0 12px rgba(181, 38, 25, 0.78);
}

.zgm-app-controls {
    min-width: 0;
    justify-content: flex-end;
    gap: 0.35rem;
}

.zgm-header-button,
.zgm-header-icon-button {
    min-height: 2.35rem;
    justify-content: center;
    gap: 0.38rem;
    padding: 0.52rem 0.65rem;
    color: var(--zgm-parchment);
    background: linear-gradient(180deg, var(--zgm-surface-highest), var(--zgm-surface));
    border: 1px solid var(--zgm-border);
    cursor: pointer;
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.63rem;
    font-weight: 700;
    letter-spacing: 0.055em;
    line-height: 1;
    text-decoration: none;
    text-transform: uppercase;
    white-space: nowrap;
}

.zgm-header-icon-button {
    width: 2.35rem;
    flex: 0 0 2.35rem;
    padding: 0;
    color: var(--zgm-gold-bright);
}

.zgm-header-button:hover,
.zgm-header-button:focus-visible,
.zgm-header-icon-button:hover,
.zgm-header-icon-button:focus-visible {
    color: var(--zgm-parchment);
    background: var(--zgm-crimson);
    border-color: var(--zgm-error);
    box-shadow: 0 0 12px rgba(255, 180, 168, 0.24);
}

.zgm-header-button-primary {
    color: #271900;
    background: linear-gradient(180deg, var(--zgm-gold-bright), var(--zgm-gold));
    border-color: #5d4200;
}

.zgm-header-button-danger {
    background: linear-gradient(180deg, var(--zgm-crimson-bright), var(--zgm-crimson));
    border-color: #690000;
}

.zgm-header-back {
    margin-left: 0.25rem;
    border-color: var(--zgm-gold);
}

.zgm-app-main {
    width: 100%;
    flex: 1 0 auto;
    padding: clamp(0.7rem, 1.25vw, 1rem);
}

.zgm-screen {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
}

.zgm-layout-switcher {
    display: flex;
    width: fit-content;
    align-items: center;
    gap: 0.35rem;
    margin: 0 0 clamp(0.7rem, 1vw, 1rem);
    padding: 0.35rem;
    background: linear-gradient(180deg, var(--zgm-surface-low), var(--zgm-bg));
    border: 1px solid var(--zgm-border);
    box-shadow: inset 0 0 0 1px rgba(184, 134, 11, 0.1);
}

.zgm-layout-switcher-label {
    padding: 0 0.45rem;
    color: var(--zgm-muted);
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.zgm-layout-option {
    display: inline-flex;
    min-height: 2.15rem;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.45rem 0.6rem;
    color: var(--zgm-muted);
    background: var(--zgm-surface);
    border: 1px solid transparent;
    cursor: pointer;
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.zgm-layout-option:hover,
.zgm-layout-option:focus-visible {
    color: var(--zgm-parchment);
    border-color: var(--zgm-gold);
}

.zgm-layout-option.is-active {
    color: #271900;
    background: linear-gradient(180deg, var(--zgm-gold-bright), var(--zgm-gold));
    border-color: #5d4200;
}

.zgm-layout-option .material-symbols-outlined {
    font-size: 1rem;
}

.zgm-dashboard {
    column-gap: clamp(0.7rem, 1vw, 1rem);
    row-gap: clamp(0.7rem, 1vw, 1rem);
}

.zgm-help-frame {
    max-width: 760px;
    margin: 0 auto;
}

.zgm-help-content {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.zgm-help-content section {
    padding: 0.9rem;
    background: rgba(0, 0, 0, 0.24);
    border: 1px solid var(--zgm-surface-high);
    border-left: 3px solid var(--zgm-gold);
}

.zgm-help-content h3 {
    margin: 0 0 0.45rem;
    color: var(--zgm-gold-bright);
    font-family: "Noto Serif", Georgia, serif;
    font-size: 1.05rem;
}

.zgm-help-content p {
    margin: 0;
    color: var(--zgm-muted);
    font-family: "Source Serif 4", Georgia, serif;
    line-height: 1.55;
}

.zgm-app-footer {
    min-height: 3rem;
    flex: 0 0 auto;
    justify-content: space-between;
    gap: 0.75rem 1.5rem;
    padding: 0.65rem clamp(0.75rem, 1.5vw, 1.25rem);
    background: linear-gradient(180deg, var(--zgm-surface-low), var(--zgm-bg));
    border-top: 1px solid var(--zgm-border);
}

.zgm-app-footer-identity {
    min-width: 0;
    flex-wrap: wrap;
    gap: 0.35rem 0.8rem;
}

.zgm-app-footer-identity strong {
    color: var(--zgm-parchment);
    font-family: "Noto Serif", Georgia, serif;
    font-size: 0.85rem;
}

.zgm-app-footer-identity span,
.zgm-app-footer-links a {
    color: var(--zgm-muted);
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.58rem;
    letter-spacing: 0.055em;
    text-transform: uppercase;
}

.zgm-app-footer-links {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.45rem 1rem;
}

.zgm-app-footer-links a {
    text-decoration: none;
}

.zgm-app-footer-links a:hover,
.zgm-app-footer-links a:focus-visible {
    color: var(--zgm-gold-bright);
}

@media (max-width: 1280px) {
    .zgm-app-header {
        grid-template-columns: minmax(15rem, auto) 1fr;
    }

    .zgm-app-save-state {
        display: none;
    }
}

@media (max-width: 980px) {
    :root {
        --zgm-header-height: auto;
    }

    .zgm-app-header {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 0.4rem 0.75rem;
        padding-bottom: 0.55rem;
    }

    .zgm-app-brand-group {
        grid-column: 1;
        grid-row: 1;
    }

    .zgm-app-save-state {
        display: flex;
        grid-column: 2;
        grid-row: 1;
    }

    .zgm-app-controls {
        grid-column: 1 / -1;
        grid-row: 2;
        justify-content: flex-start;
        overflow-x: auto;
        padding-bottom: 0.15rem;
        scrollbar-width: thin;
    }

    .zgm-header-back {
        margin-left: auto;
    }
}

@media (max-width: 700px) {
    .zgm-app-header {
        position: sticky;
    }

    .zgm-app-logo-link {
        width: 2.5rem;
        height: 2.5rem;
        flex-basis: 2.5rem;
    }

    .zgm-app-save-state {
        max-width: 9rem;
        font-size: 0.54rem;
    }

    .zgm-control-label {
        display: none;
    }

    .zgm-header-button,
    .zgm-header-icon-button {
        width: 2.4rem;
        min-width: 2.4rem;
        padding: 0;
    }

    .zgm-header-back {
        margin-left: 0;
    }

    .zgm-app-main {
        padding: 0.65rem;
    }

    .zgm-layout-switcher {
        width: 100%;
    }

    .zgm-layout-switcher-label {
        display: none;
    }

    .zgm-layout-option {
        flex: 1 1 50%;
    }

    .zgm-screen {
        padding: 0;
    }

    .zgm-help-content {
        grid-template-columns: 1fr;
    }

    .zgm-app-footer {
        align-items: flex-start;
        flex-direction: column;
    }

    .zgm-app-footer-links {
        justify-content: flex-start;
    }
}

@media (max-width: 480px) {
    .zgm-app-title {
        font-size: 0.92rem;
    }

    .zgm-app-save-state {
        max-width: 7.5rem;
    }

    .zgm-app-footer-identity span {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .zgm-dock-overflow-button .material-symbols-outlined {
        animation: none;
    }

    .zgm-app-body *,
    .zgm-app-body *::before,
    .zgm-app-body *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}


/* =========================================================
   Edge-pinned control bar and docked panel fly-outs
   ========================================================= */
.zgm-workspace {
    --zgm-dock-size: 3.4rem;
    align-items: start;
    display: grid;
    gap: clamp(0.55rem, 0.9vw, 0.85rem);
    min-width: 0;
    position: relative;
}

.zgm-workspace[data-dock-position="left"] {
    grid-template-areas: "dock canvas";
    grid-template-columns: var(--zgm-dock-size) minmax(0, 1fr);
}

.zgm-workspace[data-dock-position="right"] {
    grid-template-areas: "canvas dock";
    grid-template-columns: minmax(0, 1fr) var(--zgm-dock-size);
}

.zgm-workspace[data-dock-position="top"] {
    grid-template-areas:
        "dock"
        "canvas";
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: var(--zgm-dock-size) auto;
}

.zgm-workspace[data-dock-position="bottom"] {
    grid-template-areas: "canvas";
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
}

.zgm-workspace-canvas {
    grid-area: canvas;
    min-width: 0;
}

.zgm-panel-dock {
    align-items: center;
    align-self: start;
    background:
        linear-gradient(135deg, rgba(184, 134, 11, 0.12), transparent 46%),
        linear-gradient(180deg, var(--zgm-surface-high), var(--zgm-bg));
    border: 1px solid var(--zgm-border);
    box-shadow:
        inset 0 0 0 1px rgba(247, 189, 72, 0.13),
        0 10px 28px rgba(0, 0, 0, 0.72);
    display: flex;
    gap: 0.35rem;
    grid-area: dock;
    min-width: 0;
    padding: 0.35rem;
    position: sticky;
    z-index: 55;
}

.zgm-workspace[data-dock-position="left"] .zgm-panel-dock,
.zgm-workspace[data-dock-position="right"] .zgm-panel-dock {
    flex-direction: column;
    height: min(72dvh, 44rem);
    min-height: 18rem;
    top: var(--zgm-dock-sticky-top, 4.75rem);
    width: var(--zgm-dock-size);
}

.zgm-workspace[data-dock-position="top"] .zgm-panel-dock {
    flex-direction: row;
    height: var(--zgm-dock-size);
    top: var(--zgm-dock-sticky-top, 4.75rem);
    width: 100%;
}

.zgm-workspace[data-dock-position="bottom"] .zgm-panel-dock {
    bottom: max(0.75rem, env(safe-area-inset-bottom));
    flex-direction: row;
    height: var(--zgm-dock-size);
    left: clamp(0.7rem, 1.25vw, 1rem);
    position: fixed;
    right: clamp(0.7rem, 1.25vw, 1rem);
    width: auto;
    z-index: 1100;
}

.zgm-app-body.zgm-bottom-dock-active {
    padding-bottom: calc(4.9rem + env(safe-area-inset-bottom));
}

.zgm-dock-grip,
.zgm-dock-panel-button,
.zgm-dock-overflow-button,
.zgm-dock-settings {
    align-items: center;
    background: var(--zgm-surface);
    border: 1px solid var(--zgm-border);
    color: var(--zgm-parchment);
    cursor: pointer;
    display: inline-flex;
    flex: 0 0 2.55rem;
    height: 2.55rem;
    justify-content: center;
    padding: 0;
    width: 2.55rem;
}

.zgm-dock-grip {
    color: var(--zgm-gold-bright);
    cursor: grab;
}

.zgm-dock-grip:active {
    cursor: grabbing;
}

.zgm-dock-grip .material-symbols-outlined {
    font-size: 1.4rem;
}

.zgm-dock-panel-list {
    align-items: center;
    display: flex;
    flex: 1 1 auto;
    gap: 0.35rem;
    min-height: 0;
    min-width: 0;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.zgm-dock-panel-list::-webkit-scrollbar {
    display: none;
    height: 0;
    width: 0;
}

.zgm-workspace[data-dock-position="left"] .zgm-dock-panel-list,
.zgm-workspace[data-dock-position="right"] .zgm-dock-panel-list {
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    touch-action: pan-y;
    width: 100%;
}

.zgm-workspace[data-dock-position="top"] .zgm-dock-panel-list,
.zgm-workspace[data-dock-position="bottom"] .zgm-dock-panel-list {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    touch-action: pan-x;
}

.zgm-workspace[data-dock-position="left"] .zgm-dock-settings,
.zgm-workspace[data-dock-position="right"] .zgm-dock-settings {
    margin-top: auto;
}

.zgm-workspace[data-dock-position="top"] .zgm-dock-settings,
.zgm-workspace[data-dock-position="bottom"] .zgm-dock-settings {
    margin-left: auto;
}

.zgm-dock-overflow-button {
    color: var(--zgm-gold-bright);
    flex: 0 0 2rem;
    height: 2rem;
    position: relative;
    width: 2.55rem;
}

.zgm-dock-overflow-button[hidden] {
    display: none;
}

.zgm-dock-overflow-button::before {
    background: linear-gradient(180deg, transparent, rgba(247, 189, 72, 0.14));
    content: "";
    inset: 0;
    pointer-events: none;
    position: absolute;
}

.zgm-dock-overflow-button .material-symbols-outlined {
    animation: zgm-dock-more-pulse 1.25s ease-in-out infinite;
    position: relative;
}

@keyframes zgm-dock-more-pulse {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(0, 2px); }
}

.zgm-workspace[data-dock-position="top"] .zgm-dock-overflow-button .material-symbols-outlined,
.zgm-workspace[data-dock-position="bottom"] .zgm-dock-overflow-button .material-symbols-outlined {
    animation-name: zgm-dock-more-pulse-horizontal;
}

@keyframes zgm-dock-more-pulse-horizontal {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(2px, 0); }
}

.zgm-dock-panel-button {
    color: var(--zgm-gold-bright);
    cursor: grab;
    position: relative;
}

.zgm-dock-panel-button:active {
    cursor: grabbing;
}

.zgm-dock-panel-button.is-dock-drop-before::before,
.zgm-dock-panel-button.is-dock-drop-after::after {
    background: var(--zgm-gold-bright);
    box-shadow: 0 0 8px rgba(247, 189, 72, 0.82);
    content: "";
    pointer-events: none;
    position: absolute;
    z-index: 2;
}

.zgm-workspace[data-dock-position="left"] .zgm-dock-panel-button.is-dock-drop-before::before,
.zgm-workspace[data-dock-position="right"] .zgm-dock-panel-button.is-dock-drop-before::before {
    height: 2px;
    left: -0.2rem;
    right: -0.2rem;
    top: -0.22rem;
}

.zgm-workspace[data-dock-position="left"] .zgm-dock-panel-button.is-dock-drop-after::after,
.zgm-workspace[data-dock-position="right"] .zgm-dock-panel-button.is-dock-drop-after::after {
    bottom: -0.22rem;
    height: 2px;
    left: -0.2rem;
    right: -0.2rem;
}

.zgm-workspace[data-dock-position="top"] .zgm-dock-panel-button.is-dock-drop-before::before,
.zgm-workspace[data-dock-position="bottom"] .zgm-dock-panel-button.is-dock-drop-before::before {
    bottom: -0.2rem;
    left: -0.22rem;
    top: -0.2rem;
    width: 2px;
}

.zgm-workspace[data-dock-position="top"] .zgm-dock-panel-button.is-dock-drop-after::after,
.zgm-workspace[data-dock-position="bottom"] .zgm-dock-panel-button.is-dock-drop-after::after {
    bottom: -0.2rem;
    right: -0.22rem;
    top: -0.2rem;
    width: 2px;
}

.zgm-dock-panel-list.is-empty-drop-target {
    background: rgba(184, 134, 11, 0.08);
    outline: 1px dashed rgba(247, 189, 72, 0.62);
    outline-offset: -1px;
}

.zgm-dock-panel-button:hover,
.zgm-dock-panel-button:focus-visible,
.zgm-dock-panel-button.is-active,
.zgm-dock-overflow-button:hover,
.zgm-dock-overflow-button:focus-visible,
.zgm-dock-settings:hover,
.zgm-dock-settings:focus-visible,
.zgm-dock-grip:hover,
.zgm-dock-grip:focus-visible {
    background: var(--zgm-crimson);
    border-color: var(--zgm-error);
    color: var(--zgm-parchment);
    box-shadow: 0 0 0 2px rgba(181, 38, 25, 0.5);
    outline: none;
}

.zgm-dock-panel-button.is-dragging {
    opacity: 0.38;
}

.zgm-panel-dock.is-panel-drop-target {
    border-color: var(--zgm-gold-bright);
    box-shadow:
        inset 0 0 0 2px rgba(247, 189, 72, 0.38),
        0 0 24px rgba(247, 189, 72, 0.28);
}

.zgm-dashboard.is-panel-drop-target:empty,
.zgm-dashboard.is-panel-drop-target {
    outline: 1px dashed rgba(247, 189, 72, 0.65);
    outline-offset: 0.35rem;
}

.zgm-dock-flyout {
    background:
        linear-gradient(135deg, rgba(184, 134, 11, 0.1), transparent 38%),
        linear-gradient(180deg, var(--zgm-surface), var(--zgm-bg));
    border: 1px solid var(--zgm-gold);
    box-shadow:
        inset 0 0 0 1px rgba(247, 189, 72, 0.15),
        0 18px 52px rgba(0, 0, 0, 0.86);
    display: flex;
    flex-direction: column;
    max-width: calc(100vw - 1rem);
    overflow: hidden;
    padding: 0.4rem;
    position: fixed;
    z-index: 1200;
}

.zgm-dock-flyout[hidden] {
    display: none;
}

.zgm-dock-flyout-toolbar {
    align-items: center;
    background: var(--zgm-surface-low);
    border-bottom: 1px solid var(--zgm-border);
    display: flex;
    gap: 0.35rem;
    justify-content: flex-end;
    margin: -0.4rem -0.4rem 0.4rem;
    padding: 0.35rem;
    flex: 0 0 auto;
    position: relative;
    z-index: 3;
}

.zgm-dock-flyout-content,
.zgm-dock-flyout .zgm-panel {
    min-height: 0;
    min-width: 0;
    width: 100%;
}

.zgm-dock-flyout-content {
    display: flex;
    flex: 1 1 auto;
    overflow: hidden;
}

.zgm-dock-flyout .zgm-panel {
    align-self: stretch;
    flex: 1 1 auto;
    grid-column: auto;
    grid-row: auto;
    height: 100%;
    max-height: 100%;
}

.zgm-dock-flyout .zgm-panel.is-dragging {
    opacity: 0.5;
}

.zgm-dock-tooltip {
    background: var(--zgm-surface-highest);
    border: 1px solid var(--zgm-gold);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.72);
    color: var(--zgm-parchment);
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.62rem;
    letter-spacing: 0.04em;
    max-width: 16rem;
    padding: 0.45rem 0.55rem;
    pointer-events: none;
    position: fixed;
    text-transform: uppercase;
    z-index: 1500;
}

.zgm-dock-tooltip[hidden] {
    display: none;
}

.zgm-dock-edge-zones {
    display: none;
    inset: 0;
    pointer-events: none;
    position: fixed;
    z-index: 2000;
}

.zgm-workspace.is-dock-dragging .zgm-dock-edge-zones {
    display: block;
}

.zgm-dock-edge-zone {
    align-items: center;
    background: rgba(19, 19, 19, 0.74);
    border: 1px dashed rgba(247, 189, 72, 0.55);
    color: var(--zgm-muted);
    display: flex;
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.62rem;
    font-weight: 700;
    justify-content: center;
    letter-spacing: 0.08em;
    position: absolute;
    text-transform: uppercase;
}

.zgm-dock-edge-zone.is-active {
    background: rgba(139, 0, 0, 0.78);
    border-color: var(--zgm-gold-bright);
    color: var(--zgm-parchment);
    box-shadow: inset 0 0 0 2px rgba(247, 189, 72, 0.28);
}

.zgm-dock-edge-zone-top,
.zgm-dock-edge-zone-bottom {
    height: 14vh;
    left: 14vw;
    right: 14vw;
}

.zgm-dock-edge-zone-left,
.zgm-dock-edge-zone-right {
    bottom: 14vh;
    top: 14vh;
    width: 14vw;
}

.zgm-dock-edge-zone-top {
    top: 0;
}

.zgm-dock-edge-zone-right {
    right: 0;
}

.zgm-dock-edge-zone-bottom {
    bottom: 0;
}

.zgm-dock-edge-zone-left {
    left: 0;
}

/* Hero combat stats stay in one compact horizontal row. */
.zgm-field-grid-stats {
    gap: clamp(0.3rem, 0.75vw, 0.65rem);
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.zgm-field-grid-stats .zgm-field {
    min-width: 0;
}

.zgm-field-grid-stats input {
    padding-inline: 0.3rem;
    text-align: center;
}

@container (max-width: 520px) {
    .zgm-field-grid-stats .zgm-field {
        font-size: 0.56rem;
        letter-spacing: 0.025em;
    }

    .zgm-field-grid-stats input {
        padding-block: 0.5rem;
    }

    .zgm-field-grid-stats .zgm-field-note {
        font-size: 0.64rem;
    }
}

@media (max-width: 700px) {
    .zgm-workspace {
        --zgm-dock-size: 3rem;
        gap: 0.5rem;
    }

    .zgm-panel-dock {
        padding: 0.25rem;
    }

    .zgm-workspace[data-dock-position="bottom"] .zgm-panel-dock {
        left: 0.65rem;
        right: 0.65rem;
    }

    .zgm-app-body.zgm-bottom-dock-active {
        padding-bottom: calc(4.5rem + env(safe-area-inset-bottom));
    }

    .zgm-workspace[data-dock-position="left"] .zgm-panel-dock,
    .zgm-workspace[data-dock-position="right"] .zgm-panel-dock {
        min-height: 14rem;
    }

    .zgm-dock-grip,
    .zgm-dock-panel-button,
    .zgm-dock-settings {
        flex-basis: 2.35rem;
        height: 2.35rem;
        width: 2.35rem;
    }
}

/* =========================================================
   Control settings and focused tool dialogs
   ========================================================= */
.zgm-settings-frame,
.zgm-history-frame,
.zgm-dice-config-frame,
.zgm-player-rule-frame,
.zgm-table-config-frame,
.zgm-image-config-frame {
    max-width: 760px;
    margin: 0 auto;
}

.zgm-settings-section {
    display: grid;
    gap: 1rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.24);
    border: 1px solid var(--zgm-surface-high);
    border-left: 3px solid var(--zgm-gold);
}

.zgm-settings-section h3 {
    margin: 0 0 0.35rem;
    color: var(--zgm-gold-bright);
    font-family: "Noto Serif", Georgia, serif;
    font-size: 1.1rem;
}

.zgm-settings-section p {
    margin: 0;
    color: var(--zgm-muted);
    font-family: "Source Serif 4", Georgia, serif;
    line-height: 1.5;
}

.zgm-settings-layout {
    width: 100%;
    margin: 0;
}

.zgm-settings-layout .zgm-layout-option {
    flex: 1 1 50%;
}

.zgm-panel-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem 1rem;
    margin-top: 0.9rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--zgm-border);
}

.zgm-text-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0;
    color: var(--zgm-gold-bright);
    background: transparent;
    border: 0;
    border-bottom: 1px solid transparent;
    cursor: pointer;
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.zgm-text-link:hover,
.zgm-text-link:focus-visible {
    color: var(--zgm-parchment);
    border-bottom-color: var(--zgm-crimson-bright);
    box-shadow: none;
    outline: none;
}

.zgm-text-link .material-symbols-outlined {
    font-size: 1rem;
}

.zgm-modal-panel-context {
    width: 100%;
    min-width: 0;
    padding: 0.9rem;
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid var(--zgm-surface-high);
    box-shadow: inset 0 0 0 1px rgba(184, 134, 11, 0.08);
}

.zgm-modal-history {
    max-height: min(62vh, 38rem);
    overflow: auto;
}

.zgm-modal-history li {
    display: grid;
    gap: 0.25rem;
}

.zgm-modal-history strong,
.zgm-roll-history strong {
    color: var(--zgm-parchment);
    font-family: "Noto Serif", Georgia, serif;
    font-size: 1rem;
}

.zgm-modal-history time,
.zgm-roll-history time {
    color: var(--zgm-muted);
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.58rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.zgm-history-empty {
    color: var(--zgm-muted);
    font-family: "Source Serif 4", Georgia, serif;
    font-style: italic;
}

.zgm-roll-history {
    display: grid;
    gap: 0.65rem;
    max-height: min(62vh, 38rem);
    margin: 0;
    padding: 0;
    overflow: auto;
    list-style: none;
}

.zgm-roll-history-item {
    display: grid;
    gap: 0.65rem;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.24);
    border: 1px solid var(--zgm-surface-high);
    border-left: 3px solid var(--zgm-gold);
}

.zgm-roll-history-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
}

.zgm-roll-history-values {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.zgm-roll-history-value {
    display: inline-flex;
    width: 2.25rem;
    height: 2.25rem;
    align-items: center;
    justify-content: center;
    padding: 0.25rem;
    overflow-wrap: anywhere;
    color: var(--zgm-parchment);
    background: var(--zgm-surface-high);
    border: 1px solid var(--zgm-border);
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.58rem;
    font-weight: 700;
    text-align: center;
}

.zgm-roll-history-value > .zgm-dice-face-icon-single {
    display: block;
    width: 78%;
    height: 78%;
    object-fit: contain;
}

.zgm-roll-history-value .zgm-dice-icon-stack {
    height: 100%;
    width: 100%;
}

.zgm-dashboard.is-panel-drop-target {
    min-height: 9rem;
}

@media (max-width: 700px) {
    .zgm-settings-section {
        padding: 0.75rem;
    }

    .zgm-roll-history-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.2rem;
    }
}

/* =========================================================
   Default and player-authored rules library
   ========================================================= */
.zgm-rule-library-summary {
    margin: 0.65rem 0 0;
    color: var(--zgm-muted);
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.6rem;
    letter-spacing: 0.045em;
    line-height: 1.45;
    text-transform: uppercase;
}

.zgm-rule-reference {
    margin: 0.65rem 0 0;
    color: var(--zgm-gold-bright);
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.58rem;
    letter-spacing: 0.045em;
    line-height: 1.45;
    text-transform: uppercase;
}

.zgm-rule-preview .zgm-rule-reference {
    margin: 0;
}

.zgm-rule-detail-frame {
    max-width: 780px;
    margin: 0 auto;
}

.zgm-rule-detail-meta {
    display: grid;
    gap: 0.35rem;
    margin-bottom: 1rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--zgm-border);
}

.zgm-rule-detail-meta .zgm-rule-reference {
    margin: 0;
}

.zgm-rule-detail-body {
    color: var(--zgm-parchment);
    font-family: "Source Serif 4", Georgia, serif;
    font-size: 1.05rem;
    line-height: 1.7;
    white-space: pre-wrap;
}

.zgm-rule-detail-actions {
    margin-top: 1.25rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--zgm-border);
}


/* =========================================================
   Monster defeat history, reference tables, images, and turns
   ========================================================= */
.zgm-monster-table th:first-child,
.zgm-monster-table td:first-child {
    width: 3rem;
    min-width: 3rem;
    text-align: center;
    vertical-align: middle;
}

.zgm-monster-defeat-button {
    margin: 0 auto;
    color: var(--zgm-parchment);
}

.zgm-monster-defeat-button .material-symbols-outlined {
    font-size: 1.2rem;
}

.zgm-monster-kill-frame {
    max-width: 620px;
    margin: 0 auto;
}

.zgm-monster-kill-form {
    display: grid;
    gap: 1rem;
}

.zgm-monster-history {
    display: grid;
    gap: 0.75rem;
    max-height: min(65vh, 42rem);
    margin: 0;
    padding: 0;
    overflow: auto;
    list-style: none;
}

.zgm-monster-history-item {
    display: grid;
    gap: 0.75rem;
    padding: 0.85rem;
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid var(--zgm-surface-high);
    border-left: 3px solid var(--zgm-crimson-bright);
}

.zgm-monster-history-heading {
    display: grid;
    gap: 0.2rem;
}

.zgm-monster-history-heading strong {
    color: var(--zgm-parchment);
    font-family: "Noto Serif", Georgia, serif;
    font-size: 1.1rem;
}

.zgm-monster-history-heading span {
    color: var(--zgm-gold-bright);
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.65rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.zgm-monster-history-heading time {
    color: var(--zgm-muted);
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.58rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.zgm-monster-history-item > p {
    margin: 0;
    color: var(--zgm-muted);
    font-family: "Source Serif 4", Georgia, serif;
    line-height: 1.5;
}

.zgm-monster-history-stats {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.45rem;
    margin: 0;
}

.zgm-monster-history-stats div {
    padding: 0.45rem;
    background: var(--zgm-bg);
    border: 1px solid var(--zgm-surface-high);
    text-align: center;
}

.zgm-monster-history-stats dt {
    color: var(--zgm-muted);
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.55rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.zgm-monster-history-stats dd {
    margin: 0.2rem 0 0;
    color: var(--zgm-parchment);
    font-family: "Noto Serif", Georgia, serif;
    font-size: 1.15rem;
}

.zgm-reference-panel,
.zgm-image-panel,
.zgm-turn-panel,
.zgm-reference-editor,
.zgm-image-editor,
.zgm-reference-custom-fields {
    display: grid;
    gap: 0.85rem;
}

.zgm-reference-description {
    margin: 0;
    color: var(--zgm-muted);
    font-family: "Source Serif 4", Georgia, serif;
    line-height: 1.5;
}

.zgm-reference-table-wrap {
    max-height: min(58vh, 38rem);
    border: 1px solid var(--zgm-surface-high);
    overflow: auto;
}

.zgm-reference-table {
    width: 100%;
    min-width: 640px;
    border-collapse: collapse;
}

.zgm-reference-table caption {
    caption-side: top;
    padding: 0.75rem;
    color: var(--zgm-crimson-bright);
    background: var(--zgm-surface-low);
    border-bottom: 1px solid var(--zgm-border);
    font-family: "Noto Serif", Georgia, serif;
    font-size: 1.2rem;
    font-weight: 700;
    text-align: left;
}

.zgm-reference-table th,
.zgm-reference-table td {
    padding: 0.55rem;
    border: 1px solid var(--zgm-surface-high);
    vertical-align: top;
    text-align: left;
}

.zgm-reference-table th {
    position: sticky;
    z-index: 1;
    top: 0;
    color: var(--zgm-gold-bright);
    background: var(--zgm-surface-low);
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.63rem;
    letter-spacing: 0.055em;
    text-transform: uppercase;
}

.zgm-reference-table td {
    color: var(--zgm-parchment);
    background: rgba(0, 0, 0, 0.24);
    font-family: "Source Serif 4", Georgia, serif;
    line-height: 1.45;
}

.zgm-reference-table tbody tr:nth-child(even) td {
    background: rgba(42, 42, 42, 0.32);
}

.zgm-reference-custom-fields[hidden] {
    display: none;
}

.zgm-reference-editor,
.zgm-image-editor {
    padding: 0.15rem;
}

.zgm-image-stage {
    display: grid;
    min-height: 12rem;
    place-items: center;
    margin: 0;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.34);
    border: 1px solid var(--zgm-surface-high);
}

.zgm-image-stage img {
    display: block;
    width: 100%;
    max-height: min(70vh, 46rem);
    object-fit: contain;
}

.zgm-image-stage figcaption {
    width: 100%;
    margin-top: 0.65rem;
    padding-top: 0.55rem;
    color: var(--zgm-muted);
    border-top: 1px solid var(--zgm-border);
    font-family: "Source Serif 4", Georgia, serif;
    font-style: italic;
    line-height: 1.45;
    text-align: center;
}

.zgm-image-error {
    margin: 0;
    color: var(--zgm-error);
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.68rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.zgm-turn-current {
    padding: 0.85rem;
    color: var(--zgm-muted);
    background: var(--zgm-bg);
    border: 1px solid var(--zgm-border);
    font-family: "Noto Serif", Georgia, serif;
    font-size: 1.15rem;
    font-weight: 700;
    text-align: center;
}

.zgm-turn-current[data-has-participant="true"] {
    color: var(--zgm-parchment);
    border-color: var(--zgm-gold);
    box-shadow: inset 0 0 0 1px rgba(247, 189, 72, 0.18);
}

.zgm-turn-list {
    display: grid;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.zgm-turn-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.65rem;
    padding: 0.65rem;
    background: rgba(0, 0, 0, 0.26);
    border: 1px solid var(--zgm-surface-high);
    border-left: 3px solid var(--zgm-border);
    cursor: grab;
}

.zgm-turn-item:active {
    cursor: grabbing;
}

.zgm-turn-item.is-current {
    background: rgba(184, 134, 11, 0.13);
    border-color: var(--zgm-gold);
    border-left-color: var(--zgm-gold-bright);
    box-shadow: inset 0 0 0 1px rgba(247, 189, 72, 0.18);
}

.zgm-turn-item.is-skip-pending {
    border-right: 3px solid var(--zgm-crimson-bright);
}

.zgm-turn-item.is-dragging {
    opacity: 0.35;
}

.zgm-turn-item.is-drag-target {
    border-color: var(--zgm-gold-bright);
    transform: translateY(2px);
}

.zgm-turn-grip {
    color: var(--zgm-gold-bright);
}

.zgm-turn-identity {
    display: grid;
    min-width: 0;
    gap: 0.15rem;
}

.zgm-turn-identity strong {
    overflow: hidden;
    color: var(--zgm-parchment);
    font-family: "Noto Serif", Georgia, serif;
    font-size: 1rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.zgm-turn-identity span {
    color: var(--zgm-muted);
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.58rem;
    letter-spacing: 0.045em;
    text-transform: uppercase;
}

.zgm-turn-item-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.zgm-turn-skip {
    min-height: 2rem;
    padding: 0.4rem 0.55rem;
    font-size: 0.58rem;
}

.zgm-turn-controls {
    justify-content: center;
}

@container (max-width: 520px) {
    .zgm-turn-item {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .zgm-turn-item-actions {
        grid-column: 1 / -1;
        justify-content: flex-end;
    }
}

@media (max-width: 560px) {
    .zgm-monster-history-stats {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}


/* Display-first reference and image panels keep editing in focused dialogs. */
.zgm-reference-panel > .zgm-panel-links,
.zgm-image-panel > .zgm-panel-links {
    margin-top: 0;
}

.zgm-reference-panel .zgm-reference-description:empty {
    display: none;
}


/* =========================================================
   Linked combatant statuses and general turn tracking
   ========================================================= */
.zgm-status-frame {
    max-width: 760px;
    margin: 0 auto;
}

.zgm-status-existing-section,
.zgm-status-form {
    display: grid;
    gap: 0.75rem;
    padding: 0.9rem;
    background: rgba(0, 0, 0, 0.24);
    border: 1px solid var(--zgm-surface-high);
    border-left: 3px solid var(--zgm-gold);
}

.zgm-status-form {
    margin-top: 0.85rem;
    border-left-color: var(--zgm-crimson-bright);
}

.zgm-status-existing-section h3,
.zgm-status-form h3 {
    margin: 0;
    color: var(--zgm-gold-bright);
    font-family: "Noto Serif", Georgia, serif;
    font-size: 1.05rem;
}

.zgm-status-manager-list {
    display: grid;
    gap: 0.55rem;
}

.zgm-status-manager-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 0.65rem;
    padding: 0.65rem;
    background: var(--zgm-bg);
    border: 1px solid var(--zgm-surface-high);
    border-left: 3px solid var(--zgm-crimson-bright);
}

.zgm-status-manager-copy {
    display: grid;
    gap: 0.2rem;
}

.zgm-status-manager-copy strong {
    color: var(--zgm-parchment);
    font-family: "Noto Serif", Georgia, serif;
}

.zgm-status-manager-copy > span {
    color: var(--zgm-gold-bright);
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.58rem;
    letter-spacing: 0.055em;
    text-transform: uppercase;
}

.zgm-status-manager-copy p {
    margin: 0.25rem 0 0;
    color: var(--zgm-muted);
    font-family: "Source Serif 4", Georgia, serif;
    line-height: 1.45;
}

.zgm-combatant-status {
    display: grid;
    gap: 0.55rem;
    margin: 0.9rem 0;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.24);
    border: 1px solid var(--zgm-surface-high);
    border-left: 3px solid var(--zgm-gold);
}

.zgm-status-summary,
.zgm-monster-status-cell,
.zgm-turn-status-summary {
    min-width: 0;
}

.zgm-status-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.zgm-status-chip {
    display: inline-flex;
    align-items: center;
    min-height: 1.45rem;
    padding: 0.18rem 0.4rem;
    color: var(--zgm-parchment);
    background: var(--zgm-crimson);
    border: 1px solid #690000;
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.54rem;
    font-weight: 700;
    letter-spacing: 0.045em;
    line-height: 1.1;
    text-transform: uppercase;
}

.zgm-status-chip[data-turn-effect="none"] {
    color: #271900;
    background: var(--zgm-gold);
    border-color: #5d4200;
}

.zgm-status-chip[data-turn-effect="block"] {
    background: #410000;
    border-color: var(--zgm-error);
    box-shadow: inset 0 0 0 1px rgba(255, 180, 171, 0.18);
}

.zgm-status-empty {
    color: var(--zgm-muted);
    font-family: "Source Serif 4", Georgia, serif;
    font-size: 0.85rem;
    font-style: italic;
}

.zgm-monster-status-cell {
    display: grid;
    min-width: 9rem;
    gap: 0.45rem;
}

.zgm-status-manage-link {
    width: fit-content;
    font-size: 0.58rem;
}

.zgm-turn-filter {
    margin-bottom: 0.65rem;
    max-width: 18rem;
}

.zgm-turn-item[data-participant-kind="hero"] {
    border-left-color: var(--zgm-gold);
}

.zgm-turn-item[data-participant-kind="monster"] {
    border-left-color: var(--zgm-crimson-bright);
}

.zgm-turn-item.is-status-blocked {
    opacity: 0.72;
    background: rgba(65, 0, 0, 0.28);
    border-right: 3px solid var(--zgm-error);
}

.zgm-turn-item.is-status-blocked .zgm-turn-identity strong {
    text-decoration: line-through;
    text-decoration-thickness: 1px;
}

.zgm-turn-status-summary .zgm-status-chip-list {
    margin-top: 0.2rem;
}

.zgm-turn-status-summary .zgm-status-chip {
    min-height: 1.2rem;
    padding: 0.12rem 0.3rem;
    font-size: 0.48rem;
}

@media (max-width: 560px) {
    .zgm-status-manager-item {
        grid-template-columns: minmax(0, 1fr) auto;
    }
}

/* =========================================================
   Compact Hero and Monster tracker layouts
   ========================================================= */
.zgm-panel-body {
    max-height: none;
    overflow: visible;
}

.zgm-panel[data-panel-height="custom"] .zgm-panel-body,
.zgm-dock-flyout .zgm-panel-body {
    max-height: none;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-color: var(--zgm-gold) var(--zgm-bg);
    scrollbar-gutter: stable;
    scrollbar-width: thin;
}

.zgm-panel[data-panel-height="custom"] .zgm-panel-body {
    overscroll-behavior: auto;
}

.zgm-dock-flyout .zgm-panel-body {
    overscroll-behavior: contain;
}

.zgm-dock-flyout .zgm-rule-results.is-scrollable {
    max-height: none;
    overflow-y: visible;
    padding-right: 0;
    scrollbar-gutter: auto;
}

.zgm-dock-flyout .zgm-monster-table-wrap {
    max-height: none;
    overflow-y: visible;
    overscroll-behavior: auto;
    scrollbar-gutter: auto;
}

.zgm-panel-body::-webkit-scrollbar,
.zgm-monster-table-wrap::-webkit-scrollbar {
    height: 0.55rem;
    width: 0.55rem;
}

.zgm-panel-body::-webkit-scrollbar-track,
.zgm-monster-table-wrap::-webkit-scrollbar-track {
    background: var(--zgm-bg);
    border-left: 1px solid var(--zgm-surface-high);
    border-top: 1px solid var(--zgm-surface-high);
}

.zgm-panel-body::-webkit-scrollbar-thumb,
.zgm-monster-table-wrap::-webkit-scrollbar-thumb {
    background: var(--zgm-gold);
    border: 1px solid #412d00;
}

.zgm-hero-identity-grid,
.zgm-monster-identity-row,
.zgm-dashboard[data-layout-mode="masonry"] .zgm-panel:is([data-panel-size="compact"], [data-panel-size="quarter"]) .zgm-hero-identity-grid,
.zgm-dashboard[data-layout-mode="masonry"] .zgm-panel:is([data-panel-size="compact"], [data-panel-size="quarter"]) .zgm-monster-identity-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.zgm-hero-details {
    margin-top: 0.9rem;
}

.zgm-hero-details-content {
    display: grid;
    gap: 0.85rem;
    padding-top: 0.85rem;
}

.zgm-hero-details-content .zgm-field-grid-stats,
.zgm-hero-details-content .zgm-combatant-status {
    margin-block: 0;
}

.zgm-monster-table-wrap {
    max-height: 375px;
    overflow: auto;
    overscroll-behavior: auto;
    scrollbar-color: var(--zgm-gold) var(--zgm-bg);
    scrollbar-gutter: stable;
    scrollbar-width: thin;
}

.zgm-monster-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    box-shadow: inset 0 -1px 0 var(--zgm-border);
}

.zgm-monster-compact-detail-row {
    display: none;
}

.zgm-panel:is([data-panel-size="compact"], [data-panel-size="quarter"]) .zgm-monster-table {
    display: block;
    min-width: 100%;
    table-layout: auto;
    width: 100%;
}

.zgm-panel:is([data-panel-size="compact"], [data-panel-size="quarter"]) .zgm-monster-table thead,
.zgm-panel:is([data-panel-size="compact"], [data-panel-size="quarter"]) .zgm-monster-table tbody {
    display: block;
    width: 100%;
}

.zgm-panel:is([data-panel-size="compact"], [data-panel-size="quarter"]) .zgm-monster-table thead tr,
.zgm-panel:is([data-panel-size="compact"], [data-panel-size="quarter"]) .zgm-monster-primary-row {
    display: grid;
    grid-template-columns:
        2.75rem
        minmax(5.5rem, 1fr)
        minmax(5.75rem, 0.72fr)
        minmax(3.5rem, 0.38fr);
    width: 100%;
}

.zgm-panel:is([data-panel-size="compact"], [data-panel-size="quarter"]) .zgm-monster-table th,
.zgm-panel:is([data-panel-size="compact"], [data-panel-size="quarter"]) .zgm-monster-table td {
    min-width: 0;
    width: auto;
}

.zgm-panel:is([data-panel-size="compact"], [data-panel-size="quarter"]) .zgm-monster-table [data-monster-column="move"],
.zgm-panel:is([data-panel-size="compact"], [data-panel-size="quarter"]) .zgm-monster-table [data-monster-column="attack"],
.zgm-panel:is([data-panel-size="compact"], [data-panel-size="quarter"]) .zgm-monster-table [data-monster-column="defend"],
.zgm-panel:is([data-panel-size="compact"], [data-panel-size="quarter"]) .zgm-monster-table [data-monster-column="status"],
.zgm-panel:is([data-panel-size="compact"], [data-panel-size="quarter"]) .zgm-monster-table [data-monster-column="notes"] {
    display: none;
}

.zgm-panel:is([data-panel-size="compact"], [data-panel-size="quarter"]) .zgm-monster-compact-detail-row {
    display: block;
    width: 100%;
}

.zgm-panel:is([data-panel-size="compact"], [data-panel-size="quarter"]) .zgm-monster-table [data-monster-column="defeat"],
.zgm-panel:is([data-panel-size="compact"], [data-panel-size="quarter"]) .zgm-monster-table [data-monster-column="name"],
.zgm-panel:is([data-panel-size="compact"], [data-panel-size="quarter"]) .zgm-monster-table [data-monster-column="body"],
.zgm-panel:is([data-panel-size="compact"], [data-panel-size="quarter"]) .zgm-monster-table [data-monster-column="mind"] {
    min-width: 0;
    width: auto;
}

.zgm-panel:is([data-panel-size="compact"], [data-panel-size="quarter"]) .zgm-monster-table input {
    min-width: 0;
    padding-inline: 0.25rem;
}

.zgm-panel:is([data-panel-size="compact"], [data-panel-size="quarter"]) .zgm-body-points-cell {
    gap: 0.18rem;
    grid-template-columns: minmax(2.2rem, 1fr) auto minmax(2.2rem, 1fr);
}

.zgm-monster-compact-detail-row > td:first-child {
    display: block;
    min-width: 0;
    padding: 0;
    text-align: left;
    vertical-align: top;
    width: 100%;
}

.zgm-monster-compact-details {
    margin: 0;
    padding: 0.55rem 0.65rem 0.65rem;
    background: rgba(0, 0, 0, 0.24);
    border-top: 0;
}

.zgm-monster-compact-details-content {
    display: grid;
    gap: 0.75rem;
    padding-top: 0.7rem;
}

.zgm-monster-compact-stat-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.zgm-monster-compact-stat-grid input {
    text-align: center;
}

.zgm-monster-compact-status {
    display: grid;
    gap: 0.45rem;
    padding: 0.65rem;
    background: var(--zgm-bg);
    border: 1px solid var(--zgm-surface-high);
    border-left: 3px solid var(--zgm-gold);
}

.zgm-monster-compact-status h4 {
    margin: 0;
    color: var(--zgm-gold-bright);
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.62rem;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

@container (max-width: 380px) {
    .zgm-hero-identity-grid,
    .zgm-monster-identity-row {
        gap: 0.45rem;
    }

    .zgm-hero-identity-grid .zgm-field,
    .zgm-monster-identity-row .zgm-field {
        font-size: 0.56rem;
        letter-spacing: 0.025em;
    }
}


/* =========================================================
   Explicit masonry column placement
   ========================================================= */
.zgm-dashboard[data-layout-mode="masonry"].is-panel-drop-target[data-drop-columns="3"] {
    background-image:
        linear-gradient(90deg, transparent calc(33.333% - 0.5px), rgba(184, 134, 11, 0.22) calc(33.333% - 0.5px), rgba(184, 134, 11, 0.22) calc(33.333% + 0.5px), transparent calc(33.333% + 0.5px)),
        linear-gradient(90deg, transparent calc(66.666% - 0.5px), rgba(184, 134, 11, 0.22) calc(66.666% - 0.5px), rgba(184, 134, 11, 0.22) calc(66.666% + 0.5px), transparent calc(66.666% + 0.5px));
    background-repeat: no-repeat;
}

.zgm-dashboard[data-layout-mode="masonry"].is-panel-drop-target[data-drop-columns="2"] {
    background-image: linear-gradient(90deg, transparent calc(50% - 0.5px), rgba(184, 134, 11, 0.22) calc(50% - 0.5px), rgba(184, 134, 11, 0.22) calc(50% + 0.5px), transparent calc(50% + 0.5px));
    background-repeat: no-repeat;
}

.zgm-dashboard[data-layout-mode="masonry"] .zgm-panel.is-dragging {
    border-color: var(--zgm-gold-bright);
    box-shadow:
        inset 0 0 0 1px rgba(247, 189, 72, 0.28),
        0 0 24px rgba(247, 189, 72, 0.16);
}

@media (max-width: 700px) {
    .zgm-dashboard[data-layout-mode="masonry"].is-panel-drop-target {
        background-image: none;
    }
}
