/*
 * The Dungeon Generator's features built on the editor's host (dungeon_random_options.js, dungeon_restock.js,
 * dungeon_saved_list.js, dungeon_share.js, dungeon_versions.js, dungeon_shared_view.js). Loaded after
 * dungeon_generator.css; every rule is scoped to the page (.dungeon-page) or to the Random dungeon window.
 */

/* --- The Random dungeon window's "More options" -------------------------------------------------------------------- */

.dungeon-random-more {
    margin-bottom: 16px;
    border: 1px solid var(--dungeon-border, rgba(231, 191, 143, 0.4));
    border-radius: 8px;
    padding: 0 14px;
}

.dungeon-random-more > summary {
    display: flex;
    align-items: center;
    min-height: 44px;
    cursor: pointer;
}

.dungeon-random-more[open] {
    padding-bottom: 14px;
}

.dungeon-random-more[open] > summary {
    margin-bottom: 8px;
}

.dungeon-seed-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.dungeon-seed-row .form-control {
    flex: 1 1 8em;
    min-width: 0;
}

.dungeon-seed-btn {
    min-height: 44px;
    white-space: nowrap;
}

.dungeon-random-more .form-select,
.dungeon-random-more .form-control {
    min-height: 44px;
}

@media (max-width: 575px) {
    .dungeon-seed-row {
        flex-wrap: wrap;
    }

    .dungeon-seed-row .dungeon-seed-btn:last-child {
        flex: 1 1 100%;
    }
}

/* --- The Dungeon tab: Generation, Share and history ----------------------------------------------------------------- */

.dungeon-page .dungeon-generation,
.dungeon-page .dungeon-sharing {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(182, 203, 208, 0.12);
}

.dungeon-page .dungeon-generation-label {
    display: block;
    margin-top: 10px;
    color: var(--dungeon-muted);
    font-size: 0.78rem;
    text-transform: uppercase;
}

.dungeon-page .dungeon-generation-row {
    display: flex;
    gap: 8px;
    margin-top: 6px;
}

.dungeon-page .dungeon-generation-seed {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 44px;
    border: 1px solid var(--dungeon-border);
    border-radius: 6px;
    background: var(--dungeon-bg);
    color: #f7dfbf;
    padding: 8px 10px;
    font-variant-numeric: tabular-nums;
}

.dungeon-page .dungeon-generation-summary {
    color: #f7dfbf;
}

.dungeon-page .dungeon-generation-detail {
    font-size: 0.8rem;
}

.dungeon-page .dungeon-generation-buttons {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 8px;
}

.dungeon-page .dungeon-generation-buttons .dungeon-btn {
    min-height: 44px;
    white-space: normal;
    justify-content: center;
}

.dungeon-page .dungeon-generation-status {
    min-height: 1.3em;
}

.dungeon-page .dungeon-generation-status.is-error {
    color: #ffd2d2;
}

.dungeon-page .dungeon-generation .dungeon-full-width {
    min-height: 44px;
}

/* --- The Saved tab ---------------------------------------------------------------------------------------------------- */

.dungeon-page .dungeon-saved-tools {
    margin-bottom: 10px;
}

.dungeon-page .dungeon-saved-search,
.dungeon-page .dungeon-history-rename {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--dungeon-border);
    border-radius: 6px;
    background: var(--dungeon-bg);
    color: #f7dfbf;
    padding: 8px 10px;
}

.dungeon-page .dungeon-history-item.has-thumb {
    grid-template-columns: 72px minmax(0, 1fr);
    align-items: start;
}

.dungeon-page .dungeon-history-list .dungeon-history-item.has-thumb {
    grid-template-columns: 72px minmax(0, 1fr);
}

.dungeon-page .dungeon-history-item.has-thumb > .dungeon-history-actions {
    grid-column: 1 / -1;
    flex-wrap: wrap;
}

.dungeon-page .dungeon-history-thumb {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    overflow: hidden;
    border: 1px solid rgba(182, 203, 208, 0.18);
    border-radius: 6px;
    background: var(--dungeon-bg);
    color: var(--dungeon-border);
    font-size: 1.5rem;
}

.dungeon-page .dungeon-history-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* The header's buttons (New, Random dungeon, Print PDF, Export, Share, Save): the icon and the word sit in the middle of the pill,
   horizontally and vertically, whichever of them a button has. */
