@font-face {
    font-family: "FrizQuadrata";
    src: url(./fonts/FrizQuadrata.ttf);
}

/* Dark parchment, brass and amber. PS1-sharp: no rounding, no blur, hard pixel shadows. */
:root {
    --ink: #0c0906;
    --soot: #15100b;
    --parchment-dark: #241a11;
    --parchment: #33261a;
    --parchment-light: #4a3824;
    --brass-dark: #5e4622;
    --brass: #a8834a;
    --brass-light: #d9b779;
    --amber: #ffb340;
    --amber-dim: #b9761f;
    --text: #e8d6ae;
    --muted: #a38f68;
    --danger: #e0674a;
    --pixel: 2px;
    --hard-shadow: 4px 4px 0 #000000b0;
    --font-display: "FrizQuadrata", "Palatino Linotype", "Book Antiqua", Georgia, serif;
    --font-body: "Palatino Linotype", "Book Antiqua", Georgia, serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    border-radius: 0;
}

html {
    font-family: var(--font-display);
    user-select: none;
    -webkit-font-smoothing: none;
    font-smooth: never;
}

body {
    background-color: var(--ink);
    padding: 0;
    margin: 0;
    overflow: hidden;
    height: 100vh;
    color: var(--text);
}

[hidden] {
    display: none !important;
}

canvas {
    pointer-events: all;
    display: block;
    width: 100%;
    height: 100%;
}

#game {
    position: fixed;
    inset: 0;
}

#interface {
    position: absolute;
    inset: 0;
    pointer-events: none;
    box-shadow: inset 0 0 0 3px #00000080, inset 0 0 0 4px #a8834a22;
    image-rendering: pixelated;
}

.window,
.displayer {
    position: absolute;
}

.window {
    inset: 0;
    z-index: 1;
    pointer-events: auto;
}

.window[is-visible="false"],
.displayer[is-visible="false"] {
    display: none;
}

.displayer {
    z-index: 0;
    pointer-events: none;
}

/* ---------- shared surfaces ---------- */

