:root {
  color-scheme: dark;
  --bg: #202629;
  --panel: #2b3336;
  --line: #546165;
  --ink: #dfe3dc;
  --muted: #aab6b6;
  --gold: #c6b58a;
  --mint: #a8bfb4;
  --accent: #a8bfb4;
  --selected: #3a4a45;
  --masthead-height: 52px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); height: 100dvh; overflow: hidden; }
::selection { background: var(--gold); color: #272e31; }
* { scrollbar-width: thin; scrollbar-color: #758583 var(--panel); }
button, input, select { font: inherit; }
button, a, input, select, summary { outline-offset: 3px; }
:focus-visible { outline: 2px solid var(--gold); }
input { caret-color: var(--gold); font-variant-numeric: tabular-nums; }
input::placeholder { color: var(--muted); opacity: 1; }
button, .button-link {
  border: 1px solid var(--line); border-radius: 5px; background: #343e41;
  color: var(--ink); min-height: 36px; padding: 8px 12px; cursor: pointer;
  font-size: 12px; line-height: 1.4; font-weight: 600; white-space: nowrap;
}
button:hover, .button-link:hover { background: #424f52; border-color: #839692; }
button.active, button.gold { background: var(--gold); color: #272e31; border-color: var(--gold); }
button:disabled { opacity: .55; cursor: default; }
button:disabled:hover { background: #343e41; border-color: var(--line); }
a { color: var(--gold); text-decoration: underline; text-underline-offset: 3px; }
a:hover { color: #ded3b5; }
.button-link { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
summary { cursor: pointer; font-size: 12px; font-weight: 600; padding: 10px 0; color: var(--ink); }
summary:hover { color: var(--gold); }
h2 { font: 400 24px/1.25 Georgia, serif; margin: 0 0 12px; text-wrap: balance; }
h3 { font-size: 13px; line-height: 1.4; font-weight: 600; color: var(--ink); margin: 24px 0 10px; }
p { line-height: 1.65; }
.muted { color: var(--muted); font-size: 12px; line-height: 1.7; }
.fine-print { font-size: 11px; line-height: 1.7; color: var(--muted); }

.skip-link { position: fixed; left: 12px; top: 8px; z-index: 40; padding: 12px 16px; background: var(--gold); color: #272e31; transform: translateY(-150%); border-radius: 5px; }
.skip-link:focus { transform: translateY(0); }
.masthead { height: var(--masthead-height); border-bottom: 1px solid var(--line); display: flex; align-items: center; padding: 0 16px; gap: 16px; background: #272e31; }
.brand { display: flex; align-items: center; gap: 9px; flex-shrink: 0; }
.site-mark { image-rendering: pixelated; }
.brand h1 { font: 600 18px Georgia, serif; letter-spacing: .3px; margin: 0; }
.brand h1 span { font-weight: 400; color: var(--gold); }
.site-wordmark { display: block; width: 175px; height: auto; }
.header-actions { display: flex; gap: 6px; margin-left: auto; }
.masthead button { padding-inline: 12px; min-height: 34px; background: transparent; }
.masthead button[aria-expanded=true], #edit.active { color: var(--gold); background: #3a4a45; border-color: var(--gold); }
main { height: calc(100dvh - var(--masthead-height)); display: flex; position: relative; }
.sidebar { display: none; width: 264px; flex-shrink: 0; background: var(--panel); border-right: 1px solid var(--line); flex-direction: column; min-height: 0; padding: 22px 16px 0; }
.sidebar.open { display: flex; }
.library-heading { display: flex; gap: 12px; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.library-heading h2 { margin: 0; }
.search-label, .era-label { font-size: 12px; color: var(--muted); margin-bottom: 7px; }
.search { display: flex; align-items: center; background: #22292c; border: 1px solid var(--line); border-radius: 5px; margin-bottom: 16px; }
.search:focus-within { outline: 2px solid var(--gold); outline-offset: 2px; }
.search input { background: transparent; border: 0; width: 100%; min-width: 0; min-height: 40px; padding: 9px 10px; font-size: 12px; color: var(--ink); outline: none; }
.search input::-webkit-search-cancel-button { display: none; }
.search button { border: 0; background: transparent; padding-inline: 8px; color: var(--gold); }
select { min-height: 40px; width: 100%; border: 1px solid var(--line); border-radius: 5px; padding: 9px; background: #343e41; font-size: 12px; color: var(--ink); }
label input[type=checkbox] { accent-color: var(--gold); vertical-align: middle; margin: 0 5px 0 0; }
.map-tabs { display: flex; gap: 6px; margin-top: 16px; }
.map-tabs button { flex: 1; min-width: 0; padding-inline: 8px; }
.count { font-size: 11px; color: var(--muted); border-top: 1px solid var(--line); padding: 14px 0 8px; margin-top: 14px; }
.map-list { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; margin: 0 -6px; padding: 0 6px 12px; contain: content; }
.era-group h3 { margin: 20px 0 6px; padding: 0 5px; color: var(--gold); font-size: 12px; }
.era-group:first-child h3 { margin-top: 8px; }
.map-group-list { display: flex; flex-direction: column; }
.map-item { display: flex; align-items: center; width: 100%; border: 0; background: transparent; text-align: left; padding: 10px 5px; min-height: 42px; border-radius: 3px; gap: 10px; color: var(--ink); content-visibility: auto; contain-intrinsic-size: auto 42px; }
.map-item:hover { background: #354245; }
.map-item.selected { background: #3a4a45; color: var(--gold); }
.map-id { width: 25px; flex-shrink: 0; font: 11px ui-monospace, monospace; font-variant-numeric: tabular-nums; color: var(--muted); }
.map-title { font-size: 12px; font-weight: 400; line-height: 1.5; white-space: normal; }
.boss-mark { color: var(--gold); font-size: 10px; margin-left: auto; }
.artwork-details { border-top: 1px solid var(--line); margin-top: auto; flex-shrink: 0; }
.artwork-details summary { font-size: 11px; color: var(--muted); }
.artwork-details p { margin: 0 0 14px; font-size: 11px; color: var(--muted); }
.empty-search { padding: 10px 0 16px; }
.empty-search p { font-size: 12px; color: var(--muted); }
.hidden-map { display: grid; grid-template-columns: 64px 1fr; gap: 8px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.hidden-map img { width: 64px; height: 60px; object-fit: contain; image-rendering: pixelated; background: #11171b; }
.hidden-map p { font-size: 12px; margin: 0; }
.hidden-map button { grid-column: 2; justify-self: start; }
.workspace { position: relative; flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
#viewport { position: relative; flex: 1; min-height: 0; overflow: hidden; background: #202629; cursor: grab; touch-action: none; isolation: isolate; }
#viewport:focus { outline: none; }
.canvas-focus-hint { display: none; position: absolute; left: 12px; bottom: 68px; z-index: 8; padding: 5px 8px; border: 2px solid var(--gold); border-radius: 4px; background: var(--panel); color: var(--ink); font-size: 11px; pointer-events: none; }
#viewport:focus-visible:not(.pointer-focus) .canvas-focus-hint { display: block; }
#viewport.moving { cursor: grabbing; }
#viewport.editing { cursor: move; }
#viewport, #viewport * { -webkit-user-select: none; user-select: none; -webkit-user-drag: none; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; image-rendering: pixelated; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--gold); background: var(--bg); font: 20px Georgia, serif; z-index: 10; }
.load-error { text-align: center; max-width: 320px; padding: 16px; font: 15px/1.7 ui-sans-serif, system-ui; }
.load-error button { margin-top: 18px; }
.empty-atlas { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; color: var(--muted); }
.empty-atlas button { pointer-events: auto; }
.zoom-controls { position: absolute; bottom: 12px; left: 12px; right: auto; display: flex; align-items: center; gap: 2px; border: 1px solid var(--line); border-radius: 5px; background: #2b3336; }
.zoom-controls button { border: 0; background: transparent; font-size: 18px; padding: 8px 12px; }
.zoom-controls output { min-width: 44px; text-align: center; font-size: 12px; font-variant-numeric: tabular-nums; color: var(--muted); }
.zoom-controls #nativeZoom { font-size: 12px; border-left: 1px solid var(--line); }
.canvas-footer { flex-shrink: 0; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; min-height: 26px; border-top: 1px solid var(--line); font-size: 11px; color: var(--muted); padding: 3px 12px; gap: 4px 16px; }
.save-state, .quality-status, .image-status { display: flex; align-items: center; gap: 8px; }
.save-state { color: var(--mint); }
.save-state button, .image-status button { font-size: 11px; min-height: 30px; padding: 4px 8px; }
#toast { position: absolute; left: 50%; top: 16px; transform: translateX(-50%); max-width: calc(100% - 24px); width: max-content; display: flex; align-items: center; gap: 12px; background: var(--gold); color: #272e31; border-radius: 5px; padding: 12px 16px; font-size: 12px; line-height: 1.5; box-shadow: 0 8px 24px #0005; z-index: 20; }
#toastUndo { flex: none; background: #343e41; color: #dfe3dc; border-color: #343e41; }
.inspector { position: absolute; right: 12px; bottom: 38px; z-index: 9; width: 330px; max-width: calc(100% - 24px); max-height: calc(100% - 100px); border: 1px solid var(--line); border-radius: 4px; flex-shrink: 0; background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.inspector-heading { display: flex; flex-shrink: 0; align-items: flex-start; gap: 10px; padding: 12px; }
.inspector-heading > div:first-child { flex: 1; min-width: 0; }
.inspector h2 { font: 600 14px/1.4 ui-sans-serif, system-ui; line-height: 1.35; margin: 0; overflow-wrap: anywhere; text-wrap: pretty; }
.inspector-heading-actions { display: flex; flex-shrink: 0; gap: 6px; }
.inspector-heading-actions button { padding-inline: 9px; }
.map-meta { color: var(--muted); font-size: 11px; margin: 7px 0 0; font-variant-numeric: tabular-nums; }
.inspector-body { overflow-y: auto; min-height: 0; padding: 0 16px 18px; }
.inspect-preview { height: 160px; background: #202629; border-radius: 5px; padding: 12px; margin: 16px 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.inspect-preview img, .inspect-preview canvas { max-width: 100%; max-height: 100%; object-fit: contain; image-rendering: pixelated; }
#inspectBosses { font-size: 12px; color: var(--gold); line-height: 1.7; }
.coordinate-row { display: flex; gap: 10px; margin: 18px 0 8px; }
.coordinate-row label { font-size: 12px; color: var(--muted); flex: 1; min-width: 0; }
.coordinate-row input { width: 100%; background: #22292c; border: 1px solid var(--line); border-radius: 5px; color: var(--ink); padding: 9px; margin-top: 6px; font-size: 12px; }
.nudge-hint { margin-top: 0; }
.inspect-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 18px 0; }
.crop-actions { margin-top: 20px; }
.crop-actions button { margin-right: 4px; }
.inspect-links { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 12px; }
.inspect-links button { text-align: left; white-space: normal; font-size: 12px; line-height: 1.5; }
.editing-help { margin-top: 20px; border-top: 1px solid var(--line); }
dialog { background: var(--panel); color: var(--ink); border: 1px solid #758583; border-radius: 12px; width: min(660px, calc(100vw - 32px)); max-height: 90dvh; padding: 28px; overflow-y: auto; }
dialog::backdrop { background: #202629cf; }
dialog h2 { font-size: 26px; }
dialog h2[tabindex]:focus { outline: none; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.dialog-heading h2 { min-width: 0; }
.dialog-heading button { flex: none; }
.export-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; padding: 12px 0 22px; }
.export-actions button { width: 100%; min-height: 44px; }
.export-actions p { margin: 10px 0 0; font-size: 12px; color: var(--muted); }
.export-animation { padding: 12px 0 16px; }
.export-animation > .gold { width: 100%; min-height: 44px; }
.export-animation p { margin: 10px 0; font-size: 12px; color: var(--muted); }
.export-animation #cancelExport { min-height: 44px; }
.source-assets { border-top: 1px solid var(--line); }
.source-assets > summary { padding: 16px 0; font-size: 14px; }
.source-links { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; font-size: 12px; margin: 20px 0; }
.download-card { display: block; padding: 16px 0; border-bottom: 1px solid var(--line); text-decoration: none; }
.download-card strong { font-size: 13px; display: block; }
.download-card span { display: block; font-size: 12px; color: var(--muted); margin-top: 7px; line-height: 1.6; }
.download-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 22px 0; }
.small-download { padding: 14px; border: 1px solid var(--line); border-radius: 5px; background: #343e41; text-decoration: none; }
.small-download strong { display: block; font-size: 12px; font-weight: 600; }
.small-download span { display: block; color: var(--muted); font-size: 11px; line-height: 1.6; margin-top: 8px; }
.download-instructions { border-top: 1px solid var(--line); }
.download-instructions li { font-size: 12px; line-height: 1.9; color: var(--muted); }
.download-instructions p { font-size: 12px; line-height: 1.8; color: var(--muted); }
code { font: 11px ui-monospace, monospace; background: #22292c; padding: 3px 5px; border-radius: 3px; }
.crop-dialog { width: min(850px, calc(100vw - 32px)); }
.crop-stage-frame { padding: 18px; margin: 8px 0; }
.crop-stage { position: relative; overflow: visible; margin: 0 auto; max-width: 100%; width: fit-content; touch-action: none; user-select: none; }
.crop-stage canvas { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.crop-box { position: absolute; border: 0; box-shadow: none; cursor: move; --handle-offset: 12px; }
.crop-shade { position: absolute; pointer-events: none; background: #000b; }
.crop-box span { position: absolute; width: 14px; height: 14px; transform: translate(-50%, -50%); touch-action: none; }
.crop-box span::after { content: ''; position: absolute; width: 14px; height: 14px; left: 50%; top: 50%; transform: translate(-50%, -50%); background: var(--gold); border: 2px solid #272e31; pointer-events: none; }
.crop-box [data-handle=nw] { left: calc(0px - var(--handle-offset)); top: calc(0px - var(--handle-offset)); cursor: nwse-resize; }
.crop-box [data-handle=n] { left: 50%; top: calc(0px - var(--handle-offset)); cursor: ns-resize; }
.crop-box [data-handle=ne] { left: calc(100% + var(--handle-offset)); top: calc(0px - var(--handle-offset)); cursor: nesw-resize; }
.crop-box [data-handle=e] { left: calc(100% + var(--handle-offset)); top: 50%; cursor: ew-resize; }
.crop-box [data-handle=se] { left: calc(100% + var(--handle-offset)); top: calc(100% + var(--handle-offset)); cursor: nwse-resize; }
.crop-box [data-handle=s] { left: 50%; top: calc(100% + var(--handle-offset)); cursor: ns-resize; }
.crop-box [data-handle=sw] { left: calc(0px - var(--handle-offset)); top: calc(100% + var(--handle-offset)); cursor: nesw-resize; }
.crop-box [data-handle=w] { left: calc(0px - var(--handle-offset)); top: 50%; cursor: ew-resize; }
.crop-detail-panel { display: flex; gap: 20px; align-items: center; margin: 12px 0 20px; padding: 12px; background: #22292c; border-radius: 6px; }
.crop-detail-panel canvas { flex: none; image-rendering: pixelated; max-width: 100%; }
.crop-detail-panel strong { font-size: 13px; }
.crop-detail-panel p { font-size: 12px; color: var(--muted); margin: 8px 0; }
.crop-edge-buttons { display: flex; gap: 6px; flex-wrap: wrap; }
.crop-edge-buttons button { padding: 6px 10px; font-size: 12px; }
.crop-detail-panel .fine-print { max-width: 400px; }
.crop-fields { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.crop-fields label { font-size: 12px; color: var(--muted); min-width: 0; }
.crop-fields input { display: block; width: 100%; margin-top: 6px; padding: 9px; color: var(--ink); background: #22292c; border: 1px solid var(--line); border-radius: 5px; }
.crop-dialog-actions { position: sticky; bottom: -28px; display: flex; gap: 8px; justify-content: flex-end; background: var(--panel); border-top: 1px solid var(--line); padding: 14px 0 20px; margin: 16px 0 -20px; z-index: 3; }
.crop-dialog-actions button:first-child { margin-right: auto; }
@media (max-width: 1150px) {
  .sidebar { width: 230px; padding-inline: 12px; }
  .inspector { width: 270px; }
  #modeHint { display: none; }
}
@media (max-width: 760px) {
  :root { --masthead-height: 56px; }
  button, .button-link, select, summary { min-height: 44px; }
  button, .button-link { min-width: 44px; }
  button, .button-link { font-size: 12px; }
  input[type=number], .search input { min-height: 44px; font-size: 16px; }
  .masthead { padding: 0 8px; gap: 8px; }
  .brand h1 { font-size: 15px; letter-spacing: 0; }
  .site-wordmark { width: 132px; }
  .brand h1 span { display: none; }
  .brand { gap: 5px; }
  .header-actions { gap: 4px; }
  .masthead button { padding-inline: 9px; min-height: 44px; }
  main { flex-direction: column; }
  .sidebar { display: none; position: absolute; inset: 0 auto 0 0; width: min(330px, calc(100vw - 24px)); border-right: 1px solid var(--line); padding: 18px 16px 0; z-index: 31; }
  .sidebar.open { display: flex; box-shadow: 10px 0 32px #0006; }
  .library-backdrop { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; border: 0; border-radius: 0; background: #202629b8; z-index: 30; }
  .library-backdrop:hover { background: #202629b8; }
  .library-heading { margin-bottom: 16px; }
  .search-label, .era-label { font-size: 13px; }
  .map-item { min-height: 44px; padding-block: 12px; }
  .map-title { font-size: 13px; }
  .map-tabs button { min-height: 44px; }
  .zoom-controls { left: 8px; right: auto; bottom: 8px; }
  .zoom-controls button { min-width: 44px; min-height: 44px; }
  .zoom-controls output { min-width: 42px; }
  .canvas-footer { padding: 3px 10px; min-height: 26px; font-size: 11px; gap: 6px; }
  .image-status button { min-height: 44px; }
  .save-state button { min-height: 44px; }
  .inspector { position: static; width: 100%; max-width: none; border: 0; border-top: 1px solid var(--line); border-radius: 0; max-height: 50dvh; flex-shrink: 0; }
  .inspector-heading { padding: 10px 12px; align-items: center; gap: 8px; min-height: 66px; }
  .inspector h2 { font-size: 14px; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
  .map-meta { margin-top: 4px; }
  .inspector-heading-actions { align-items: center; }
  .inspector-heading-actions button { min-height: 44px; padding-inline: 8px; }
  .inspector:not(.expanded) .inspector-body { display: none; }
  .inspector.expanded { height: min(50dvh, 420px); }
  .inspector-body { padding: 0 12px 16px; }
  .inspect-preview { height: 100px; padding: 8px; margin-block: 12px; }
  .inspect-actions { margin-block: 14px; }
  dialog { width: calc(100vw - 24px); padding: 20px; max-height: 92dvh; }
  dialog h2 { font-size: 26px; }
  .dialog-heading { gap: 10px; }
  .export-actions { grid-template-columns: 1fr; gap: 20px; padding-top: 8px; }
  .source-assets > summary { min-height: 48px; }
  .download-grid { grid-template-columns: 1fr; }
  .source-links a { display: inline-flex; align-items: center; min-height: 44px; }
  .download-card { padding-block: 18px; }
  .crop-stage-frame { padding: 18px; }
  .crop-fields { grid-template-columns: repeat(2, 1fr); }
  .crop-detail-panel { gap: 12px; flex-direction: column; align-items: flex-start; }
  .crop-detail-panel canvas { align-self: center; }
  .crop-dialog-actions { bottom: -20px; padding-bottom: 16px; margin-bottom: -16px; flex-wrap: wrap; }
  .crop-dialog-actions button { padding-inline: 10px; }
  #toast { padding: 10px 12px; align-items: flex-start; }
}
@media (pointer: coarse) {
  .crop-box { --handle-offset: 28px; }
  .crop-box span { width: 44px; height: 44px; }
  .crop-stage-frame { padding: 50px 32px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}

.export-status { color: var(--mint); font-size: 13px; line-height: 1.6; }
.export-status:empty { display: none; }
.crop-reference { display: none; }
@media (max-width: 760px) {
  .crop-reference { display: flex; align-items: center; gap: 12px; position: sticky; top: -20px; z-index: 2; background: var(--panel); padding: 8px 0; min-height: 72px; color: var(--muted); font-size: 12px; }
  .crop-reference canvas { image-rendering: pixelated; max-width: 96px; max-height: 64px; }
}

/* Primary display controls sit on the canvas, with no nested menus. */
.display-controls { position: absolute; top: 12px; left: 12px; z-index: 8; display: flex; gap: 0; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.display-controls button { min-height: 36px; padding: 8px 12px; border: 0; border-radius: 0; background: transparent; font-weight: 500; color: var(--muted); }
.display-controls button:hover { background: #424f52; color: var(--ink); }
.display-controls button.active { background: transparent; color: var(--ink); }
.display-toggle::before { content: ''; display: inline-block; width: 8px; height: 8px; margin-right: 7px; border: 1px solid var(--muted); border-radius: 1px; }
.display-toggle[aria-pressed=true]::before { background: var(--accent); border-color: var(--accent); }
.display-controls #play { border-left: 1px solid var(--line); }
.extra-tools { position: absolute; z-index: 22; right: 12px; top: 10px; width: 280px; max-width: calc(100% - 24px); max-height: calc(100dvh - 100px); overflow-y: auto; padding: 18px; border: 1px solid var(--line); border-radius: 4px; background: var(--panel); }
.extra-tools h2 { font: 600 14px ui-sans-serif,system-ui; margin: 0 0 14px; }
.history-controls { display: flex; gap: 8px; }
.history-controls button { flex: 1; }
.snap-control { display: flex; align-items: center; gap: 8px; margin: 18px 0; font-size: 12px; color: var(--ink); }
.tool-actions { display: flex; flex-direction: column; gap: 8px; }
.tool-actions button { text-align: left; }
#reset { color: #e4b2a0; margin-top: 8px; }
.extra-tools .editing-help { margin-top: 16px; }
.extra-tools p { font-size: 12px; color: var(--muted); }
.inspector.expanded { top: 60px; bottom: 38px; max-height: none; }
.inspector.expanded .inspector-heading { border-bottom: 1px solid var(--line); }
.inspector-heading-actions { flex-direction: column; gap: 4px; }
.inspector-heading-actions button { min-height: 28px; font-size: 11px; padding: 4px 8px; }
.inspector:not(.expanded) .inspector-body { display: none; }
.inspector:not(.expanded) h2 { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.preview-details, .connections-details { border-bottom: 1px solid var(--line); }
.connections-details { padding-bottom: 8px; }
.inspector-body .editing-help { border: 0; }
@media (max-width:760px) {
  .display-controls { top: 8px; left: 8px; }
  .display-controls button { min-height: 44px; min-width: 44px; padding: 8px 11px; }
  .display-toggle::before { margin-right: 6px; }
  .header-actions button { font-size: 11px; }
  .inspector.expanded { top: auto; bottom: auto; max-height: 50dvh; }
  .inspector-heading-actions { flex-direction: row; }
  .inspector-heading-actions button { min-height: 44px; font-size: 12px; padding-inline: 8px; }
  .extra-tools { right: 8px; top: 8px; }
  .snap-control { min-height: 44px; }
  .snap-control input { width: 20px; height: 20px; }
}
@media (max-width:360px) {
  .brand h1 { display: none; }
  .masthead button { padding-inline: 7px; }
  .header-actions { gap: 3px; }
}

.zoom-controls #fit { font-size: 12px; }
.display-controls button:focus-visible { outline-offset: -3px; }

/* Quiet state cues keep the native artwork in front. */
.display-controls button.active { color: var(--ink); }
.display-toggle::before { border-color: var(--accent); }
.display-toggle.active::before { background: var(--accent); }
button.active { background: var(--selected); color: var(--ink); border-color: var(--accent); }
.inspector-group-actions { padding: 0 12px 12px; }
.inspector-group-actions button { width: 100%; }
.hide-selection-dialog { width: min(440px, calc(100vw - 32px)); }
.hide-selection-dialog h2 { font-size: 24px; }
.hide-selection-dialog p { font-size: 13px; color: var(--muted); }
.hide-selection-list { max-height: 24dvh; overflow-y: auto; margin: 16px 0 22px; padding-left: 22px; font-size: 13px; line-height: 1.8; }
.confirm-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.confirm-actions button { min-height: 44px; }
@media (max-width:760px) {
  .canvas-focus-hint { left: 8px; bottom: 64px; }
  .hide-selection-dialog { width: calc(100vw - 24px); }
}

.quality-status { margin-left: auto; flex: none; }
.hovered-map { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; color: var(--ink); }
.image-status { flex-basis: 100%; color: var(--ink); }
@media (max-width:480px) { .brand h1 { display: none; } }
@media (max-width:760px) { .hovered-map { text-align: left; } .image-status { order: 4; } }
/* The game selector inherits the existing compact instrument controls. */
.game-picker{display:flex;align-items:center;gap:6px;font-size:12px;flex-shrink:0}
.game-picker select{max-width:150px;font:inherit;color:inherit;background:var(--field,#22292c);border:1px solid var(--line,#546165);border-radius:5px;padding:6px}
@media(max-width:760px){:root{--masthead-height:96px}.game-picker{font-size:0}.game-picker select{font-size:11px;max-width:115px}.masthead{flex-wrap:wrap;align-content:center;gap:6px 10px}}

/* The existing map is the wallpaper; only its compact controls remain. */
#viewport.wallpaper { position: fixed; inset: 0; width: 100%; height: 100dvh; z-index: 70; border: 0; border-radius: 0; background: var(--bg); }
#viewport.wallpaper .display-controls, #viewport.wallpaper .zoom-controls, #viewport.wallpaper .canvas-focus-hint { display: none; }
.wallpaper-controls { position: absolute; z-index: 8; bottom: max(20px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px); display: flex; align-items: center; gap: 20px; background: #272e31; padding: 14px 18px; border-radius: 6px; box-shadow: 0 6px 24px #0005; }
.wallpaper-heading { display: flex; flex-direction: column; gap: 5px; font-size: 13px; }
.wallpaper-heading span { color: var(--muted); font-size: 11px; max-width: 180px; }
.wallpaper-controls label { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: 12px; min-width: 110px; }
.wallpaper-controls input { grid-column: 1 / -1; width: 130px; height: 28px; margin: 0; accent-color: var(--gold); cursor: pointer; }
.wallpaper-controls select { grid-column: 1 / -1; min-height: 36px; width: 138px; padding: 6px; }
.wallpaper-controls output { color: var(--gold); font-variant-numeric: tabular-nums; }
.wallpaper-actions { display: flex; gap: 8px; }
.wallpaper-actions button { min-height: 44px; }
@media (max-width: 900px) {
 .wallpaper-controls { gap: 12px 16px; flex-wrap: wrap; justify-content: space-between; width: min(620px, calc(100% - 24px)); padding: 12px 14px; bottom: max(12px, env(safe-area-inset-bottom)); }
 .wallpaper-heading { width: 100%; flex-direction: row; align-items: center; justify-content: space-between; }
 .wallpaper-controls input { width: 100%; }
 .wallpaper-controls label { flex: 1; min-width: 110px; }
 .wallpaper-controls select { width: 100%; }
 .wallpaper-actions { width: 100%; justify-content: flex-end; }
}
@media (max-width: 480px) { #wallpaperEnter { padding-inline: 8px; } .wallpaper-controls label { min-width: 92px; } }

.wallpaper-controls { opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 180ms ease, visibility 0ms 180ms; }
.wallpaper-controls.is-revealed { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity 180ms ease; }
@media (max-width: 1100px) { .wallpaper-controls { flex-wrap: wrap; width: min(620px, calc(100% - 24px)); gap: 12px 16px; } .wallpaper-heading, .wallpaper-actions { width: 100%; } .wallpaper-controls label { flex: 1; } }
@media (max-width: 480px) { .wallpaper-controls label { flex-basis: calc(50% - 8px); } }
@media (prefers-reduced-motion: reduce) { .wallpaper-controls, .wallpaper-controls.is-revealed { transition: none; } }
.wallpaper-controls button, .wallpaper-controls input, .wallpaper-controls select { -webkit-tap-highlight-color: transparent; }
.wallpaper-controls button:active { background: var(--selected); }
@media (pointer: coarse) { .wallpaper-controls select, .wallpaper-controls input { min-height: 44px; } }

/* The tour is the primary way to experience the atlas. */
.wallpaper-entry-controls { position: absolute; top: 12px; right: 12px; z-index: 8; display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.wallpaper-auto-link { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 5px; background: var(--panel); color: var(--ink); cursor: pointer; font-size: 13px; white-space: nowrap; touch-action: manipulation; }
.wallpaper-auto-link input { width: 18px; height: 18px; margin: 0 !important; cursor: pointer; }
.wallpaper-auto-link:has(input:focus-visible) { outline: 2px solid var(--gold); outline-offset: 3px; }
.wallpaper-entry { display: inline-flex; align-items: center; justify-content: center; gap: 12px; min-height: 56px; min-width: 218px; padding: 14px 24px; border-color: var(--gold); background: var(--gold); color: #272e31; font-size: 16px; font-weight: 600; }
.wallpaper-entry svg { width: 22px; height: 22px; flex: none; fill: currentColor; }
.wallpaper-entry:hover { background: #ded3b5; border-color: #ded3b5; }
.wallpaper-entry:active { background: var(--gold); }
.wallpaper-entry.is-auto-link { background: #287646; border-color: #55a771; color: #fff; }
.wallpaper-entry.is-auto-link:hover { background: #21633b; border-color: #70be89; }
.wallpaper-entry.is-auto-link:active { background: #194f2e; }
.wallpaper-entry span { min-width: 0; white-space: normal; line-height: 1.3; }
#viewport.wallpaper .wallpaper-entry-controls { display: none; }
@media (max-width:760px) { .wallpaper-entry-controls { top: 64px; left: 8px; right: 8px; flex-direction: row; } .wallpaper-entry { flex: 1; min-width: 0; gap: 8px; padding-inline: 10px; } .wallpaper-auto-link { padding-inline: 10px; } }
@media (max-width:360px) { .wallpaper-entry { font-size: 14px; } .wallpaper-auto-link { font-size: 12px; } }

/* Options dismissal is separate from leaving the wallpaper. */
.wallpaper-controls { padding-right:70px; }
.wallpaper-close { position:absolute; top:8px; right:8px; display:grid; place-items:center; width:44px; height:44px; padding:0; }
.wallpaper-heading { min-height:44px; }
#wallpaperDismissHint { max-width:none; line-height:1.5; }
@media(max-width:1100px) { .wallpaper-controls { padding-right:14px; } .wallpaper-heading { flex-direction:column; align-items:flex-start; justify-content:center; padding-right:48px; } }
@media(hover:none) and (pointer:coarse) { .wallpaper-escape-hint { display:none; } }
/* Brief instruction stays inside the fullscreen viewport and never blocks it. */
.wallpaper-entry-hint { position:absolute; top:max(120px,25vh,env(safe-area-inset-top)); left:50%; transform:translateX(-50%); z-index:20; width:max-content; max-width:calc(100% - 32px); margin:0; padding:12px 16px; border-radius:6px; background:#272e31; color:var(--gold); box-shadow:0 6px 24px #0005; text-align:center; font-size:14px; line-height:1.5; pointer-events:none; opacity:1; transition:opacity 600ms ease; }
.wallpaper-entry-hint.is-fading { opacity:0; }
@media(prefers-reduced-motion:reduce) { .wallpaper-entry-hint { transition:none; } }

/* Live renderer integration preserves the incumbent atlas controls. */
.live-subtitle { display:block; font:400 12px/1.4 ui-sans-serif,system-ui; letter-spacing:.04em; }
.inspector-body details { margin-top:18px; }
.export-actions { display:flex; gap:8px; flex-wrap:wrap; }
.canvas-footer #detailStatus { margin-left:auto; font-variant-numeric:tabular-nums; }
#aboutDialog, #downloadDialog { max-width:560px; max-height:85dvh; overflow:auto; }
#aboutDialog p, #downloadDialog p { line-height:1.7; }
@media(max-width:760px) { .header-actions { margin-left:auto; } .masthead .game-picker select { max-width:145px; } .inspector { max-height:40dvh; } .canvas-footer { font-size:10px; } }

/* Narrow Link sandbox extension inside the pinned atlas interface. */
.play-panel{position:absolute;right:12px;bottom:12px;width:min(360px,calc(100% - 24px));background:#2b3336;border:1px solid #53636a;border-radius:6px;padding:12px;z-index:12;box-shadow:0 8px 24px #0005}
.play-heading,.play-controls,.play-actions{display:flex;gap:6px;align-items:center}.play-heading{justify-content:space-between}.play-panel p{font-size:12px;line-height:1.5;margin:10px 0;color:#b1bcbe}.play-controls button{flex:1;min-height:44px;padding:6px;touch-action:none}.play-actions{margin-top:8px}.play-panel output{display:block;font-size:11px;line-height:1.4;color:#b1bcbe;margin-top:8px;font-variant-numeric:tabular-nums}.play-panel button[aria-pressed=true]{background:#526167;color:#e1e4db}.play-controls button.is-held{background:#c4b68b;color:#263137}
@media(max-width:760px){.play-panel{left:8px;right:8px;bottom:68px;width:auto;padding:10px}.play-panel p{font-size:11px;margin:7px 0}.play-panel output{margin-top:6px}.play-controls button{min-width:0}.display-controls button{padding-inline:11px}}

.play-modes{display:flex;gap:6px;margin-top:10px}.play-modes button{flex:1;min-height:44px}.enemy-reset{margin-top:10px;color:#b1bcbe;font-size:12px}.enemy-reset summary{cursor:pointer}.enemy-reset label{display:flex;align-items:center;gap:8px;margin:10px 0}.enemy-reset input{width:18px;height:18px}.enemy-reset button{min-height:44px}.placing-link canvas{cursor:crosshair}.wallpaper .play-panel{display:none}#autoDetail:empty{display:none}#placeLink{cursor:grab}@media(max-width:760px){.play-panel{max-height:calc(100% - 260px);overflow:auto}.display-controls button{padding-inline:9px}.play-actions{flex-wrap:wrap}}

.placing-link .play-panel{display:none}.placement-prompt{position:absolute;left:12px;right:12px;bottom:68px;z-index:15;display:flex;align-items:center;justify-content:space-between;gap:12px;padding:10px 12px;background:#2b3336;border:1px solid #53636a;border-radius:6px;color:#e1e4db;font-size:13px}.placement-prompt button{min-height:44px;flex-shrink:0}.placement-prompt[hidden]{display:none}@media(max-width:760px){.placement-prompt{left:8px;right:8px;font-size:12px;line-height:1.4}}

.play-party{display:flex;gap:6px;align-items:flex-end;flex-wrap:wrap;margin-top:10px}.play-party label{flex:1;min-width:124px;font-size:11px;color:#b1bcbe}.play-party select{display:block;width:100%;min-height:44px;margin-top:4px}.play-party button{min-height:44px}.play-actions{flex-wrap:wrap}.play-controls button{min-width:0}

.play-controls button{white-space:normal;line-height:1.2}

/* Wallpaper options dismiss independently of leaving the native scene. */
#viewport.wallpaper #toast, #viewport.wallpaper .placement-prompt { display:none; }
.wallpaper-close { width:auto; min-width:104px; padding:0 12px; font-size:12px; }
.wallpaper-controls { padding-right:130px; }
@media(max-width:1100px) { .wallpaper-controls { padding-right:14px; } .wallpaper-heading { padding-right:116px; } }

/* Keyboard focus must not reveal ordinary Play help over wallpaper. */
#viewport.wallpaper:focus-visible .canvas-focus-hint { display:none; }

.respawn-duration{display:flex;align-items:center;gap:8px;flex-wrap:wrap}.respawn-duration input{width:72px;min-height:44px;font:inherit;font-size:16px;color:var(--ink);background:var(--field);border:1px solid var(--line);border-radius:4px;padding:7px}.respawn-duration input:disabled{opacity:.55}
/* Compact phones retain every display and placement action in one touch row. */
@media(max-width:360px){.display-controls{right:8px}.display-controls button{flex:1 1 0;min-width:0;padding-inline:4px;white-space:normal;line-height:1.2;font-size:11px}.display-toggle::before{display:block;margin:0 auto 3px}}


/* Totals share a row when space permits and wrap on compact phones. */
.play-totals { display: flex; flex-wrap: wrap; column-gap: 14px; }
.play-totals output { white-space: nowrap; }

/* Approved Master Sword wordmark; only this live header is adapted. */
.masthead .brand h1{display:block;font-size:0;line-height:0}
.live-wordmark{display:block;width:176px;height:40px;max-width:none;image-rendering:auto}
@media(max-width:760px){.live-wordmark{width:132px;height:30px}}

/* Character controls never reveal Dog options in a Link session. */
#dogOptions[hidden],#dogNativeStatus[hidden]{display:none!important}
#characterDialog{max-width:30rem}#characterChoice{display:block;width:100%;margin-top:.5rem}#characterDialog p{line-height:1.5}#dogNativeStatus{font-size:11px;color:var(--muted,#aab6b9)}#dogNativeStatus.is-error{color:#ffc4b3}
@media(max-width:760px){.display-controls{right:8px}.display-controls button{flex:1 1 0;min-width:0;padding-inline:3px;white-space:normal;line-height:1.2;font-size:11px}}

/* Keep the native map's quiet slate-and-gold control language. */
.play-panel{max-height:calc(100% - 136px);overflow:auto;overscroll-behavior:contain}
.play-manual-controls{display:grid;gap:12px;margin-top:14px}
.play-control-group{min-width:0;border:0;padding:0;margin:0}
.play-control-group legend{width:100%;display:flex;justify-content:space-between;gap:8px;padding:0;margin-bottom:6px;color:var(--ink);font-size:12px;font-weight:600}
.play-control-group legend span{font-size:11px;font-weight:400;color:var(--muted)}
.play-movement{display:grid;grid-template-columns:repeat(4,minmax(0,1fr))}
.play-tools{display:grid;grid-template-columns:repeat(2,minmax(0,1fr))}
.play-tools button{display:flex;align-items:center;justify-content:space-between;gap:6px;text-align:left;padding:8px 10px}
.play-panel kbd{font:inherit;font-size:10px;line-height:1.2;color:var(--muted);white-space:nowrap}
.play-tools button.is-held kbd{color:inherit}
.play-control-group button:focus-visible{outline:2px solid var(--gold);outline-offset:2px}
.play-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));margin-top:14px;padding-top:12px;border-top:1px solid var(--line)}
.play-actions button{min-height:44px;white-space:normal;font-size:12px}
.play-actions kbd{margin-left:4px}
.play-session-notes{margin-top:10px;font-size:12px;color:var(--muted)}
.play-session-notes ul{padding-left:18px;margin:0 0 8px;line-height:1.5}
.play-session-notes li+li{margin-top:4px}
.play-panel .play-tool-note{margin:8px 0 0;font-size:11px}
@media(max-width:760px){.play-panel{max-height:calc(100% - 204px)}.play-manual-controls{gap:10px;margin-top:12px}}

/* Seamless World: genuine default-on checkbox, keyboard and touch friendly. */
.seamless-option{display:inline-flex;align-items:center;gap:7px;padding:7px 10px;white-space:nowrap;font:inherit;cursor:pointer;color:inherit}.seamless-option input{width:15px;height:15px;accent-color:#d1bb78}.seamless-option:has(input:focus-visible){outline:2px solid #d1bb78;outline-offset:2px}.display-controls{flex-wrap:wrap}