.dungeon-page .dungeon-header-actions .dungeon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    line-height: 1.2;
    text-align: center;
}

.dungeon-page .dungeon-history-actions .dungeon-icon-btn {
    min-width: 40px;
    min-height: 40px;
}

#dungeon-saved-more {
    min-height: 44px;
}

/* --- Share and Version history windows ------------------------------------------------------------------------------------ */

.dungeon-page .dungeon-feature-dialog p {
    color: var(--dungeon-muted);
}

.dungeon-page .dungeon-share-toggle,
.dungeon-page .dungeon-share-choice {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    color: #f7dfbf;
    cursor: pointer;
}

.dungeon-page .dungeon-share-toggle input,
.dungeon-page .dungeon-share-choice input {
    width: 22px;
    height: 22px;
    flex: none;
    accent-color: var(--dungeon-accent);
}

.dungeon-page .dungeon-share-choices {
    margin: 12px 0 0;
    padding: 0;
    border: 0;
}

.dungeon-page .dungeon-share-choices legend {
    float: none;
    width: auto;
    margin: 0;
    padding: 0;
    color: var(--dungeon-muted);
    font-size: 0.78rem;
    text-transform: uppercase;
}

.dungeon-page .dungeon-share-row {
    display: flex;
    gap: 8px;
    margin: 10px 0;
}

.dungeon-page .dungeon-share-link {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 44px;
    border: 1px solid var(--dungeon-border);
    border-radius: 6px;
    background: var(--dungeon-bg);
    color: #f7dfbf;
    padding: 8px 10px;
}

.dungeon-page .dungeon-feature-dialog .dungeon-btn {
    min-height: 44px;
}

.dungeon-page .dungeon-versions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
    gap: 16px;
}

.dungeon-page .dungeon-versions-list {
    display: grid;
    align-content: start;
    gap: 6px;
    max-height: min(60vh, 460px);
    overflow-y: auto;
}

.dungeon-page .dungeon-version-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    min-height: 52px;
    padding: 8px 12px;
    border: 1px solid rgba(182, 203, 208, 0.14);
    border-radius: 6px;
    background: rgba(18, 32, 39, 0.72);
    color: #f7dfbf;
    text-align: left;
}

.dungeon-page .dungeon-version-row.is-selected {
    border-color: var(--dungeon-accent);
}

.dungeon-page .dungeon-version-meta {
    color: var(--dungeon-muted);
    font-size: 0.8rem;
}

.dungeon-page .dungeon-versions-preview {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}

.dungeon-page .dungeon-versions-canvas {
    max-width: 100%;
    height: auto !important;
    border: 1px solid rgba(182, 203, 208, 0.18);
    border-radius: 6px;
    background: var(--dungeon-bg);
}