.overlay {
    position: absolute;
    inset: 0;
    overflow: hidden;
    background-color: #0c090699;
    /* ordered 2x2 dither instead of a soft blur */
    background-image:
        repeating-conic-gradient(#00000059 0 25%, transparent 0 50%);
    background-size: 4px 4px;
}

.parchment {
    position: relative;
    color: var(--text);
    background-color: var(--parchment-dark);
    background-image:
        repeating-linear-gradient(0deg, #ffffff06 0 2px, transparent 2px 6px),
        repeating-linear-gradient(90deg, #00000026 0 2px, transparent 2px 8px),
        linear-gradient(180deg, var(--parchment) 0%, var(--parchment-dark) 55%, var(--soot) 100%);
    border: var(--pixel) solid var(--brass);
    outline: var(--pixel) solid var(--brass-dark);
    outline-offset: 2px;
    box-shadow: inset 0 0 0 var(--pixel) #00000080, inset 0 0 0 4px #d9b77918, var(--hard-shadow);
}

/* brass rivets */
.parchment::before,
.parchment::after {
    content: "";
    position: absolute;
    top: 6px;
    width: 6px;
    height: 6px;
    background: var(--brass-light);
    box-shadow: 2px 2px 0 var(--brass-dark);
}

.parchment::before {
    left: 6px;
}

.parchment::after {
    right: 6px;
}

.sigil {
    color: var(--amber);
    text-shadow: 2px 2px 0 #000;
}

h1 {
    margin: 0;
    font-family: var(--font-display);
    font-weight: normal;
    font-variant-caps: petite-caps;
    letter-spacing: 2px;
    color: var(--brass-light);
    text-shadow: 2px 2px 0 #000;
}

button {
    font-family: var(--font-display);
    cursor: pointer;
}

button:focus-visible,
input:focus-visible {
    outline: var(--pixel) solid var(--amber);
    outline-offset: 2px;
}

.brass-button {
    padding: 8px 22px;
    border: var(--pixel) solid var(--brass);
    background: linear-gradient(180deg, var(--parchment-light) 0 50%, var(--parchment) 50% 100%);
    color: var(--brass-light);
    font-size: 18px;
    font-variant-caps: petite-caps;
    letter-spacing: 1px;
    text-shadow: 1px 1px 0 #000;
    box-shadow: inset 0 0 0 1px #00000080, 3px 3px 0 #000;
}

.brass-button:hover,
.brass-button:focus-visible {
    color: var(--amber);
    border-color: var(--amber-dim);
}

.brass-button:active {
    transform: translate(2px, 2px);
    box-shadow: inset 0 0 0 1px #00000080, 1px 1px 0 #000;
}

/* ---------- main menu ---------- */

.main-menu-panel {
    position: absolute;
    top: 0;
    bottom: 0;
    left: clamp(0px, 7vw, 100px);
    width: min(340px, 100%);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: min(22vh, 170px) 28px 28px;
    border-top: none;
    border-bottom: none;
    outline: none;
    box-shadow: inset 0 0 0 4px #d9b77912, 6px 0 0 #000000b0;
}

.main-menu-panel::before,
.main-menu-panel::after {
    top: auto;
    bottom: 10px;
}

.main-menu-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    margin-bottom: 26px;
}

.main-menu-sigil {
    font-size: 34px;
    line-height: 1;
}

.main-menu-kicker {
    margin: 0;
    font-family: var(--font-body);
    font-style: italic;
    font-size: 14px;
    letter-spacing: 1px;
    color: var(--muted);
}

.main-menu-title {
    font-size: 34px;
}

.rule {
    display: block;
    width: 100%;
    height: 4px;
    margin-top: 6px;
    border-top: var(--pixel) solid var(--brass);
    border-bottom: var(--pixel) solid var(--brass-dark);
}

.menu-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.menu-action {
    position: relative;
    padding: 8px 8px 8px 26px;
    border: none;
    border-bottom: 1px solid #a8834a33;
    background: none;
    color: var(--brass-light);
    font-size: 26px;
    font-variant-caps: petite-caps;
    text-align: left;
    text-shadow: 2px 2px 0 #000;
    transition: padding-left 0.2s steps(3), color 0.2s steps(2);
}

.menu-action::before {
    content: "\25B8";
    position: absolute;
    left: 4px;
    color: var(--amber);
    opacity: 0;
}

.menu-action:not(:disabled):hover,
.menu-action:not(:disabled):focus-visible {
    padding-left: 38px;
    color: var(--amber);
    outline: none;
}

.menu-action:not(:disabled):hover::before,
.menu-action:not(:disabled):focus-visible::before {
    opacity: 1;
}

.menu-action:disabled {
    cursor: default;
    color: var(--muted);
    opacity: 0.55;
}

.main-menu-readiness {
    margin: auto 0 0;
    padding-top: 16px;
    font-family: var(--font-body);
    font-style: italic;
    font-size: 14px;
    color: var(--muted);
}

.main-menu-readiness[data-state="ready"] {
    color: var(--amber);
}

.main-menu-readiness[data-state="failed"] {
    color: var(--danger);
}

/* ---------- dialogs ---------- */

.inventory-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
    gap: 12px;
    align-content: start;
    overflow-y: auto;
    min-height: 0;
    padding: 8px;
}

.inventory-empty {
    grid-column: 1 / -1;
    margin: 4px 0;
    color: var(--muted);
    font: italic 15px var(--font-body);
}

.inventory-entry {
    min-width: 0;
}

.inventory-empty-slot {
    height: 64px;
    box-sizing: border-box;
    border: 1px solid #b495573d;
    background: #17141055;
    box-shadow: inset 0 1px 5px #00000040;
}

.inventory-entry > .inventory-item {
    width: 100%;
}

.inventory-entry > .inventory-item-icon {
    width: 100%;
}

.text-dialog-actions {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 12px;
}

.text-dialog-message {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    line-height: 1.7;
}

.text-dialog-subject {
    padding: 14px 18px;
    border-left: 2px solid var(--brass);
    background: #201a1266;
    overflow-wrap: anywhere;
}

.text-dialog-subject-name {
    color: var(--brass-light);
    font-size: 21px;
}

.text-dialog-subject-author {
    margin: 8px 0 0;
    color: var(--muted);
    font-style: italic;
}

.text-dialog-error {
    color: var(--danger);
}

.inventory-item-icon {
    width: 64px;
    height: 64px;
    border: 2px solid var(--brass);
    background: var(--parchment);
    padding: 8px;
    color: var(--amber);
}

.inventory-item-icon svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
    fill-opacity: 0.12;
    stroke: currentColor;
    stroke-width: 2;
}

