/*
HTG Maps 1.0.20
Structured source edition

Source map
  CSS-01  Theme tokens and theme variants
  CSS-02  Global defaults and accessibility
  CSS-03  Application shell and header
  CSS-04  Maps workspace and markers
  CSS-05  Side panel and selected-location content
  CSS-06  Install dialog and footer controls
  CSS-07  Base responsive rules
  CSS-08  Overlay controls and onboarding
  CSS-09  App views, Wiki, Settings, and view-specific scrolling

Cascade order is compatibility-sensitive. Responsive rules remain near the
behavior they refine unless equivalence has been proven.
*/

/* =====================================================================
[CSS-01] THEME TOKENS + THEME VARIANTS
===================================================================== */
:root {
    color-scheme: dark;
    --escape-cellar: #ef3b46;
    --escape-gate: #31d873;
    --escape-car: #4eb5ff;

    --bg: #0e0d11;
    --bg-2: #17131b;
    --surface: rgba(22, 20, 26, 0.96);
    --surface-2: rgba(31, 27, 35, 0.96);
    --surface-3: rgba(12, 11, 14, 0.82);
    --border: rgba(255, 255, 255, 0.13);
    --border-strong: rgba(255, 255, 255, 0.24);
    --text: #f7f3ee;
    --muted: #b9b1aa;
    --accent: #e67828;
    --accent-2: #ffbc4b;
    --focus: #ffd36a;
    --shadow: 0 16px 42px rgba(0, 0, 0, 0.38);
    --theme-art:
        radial-gradient(circle at 18% 18%, rgba(255, 181, 78, .10), transparent 22%),
        radial-gradient(circle at 82% 12%, rgba(128, 139, 192, .10), transparent 25%),
        linear-gradient(145deg, #0b0b10 0%, #15121a 46%, #09090c 100%);
}

body[data-theme="jack-o-lantern-glow"] {
    --bg: #120d08;
    --bg-2: #201208;
    --surface: rgba(34, 23, 15, 0.96);
    --surface-2: rgba(45, 29, 17, 0.96);
    --accent: #f27d1c;
    --accent-2: #ffc257;
    --focus: #ffd98a;
    --theme-art:
        radial-gradient(circle at 14% 20%, rgba(255, 132, 28, .25), transparent 18%),
        radial-gradient(circle at 82% 78%, rgba(255, 177, 55, .15), transparent 24%),
        linear-gradient(145deg, #0d0906, #211007 55%, #0a0806);
}

body[data-theme="witching-hour"] {
    --bg: #0f0a16;
    --bg-2: #1b1026;
    --surface: rgba(28, 20, 38, 0.96);
    --surface-2: rgba(41, 27, 55, 0.96);
    --accent: #a466d9;
    --accent-2: #d3a3ff;
    --focus: #e2c6ff;
    --theme-art:
        radial-gradient(circle at 84% 16%, rgba(180, 125, 245, .19), transparent 17%),
        radial-gradient(circle at 18% 76%, rgba(105, 73, 145, .16), transparent 22%),
        linear-gradient(145deg, #09070e, #1a0d25 55%, #09060f);
}

body[data-theme="graveyard-fog"] {
    --bg: #0c1110;
    --bg-2: #151c1a;
    --surface: rgba(25, 31, 29, 0.96);
    --surface-2: rgba(34, 43, 40, 0.96);
    --accent: #8da795;
    --accent-2: #c7d5ca;
    --focus: #e0eadf;
    --theme-art:
        radial-gradient(ellipse at 50% 10%, rgba(214, 225, 220, .12), transparent 30%),
        linear-gradient(180deg, rgba(180, 194, 187, .08), transparent 42%),
        linear-gradient(145deg, #09100e, #18201d 58%, #0b0e0d);
}

body[data-theme="zombie-night"] {
    --bg: #0c1008;
    --bg-2: #151d0d;
    --surface: rgba(24, 31, 18, 0.96);
    --surface-2: rgba(36, 47, 26, 0.96);
    --accent: #7d9c42;
    --accent-2: #b7ce78;
    --focus: #d6e6a7;
    --theme-art:
        radial-gradient(circle at 20% 22%, rgba(137, 166, 77, .16), transparent 20%),
        radial-gradient(circle at 82% 72%, rgba(78, 103, 48, .20), transparent 26%),
        linear-gradient(145deg, #080b06, #17200e 58%, #090b07);
}

body[data-theme="blood-moon"] {
    --bg: #12090a;
    --bg-2: #211013;
    --surface: rgba(34, 18, 21, 0.96);
    --surface-2: rgba(49, 24, 29, 0.96);
    --accent: #b8353d;
    --accent-2: #ef747b;
    --focus: #ffb0b4;
    --theme-art:
        radial-gradient(circle at 84% 14%, rgba(192, 45, 57, .30) 0 5%, transparent 15%),
        radial-gradient(circle at 84% 14%, rgba(160, 30, 40, .15), transparent 24%),
        linear-gradient(145deg, #0b0708, #210d11 58%, #090607);
}

body[data-theme="myers-house"] {
    --bg: #0b0d0d;
    --bg-2: #151817;
    --surface: rgba(22, 25, 24, 0.96);
    --surface-2: rgba(31, 36, 34, 0.96);
    --accent: #8f9b92;
    --accent-2: #d4ddd6;
    --focus: #edf3ee;
    --theme-art:
        radial-gradient(circle at 75% 16%, rgba(226, 232, 222, .10), transparent 18%),
        linear-gradient(160deg, rgba(63, 75, 68, .12), transparent 35%),
        linear-gradient(145deg, #070909, #161b18 58%, #080909);
}

body[data-theme="october-31st"] {
    --bg: #120b05;
    --bg-2: #241207;
    --surface: rgba(34, 22, 13, 0.96);
    --surface-2: rgba(48, 29, 15, 0.96);
    --accent: #ff8a1f;
    --accent-2: #ffd06a;
    --focus: #ffe2a0;
    --theme-art:
        radial-gradient(circle at 18% 16%, rgba(255, 141, 32, .24), transparent 17%),
        radial-gradient(circle at 82% 76%, rgba(196, 70, 14, .18), transparent 24%),
        linear-gradient(145deg, #0c0805, #281207 58%, #0b0704);
}

body[data-theme="lauries-porch"] {
    --bg: #0b1013;
    --bg-2: #111c22;
    --surface: rgba(17, 28, 34, 0.96);
    --surface-2: rgba(24, 39, 47, 0.96);
    --accent: #4f93a9;
    --accent-2: #9ed8e5;
    --focus: #cdeff4;
    --theme-art:
        radial-gradient(circle at 22% 18%, rgba(144, 204, 218, .15), transparent 20%),
        linear-gradient(180deg, rgba(80, 128, 144, .08), transparent 45%),
        linear-gradient(145deg, #080d10, #12222a 58%, #081014);
}

body[data-theme="haddonfield-memorial"] {
    --bg: #0b1113;
    --bg-2: #132025;
    --surface: rgba(18, 31, 36, 0.96);
    --surface-2: rgba(25, 43, 49, 0.96);
    --accent: #4b9da2;
    --accent-2: #8fd4d4;
    --focus: #b9eceb;
    --theme-art:
        radial-gradient(circle at 80% 20%, rgba(90, 176, 181, .17), transparent 18%),
        radial-gradient(circle at 20% 76%, rgba(59, 114, 125, .13), transparent 24%),
        linear-gradient(145deg, #080d0f, #122126 58%, #080e10);
}

body[data-theme="night-he-came-home"] {
    --bg: #08090a;
    --bg-2: #111214;
    --surface: rgba(18, 19, 21, 0.97);
    --surface-2: rgba(29, 30, 33, 0.97);
    --accent: #d7d7d1;
    --accent-2: #ffffff;
    --focus: #ffffff;
    --theme-art:
        radial-gradient(circle at 82% 16%, rgba(255, 255, 245, .15) 0 4%, transparent 13%),
        linear-gradient(180deg, rgba(200, 205, 200, .05), transparent 40%),
        linear-gradient(145deg, #060708, #141517 58%, #070809);
}

body[data-theme="final-girl"] {
    --bg: #10090c;
    --bg-2: #211016;
    --surface: rgba(31, 17, 23, 0.96);
    --surface-2: rgba(45, 23, 31, 0.96);
    --accent: #b64f68;
    --accent-2: #f1a4b5;
    --focus: #ffd0da;
    --theme-art:
        radial-gradient(circle at 18% 18%, rgba(225, 103, 133, .16), transparent 18%),
        radial-gradient(circle at 80% 75%, rgba(123, 40, 61, .17), transparent 24%),
        linear-gradient(145deg, #0a0708, #231018 58%, #090708);
}

/* =====================================================================
[CSS-02] GLOBAL DEFAULTS + ACCESSIBILITY
===================================================================== */
* {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    min-width: 100%;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.45;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -2;
    background: var(--theme-art);
    background-size: cover;
    background-position: center;
    pointer-events: none;
}

button,
select {
    font: inherit;
}

button,
select,
a {
    -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
select:focus-visible,
a:focus-visible,
.map-viewport:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.skip-link {
    position: fixed;
    top: max(8px, env(safe-area-inset-top));
    left: max(8px, env(safe-area-inset-left));
    z-index: 1000;
    transform: translateY(-160%);
    border-radius: 8px;
    padding: 10px 14px;
    background: #fff;
    color: #111;
    font-weight: 700;
}

.skip-link:focus {
    transform: translateY(0);
}

/* =====================================================================
[CSS-03] APPLICATION SHELL + HEADER
===================================================================== */
.app-header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: end;
    gap: 22px;
    padding: calc(12px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
    background: rgba(8, 8, 10, .92);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
}

.brand-block {
    min-width: 240px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-logo {
    flex: 0 0 auto;
    width: 56px;
    height: 56px;
    border-radius: 10px;
    object-fit: cover;
}

.brand-copy {
    min-width: 0;
}

.toolbar-kicker {
    margin: 0;
    color: var(--accent-2);
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
}

h1,
h2,
h3,
p {
    overflow-wrap: anywhere;
}

.brand-title {
    margin: 0;
    color: var(--accent-2);
    font-size: clamp(1.55rem, 2.15vw, 2.15rem);
    font-weight: 850;
    line-height: 1.04;
    letter-spacing: .025em;
}

.header-credit {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: .75rem;
    line-height: 1.2;
}

.header-credit a {
    color: var(--accent-2);
    font-weight: 800;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}


.map-picker {
    min-width: 0;
}

.map-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 2px 2px 6px;
    scrollbar-width: thin;
}

.map-tab {
    flex: 0 0 auto;
    min-height: 44px;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 13px;
    background: rgba(255, 255, 255, .045);
    color: var(--text);
    cursor: pointer;
    font-weight: 750;
    white-space: nowrap;
}

.map-tab[aria-selected="true"] {
    border-color: var(--accent);
    background: rgba(230, 120, 40, .16);
    box-shadow: inset 0 -2px 0 var(--accent);
}

.map-select,
.mobile-map-label {
    display: none;
}

.app-main {
    flex: 1 1 auto;
    min-height: 0;
    padding: 12px max(12px, env(safe-area-inset-right)) 12px max(12px, env(safe-area-inset-left));
}

/* =====================================================================
[CSS-04] MAPS WORKSPACE + MARKERS
===================================================================== */
.workspace {
    width: min(1760px, 100%);
    height: 100%;
    min-height: 0;
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(290px, 340px);
    gap: 12px;
}

.map-panel,
/* =====================================================================
[CSS-05] SIDE PANEL + LOCATION CONTENT
===================================================================== */
.escape-panel {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.map-panel {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.map-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}

.map-toolbar h2,
.panel-heading h2 {
    margin: 2px 0 0;
    font-size: clamp(1rem, 1.5vw, 1.25rem);
}

.map-controls {
    display: flex;
    gap: 7px;
}

.icon-button {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: rgba(255, 255, 255, .055);
    color: var(--text);
    cursor: pointer;
    font-size: 1.35rem;
    font-weight: 850;
}

.icon-button:hover {
    background: rgba(255, 255, 255, .10);
}

.map-viewport {
    position: relative;
    flex: 1 1 auto;
    min-height: 440px;
    overflow: hidden;
    isolation: isolate;
    cursor: grab;
    touch-action: none;
    user-select: none;
    background:
        linear-gradient(rgba(0, 0, 0, .28), rgba(0, 0, 0, .28)),
        #07080a;
}

.map-viewport.is-dragging {
    cursor: grabbing;
}

.map-image {
    position: absolute;
    inset: 0 auto auto 0;
    width: 4096px;
    height: 4096px;
    max-width: none;
    transform-origin: 0 0;
    will-change: transform;
    pointer-events: none;
    -webkit-user-drag: none;
}

.marker-layer {
    position: absolute;
    inset: 0;
    z-index: 6;
    pointer-events: none;
}

.map-marker {
    position: absolute;
    width: 48px;
    height: 48px;
    padding: 0;
    border: 4px solid var(--marker-color);
    border-radius: 50%;
    display: grid;
    place-items: center;
    transform: translate(-50%, -50%);
    background: rgba(11, 11, 13, .86);
    box-shadow: 0 3px 12px rgba(0, 0, 0, .75), inset 0 0 0 2px rgba(255,255,255,.08);
    color: #fff;
    pointer-events: auto;
    cursor: pointer;
    z-index: 5;
}

.map-marker:hover,
.map-marker:focus-visible {
    z-index: 10;
    box-shadow:
        0 0 0 3px rgba(255, 255, 255, .82),
        0 5px 18px rgba(0, 0, 0, .78);
}

.map-marker.is-selected {
    z-index: 11;
    box-shadow:
        0 0 0 4px #ff8a1f,
        0 0 0 8px rgba(255, 138, 31, .28),
        0 0 22px rgba(255, 138, 31, .72),
        0 6px 20px rgba(0, 0, 0, .82);
}

.map-marker.is-pinned {
    z-index: 12;
}


.map-marker img {
    display: block;
    width: 30px;
    height: 30px;
    pointer-events: none;
}

.map-marker[data-type="cellar"] {
    --marker-color: var(--escape-cellar);
}

.map-marker[data-type="gate"] {
    --marker-color: var(--escape-gate);
}

.map-marker[data-type="car"] {
    --marker-color: var(--escape-car);
}

.marker-tooltip {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 10px);
    width: min(224px, calc(100vw - 32px));
    padding: 9px 10px;
    border: 1px solid var(--border-strong);
    border-radius: 9px;
    background: rgba(13, 12, 15, .98);
    color: var(--text);
    box-shadow: 0 8px 22px rgba(0, 0, 0, .55);
    transform: translateX(-50%) translateY(4px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    text-align: left;
    font-size: .75rem;
    font-weight: 500;
    line-height: 1.35;
    transition: opacity .12s ease, transform .12s ease;
}

.marker-tooltip strong,
.marker-tooltip-line {
    display: block;
}

.marker-tooltip strong {
    margin-bottom: 4px;
    color: var(--marker-color);
    font-size: .8rem;
}

.marker-tooltip-line + .marker-tooltip-line {
    margin-top: 2px;
}

.marker-tooltip-items {
    margin-top: 5px;
}

.map-marker.tooltip-below .marker-tooltip {
    top: calc(100% + 10px);
    bottom: auto;
}

.map-marker.tooltip-left .marker-tooltip {
    left: -8px;
    transform: translateY(4px);
}

.map-marker.tooltip-right .marker-tooltip {
    right: -8px;
    left: auto;
    transform: translateY(4px);
}

.map-marker:hover .marker-tooltip,
.map-marker:focus-visible .marker-tooltip,
.map-marker.is-pinned .marker-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.map-marker.tooltip-left:hover .marker-tooltip,
.map-marker.tooltip-left:focus-visible .marker-tooltip,
.map-marker.tooltip-left.is-pinned .marker-tooltip,
.map-marker.tooltip-right:hover .marker-tooltip,
.map-marker.tooltip-right:focus-visible .marker-tooltip,
.map-marker.tooltip-right.is-pinned .marker-tooltip {
    transform: translateY(0);
}

.map-hint {
    position: absolute;
    right: 10px;
    bottom: 10px;
    z-index: 3;
    padding: 5px 8px;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 8px;
    background: rgba(0, 0, 0, .62);
    color: rgba(255, 255, 255, .78);
    font-size: .7rem;
    pointer-events: none;
}

.escape-panel {
    min-height: 0;
    overflow: auto;
    padding: 13px;
}

.panel-heading {
    margin-bottom: 10px;
}

.spawn-note {
    margin: 0 0 12px;
    padding: 9px 10px;
    border-left: 3px solid var(--accent);
    background: rgba(255,255,255,.04);
    color: var(--muted);
    font-size: .82rem;
}

.legend-list {
    display: grid;
    gap: 9px;
}

.legend-card {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: start;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: rgba(255,255,255,.035);
}

.legend-icon {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border: 3px solid var(--legend-color);
    border-radius: 50%;
    background: rgba(8,8,10,.84);
}

.legend-icon img {
    width: 27px;
    height: 27px;
}

.legend-copy h3 {
    margin: 0;
    color: var(--legend-color);
    font-size: .95rem;
}

.legend-copy p {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: .74rem;
    font-weight: 700;
}

.item-list {
    margin: 6px 0 0;
    padding-left: 18px;
    color: var(--text);
    font-size: .8rem;
}

.item-list li + li {
    margin-top: 2px;
}

.legend-count {
    min-width: 34px;
    padding: 3px 7px;
    border-radius: 999px;
    background: rgba(255,255,255,.08);
    color: var(--text);
    text-align: center;
    font-size: .75rem;
    font-weight: 800;
}

.selected-location {
    margin: 0 0 12px;
    padding: 11px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface-3);
}

.selected-location h3 {
    margin: 0 0 4px;
    font-size: .95rem;
}

.selected-location p {
    margin: 0;
    color: var(--muted);
    font-size: .82rem;
}

.selected-location .selected-type {
    color: var(--selected-color, var(--accent-2));
    font-weight: 800;
}


.rally-picker {
    display: grid;
    gap: 4px;
    margin: 7px 0 10px;
}

.rally-picker label {
    color: var(--muted);
    font-size: .72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .06em;
}

.rally-select {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--border-strong);
    border-radius: 9px;
    padding: 7px 34px 7px 9px;
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-size: .82rem;
    font-weight: 750;
}

.rally-select:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

.selected-location .selected-empty {
    margin-top: 4px;
}

.clear-selection-button {
    min-height: 44px;
    margin: 0 0 10px;
    padding: 7px 11px;
    border: 1px solid var(--border-strong);
    border-radius: 9px;
    background: rgba(255, 138, 31, .10);
    color: var(--text);
    font: inherit;
    font-size: .78rem;
    font-weight: 800;
    cursor: pointer;
}

.clear-selection-button:hover {
    background: rgba(255, 138, 31, .18);
}

.clear-selection-button:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

.selected-location .items-needed-label {
    margin-top: 7px;
}

.selected-callout {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 4px 9px;
    margin: 9px 0 2px;
    padding: 8px 9px;
    border-radius: 8px;
    background: rgba(255,255,255,.04);
}

.selected-callout dt,
.selected-callout dd {
    margin: 0;
    font-size: .8rem;
    line-height: 1.35;
}

.selected-callout dt {
    color: var(--muted);
    font-weight: 700;
}

.selected-callout dd {
    color: var(--text);
    font-weight: 850;
}

.selected-location .item-list {
    margin-top: 7px;
}

.panel-footer {
    display: grid;
    gap: 10px;
    margin: 0 12px 12px;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(255, 255, 255, .035);
    color: var(--muted);
    font-size: .75rem;
}

/* =====================================================================
[CSS-06] FOOTER CONTROLS + INSTALL DIALOG
===================================================================== */
.footer-controls {
    display: grid;
    gap: 7px;
}

.footer-controls label {
    font-weight: 750;
    color: var(--text);
}

.footer-select,
.footer-button {
    min-height: 36px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: rgba(255,255,255,.06);
    color: var(--text);
}

.footer-select {
    width: 100%;
    max-width: none;
    padding: 5px 30px 5px 8px;
    background-color: #17151a;
    color: #f7f3ee;
    color-scheme: dark;
    font-weight: 700;
}

.footer-select option {
    background-color: #17151a;
    color: #f7f3ee;
}

.footer-button {
    padding: 5px 10px;
    cursor: pointer;
    font-weight: 800;
}

.footer-button:hover {
    background: rgba(255,255,255,.11);
}

.footer-meta {
    text-align: left;
    line-height: 1.45;
}

.p8core-brand {
    color: var(--accent-2);
    white-space: nowrap;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

.install-dialog {
    width: min(760px, calc(100vw - 24px));
    max-height: min(86dvh, 760px);
    padding: 0;
    border: 1px solid var(--border-strong);
    border-radius: 14px;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 24px 80px rgba(0,0,0,.62);
}

.install-dialog::backdrop,
.p8-dialog-backdrop {
    background: rgba(0,0,0,.72);
}

.dialog-card {
    padding: 15px;
}

.dialog-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.dialog-heading h2 {
    margin: 2px 0 0;
    font-size: 1.2rem;
}

.dialog-close {
    width: 44px;
    height: 44px;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: rgba(255,255,255,.05);
    color: var(--text);
    cursor: pointer;
    font-size: 1.55rem;
    line-height: 1;
}

.dialog-intro,
.dialog-note {
    color: var(--muted);
    font-size: .86rem;
}

.install-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0,1fr));
    gap: 10px;
}

.install-grid section {
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(255,255,255,.035);
}

.install-grid h3 {
    margin: 0 0 6px;
    color: var(--accent-2);
    font-size: .96rem;
}

.install-grid p {
    margin: 0;
    font-size: .8rem;
}

.install-grid p + p {
    margin-top: 7px;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
}

.primary-button {
    min-height: 44px;
    border: 1px solid var(--accent-2);
    border-radius: 9px;
    padding: 8px 16px;
    background: var(--accent);
    color: #111;
    cursor: pointer;
    font-weight: 850;
}

[hidden] {
    display: none !important;
}

/* =====================================================================
[CSS-07] BASE RESPONSIVE RULES
===================================================================== */
@media (min-width: 900px) {
    .app-header,
    .panel-footer {
        flex: 0 0 auto;
    }

    .map-viewport {
        min-height: 0;
    }
}

@media (max-width: 1100px) {
    .workspace {
        grid-template-columns: minmax(0, 1fr) minmax(270px, 310px);
    }

    .brand-block {
        min-width: 210px;
    }
}

@media (max-width: 899px) {
    body {
        min-height: 100%;
    }

    .app-main {
        flex: 0 0 auto;
    }

    .workspace {
        height: auto;
        grid-template-columns: 1fr;
    }

    .map-viewport {
        min-height: 0;
        height: 68vh;
        height: 68dvh;
        max-height: 760px;
    }

    .escape-panel {
        overflow: visible;
    }

    .legend-list {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .legend-card {
        grid-template-columns: 42px minmax(0, 1fr);
    }

    .legend-count {
        grid-column: 1;
        grid-row: 2;
        justify-self: center;
    }

    .legend-icon {
        width: 42px;
        height: 42px;
    }

    .install-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 700px) {
    .app-header {
        grid-template-columns: 1fr;
        align-items: stretch;
        gap: 9px;
    }

    .brand-block {
        min-width: 0;
        gap: 8px;
    }

    .brand-logo {
        width: 48px;
        height: 48px;
        border-radius: 9px;
    }

    .tagline {
        display: none;
    }

    .map-tabs {
        display: none;
    }

    .mobile-map-label,
    .map-select {
        display: block;
    }

    .mobile-map-label {
        margin-bottom: 4px;
        color: var(--muted);
        font-size: .72rem;
        font-weight: 800;
        text-transform: uppercase;
        letter-spacing: .08em;
    }

    .map-select {
        width: 100%;
        min-height: 44px;
        border: 1px solid var(--border-strong);
        border-radius: 10px;
        padding: 7px 34px 7px 10px;
        background: var(--surface-2);
        color: var(--text);
        font-weight: 750;
    }

    .map-viewport {
        height: 62vh;
        height: 62dvh;
        min-height: 360px;
    }

    .map-toolbar {
        padding: 8px 9px;
    }

    .map-marker {
        width: 46px;
        height: 46px;
        border-width: 4px;
    }

    .map-marker img {
        width: 28px;
        height: 28px;
    }

    .legend-list {
        grid-template-columns: 1fr;
    }

    .legend-card {
        grid-template-columns: 46px minmax(0,1fr) auto;
    }

    .legend-count {
        grid-column: auto;
        grid-row: auto;
        justify-self: auto;
    }

    .panel-footer {
        align-items: flex-start;
    }

    .footer-meta {
        width: 100%;
        text-align: left;
    }
}

@media (max-width: 390px) {
    .app-main {
        padding-left: 8px;
        padding-right: 8px;
    }

    .app-header {
        padding-left: 10px;
        padding-right: 10px;
    }

    .map-controls {
        gap: 5px;
    }

    .icon-button {
        width: 42px;
        height: 42px;
    }

    .map-hint {
        display: none;
    }

    .footer-controls {
        width: 100%;
    }

    .footer-select {
        flex: 1 1 160px;
        min-width: 0;
    }
}


/* =====================================================================
[CSS-08] OVERLAY CONTROLS + ONBOARDING
===================================================================== */
.layer-panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.layer-panel .layer-panel-heading h3 {
    margin: 0;
}

.tour-replay-button,
.tour-secondary-button,
.tour-primary-button {
    min-height: 44px;
    border: 1px solid var(--border-strong);
    border-radius: 9px;
    padding: 7px 11px;
    font: inherit;
    font-size: .76rem;
    font-weight: 800;
    cursor: pointer;
}

.tour-replay-button,
.tour-secondary-button {
    background: rgba(255, 255, 255, .06);
    color: var(--text);
}

.tour-primary-button {
    background: var(--accent);
    color: #0a0a0b;
}

.tour-replay-button:hover,
.tour-secondary-button:hover {
    background: rgba(255, 255, 255, .11);
}

.onboarding-tour {
    position: fixed;
    z-index: 80;
    width: min(360px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
    pointer-events: auto;
}

.onboarding-tour-card {
    padding: 15px;
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 16px 44px rgba(0, 0, 0, .52);
}

.onboarding-tour-step {
    margin: 0 0 5px;
    color: var(--accent);
    font-size: .72rem;
    font-weight: 850;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.onboarding-tour-title {
    margin: 0 0 7px;
    font-size: 1.05rem;
    line-height: 1.2;
}

.onboarding-tour-text {
    margin: 0;
    color: var(--muted);
    font-size: .86rem;
    line-height: 1.48;
}

.onboarding-tour-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 9px;
    margin-top: 13px;
}

.onboarding-tour-nav {
    display: flex;
    gap: 7px;
}

.tour-target-highlight {
    outline: 3px solid var(--accent) !important;
    outline-offset: 4px;
}

@media (max-width: 430px) {
    .onboarding-tour {
        width: calc(100vw - 16px);
        max-width: calc(100vw - 16px);
    }

    .onboarding-tour-card {
        padding: 13px;
    }

    .onboarding-tour-actions {
        align-items: stretch;
    }

    .tour-replay-button,
    .tour-secondary-button,
    .tour-primary-button {
        min-height: 44px;
    }
}


@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: .001ms !important;
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
    }
}

.map-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.grid-layer {
    z-index: 2;
    overflow: hidden;
}

.grid-surface {
    position: absolute;
    border: 1px solid rgba(245, 245, 245, .34);
    background-image:
        repeating-linear-gradient(
            to right,
            rgba(245, 245, 245, .24) 0,
            rgba(245, 245, 245, .24) 1px,
            transparent 1px,
            transparent var(--grid-col-size)
        ),
        repeating-linear-gradient(
            to bottom,
            rgba(245, 245, 245, .24) 0,
            rgba(245, 245, 245, .24) 1px,
            transparent 1px,
            transparent var(--grid-row-size)
        );
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .3);
}

.grid-label {
    position: absolute;
    min-width: 22px;
    min-height: 22px;
    display: grid;
    place-items: center;
    transform: translate(-50%, -50%);
    border-radius: 6px;
    background: rgba(5, 7, 9, .72);
    color: #f7f7f7;
    font-size: clamp(.58rem, .95vw, .74rem);
    font-weight: 850;
    line-height: 1;
    text-shadow: 0 1px 2px #000;
}

.street-layer {
    z-index: 3;
}

.address-layer {
    z-index: 5;
    pointer-events: none;
}

.map-label {
    position: absolute;
    transform: translate(-50%, -50%);
    white-space: nowrap;
    text-shadow:
        0 1px 2px #000,
        0 0 4px #000;
}

.address-label {
    min-width: 30px;
    padding: 3px 5px;
    appearance: none;
    font-family: inherit;
    cursor: pointer;
    pointer-events: auto;
    border: 1px solid rgba(255, 235, 185, .72);
    border-radius: 5px;
    background: rgba(8, 8, 10, .82);
    color: #fff1c8;
    font-size: clamp(.66rem, 1.1vw, .82rem);
    font-weight: 850;
    line-height: 1;
    text-align: center;
}

.address-label:hover,
.address-label:focus-visible {
    border-color: #fff1c8;
    background: rgba(80, 58, 18, .94);
    box-shadow: 0 0 0 2px rgba(255, 241, 200, .18);
}

.address-label.is-selected {
    border-color: #ff8a1f;
    background: rgba(111, 48, 0, .96);
    color: #fff7ed;
    box-shadow:
        0 0 0 3px #ff8a1f,
        0 0 0 6px rgba(255, 138, 31, .22),
        0 0 18px rgba(255, 138, 31, .62);
}

.address-label:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

.street-label {
    padding: 3px 6px;
    border-radius: 5px;
    background: rgba(6, 8, 10, .68);
    color: #f1f1f1;
    font-size: clamp(.62rem, 1vw, .78rem);
    font-weight: 750;
    letter-spacing: .045em;
    line-height: 1;
    text-transform: uppercase;
}

.layer-panel {
    margin: 0 12px 12px;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(255, 255, 255, .035);
}

.layer-panel h3,
.player-tip h3 {
    margin: 0 0 8px;
    font-size: .9rem;
}

.layer-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px 10px;
}

.layer-option {
    min-width: 0;
    padding: 8px;
    border: 1px solid rgba(255,255,255,.07);
    border-radius: 9px;
    background: rgba(0,0,0,.12);
}

.layer-toggle {
    min-height: 36px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    font-size: .82rem;
    font-weight: 700;
    cursor: pointer;
}

.layer-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    margin: 0;
    accent-color: var(--accent);
}

.layer-opacity {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 2px 8px;
    min-width: 0;
}

.layer-opacity label,
.layer-opacity output {
    color: var(--muted);
    font-size: .7rem;
}

.layer-opacity output {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.layer-opacity input[type="range"] {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
    min-height: 32px;
    margin: 0;
    accent-color: var(--accent);
}

.layer-opacity input[type="range"]:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.player-tip {
    margin: 0 12px 12px;
    padding: 11px 12px;
    border-left: 3px solid var(--accent);
    border-radius: 8px;
    background: rgba(255, 255, 255, .045);
}

.player-tip p {
    margin: 0;
    color: var(--muted);
    font-size: .8rem;
    line-height: 1.45;
}

@media (max-width: 560px) {
    .layer-options {
        grid-template-columns: 1fr;
    }

    .address-label {
        font-size: .64rem;
        padding: 2px 4px;
    }

    .street-label {
        font-size: .6rem;
        padding: 2px 4px;
    }

    .grid-label {
        font-size: .64rem;
    }
}

@media (max-width: 1023px) {
    body {
        height: auto;
        min-height: 100dvh;
        overflow-y: auto;
    }

    .app-header {
        grid-template-columns: 1fr;
        align-items: stretch;
        gap: 8px;
        padding-top: calc(9px + env(safe-area-inset-top));
        padding-bottom: 9px;
    }

    .brand-block {
        min-width: 0;
    }

    .brand-title {
        font-size: 1.28rem;
    }

    .header-credit {
        font-size: .72rem;
    }

    .map-tabs {
        display: none;
    }

    .mobile-map-label,
    .map-select {
        display: block;
    }

    .mobile-map-label {
        margin-bottom: 4px;
        color: var(--muted);
        font-size: .7rem;
        font-weight: 800;
        text-transform: uppercase;
        letter-spacing: .08em;
    }

    .map-select {
        width: 100%;
        min-height: 44px;
        border: 1px solid var(--border-strong);
        border-radius: 10px;
        padding: 7px 34px 7px 10px;
        background: var(--surface-2);
        color: var(--text);
        font-weight: 750;
    }

    .app-main {
        flex: 0 0 auto;
        overflow: visible;
    }

    .workspace {
        height: auto;
        grid-template-columns: 1fr;
    }

    .map-viewport {
        min-height: 420px;
        height: 70dvh;
        max-height: 820px;
    }

    .escape-panel {
        overflow: visible;
    }
}

@media (max-width: 599px) {
    .app-header {
        gap: 6px;
        padding-left: max(10px, env(safe-area-inset-left));
        padding-right: max(10px, env(safe-area-inset-right));
    }

    .brand-logo {
        width: 40px;
        height: 40px;
        border-radius: 8px;
    }

    .brand-block {
        gap: 7px;
    }

    .brand-title {
        font-size: 1.05rem;
        line-height: 1.05;
    }

    .header-credit {
        margin-top: 2px;
        font-size: .66rem;
    }

    .app-main {
        padding: 8px max(8px, env(safe-area-inset-right)) 10px max(8px, env(safe-area-inset-left));
    }

    .workspace {
        gap: 9px;
    }

    .map-panel,
    .escape-panel {
        border-radius: 11px;
    }

    .map-toolbar {
        gap: 8px;
        padding: 6px 8px;
    }

    .map-toolbar h2 {
        margin: 0;
        font-size: 1rem;
    }

    .map-controls {
        gap: 4px;
    }

    .icon-button {
        width: 42px;
        height: 42px;
    }

    .map-viewport {
        height: 64dvh;
        min-height: 340px;
        max-height: 680px;
    }

    .marker-tooltip {
        width: min(210px, calc(100vw - 24px));
        padding: 8px 9px;
        font-size: .72rem;
    }

    .legend-list {
        grid-template-columns: 1fr;
    }

    .panel-footer {
        gap: 8px;
        align-items: flex-start;
    }

    .footer-controls,
    .footer-meta {
        width: 100%;
    }

    .footer-meta {
        text-align: left;
    }
}

@media (min-width: 600px) and (max-width: 1023px) {
    .app-main {
        padding: 10px max(12px, env(safe-area-inset-right)) 12px max(12px, env(safe-area-inset-left));
    }

    .map-viewport {
        height: 72dvh;
        min-height: 500px;
    }

    .legend-list {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* =====================================================================
[CSS-09] APP VIEWS + WIKI + SETTINGS
Navigation and non-map workspaces, including view-specific scroll behavior.
===================================================================== */

.primary-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 0;
}

.primary-nav-button {
    min-height: 44px;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 14px;
    background: rgba(255, 255, 255, .045);
    color: var(--muted);
    cursor: pointer;
    font-weight: 800;
}

.primary-nav-button:hover {
    border-color: var(--border-strong);
    color: var(--text);
}

.primary-nav-button.is-active,
.primary-nav-button[aria-current="page"] {
    border-color: var(--accent);
    background: rgba(230, 120, 40, .16);
    color: var(--text);
    box-shadow: inset 0 -2px 0 var(--accent);
}

.app-view {
    min-width: 0;
}

body[data-active-view="maps"] #mapsView {
    min-height: 0;
}

.wiki-shell,
.settings-shell {
    width: min(1440px, 100%);
    margin: 0 auto;
}

.section-hero {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 14px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.section-hero h2 {
    margin: 3px 0 5px;
    color: var(--text);
    font-size: clamp(1.7rem, 3.2vw, 2.75rem);
    line-height: 1;
}

.section-hero p:last-child {
    margin: 0;
    color: var(--muted);
}

.wiki-entry-count {
    flex: 0 0 auto;
    display: grid;
    justify-items: end;
    color: var(--muted);
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.wiki-entry-count strong {
    color: var(--accent-2);
    font-size: 1.8rem;
    line-height: 1;
}

.wiki-search-panel {
    margin-bottom: 12px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
}

.wiki-search-panel > label {
    display: block;
    margin: 0 0 7px;
    color: var(--muted);
    font-size: .72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.wiki-search-row,
.map-search-row {
    display: flex;
    gap: 8px;
}

.wiki-search-row input,
.map-search-row input,
.settings-select {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    border: 1px solid var(--border-strong);
    border-radius: 9px;
    padding: 8px 10px;
    background: var(--surface-2);
    color: var(--text);
}

.compact-button {
    min-height: 44px;
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 7px 12px;
    background: rgba(255,255,255,.05);
    color: var(--text);
    cursor: pointer;
    font-weight: 750;
}

.wiki-category-filters {
    display: flex;
    gap: 7px;
    overflow-x: auto;
    margin-top: 10px;
    padding-bottom: 2px;
    scrollbar-width: thin;
}

.wiki-category-button {
    flex: 0 0 auto;
    min-height: 40px;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 7px 12px;
    background: rgba(255,255,255,.035);
    color: var(--muted);
    cursor: pointer;
    font-weight: 750;
}

.wiki-category-button.is-active {
    border-color: var(--accent);
    background: rgba(230,120,40,.15);
    color: var(--text);
}

.wiki-layout {
    display: grid;
    grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
    gap: 12px;
    align-items: start;
}

.wiki-index,
.wiki-article,
.settings-card {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.wiki-index {
    overflow: hidden;
}

.wiki-result-meta {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    min-height: 42px;
    padding: 11px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--muted);
    font-size: .72rem;
}

.wiki-results {
    max-height: min(68dvh, 760px);
    overflow: auto;
}

.wiki-result-button {
    display: block;
    width: 100%;
    border: 0;
    border-bottom: 1px solid var(--border);
    padding: 13px 14px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    text-align: left;
}

.wiki-result-button:last-child {
    border-bottom: 0;
}

.wiki-result-button:hover,
.wiki-result-button.is-active {
    background: var(--surface-2);
}

.wiki-result-heading {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 4px;
}

.wiki-result-title {
    font-weight: 850;
}

.wiki-result-type {
    flex: 0 0 auto;
    color: var(--accent-2);
    font-size: .68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .06em;
}

.wiki-result-summary {
    color: var(--muted);
    font-size: .8rem;
    line-height: 1.4;
}

.wiki-empty {
    margin: 0;
    padding: 18px;
    color: var(--muted);
}

.wiki-article {
    min-height: 420px;
    padding: clamp(18px, 3vw, 32px);
}

.wiki-article-kicker {
    margin: 0 0 4px;
    color: var(--accent-2);
    font-size: .7rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.wiki-article h2 {
    margin: 0 0 10px;
    color: var(--text);
    font-size: clamp(1.6rem, 3vw, 2.6rem);
    line-height: 1.05;
}

.wiki-article-summary {
    margin: 0;
    color: var(--text);
    font-size: 1.02rem;
    line-height: 1.6;
}

.wiki-detail-list {
    display: grid;
    gap: 8px;
    margin: 20px 0 0;
    padding: 0;
    list-style: none;
}

.wiki-detail-list li {
    position: relative;
    margin: 0;
    padding: 11px 12px 11px 34px;
    border-radius: 9px;
    background: var(--surface-2);
    color: var(--text);
}

.wiki-detail-list li::before {
    content: "";
    position: absolute;
    left: 13px;
    top: 18px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent-2);
}

.wiki-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 18px;
}

.wiki-tag {
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 5px 9px;
    color: var(--muted);
    font-size: .7rem;
}

.wiki-related-section {
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.wiki-related-section h3 {
    margin: 0 0 10px;
    font-size: .82rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
}

.wiki-related-list {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.wiki-related-button {
    min-height: 40px;
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 7px 10px;
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.settings-card {
    padding: 18px;
}

.settings-card h3 {
    margin: 0 0 10px;
    color: var(--text);
}

.settings-card p {
    color: var(--muted);
}

.settings-card label {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: .75rem;
    font-weight: 800;
}

.about-list {
    display: grid;
    gap: 8px;
    margin: 0;
}

.about-list div {
    display: flex;
    justify-content: space-between;
    gap: 16px;
}

.about-list dt {
    color: var(--muted);
}

.about-list dd {
    margin: 0;
    color: var(--text);
    font-weight: 750;
}

.settings-credit {
    margin-bottom: 0;
}

.settings-credit a {
    color: var(--accent-2);
}

.settings-app-version {
    margin: 12px 0 0;
}

.settings-app-version strong {
    color: var(--text);
}

/* Desktop Maps stays locked to the viewport. Wiki and Settings can scroll. */
@media (min-width: 1024px) {
    .app-header {
        grid-template-columns: auto auto minmax(0, 1fr);
    }

    body[data-active-view="maps"] {
        height: 100vh;
        height: 100dvh;
        overflow-y: hidden;
    }

    body[data-active-view="maps"] .app-main {
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
    }

    body[data-active-view="maps"] #mapsView,
    body[data-active-view="maps"] .workspace {
        height: 100%;
        min-height: 0;
    }

    body[data-active-view="maps"] .escape-panel {
        min-height: 0;
        overflow: auto;
    }

    body[data-active-view="wiki"],
    body[data-active-view="settings"] {
        height: auto;
        min-height: 100dvh;
        overflow-y: auto;
    }

    body[data-active-view="wiki"] .app-main,
    body[data-active-view="settings"] .app-main {
        flex: 0 0 auto;
        overflow: visible;
    }
}

@media (max-width: 1023px) {
    .primary-nav {
        justify-content: flex-start;
        overflow-x: auto;
        padding-bottom: 2px;
    }

    .primary-nav-button {
        flex: 1 0 auto;
    }

    .wiki-layout {
        grid-template-columns: 1fr;
    }

    .wiki-results {
        max-height: 420px;
    }

    .settings-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 599px) {
    .section-hero {
        align-items: flex-start;
        padding: 14px;
    }

    .wiki-entry-count {
        display: none;
    }

    .wiki-search-row {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .wiki-article {
        min-height: 320px;
        padding: 16px;
    }
}

/* MAPS V1.2.0 | SOURCE-REGISTERED TWO-VIEW MARKERS + CUSTOMIZATION */
.map-toolbar {flex-wrap:wrap}
.map-style-controls{display:flex;gap:4px;padding:3px;border:1px solid var(--border-strong);border-radius:12px;background:var(--surface)}
.style-choice{min-height:40px;padding:7px 13px;border:0;border-radius:9px;background:transparent;color:var(--text);cursor:pointer;font-weight:750}
.style-choice.is-current{background:var(--accent);color:#101015}
.style-choice:focus-visible,.custom-layer-row:focus-within,.map-settings-buttons button:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.map-marker{width:var(--marker-size,34px);height:var(--marker-size,34px);min-width:30px;min-height:30px;border-width:3px}
.map-marker img{width:var(--marker-glyph,21px);height:var(--marker-glyph,21px)}
.map-marker[hidden],.map-overlay[hidden]{display:none!important}
.map-marker--item{border-style:dashed;background:rgba(39,31,13,.93)}
.map-custom-panel{padding:15px;border:1px solid var(--border);border-radius:14px;background:var(--surface);margin:12px 0}
.map-layer-controls{display:grid;gap:12px}
.custom-layer-group{border:1px solid var(--border);border-radius:11px;padding:10px;display:grid;gap:6px;min-width:0}
.custom-layer-group legend{padding:0 6px;font-weight:800;color:var(--text)}
.custom-layer-row,.custom-map-only{display:flex;align-items:center;gap:11px;cursor:pointer;min-height:37px;font-size:.86rem;color:var(--text)}
.custom-layer-row input,.custom-map-only input{width:19px;height:19px;flex-shrink:0;accent-color:var(--accent)}
.map-help-copy,.map-preference-status,.source-caution{font-size:.79rem;line-height:1.45;color:var(--muted)}
.map-help-copy{margin:9px 0}.custom-map-only{margin-bottom:12px;font-weight:700}
.map-settings-buttons{display:flex;gap:9px;flex-wrap:wrap;margin-top:14px}
.map-settings-buttons button{flex:1 1 auto;min-height:42px}
.nearby-choices{display:flex;flex-wrap:wrap;gap:8px;padding:10px 0}
.nearby-choices strong{width:100%;font-size:.82rem}
.nearby-choices button{font-size:.78rem}
.legend-count{font-size:.73rem;white-space:nowrap}
@media(max-width:690px){.map-style-controls{order:3;width:100%;justify-content:center}.style-choice{flex:1}}

/* Maintain a >=44px pointer/keyboard hit target while the visible symbol follows zoom. */
.map-marker {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    border: 0;
    background: transparent;
    box-shadow: none;
    isolation: isolate;
}
.map-marker::before {
    content: "";
    position: absolute;
    z-index: -1;
    width: var(--marker-size, 34px);
    height: var(--marker-size, 34px);
    box-sizing: border-box;
    border: 3px solid var(--marker-color);
    border-radius: 50%;
    background: rgba(11,11,13,.9);
    box-shadow: 0 3px 12px rgba(0,0,0,.75), inset 0 0 0 2px rgba(255,255,255,.08);
}
.map-marker--item::before {border-style:dashed;background:rgba(39,31,13,.95)}
.map-marker:hover::before,.map-marker:focus-visible::before {box-shadow:0 0 0 3px rgba(255,255,255,.75),0 5px 18px rgba(0,0,0,.78)}
.map-marker.is-selected::before {box-shadow:0 0 0 4px #ff8a1f,0 0 0 8px rgba(255,138,31,.25),0 0 22px rgba(255,138,31,.7)}
.map-marker.is-selected,.map-marker:hover,.map-marker:focus-visible {box-shadow:none}


/* Escape opacity dims pin artwork, not keyboard hit targets or explanatory tooltips. */
.marker-layer .map-marker::before,
.marker-layer .map-marker > img {
    opacity: var(--escape-marker-opacity, 1);
}

/* 1.2.0 map accuracy/update refinement: selector is a full-width row beneath the app header. */
.app-header {grid-template-columns: minmax(0,1fr) auto;align-items:center;}
.map-picker {flex:0 0 auto;min-width:0;padding:8px max(16px, env(safe-area-inset-right)) 4px max(16px, env(safe-area-inset-left));background:rgba(8,8,10,.89);border-bottom:1px solid var(--border);}
body[data-active-view="wiki"] .map-picker,body[data-active-view="settings"] .map-picker {display:none;}
.map-tabs {max-width:1760px;margin:0 auto;justify-content:center;flex-wrap:wrap;overflow-x:visible;row-gap:6px;}
@media(max-width:1023px){.app-header{grid-template-columns:1fr;}}
@media(max-width:700px){.map-picker{padding-top:5px;padding-bottom:9px;}}

/* Escape guide: compact, readable overview without repeating spawn warnings. */
.escape-quick-notes {
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
}
.escape-quick-notes > h3 { margin: 0 0 12px; font-size: 1.02rem; }
.escape-notes-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.escape-note { min-width: 0; padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: rgba(255,255,255,.025); }
.escape-note h4 { margin: 0 0 5px; color: var(--accent-2); font-size: .87rem; }
.escape-note p { margin: 0; color: var(--text); font-size: .8rem; line-height: 1.48; overflow-wrap: anywhere; }
.spawn-disclaimer { margin: 8px 0 0; padding-top: 9px; border-top: 1px solid var(--border); color: var(--muted); font-size: .78rem; line-height: 1.5; }
@media (max-width: 600px) {
    .escape-notes-grid { grid-template-columns: minmax(0, 1fr); }
}

/* 1.2.4 verified game texture icons. Keep existing marker hit targets and ring colors. */
.legend-icon img[src*="/icons/game/"] {width:33px;height:33px;object-fit:contain;}
.item-list li.with-game-item-icon {display:flex;align-items:center;gap:8px;margin-left:-18px;}
.item-list .game-item-icon {width:23px;height:23px;flex:0 0 23px;object-fit:contain;}

/* 1.2.5: verified item icons on the actual spawn-source markers. */
.map-marker .map-item-marker-art {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: minmax(0, 1fr);
    align-items: center;
    justify-items: center;
    width: var(--marker-glyph, 24px);
    height: var(--marker-glyph, 24px);
    overflow: visible;
    pointer-events: none;
    opacity: var(--escape-marker-opacity, 1);
}
.map-marker .map-item-marker-art[data-count="1"] {grid-template-columns: 1fr;}
.map-marker .map-item-marker-art > img {
    display: block;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    object-fit: contain;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,.8));
}
.map-marker .map-item-marker-art[data-count="3"] > img:last-child {
    grid-column: 1 / -1;
    width: 50%;
}

/* [MAPS-1.3] Searchable-object icons are not verified escape-supply spawns. */
.map-marker--searchable::before {background:rgba(25,31,44,.93);border-style:dotted;border-color:#b8bfd2}
.map-marker--searchable > img {filter:drop-shadow(0 2px 1px #111)}
.wiki-source-note {border-left:3px solid var(--accent-2);padding:9px 12px;margin:14px 0;color:var(--muted);background:rgba(128,128,128,.08);font-size:.88rem;line-height:1.5}
.wiki-source-note strong {color:var(--text)}

/* [CSS-11] Adaptive PWA installation guidance in Settings. */
.settings-install-card {
    min-width: 0;
}
.settings-install-card .install-device-label {
    display: inline-block;
    margin: 0 0 10px;
    padding: 5px 9px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    color: var(--text);
    background: var(--surface-2);
    font-size: .8rem;
    overflow-wrap: anywhere;
}
.settings-install-card .install-status {
    margin: 0 0 12px;
    line-height: 1.5;
}
.settings-install-card .install-primary-button {
    min-height: 44px;
    padding: 9px 18px;
    margin-bottom: 8px;
}
.install-guide {
    border-top: 1px solid var(--border);
    padding-top: 12px;
    margin-top: 2px;
}
.install-guide h4 {
    font-size: .95rem;
    margin: 0 0 9px;
    color: var(--text);
}
.install-guide ol {
    padding-left: 1.5rem;
    margin: 0;
    display: grid;
    gap: 8px;
}
.install-guide li {
    line-height: 1.5;
    font-size: .87rem;
    overflow-wrap: anywhere;
}
.install-guide .install-help {
    margin: 12px 0 0;
    font-size: .8rem;
    color: var(--muted);
}

/* [CSS-10] Automatic update guidance in Settings > About. */
.settings-update-note {
    margin: 12px 0;
    line-height: 1.55;
    font-size: .87rem;
    max-width: 65ch;
}
.settings-update-note kbd {
    font: inherit;
    font-size: .83rem;
    font-weight: 750;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 5px;
    white-space: nowrap;
}
.settings-update-status {
    min-height: 1.1em;
    font-size: .82rem;
    margin: 8px 0 0;
}

/* [CSS-11] Copyright notice in Settings > About. */
.settings-copyright-notice {
    border-top: 1px solid var(--border);
    margin-top: 14px;
    padding-top: 12px;
    font-size: .79rem;
    line-height: 1.5;
    color: var(--text-muted, var(--text));
}
.settings-copyright-notice p { margin: 0 0 7px; }
.settings-copyright-notice p:last-child { margin-bottom: 0; }
.settings-copyright-notice strong { color: var(--text); font-size: .86rem; }
.settings-copyright-notice h4 { margin: 0 0 8px; color: var(--text); font-size: .86rem; }
.settings-copyright-notice ul { margin: 0 0 8px; padding-inline-start: 1.3em; }
.settings-copyright-notice li + li { margin-top: 4px; }