.dungeon-page .dungeon-versions-floors {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

@media (max-width: 640px) {
    .dungeon-page .dungeon-versions {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* --- The free plan's chip on a landscape phone: "Free plan", the rest on a tap ---------------------------------------------- */

.dungeon-page[data-layout="phone"][data-orient="landscape"] .dungeon-header--slim .dungeon-plan-note:not(.is-expanded) .dungeon-plan-left,
.dungeon-page[data-layout="phone"][data-orient="landscape"] .dungeon-header--slim .dungeon-plan-note:not(.is-expanded) a {
    display: none;
}

.dungeon-page[data-layout="phone"][data-orient="landscape"] .dungeon-header--slim .dungeon-plan-note:not(.is-expanded) strong {
    margin-right: 0;
}

/* --- A shared dungeon (read only) ------------------------------------------------------------------------------------------- */

.dungeon-page .dungeon-shared-banner {
    display: flex;
    grid-column: 1 / -1;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    padding: 6px 12px;
    border: 1px solid rgba(242, 192, 128, 0.35);
    border-radius: 8px;
    background: rgba(242, 192, 128, 0.08);
    color: #f7dfbf;
}

.dungeon-page .dungeon-shared-banner-text {
    flex: 1 1 auto;
    font-weight: 700;
}

.dungeon-page .dungeon-shared-make {
    min-height: 44px;
    text-decoration: none;
}

/* The editing controls a viewer does not have (the editor's code ignores them too; this is what the viewer sees). */
.dungeon-page[data-read-only="true"] .dungeon-rail,
.dungeon-page[data-read-only="true"] .dungeon-flyout,
.dungeon-page[data-read-only="true"] .dungeon-header-actions,
.dungeon-page[data-read-only="true"] .dungeon-size-controls,
.dungeon-page[data-read-only="true"] .dungeon-plan-note,
.dungeon-page[data-read-only="true"] .dungeon-save-status,
.dungeon-page[data-read-only="true"] .dungeon-chip,
.dungeon-page[data-read-only="true"] .dungeon-peek,
.dungeon-page[data-read-only="true"] .dungeon-held-actions,
.dungeon-page[data-read-only="true"] [data-side-tab][hidden],
.dungeon-page[data-read-only="true"] [data-side-panel][hidden],
.dungeon-page[data-read-only="true"] #dungeon-undo-btn,
.dungeon-page[data-read-only="true"] #dungeon-redo-btn,
.dungeon-page[data-read-only="true"] #dungeon-right-click-btn,
.dungeon-page[data-read-only="true"] #dungeon-phone-undo,
.dungeon-page[data-read-only="true"] .dungeon-phonebar > .dungeon-tool:not(#dungeon-phone-more),
.dungeon-page[data-read-only="true"] .dungeon-more {
    display: none !important;
}

.dungeon-page[data-read-only="true"] .dungeon-title-row {
    grid-template-columns: minmax(0, 1fr);
}

.dungeon-page[data-read-only="true"] .dungeon-title-input {
    pointer-events: none;
    text-align: center;
}

.dungeon-page[data-read-only="true"] .dungeon-canvas-wrap {
    cursor: grab;
}

/* --- Share in the header: its label gives way to the icon where the header is crowded (the tooltip names it) ------------------- */

@media (min-width: 1200px) and (max-width: 1599px) {
    .dungeon-page .dungeon-header-actions > #dungeon-share-btn .dungeon-btn-label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
    }
}

.dungeon-page .dungeon-generation-detail summary {
    min-height: 32px;
    cursor: pointer;
    color: var(--dungeon-muted);
    font-size: 0.82rem;
}

/* --- The header's title keeps room to be read: the controls beside it wrap rather than squeeze it away ---------------------- */

.dungeon-page .dungeon-header--slim .dungeon-title-row {
    flex: 1 1 15rem;
    min-width: 15rem;
}

@media (max-width: 1199px) {
    .dungeon-page .dungeon-header--slim .dungeon-title-row {
        flex: initial;
        min-width: 0;
    }
}

/* Landscape phone: the banner is one slim line, its link the only 44 px control. */
.dungeon-page[data-layout="phone"][data-orient="landscape"] .dungeon-shared-banner {
    padding: 2px 8px;
    font-size: 0.8rem;
}

.dungeon-page[data-layout="phone"][data-orient="landscape"] .dungeon-shared-make {
    min-height: 40px;
}

/* --- Random window: legible hints, and the seed's buttons in the editor's gold outline -------------------------------------- */

.dungeon-random-more .form-text,
.dungeon-random-more .form-control::placeholder {
    color: #b6cbd0;
    opacity: 1;
}

.dungeon-random-more .dungeon-seed-btn {
    border: 1px solid rgba(242, 192, 128, 0.55);
    background: transparent;
    color: #f2c080;
}

.dungeon-random-more .dungeon-seed-btn:disabled {
    opacity: 0.45;
}

.dungeon-page .dungeon-share-toggle span,
.dungeon-page .dungeon-share-choice span {
    font-size: 1rem;
}

/* The opened chip is a paragraph again, not a row of flex items. */
.dungeon-page[data-layout="phone"][data-orient="landscape"] .dungeon-header--slim .dungeon-plan-note.is-expanded {
    display: block;
    padding: 8px 12px;
    font-size: 0.8rem;
    line-height: 1.4;
}

.dungeon-page[data-layout="phone"][data-orient="landscape"] .dungeon-header--slim .dungeon-plan-note.is-expanded strong {
    margin-right: 0;
}

/* --- Under the site's cookie notice ---------------------------------------------------------------------------------- */

/* The notice (z-index 1001, base template) sits at the bottom of the screen on a first visit and has to stay answerable.
   The fixed parts of the editor that can lie under it (the phone bar, the sheets and their scrim, the narrow layout's
   sidebar) therefore sit just below it, around 900 as on the Battlemap page (battlemap_layout.css), and keep their own
   order: the bar, then the scrim that dims the editor, then the sheet the scrim belongs to (a sheet level with its
   scrim would lie under it, and every tap in the sheet would close it). Dialogs, toasts and the full-screen mode stay
   over the notice. */
.dungeon-page {
    --dungeon-under-notice-z: 900;
    --dungeon-bar-z: calc(var(--dungeon-under-notice-z) - 10);
    --dungeon-sheet-z: calc(var(--dungeon-under-notice-z) + 10);
}

.dungeon-page .dungeon-scrim {
    z-index: var(--dungeon-under-notice-z);
}

.dungeon-page[data-layout="phone"] .dungeon-phonebar {
    z-index: var(--dungeon-bar-z);
}

.dungeon-page[data-layout="tablet"] .dungeon-side,
.dungeon-page[data-layout="phone"] .dungeon-side,
.dungeon-page[data-layout="phone"] .dungeon-flyout {
    z-index: var(--dungeon-sheet-z);
}

@media (max-width: 920px) {
    .dungeon-page .dungeon-sidebar {
        z-index: var(--dungeon-under-notice-z);
    }
}

/* --- The desktop header gives things up before the name is squeezed (dungeon_editor_shell.js, fitHeader) ----------------------------
   The name keeps room for 22 characters and shows an ellipsis beyond them (its full text is in the box's tooltip). When the row
   is too crowded for that the shell sets data-header-step: 1 the saving status shrinks to a dot and a word, 2 the size folds into
   one "Size" button with a popover, 3 the rarely used actions are in the More menu, 4 every action is. */
.dungeon-page[data-layout="desktop"] .dungeon-header--slim {
    grid-template-columns: minmax(min-content, 1fr) auto auto;
}

.dungeon-page[data-layout="desktop"] .dungeon-header--slim .dungeon-title-row {
    min-width: min-content;
}

.dungeon-page[data-layout="desktop"] .dungeon-header--slim .dungeon-title-input {
    min-width: 22ch;
    text-overflow: ellipsis;
}

.dungeon-page[data-layout="desktop"] .dungeon-header--slim .dungeon-title-row .dungeon-save-status {
    flex: none;
}

.dungeon-page .dungeon-size-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

/* The saving status is never cut: it keeps its width (the name gives way and shows an ellipsis), and where the header is
   crowded (a header step, a tablet or a phone) it says one word after a dot of its colour, its sentence in the tooltip. */
.dungeon-page .dungeon-header--slim .dungeon-title-row .dungeon-save-status {
    flex: none;
    white-space: nowrap;
}

.dungeon-page .dungeon-save-short {
    display: none;
}

.dungeon-page[data-header-step]:not([data-header-step="0"]) .dungeon-save-status .dungeon-save-full,
.dungeon-page:is([data-layout="tablet"], [data-layout="phone"]) .dungeon-save-status .dungeon-save-full {
    display: none;
}

.dungeon-page[data-header-step]:not([data-header-step="0"]) .dungeon-save-status .dungeon-save-short,
.dungeon-page:is([data-layout="tablet"], [data-layout="phone"]) .dungeon-save-status .dungeon-save-short {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.dungeon-page .dungeon-save-short::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #e8a33a;
}

.dungeon-page .dungeon-save-status.is-saved .dungeon-save-short::before {
    background: var(--dungeon-accent);
}

.dungeon-page .dungeon-save-status.is-error .dungeon-save-short::before {
    background: var(--dungeon-danger);
}

.dungeon-page .dungeon-size-wrap.is-folded > .dungeon-size-controls {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 1060;
    flex-wrap: wrap;
    width: max-content;
    max-width: calc(100vw - 24px);
    padding: 12px;
    border: 1px solid rgba(242, 192, 128, 0.35);
    border-radius: 10px;
    background: var(--dungeon-surface);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.5);
}

.dungeon-page .dungeon-size-wrap.is-folded:not(.is-open) > .dungeon-size-controls {
    display: none;
}

.dungeon-page .dungeon-size-wrap.is-folded > .dungeon-size-controls .dungeon-note {
    display: block;
    flex-basis: 100%;
}

.dungeon-page[data-header-step="3"] .dungeon-more,
.dungeon-page[data-header-step="4"] .dungeon-more {
    display: block;
}

/* Before the shell has moved them into the More menu (it runs when the page has loaded) the header's actions and the map's
   size would show in the header of a tablet or phone and flash there: they stay out of sight until they are placed. */
.dungeon-page:not([data-layout="desktop"]) .dungeon-header-actions > [data-header-action],
.dungeon-page:not([data-layout="desktop"]) .dungeon-size-wrap > .dungeon-size-controls {
    display: none;
}

/* --- The floors and the map's buttons both fit: where the map's frame is too narrow for the buttons beside the floors, the floors take a row of their own ------
   (the frame is the container, so it holds for a tablet, a narrow desktop window and the drawer's state alike). A phone floats the floors over the map instead. */
@container (max-width: 919px) {
    .dungeon-page:not([data-layout="phone"]) .dungeon-map-toolbar {
        flex-wrap: wrap;
        row-gap: 6px;
    }

    .dungeon-page:not([data-layout="phone"]) .dungeon-map-toolbar .dungeon-floor-tabs {
        flex: 1 0 100%;
    }

    .dungeon-page:not([data-layout="phone"]) .dungeon-map-toolbar .dungeon-map-actions {
        flex-wrap: wrap;
        margin-left: auto;
        justify-content: flex-end;
    }
}

/* The close X of this page's windows (Bootstrap's is dark: on the dark windows it cannot be seen). */
#dungeon-random-modal .btn-close,
#dungeon-plan-modal .btn-close,
.dexp-modal .btn-close {
    filter: invert(1) brightness(1.6);
    opacity: 0.9;
}

#dungeon-random-modal .btn-close:hover,
#dungeon-plan-modal .btn-close:hover,
.dexp-modal .btn-close:hover {
    opacity: 1;
}

/* The line under the map also tells what to do next (a monster waits to be placed): that is not a problem, so it is not red. */
.dungeon-page .dungeon-map-caption.is-hint {
    border-color: rgba(242, 192, 128, 0.35);
    background: rgba(242, 192, 128, 0.1);
    color: var(--dungeon-text);
}

/* The header's Save button (the site's .btn-buy has no focus ring of its own) shows where the keyboard is, as its neighbours do. */
.dungeon-page .dungeon-header-actions .btn-buy:focus-visible {
    outline: 2px solid #e7bf8f;
    outline-offset: 3px;
}

/* --- The right-click menu of a placement (Edit, Move, Duplicate, Delete) -------------------------------------------------- */

.dungeon-page .dungeon-context-menu {
    position: fixed;
    z-index: 1070;
    display: grid;
    min-width: 168px;
    padding: 4px;
    border: 1px solid var(--dungeon-border);
    border-radius: 8px;
    background: var(--dungeon-surface);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
}

.dungeon-page .dungeon-context-menu[hidden] {
    display: none;
}

.dungeon-page .dungeon-context-item {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 34px;
    padding: 4px 10px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--dungeon-text);
    font-size: 0.9rem;
    text-align: left;
}

.dungeon-page .dungeon-context-item i {
    width: 1.1em;
    color: var(--dungeon-muted);
    text-align: center;
}

.dungeon-page .dungeon-context-item:hover,
.dungeon-page .dungeon-context-item:focus-visible {
    background: rgba(var(--dungeon-accent-rgb), 0.18);
    outline: none;
}

@media (any-pointer: coarse) {
    .dungeon-page .dungeon-context-item {
        min-height: 44px;
    }
}

/* A monster card arms its monster when clicked, and can be dragged onto the map. */
.dungeon-page .dungeon-monster-card[draggable="true"] {
    cursor: grab;
}

.dungeon-page .dungeon-monster-card:focus-visible {
    outline: 2px solid var(--dungeon-accent);
    outline-offset: 2px;
}

/* --- One standard for the controls of the panels (the tool options, the Inspector, the lists and the dialogs) -------------
   A button says what it does in a few words, in sentence case, on one line, and is no taller than the page's standard
   button; what it does in full is its tooltip. A tick box's label reads as a sentence, not as an upper-case field label. */
.dungeon-page :is(.dungeon-flyout, .dungeon-side, .dungeon-statusbar, .dungeon-dialog, .dungeon-layers-panel) .dungeon-btn:is(.btn-close-dnd, .btn-buy) {
    min-height: 36px;
    padding: 4px 12px;
    font-size: 0.86rem;
    line-height: 1.2;
    text-transform: none;
    white-space: nowrap;
}

.dungeon-page .dungeon-field--check span {
    color: var(--dungeon-text);
    font-size: 0.9rem;
    text-transform: none;
}

@media (any-pointer: coarse) {
    .dungeon-page :is(.dungeon-flyout, .dungeon-side, .dungeon-statusbar, .dungeon-dialog, .dungeon-layers-panel) .dungeon-btn:is(.btn-close-dnd, .btn-buy) {
        min-height: 44px;
    }
}

/* A choice in the Inspector takes the whole row: its options' names (a trap's, a piece of furniture's, a facing) are read
   in full, never cut after a few letters. */
.dungeon-page .dungeon-inspector-grid .dungeon-field:has(> select) {
    grid-column: 1 / -1;
}

/* --- Touch screens: docking the editor ----------------------------------------------------------------------------------
   Until the editor fills the screen (data-docked, dungeon_editor_shell.js) a finger on the map scrolls the page as it does
   anywhere else (dungeon_generator.js leaves it to the page): the map's frame does not scroll inside, and a swipe up docks
   the editor (dungeon_generator.css snaps the page to it; a fling does not fly past it). */
@media (any-pointer: coarse) {
    .dungeon-page:not([data-docked="true"]) #dungeon-canvas,
    .dungeon-page:not([data-docked="true"]) .dungeon-canvas-wrap {
        touch-action: pan-y;
    }

    .dungeon-page:not([data-docked="true"]):not([data-layout="desktop"]) .dungeon-canvas-wrap {
        overflow: hidden;
        overscroll-behavior: auto;
    }
}

@media (hover: none) and (pointer: coarse) {
    .dungeon-generator.dungeon-page {
        scroll-snap-stop: always;
    }
}

/* "Start editing": the first view's way to the editor on a phone or tablet, over the top of the map (the part of the
   editor a first view shows; the bottom of the screen is the cookie banner's). */
.dungeon-page .dungeon-start-editing {
    position: absolute;
    top: 64px;
    left: 50%;
    z-index: 25;
    transform: translateX(-50%);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
}

.dungeon-page .dungeon-start-editing[hidden] {
    display: none;
}

/* A phone held sideways shows only the top of the editor at first: the button sits at the top of the map, between the
   floors (left) and the view controls (right). */
.dungeon-page[data-layout="phone"][data-orient="landscape"] .dungeon-start-editing {
    top: 6px;
}

/* What a setting of the Dungeon tab is used for, when the editor's map does not show it (lighting, music, sky). */
.dungeon-page .dungeon-field-note {
    color: var(--dungeon-muted);
    font-size: 0.8rem;
}

/* The Keyboard shortcuts window: its groups side by side with room to breathe, each under a ruled heading. */
.dungeon-page #dungeon-shortcuts-dialog {
    width: min(1180px, calc(100vw - 32px));
}