.inventory-item-icon:focus-visible {
    outline: 2px solid var(--amber);
}

.inventory-own-journal {
    color: #e8cf89;
    background: radial-gradient(circle, #75643166, #251e19);
    border-color: #dfc37b;
}

.inventory-own-journal .journal-seal {
    fill: #d3b86d;
    fill-opacity: 1;
    stroke: var(--ink);
    stroke-width: 1;
}

.universal-tooltip {
    position: fixed;
    z-index: 100;
    pointer-events: none;
    padding: 12px 24px;
    max-width: min(300px, calc(100vw - 16px));
    overflow-wrap: anywhere;
}

.universal-tooltip p {
    margin: 8px 0 0;
}

#inventory .dialog {
    width: min(760px, calc(100% - 32px));
    height: min(560px, calc(100% - 32px));
    overflow: hidden;
}

#inventory .dialog-header,
#inventory .dialog-footer {
    flex-shrink: 0;
}

#inventory .dialog-body {
    min-height: 0;
    flex: 1;
    overflow: auto;
}

#inventory .inventory-items {
    min-height: 0;
    flex: 1;
}

#journal .dialog {
    width: min(760px, calc(100% - 32px));
    height: min(640px, calc(100% - 32px));
}

.journal-entries {
    min-height: 100px;
    max-height: 240px;
    overflow-y: auto;
}

.journal-entry {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    user-select: text;
    line-height: 1.6;
}

.journal-reader-author {
    margin: 0 0 18px;
    color: var(--muted);
    font-style: italic;
    white-space: normal;
    overflow-wrap: anywhere;
}

#journal-draft {
    background: var(--ink);
    color: var(--text);
    border: 2px solid var(--brass);
    padding: 12px;
    resize: vertical;
    font: 16px var(--font-body);
}

.journal-error {
    color: var(--danger);
}

.inventory-item {
    text-align: left;
    min-width: 0;
    overflow-wrap: anywhere;
    position: relative;
}

.inventory-item-new {
    border-color: var(--amber);
    box-shadow: inset 0 0 12px #ffb34040, 0 0 8px #ffb34055;
}

.inventory-new-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    padding: 2px 4px;
    background: var(--ink);
    pointer-events: none;
    font: 11px var(--font-body);
    color: var(--amber);
    letter-spacing: 1px;
}

.inventory-item-icon .inventory-new-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    padding: 2px 4px;
    background: var(--ink);
}

#inventory-notifications {
    left: 24px;
    top: 35%;
    width: min(300px, calc(100% - 48px));
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.inventory-popup,
.interaction-prompt {
    background: #201a12cc;
    border: 1px solid #aa844455;
    border-left: 2px solid var(--brass);
    box-shadow: 0 3px 12px #00000025;
}

.inventory-popup {
    padding: 10px 16px;
    animation: inventory-popup-life 5s both;
}

.inventory-popup::before,
.inventory-popup::after,
.interaction-prompt::before,
.interaction-prompt::after {
    display: none;
}

.inventory-popup span,
.inventory-popup strong {
    display: block;
}

.inventory-popup span {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 6px;
}

@keyframes inventory-popup-life {
    0% { opacity: 0; transform: translateX(calc(-100% - 24px)); }
    8%, 85% { opacity: 1; transform: translateX(0); }
    100% { opacity: 0; transform: translateX(-24px); }
}

@media (prefers-reduced-motion: reduce) {
    .inventory-popup {
        animation: none;
    }
}

.interaction-prompt {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 20px;
    position: absolute;
    left: 50%;
    bottom: 90px;
    transform: translateX(-50%);
    padding: 12px 28px;
    width: max-content;
    max-width: calc(100% - 48px);
}

.interaction-error {
    flex-basis: 100%;
    color: var(--danger);
}

