.isgm-open, .isgm-panel {
    font: 14px/1.5 system-ui, "Microsoft JhengHei", sans-serif;
    color: #142328;
}

.isgm-open {
    position: fixed;
    z-index: 6000;
    top: 7.5rem;
    left: .55rem;
    min-width: 42px;
    min-height: 36px;
    border: 1px solid #64848b;
    border-radius: 9px;
    color: #fff;
    background: #263d43;
    font-weight: 750;
    box-shadow: 0 2px 5px #0a202a50;
    cursor: pointer;
}

.isgm-panel {
    width: min(560px, calc(100vw - 24px));
    max-width: none;
    max-height: calc(100dvh - 24px);
    margin: auto;
    padding: 0;
    border: 1px solid #a8b9ba;
    border-radius: 16px;
    background: #f8faf9;
    overflow: auto;
    box-shadow: 0 18px 65px #081f2a55;
}

.isgm-panel::backdrop { background: #102026a0; }
.isgm-panel *, .isgm-panel { box-sizing: border-box; }
.isgm-open[hidden], .isgm-panel [hidden] { display: none !important; }

.isgm-header, .isgm-navigation, .isgm-body, .isgm-footer { padding-inline: 20px; }
.isgm-header {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 12px;
    padding-block: 18px 14px;
    background: #253d43;
    color: #fff;
}

.isgm-header h1 { margin: 0 0 3px; font-size: 22px; font-weight: 700; }
.isgm-header p { margin: 0; color: #d4e6e8; overflow-wrap: anywhere; }

.isgm-panel button, .isgm-panel input, .isgm-panel select {
    font: inherit;
    min-height: 40px;
    border: 1px solid #91a7a8;
    border-radius: 8px;
}

.isgm-panel button {
    padding: 7px 12px;
    cursor: pointer;
    color: #163234;
    background: #eef4f2;
    font-weight: 650;
}

.isgm-panel button:disabled { opacity: .55; cursor: default; }
.isgm-panel button[type="submit"] { background: #285a50; color: #fff; border-color: #285a50; }
.isgm-panel button:focus-visible, .isgm-panel input:focus-visible, .isgm-panel select:focus-visible {
    outline: 2px solid #3a8072;
    outline-offset: 2px;
}
.isgm-panel .isgm-close { min-height: 34px; padding-block: 4px; flex: none; }
.isgm-navigation {
    display: grid;
    grid-template-columns: repeat(5, minmax(0,1fr));
    gap: 6px;
    padding-block: 12px;
    border-bottom: 1px solid #d6e0dd;
}
.isgm-navigation button { padding-inline: 4px; }
.isgm-navigation button[aria-pressed="true"] { color: #164137; background: #d6e8e3; border-color: #5d8b80; }
.isgm-body { padding-block: 16px; }
.isgm-body form { display: grid; gap: 11px; }
.isgm-body form + form { margin-top: 12px; }
.isgm-body label { display: grid; gap: 4px; font-weight: 650; }
.isgm-body input, .isgm-body select { padding: 6px 9px; width: 100%; color: #142328; background: #fff; }
.isgm-body input::placeholder { color: #4e6568; }
.isgm-body .isgm-fields {
    display: grid;
    grid-template-columns: minmax(0,1fr) auto;
    gap: 10px;
    align-items: end;
}
.isgm-body .isgm-check { display: flex; align-items: center; min-height: 40px; white-space: nowrap; }
.isgm-check input { width: 18px; min-height: 18px; margin: 0 5px 0 0; accent-color: #285a50; }
.isgm-hint { margin: 0; color: #42595d; }
.isgm-hint:empty { display: none; }
.isgm-footer { background: #e8efec; min-height: 51px; padding-block: 12px; }
.isgm-footer p { margin: 0; color: #20483f; font-weight: 650; }
.isgm-footer p[data-error="true"] { color: #863427; }
.isgm-footer button { margin-top: 7px; }
@media (max-width: 420px) {
    .isgm-header, .isgm-navigation, .isgm-body, .isgm-footer { padding-inline: 14px; }
    .isgm-navigation { grid-template-columns: repeat(6, minmax(0,1fr)); }
    .isgm-navigation button { grid-column: span 2; }
    .isgm-navigation button:nth-child(n+4) { grid-column: span 3; }
}

@media (pointer: coarse) {
    .isgm-open {
        left: max(.55rem, env(safe-area-inset-left));
        min-width: 44px;
        min-height: 44px;
    }
    .isgm-panel button, .isgm-panel input, .isgm-panel select { min-height: 44px; }
    .isgm-panel input, .isgm-panel select { font-size: 16px; }
}

/* Put GM in its own column, keeping the game controls in the right column. */
#app .stage-top:has(> .isgm-open) {
    grid-template-columns: auto minmax(0, 1fr) auto;
}
#app .stage-top:has(> .isgm-open) > :is(.stage-head, .foe) {
    grid-column: 2;
}
#app .stage-top:has(> .isgm-open) > :is(.respawn, .dungeon-side) {
    grid-column: 3;
}
#app .stage-top > .isgm-open {
    position: static;
    grid-area: 1 / 1 / 3 / 2;
    z-index: auto;
}