.dungeon-page .dungeon-shortcuts {
    gap: 6px 40px;
}

.dungeon-page .dungeon-shortcuts h3 {
    padding-bottom: 4px;
    border-bottom: 1px solid var(--dungeon-surface-line);
    font-size: 0.95rem;
}

.dungeon-page .dungeon-shortcuts dl {
    gap: 10px 14px;
}

.dungeon-page .dungeon-shortcuts dd {
    font-size: 0.92rem;
    line-height: 1.35;
}

/* The Random dungeon window fits the screen (a phone's too): no gap above it, its options scroll inside, and its
   Close / Generate row stays in sight at the bottom. */
#dungeon-random-modal .modal-content {
    margin-top: 0;
}

/* The buttons line up with the fields above them: the body's padding (16px) plus the margin of the form's group
   (20px, styles9.css .free-tool-form-group), and stand apart. */
#dungeon-random-modal .modal-footer {
    position: sticky;
    bottom: -16px;
    z-index: 2;
    gap: 8px;
    margin: 0 -16px -16px;
    padding: 10px 36px;
    background: var(--dungeon-surface, #0e171c);
    border-top: 1px solid rgba(242, 192, 128, 0.16);
}

/* A phone has no room for that inset beside "Generate dungeon": the buttons keep the gap and stay on one row. */
@media (max-width: 575.98px) {
    #dungeon-random-modal .modal-footer {
        padding-inline: 20px;
    }
}

/* A tablet's map has its controls in a row (two when upright) at its top: the button sits below them. */
.dungeon-page[data-layout="tablet"] .dungeon-start-editing {
    top: 60px;
}

.dungeon-page[data-layout="tablet"]:not([data-orient="landscape"]) .dungeon-start-editing {
    top: 120px;
}