.inventory-item-name,
.inventory-item-author {
    display: block;
}

.inventory-item-name {
    padding-right: 32px;
}

.inventory-item-author {
    margin-top: 6px;
    color: var(--muted);
    font: italic 14px var(--font-body);
    font-variant-caps: normal;
    letter-spacing: 0;
}

#inventory-shortcut {
    bottom: 24px;
    left: 24px;
    pointer-events: auto;
}

#journal-shortcut {
    bottom: 24px;
    left: 236px;
    pointer-events: auto;
}

#crafting-shortcut {
    bottom: 24px;
    left: 436px;
    pointer-events: auto;
}

#journal .dialog,
#journal .journal-entries,
#journal-draft,
#inventory .dialog-body,
#inventory .inventory-items,
#item-picker .item-picker-grid,
#crafting .dialog-body {
    scrollbar-width: thin;
    scrollbar-color: var(--brass) var(--parchment-dark);
    scrollbar-gutter: stable;
}

#journal ::-webkit-scrollbar,
#inventory ::-webkit-scrollbar,
#journal .dialog::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

#journal ::-webkit-scrollbar-track,
#inventory ::-webkit-scrollbar-track,
#journal .dialog::-webkit-scrollbar-track {
    background: var(--parchment-dark);
    border-left: 1px solid var(--brass-dark);
}

#journal ::-webkit-scrollbar-thumb,
#inventory ::-webkit-scrollbar-thumb,
#journal .dialog::-webkit-scrollbar-thumb {
    background: var(--brass);
    border: 2px solid var(--parchment-dark);
}

#journal ::-webkit-scrollbar-thumb:hover,
#inventory ::-webkit-scrollbar-thumb:hover {
    background: var(--brass-light);
}

#journal ::-webkit-scrollbar-corner,
#inventory ::-webkit-scrollbar-corner {
    background: var(--parchment-dark);
}

#journal ::selection {
    background: var(--brass-light);
    color: var(--ink);
    text-shadow: none;
}

.emerald-theme {
    --parchment-dark: #10261f;
    --parchment: #193d30;
    --parchment-light: #285741;
    --soot: #091811;
    --brass-dark: #245c43;
    --brass: #52a879;
    --brass-light: #b4e4bc;
    --amber: #8befae;
    --amber-dim: #4ba373;
    --text: #d3ecda;
}

.inventory-shortcut {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
}

.inventory-bag-icon {
    width: 32px;
    height: 32px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

.input-icon {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-width: 28px;
    min-height: 28px;
    border: 2px solid var(--brass);
    box-shadow: 0 3px 0 var(--brass-dark);
    background: var(--ink);
}

@media (max-width: 540px) {
    #inventory-shortcut {
        bottom: 16px;
        left: 16px;
    }
    #journal-shortcut {
        bottom: 16px;
        left: 96px;
    }
    #crafting-shortcut {
        bottom: 16px;
        left: 176px;
    }
    #inventory-shortcut > span,
    #journal-shortcut > span,
    #crafting-shortcut > span {
        display: none;
    }
    #inventory-shortcut,
    #journal-shortcut,
    #crafting-shortcut {
        gap: 6px;
        padding: 8px;
    }
    #inventory-shortcut .inventory-bag-icon,
    #journal-shortcut .inventory-bag-icon,
    #crafting-shortcut .inventory-bag-icon {
        width: 18px;
        height: 24px;
    }
}

.inventory-item:disabled {
    cursor: default;
    opacity: 0.65;
}

.inventory-note {
    color: var(--muted);
}

.inventory-error {
    color: var(--danger);
}

#crafting .dialog {
    width: min(700px, calc(100% - 32px));
    height: min(740px, calc(100% - 32px));
    overflow: hidden;
    scrollbar-gutter: auto;
}

#crafting .dialog-body {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

#crafting .dialog-header,
#crafting .dialog-footer {
    flex-shrink: 0;
}

.craft-frame-ornament {
    position: absolute;
    top: 24%;
    width: 14px;
    height: 48%;
    fill: none;
    stroke: var(--brass);
    stroke-width: 0.7;
    opacity: 0.4;
    pointer-events: none;
}

