.game-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) clamp(19rem, 22vw, 24rem);
    gap: clamp(.7rem, 1.15vw, 1.2rem);
    align-items: start;
}

.map-panel,
.story-panel {
    border: 1px solid var(--line);
    border-radius: .75rem;
    box-shadow: var(--shadow);
}

.map-panel {
    overflow: hidden;
    min-width: 0;
    background: #000;
}

.story-panel {
    position: sticky;
    top: 1rem;
    padding: clamp(1.2rem, 2vw, 1.8rem);
    background:
        linear-gradient(180deg, rgb(67 91 77 / 32%), transparent 8rem),
        var(--surface-raised);
    border-top: .3rem solid var(--moss);
}

.panel-heading {
    display: flex;
    gap: .45rem;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    min-height: 2.9rem;
    margin: 0;
    padding: .35rem .45rem;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(90deg, #14191a, #17171a);
}

.map-state {
    display: inline-block;
    max-width: 100%;
    margin: -.25rem 0 1rem !important;
    padding: .38rem .65rem;
    border: 1px solid rgb(91 98 107 / 82%);
    border-radius: 999px;
    color: #c4c0b8;
    background: rgb(12 14 17 / 78%);
    box-shadow: 0 4px 16px rgb(0 0 0 / 28%);
    font-size: .7rem;
    font-weight: 800;
    letter-spacing: .025em;
    line-height: 1.2 !important;
    backdrop-filter: blur(7px);
}

.story-panel h2,
.story-panel p {
    margin-top: 0;
}

.story-panel h2 {
    margin-bottom: .85rem;
    color: #f0ece3;
    font-size: clamp(1.35rem, 3vw, 2rem);
    line-height: 1.05;
}

.story-panel p {
    color: #b8b2a8;
    line-height: 1.65;
}

.map-control {
    display: inline-flex;
    gap: .45rem;
    align-items: center;
    min-height: 2.15rem;
    padding: .4rem .75rem;
    border: 1px solid #48524d;
    border-radius: .45rem;
    color: #d1d8d2;
    background: rgb(30 35 33 / 86%);
    font-size: .76rem;
    font-weight: 800;
    letter-spacing: .035em;
    line-height: 1;
    text-transform: lowercase;
    box-shadow: 0 2px 7px rgb(0 0 0 / 22%);
    cursor: pointer;
    transition:
        color .18s ease,
        border-color .18s ease,
        background-color .18s ease,
        transform .18s ease;
}

.map-control:hover {
    border-color: var(--moss);
    color: #fff;
    background: var(--moss);
}

.map-control:focus-visible {
    outline: 3px solid rgb(224 154 118 / 40%);
    outline-offset: 2px;
}

.map-control:active {
    transform: translateY(1px);
}

.map-control:disabled {
    border-color: var(--line);
    color: var(--muted);
    background: #13161a;
    box-shadow: none;
    cursor: wait;
    opacity: .7;
}

.map-reset-icon {
    font-size: 1.05rem;
    line-height: .8;
}

.canvas-frame {
    position: relative;
    overflow: hidden;
    min-height: max(calc(34rem - 50px), calc(100vh - 8.6rem - 50px));
    background: #000;
}

[data-map-canvas] {
    display: block;
    width: 100%;
    height: 100%;
    min-height: inherit;
    cursor: grab;
    touch-action: none;
    user-select: none;
    overscroll-behavior: contain;
}

[data-map-canvas].has-exit-hover {
    cursor: pointer;
}

[data-map-canvas].is-dragging {
    cursor: grabbing;
}

.generation-settings {
    display: grid;
    gap: .45rem;
    margin: 1.25rem 0 1.5rem;
    padding: 1rem;
    border: 1px solid #343d38;
    border-radius: .65rem;
    background: rgb(12 16 14 / 58%);
}

.generation-settings label {
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    align-items: baseline;
    color: #c8cec9;
    font-size: .8rem;
    font-weight: 800;
}

.generation-settings output {
    flex: 0 0 auto;
    color: var(--ember);
    font-variant-numeric: tabular-nums;
}

.generation-settings input[type="range"] {
    width: 100%;
    margin: 0 0 .6rem;
    accent-color: var(--moss);
    cursor: pointer;
}

.generation-settings input[type="range"]:disabled {
    cursor: wait;
    opacity: .55;
}

.generation-settings .settings-note {
    margin: -.1rem 0 0;
    color: var(--muted);
    font-size: .72rem;
    line-height: 1.45;
}

.map-error {
    margin: 0 0 1rem;
    padding: .75rem .85rem;
    border: 1px solid rgb(216 117 117 / 44%);
    border-radius: .55rem;
    color: #efaaaa !important;
    background: rgb(122 42 42 / 22%);
    font-size: .78rem;
    line-height: 1.5 !important;
}

.system-summary {
    display: grid;
    gap: .75rem;
    margin: 2rem 0 0;
}

.map-instruction {
    margin: 1.25rem 0 0 !important;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
    color: var(--muted) !important;
    font-size: .78rem;
    line-height: 1.55 !important;
}

.system-summary div {
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    padding-bottom: .65rem;
    border-bottom: 1px solid var(--line);
}

.system-summary dt {
    color: var(--muted);
}

.system-summary dd {
    margin: 0;
    color: var(--ember);
    font-weight: 800;
}

@media (max-width: 940px) {
    .game-shell {
        grid-template-columns: 1fr;
    }

    .story-panel {
        position: static;
    }
}

@media (max-width: 560px) {
    .canvas-frame {
        min-height: max(calc(30rem - 50px), calc(100vh - 8.5rem - 50px));
    }
}

.map-door-popup {
    position: absolute;
    z-index: 4;
    width: min(16.5rem, calc(100% - 2rem));
    overflow: visible;
    border: 1px solid rgb(25 29 27 / 92%);
    border-radius: .65rem;
    color: #22211f;
    background: #e9e2d8;
    box-shadow: 0 .45rem 1.15rem rgb(0 0 0 / 24%);
    font-size: .76rem;
    line-height: 1.25;
    pointer-events: auto;
    transform: translate(-50%, calc(-100% - .8rem));
}

.map-door-popup::after {
    position: absolute;
    left: 50%;
    bottom: -.42rem;
    width: .75rem;
    height: .75rem;
    border-right: 1px solid rgb(25 29 27 / 92%);
    border-bottom: 1px solid rgb(25 29 27 / 92%);
    background: #e9e2d8;
    content: "";
    transform: translateX(-50%) rotate(45deg);
}

.map-door-popup-header {
    position: relative;
    z-index: 1;
    display: grid;
    padding: .56rem .64rem;
    color: #f3eee7;
    background: linear-gradient(180deg, #353b37 0%, #292e2b 100%);
    border-bottom: 1px solid rgb(0 0 0 / 38%);
    border-radius: .6rem .6rem 0 0;
}

.map-door-popup-title {
    display: block;
    margin: 0;
    font-size: .94rem;
    font-weight: 800;
    line-height: 1.22;
}

.map-door-popup-actions {
    position: relative;
    z-index: 1;
    display: grid;
    gap: 1px;
    width: 100%;
    padding: 0;
    overflow: hidden;
    background: #bdb5aa;
    border-radius: 0 0 .6rem .6rem;
}

.map-door-popup-action {
    display: grid;
    grid-template-columns: 2rem minmax(0, 1fr);
    align-items: center;
    width: 100%;
    min-height: 2.35rem;
    padding: .34rem .48rem;
    border: 0;
    border-radius: 0;
    color: #292724;
    background: #eee8df;
    font: inherit;
    font-size: .96rem;
    font-weight: 750;
    text-align: left;
    cursor: pointer;
    transition: background-color 120ms ease, color 120ms ease;
}

.map-door-popup-action:hover {
    color: #18211d;
    background: #d4dfd6;
}

.map-door-popup-action:focus-visible {
    outline: 2px solid #7ea292;
    outline-offset: -2px;
}

.map-door-popup-action:disabled {
    cursor: wait;
    opacity: .55;
    transform: none;
}

.map-door-popup-action .door-action-icon {
    width: 1.78rem;
    height: 1.78rem;
    border: 0;
    border-radius: 0;
    background: transparent;
}

.map-door-popup-action .door-action-icon svg {
    width: 1.58rem;
    height: 1.58rem;
    stroke-width: 1.95;
}

.door-action-icon {
    display: inline-grid;
    place-items: center;
    width: 1.45rem;
    height: 1.45rem;
    border: 1px solid rgb(62 69 65 / 22%);
    border-radius: .32rem;
    color: #4b5c53;
    background: rgb(255 255 255 / 42%);
}

.door-action-icon svg {
    width: .9rem;
    height: .9rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.door-action-label {
    min-width: 0;
}

.door-inspector {
    margin: 0 0 1rem;
    padding: .9rem;
    border: 1px solid #4c5751;
    border-radius: .65rem;
    background: rgb(14 18 16 / 82%);
}

.door-inspector-heading {
    display: flex;
    gap: .75rem;
    align-items: flex-start;
    justify-content: space-between;
}

.door-inspector-heading .eyebrow {
    margin-bottom: .2rem;
}

.door-inspector h3 {
    margin: 0 0 .65rem;
    color: #f0ece3;
    font-size: 1.12rem;
}

.door-close {
    width: 1.9rem;
    height: 1.9rem;
    border: 1px solid #47504c;
    border-radius: 50%;
    color: #cbc7bf;
    background: #171b19;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
}

.door-description {
    margin: 0 0 .8rem !important;
    color: #d0cbc2 !important;
    font-size: .82rem;
    line-height: 1.55 !important;
}

.door-known-info {
    display: grid;
    gap: .55rem;
    margin-bottom: .8rem;
}

.door-info-card {
    padding: .55rem .65rem;
    border: 1px solid #343c38;
    border-radius: .45rem;
    background: rgb(6 8 7 / 34%);
    color: #bbb6ad;
    font-size: .75rem;
    line-height: 1.45;
}

.door-info-card strong {
    color: #ebe7de;
}

.door-info-list {
    margin: .35rem 0 0;
    padding-left: 1.1rem;
}

.door-actions {
    display: grid;
    gap: .45rem;
    margin: .8rem 0;
}

.door-action-button {
    display: grid;
    grid-template-columns: 1.8rem minmax(0, 1fr);
    align-items: center;
    width: 100%;
    padding: .55rem .7rem;
    border: 1px solid #59675f;
    border-radius: .45rem;
    color: #f1eee7;
    background: #34443b;
    font: inherit;
    font-size: .78rem;
    font-weight: 800;
    text-align: left;
    cursor: pointer;
}

.door-action-button:hover {
    border-color: #7d9687;
    background: #435a4c;
}

.door-action-button.is-secondary {
    text-align: center;
    background: #252b28;
}

.door-action-button:disabled {
    cursor: wait;
    opacity: .55;
}

.door-interaction-result {
    margin: .7rem 0 !important;
    padding: .55rem .65rem;
    border: 1px solid #4d5d54;
    border-radius: .45rem;
    color: #d9d5cc !important;
    background: rgb(63 83 71 / 26%);
    font-size: .75rem;
    line-height: 1.45 !important;
}

.door-debug {
    margin-top: .8rem;
    border-top: 1px solid #353d39;
    padding-top: .65rem;
}

.door-debug > summary {
    color: #aaa59c;
    font-size: .74rem;
    font-weight: 800;
    cursor: pointer;
}

.door-debug-form {
    display: grid;
    gap: .65rem;
    margin-top: .75rem;
}

.door-debug-grid {
    display: grid;
    gap: .55rem;
}

.door-debug-field,
.door-debug-security {
    display: grid;
    gap: .3rem;
}

.door-debug-field > label,
.door-debug-security > label,
.door-debug-legend {
    color: #c9c5bd;
    font-size: .72rem;
    font-weight: 800;
}

.door-debug-field select,
.door-debug-field textarea,
.door-debug-security select,
.door-debug-security textarea {
    width: 100%;
    box-sizing: border-box;
    padding: .45rem .5rem;
    border: 1px solid #47504c;
    border-radius: .4rem;
    color: #e8e5dd;
    background: #121614;
    font: inherit;
    font-size: .75rem;
}

.door-debug-field textarea,
.door-debug-security textarea {
    min-height: 4.5rem;
    resize: vertical;
}

.door-debug-checks {
    display: grid;
    gap: .3rem;
}

.door-debug-check {
    display: flex !important;
    gap: .45rem !important;
    justify-content: flex-start !important;
    align-items: center !important;
    font-size: .72rem !important;
    font-weight: 600 !important;
}

.door-debug-security {
    padding: .55rem;
    border: 1px solid #39423e;
    border-radius: .45rem;
    background: rgb(0 0 0 / 16%);
}

.door-debug-security-heading {
    display: flex;
    gap: .5rem;
    align-items: center;
    justify-content: space-between;
}

.door-debug-remove {
    border: 0;
    color: #d9a6a6;
    background: transparent;
    cursor: pointer;
    font-size: .72rem;
}

[data-map-canvas].has-door-hover {
    cursor: pointer;
}


.door-debug-hint {
    display: block;
    margin-top: .4rem;
    color: #918d86;
    font-size: .68rem;
    line-height: 1.35;
}