.craft-frame-left { left: 9px; }
.craft-frame-right { right: 9px; }
.craft-error { color: var(--danger); flex-shrink: 0; margin: 0; }

.craft-elements {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: max(0px, min(100cqw - 36px, 100cqh - 36px, 424px));
    aspect-ratio: 1;
    border-radius: 50%;
    border: 1px solid #a8834a66;
    background: linear-gradient(#a8834a33, #a8834a33) center / 1px 90% no-repeat,
        linear-gradient(#a8834a33, #a8834a33) center / 90% 1px no-repeat,
        radial-gradient(circle, transparent 56%, #a8834a22 56.5%, transparent 57.5%, transparent 65%, #a8834a44 65.5%, transparent 66.5%);
}

.craft-elements::before,
.craft-elements::after {
    content: "";
    position: absolute;
    inset: 5%;
    border: 1px dashed #a8834a44;
    border-radius: 50%;
    pointer-events: none;
}

.craft-ornaments {
    position: absolute;
    inset: -4%;
    width: 108%;
    height: 108%;
    fill: none;
    stroke: var(--brass);
    stroke-width: 0.3;
    opacity: 0.3;
    pointer-events: none;
}

.craft-elements::after {
    inset: 23%;
    border: 1px solid #a8834a22;
    border-radius: 0;
    transform: rotate(45deg);
}

.craft-sanctum {
    position: relative;
    flex: 1;
    min-height: 0;
    width: 100%;
    container-type: size;
}

.craft-axis {
    position: absolute;
    color: var(--muted);
    font: italic 14px var(--font-body);
    background: var(--parchment-dark);
    padding: 0 6px;
}

.craft-hot { top: -10px; left: 50%; transform: translateX(-50%); }
.craft-cold { bottom: -10px; left: 50%; transform: translateX(-50%); }
.craft-dry { top: 50%; left: -16px; transform: translateY(-50%); }
.craft-wet { top: 50%; right: -16px; transform: translateY(-50%); }
.craft-fire { top: 12%; left: 12%; --element-color: #efad85; }
.craft-air { top: 12%; right: 12%; --element-color: #d6cfba; }
.craft-earth { bottom: 12%; left: 12%; --element-color: #b7c69b; }
.craft-water { bottom: 12%; right: 12%; --element-color: #9dc8e6; }

.craft-element {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 50%;
    color: var(--element-color);
    font: 13px var(--font-body);
    cursor: pointer;
    width: 76px;
    transition: color 140ms ease;
}

.craft-element svg,
.craft-slot svg {
    width: 40px;
    height: 40px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
}

.craft-element:not(:disabled):hover,
.craft-element:focus-visible,
.craft-element[aria-pressed="true"] {
    color: var(--brass-light);
}

.craft-element::after {
    content: "";
    width: 16px;
    height: 1px;
    margin-top: 3px;
    background: currentColor;
    opacity: 0;
    transform: scaleX(0.5);
    transition: opacity 140ms ease, transform 140ms ease;
}

.craft-element:not(:disabled):hover::after,
.craft-element:focus-visible::after,
.craft-element[aria-pressed="true"]::after {
    opacity: 0.7;
    transform: scaleX(1);
}

.craft-element:focus-visible {
    outline: 1px dashed var(--brass);
    outline-offset: 3px;
}

.craft-element:disabled {
    cursor: default;
}

.craft-core {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
}

.craft-slot,
.craft-slot.inventory-item-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 66px;
    height: 66px;
    border: 1px solid var(--brass);
    border-radius: 50%;
    background: var(--parchment-dark);
    padding: 10px;
    font-size: 30px;
    color: var(--text);
    cursor: pointer;
}

.craft-slot:focus-visible {
    outline: 2px solid var(--amber);
    outline-offset: 3px;
}

.craft-slot:disabled {
    opacity: 0.4;
    cursor: default;
}

.craft-conduit {
    width: 24px;
    height: 1px;
    background: #a8834a66;
}

.craft-core[data-ready="true"] .craft-conduit {
    background: #f0d7aa;
    box-shadow: 0 0 8px #a8834a66;
}

.craft-core[data-ready="true"] .craft-slot {
    border-color: #e8c994;
}

#crafting .craft-combine {
    align-self: center;
    min-width: 160px;
    flex-shrink: 0;
    margin-right: auto;
}

#crafting .dialog-footer {
    gap: 12px;
}

#inventory .dialog-footer {
    gap: 12px;
}

#inventory .inventory-craft {
    margin-right: auto;
}

#item-picker .dialog {
    width: min(600px, calc(100% - 32px));
}

.item-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, 64px);
    gap: 16px;
    max-height: 320px;
    overflow-y: auto;
    padding: 8px;
}

.item-picker-grid > p {
    grid-column: 1 / -1;
}

@media (max-width: 480px), (max-height: 600px) {
    #crafting .dialog {
        padding: 14px 18px;
    }

    #crafting .dialog-header {
        margin-bottom: 6px;
        padding-bottom: 6px;
    }

    #crafting .dialog-footer {
        margin-top: 8px;
    }

    #crafting .craft-combine {
        min-width: 0;
    }

    .craft-slot,
    .craft-slot.inventory-item-icon {
        width: 40px;
        height: 40px;
        padding: 6px;
        font-size: 24px;
    }

    .craft-conduit { width: 16px; }
    .craft-element { width: 54px; font-size: 12px; }
    .craft-element svg,
    .craft-slot svg { width: 28px; height: 28px; }
    .craft-fire,
    .craft-air { top: 4%; }
    .craft-earth,
    .craft-water { bottom: 4%; }
}

.craft-result {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 92%;
    margin: 0;
    padding: 0;
    border: 1px solid var(--brass-dark);
    background: var(--parchment-dark);
    box-shadow: var(--hard-shadow);
    text-align: center;
    font-size: clamp(12px, 4cqw, 18px);
    font-style: italic;
    animation: craft-result-popup 5s ease both;
}

.craft-result-dismiss {
    display: block;
    width: 100%;
    border: 0;
    padding: 12px;
    background: transparent;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

.craft-result-dismiss:focus-visible {
    outline: 1px solid var(--brass-light);
    outline-offset: 3px;
}

.craft-core[hidden] {
    display: none;
}

@keyframes craft-result-popup {
    0% { opacity: 0; transform: translate(-50%, calc(-50% + 8px)); }
    8%, 80% { opacity: 1; transform: translate(-50%, -50%); }
    100% { opacity: 0; transform: translate(-50%, calc(-50% - 8px)); }
}

@media (prefers-reduced-motion: reduce) {
    .craft-result { animation: none; }
}

.item-text {
    white-space: pre-wrap;
    line-height: 1.7;
}

.dialog {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(640px, calc(100% - 32px));
    max-height: calc(100% - 32px);
    overflow: auto;
    display: flex;
    flex-direction: column;
    padding: 24px 32px;
}

.dialog-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding-bottom: 12px;
    margin-bottom: 18px;
    border-bottom: var(--pixel) solid var(--brass-dark);
}

.dialog-header h1 {
    font-size: 28px;
}

.dialog-header .sigil {
    font-size: 12px;
}

.dialog-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
    font-family: var(--font-body);
}

.dialog-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 24px;
}

.dialog-note {
    margin: 6px 0 0;
    font-size: 13px;
    font-style: italic;
    color: var(--muted);
    text-align: center;
}

.setting-row {
    display: grid;
    grid-template-columns: 1fr auto 96px;
    align-items: center;
    gap: 14px;
    padding: 8px 10px;
    background: #0000002e;
    border-left: var(--pixel) solid var(--brass-dark);
}

.setting-name {
    letter-spacing: 1px;
}

#settings-language {
    grid-column: 2 / -1;
    color: var(--text);
    background: var(--ink);
    border: 1px solid var(--brass-dark);
    padding: 6px 10px;
    font: inherit;
    pointer-events: auto;
}

.setting-value {
    font-style: italic;
    color: var(--amber);
    text-align: right;
}

.controls-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px 20px;
    align-items: center;
    margin: 0;
}

.controls-list dt {
    display: flex;
    gap: 4px;
}

.controls-list dd {
    margin: 0;
}

kbd {
    display: inline-block;
    min-width: 30px;
    padding: 3px 7px;
    border: var(--pixel) solid var(--brass);
    background: var(--parchment-light);
    color: var(--amber);
    font-family: var(--font-display);
    font-size: 14px;
    text-align: center;
    text-shadow: 1px 1px 0 #000;
    box-shadow: 0 3px 0 var(--brass-dark), 0 5px 0 #000;
}

/* ---------- range inputs ---------- */

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    cursor: pointer;
    width: 220px;
    pointer-events: all;
}

input[type="range"]:disabled {
    cursor: default;
    opacity: 0.5;
}

input[type="range"]::-webkit-slider-runnable-track {
    height: 6px;
    background: var(--ink);
    border: 1px solid var(--brass-dark);
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    margin-top: -7px;
    width: 8px;
    height: 18px;
    background: var(--brass-light);
    border: 1px solid #000;
    box-shadow: 2px 2px 0 #000;
}

input[type="range"]:focus-visible::-webkit-slider-thumb {
    background: var(--amber);
}

input[type="range"]::-moz-range-track {
    height: 6px;
    background: var(--ink);
    border: 1px solid var(--brass-dark);
}

input[type="range"]::-moz-range-thumb {
    width: 8px;
    height: 18px;
    background: var(--brass-light);
    border: 1px solid #000;
    border-radius: 0;
    box-shadow: 2px 2px 0 #000;
}

input[type="range"]:focus-visible::-moz-range-thumb {
    background: var(--amber);
}

/* ---------- HUD ---------- */

.hud-plaque,
.status-plaque,
#version {
    color: var(--text);
    background: #15100bdd;
    border: var(--pixel) solid var(--brass-dark);
    box-shadow: inset 0 0 0 1px #d9b77920, 3px 3px 0 #000000a0;
    text-shadow: 1px 1px 0 #000;
}

#score {
    top: 12px;
    right: 12px;
}

.hud-plaque {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 6px 14px;
    font-size: 18px;
}

.hud-plaque .sigil {
    font-size: 11px;
}

.score-label {
    font-variant-caps: petite-caps;
    letter-spacing: 1px;
    color: var(--brass-light);
}

.score-value {
    min-width: 2ch;
    text-align: right;
    color: var(--amber);
    font-size: 22px;
}

#world-status {
    position: absolute;
    bottom: 48px;
    left: 50%;
    transform: translateX(-50%);
    max-width: calc(100% - 32px);
    padding: 8px 18px;
    font-family: var(--font-body);
    font-style: italic;
    font-size: 15px;
    text-align: center;
    color: var(--brass-light);
    z-index: 2;
}

#world-status::before {
    content: "\2697  ";
    font-style: normal;
    color: var(--amber);
}

#version {
    position: absolute;
    right: 0;
    bottom: 0;
    padding: 4px 10px 4px 14px;
    font-size: 13px;
    color: var(--muted);
    border-right: none;
    border-bottom: none;
}

body > footer {
    font-family: var(--font-display);
    letter-spacing: 0.1em;
    font-size: 0.8em;
    position: absolute;
    bottom: 2%;
    width: 100%;
    text-align: center;
    color: var(--muted);
    text-shadow: 1px 1px 0 #000;
    pointer-events: none;
}

@media (max-width: 600px) {
    .main-menu-panel {
        left: 0;
        padding-top: 72px;
    }

    .setting-row {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .setting-value {
        text-align: left;
    }

    input[type="range"] {
        width: 100%;
    }

    .dialog {
        padding: 18px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .menu-action {
        transition: none;
    }
}
.cutscene-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    pointer-events: auto;
}

body.cinematic #interface {
    visibility: hidden;
}

.cutscene-fade {
    position: absolute;
    inset: 0;
    background: #000;
    opacity: 0;
}

.cutscene-caption {
    position: absolute;
    bottom: 18%;
    width: 100%;
    box-sizing: border-box;
    padding: 0 8%;
    line-height: 1.6;
    text-align: center;
    color: #ddd4c2;
    font: 24px var(--font-body);
    letter-spacing: 0.12em;
    text-shadow: 0 2px 6px #000;
}