:root {
  color-scheme: dark;
  --bg: #0d0e0f;
  --panel: #191a1b;
  --line: #393838;
  --muted: #b9b5ac;
  --ivory: #f5f2e9;
  --accent: #ff8e4b;
  --accent-surface: #2d2019;
  --accent-edge: #764326;
  --primary: #ff833f;
  --lime: #deefa0;
  --gold: #ffcd78;
  font:
    16px/1.5 system-ui,
    -apple-system,
    'PingFang SC',
    'Microsoft YaHei',
    sans-serif;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  color: var(--ivory);
  background: radial-gradient(100% 95% at 48% 35%, #161311, var(--bg) 82%);
  min-height: 100vh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
button {
  color: inherit;
  font: inherit;
  cursor: pointer;
}
button:disabled {
  cursor: default;
}
button:focus-visible,
.scene:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}
button:active:not(:disabled) {
  translate: 0 1px;
}
[hidden] {
  display: none !important;
}
.top {
  border-bottom: 1px solid #ffffff14;
  background: var(--bg);
}
.bar,
main {
  width: min(calc(100% - 80px), 1144px);
  margin: auto;
}
.bar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand,
.top nav,
.brand span,
.top nav button,
.panel-head strong,
.mission-head > span:first-child,
.deck,
.shelf-head,
.shelf-head h2,
.stats,
.foot,
.scene-info,
.foot > span,
.tools button {
  display: flex;
  align-items: center;
}
.brand {
  gap: 11px;
}
.brand canvas {
  width: 34px;
  height: 34px;
  image-rendering: pixelated;
}
.brand span {
  font:
    800 21px/1 Menlo,
    Consolas,
    monospace;
  letter-spacing: -1px;
  color: var(--ivory);
}
.top nav {
  gap: 10px;
}
.top nav button,
.tools button,
.pad button {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 5px;
}
.top nav button {
  height: 33px;
  padding: 0 12px;
  gap: 7px;
  color: #d9d8d6;
  font-size: 13px;
  font-weight: 600;
}
.top nav b {
  border: 1px solid var(--muted);
  width: 15px;
  height: 15px;
  font: 700 12px/14px monospace;
  border-radius: 50%;
}
#sound[aria-pressed="true"] {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-surface);
}
.soundbars {
  color: var(--accent);
  font: 14px/1 monospace;
}
.top nav button:hover,
.tools button:not(:disabled):hover,
.pad button:not(:disabled):hover {
  background: var(--accent-surface);
  border-color: var(--accent-edge);
}
main {
  padding: 27px 0 18px;
}
.title-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 21px;
}
h1,
h2,
p {
  margin: 0;
}
h1 {
  font-size: clamp(27px, 3vw, 42px);
  font-weight: 850;
  line-height: 1.3;
  letter-spacing: 0.06em;
}
.title-stars {
  display: inline-block;
  color: var(--accent);
  vertical-align: top;
  margin: 5px 0 0 8px;
  font-size: 17px;
}
.mode-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}
#active-mode { color: var(--accent); font-size: 14px; }
#exit-game {
  min-height: 42px;
  padding: 5px 12px;
  color: var(--ivory);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 5px;
}
#exit-game kbd { color: var(--muted); margin-left: 3px; }
#mode-menu {
  min-height: calc(100svh - 64px);
  display: grid;
  place-items: center;
}
.entry-options .author-link {
  display: flex;
  width: fit-content;
  margin: 10px auto 0;
}
.entry-card {
  width: min(100%, 1020px);
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--accent-edge);
  border-radius: 10px;
  box-shadow: 0 18px 66px #0005;
  background: var(--panel);
}
#entry-art {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
}
.entry-options { padding: clamp(24px, 3.2vw, 46px); }
#entry-title {
  font: 800 clamp(34px, 4.4vw, 60px)/1.1 "PingFang SC", sans-serif;
  letter-spacing: 0.04em;
}
#entry-title:lang(en) {
  font-size: clamp(34px, 4vw, 54px);
  letter-spacing: normal;
}
.entry-touch, #target-size, #room-action { display: none; }
.entry-goal, .entry-touch {
  margin-top: 14px;
  line-height: 1.55;
}
.entry-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
  margin: 16px 0 0;
  padding: 13px;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--bg);
}
.entry-controls li {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}
.entry-controls li > :first-child {
  flex: none;
  white-space: nowrap;
}
.entry-controls kbd {
  display: inline-block;
  min-width: 20px;
  padding: 2px 4px;
  text-align: center;
  color: var(--ivory);
  border-color: var(--line);
  border-bottom-width: 2px;
  background: var(--panel);
}
.entry-options h2 {
  margin: 22px 0 10px;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}
.mode-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.mode-picker button {
  min-height: 44px;
  padding: 6px 4px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
}
.mode-picker button[aria-pressed="true"] {
  background: var(--accent-surface);
  border: 1px solid var(--accent);
  color: var(--accent);
}
.mode-picker button[aria-pressed="true"]::before,
.tile.active small::before {
  content: '';
  display: inline-block;
  width: 0.62em;
  height: 0.32em;
  margin-right: 0.45em;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-0.2em) rotate(-45deg);
}
.entry-options button:hover:not(:disabled), #exit-game:hover { border-color: currentColor; }
#start-game { width: 100%; justify-content: space-between; margin-top: 16px; min-height: 47px; padding-inline: 17px; }
#start-game > span[aria-hidden] { font-size: 21px; line-height: 1; font-weight: 400; }
#choose-expert-level { color: var(--accent); font-size: 13px; text-underline-offset: 3px; }
.shelf-head small {
  color: var(--muted);
  font-size: 13px;
}
.camera,
.mission-head > span:last-child,
.stats strong,
.bp-scale,
.foot > span:last-child {
  font-family: ui-monospace, Menlo, Consolas, monospace;
}
.console {
  display: grid;
  grid-template-columns: minmax(0, 2.18fr) minmax(260px, 0.91fr);
  gap: 17px;
  align-items: stretch;
}
.scene-panel,
.side,
.collection {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  overflow: hidden;
}
.scene-panel {
  display: flex;
  flex-direction: column;
  position: relative;
  container-type: inline-size;
}
.panel-head,
.mission-head {
  height: 39px;
  padding: 0 17px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.panel-head {
  background: var(--panel);
  border-bottom: 1px solid var(--bg);
}
.panel-head strong,
.mission-head > span:first-child {
  gap: 9px;
  font-size: 13px;
  letter-spacing: 0.04em;
}
.indicator,
.foot i {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: var(--accent);
}
.camera,
.mission-head > span:last-child,
.bp-scale {
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--muted);
}
.scene {
  isolation: isolate;
  position: relative;
  background: #171b20;
  min-width: 0;
  display: grid;
  place-items: center;
  flex: 1;
  overflow: hidden;
  outline-offset: -4px !important;
}
.scene canvas {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  display: block;
  image-rendering: pixelated;
  object-fit: contain;
}
.scene canvas.magnified {
  cursor: grab;
  touch-action: none;
}
.scene::before {
  content: '';
  display: block;
  width: 100%;
  aspect-ratio: 480/340;
  grid-area: 1/1;
}
.location,
.scene-result {
  position: absolute;
  pointer-events: none;
}
.location {
  top: 13px;
  left: 14px;
  display: flex;
  align-items: center;
  gap: 7px;
  background: #131313ed;
  border: 1px solid #85827b9c;
  box-shadow: 2px 2px 0 #0c0c0ca8;
  padding: 4px 9px;
  color: var(--ivory);
  font-size: 12px;
  letter-spacing: 0.06em;
}
.pin {
  width: 7px;
  height: 7px;
  border: 1px solid var(--accent);
  transform: rotate(45deg);
}
.scene-result {
  bottom: 12px;
  background: #191a1bed;
  border: 1px solid var(--gold);
  padding: 6px 16px;
  color: var(--gold);
  border-radius: 3px;
  text-align: center;
  font-size: 14px;
}
.reveal {
  animation: reveal 0.65s ease-out;
}
@keyframes reveal {
  from {
    transform: scale(1.13);
    filter: brightness(1.35);
  }
  to {
    transform: scale(1);
    filter: brightness(1);
  }
}
.deck {
  min-height: 69px;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  gap: 12px;
  background: var(--panel);
}
.scene-info {
  flex: 1;
  min-width: 0;
  align-items: flex-start;
  flex-direction: column;
}
.scene-info > span {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.08em;
}
.scene-info strong {
  font-size: 15px;
  line-height: 1.45;
}
#street-zoom {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  column-gap: 8px;
  width: 9rem;
  color: var(--muted);
  font-size: 12px;
}
#street-zoom-reset {
  padding: 2px 5px;
  min-height: 26px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}
#street-zoom-range {
  grid-column: 1 / -1;
  width: 100%;
  height: 26px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
#street-zoom-range:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}
#street-zoom-hint { grid-column: 1 / -1; }
@container (max-width: 480px) {
  #scene-actions:has(#street-zoom:not([hidden])) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }
  #scene-actions:has(#street-zoom:not([hidden])) .scene-info {
    grid-column: 1 / -1;
  }
  #street-zoom { max-width: 100%; }
}
.primary,
#dialog-actions button {
  border: 1px solid transparent;
  background: var(--primary);
  color: #1b100a;
  letter-spacing: 0.025em;
  font-weight: 760;
  border-radius: 5px;
}
.primary {
  min-height: 39px;
  padding: 6px 16px;
  display: flex;
  gap: 11px;
  align-items: center;
}
.primary:hover,
#dialog-actions button:hover {
  background: #ff945a;
}
.key,
kbd {
  border: 1px solid currentColor;
  border-radius: 3px;
  font:
    600 11px/1.3 ui-monospace,
    monospace;
  padding: 1px 4px;
}
.key {
  color: inherit;
}
.pad {
  display: flex;
  gap: 4px;
}
.pad button {
  min-width: 31px;
  height: 34px;
  font-size: 14px;
  color: var(--ivory);
}
.pad button:disabled {
  opacity: 0.35;
}
.side {
  display: flex;
  flex-direction: column;
  background: var(--panel);
}
.mission-head {
  height: auto;
  min-height: 39px;
  flex-wrap: wrap;
  column-gap: 10px;
  background: var(--accent-surface);
  border-bottom: 1px solid var(--accent-edge);
}
.mission-head > span:first-child {
  color: var(--accent);
  font-weight: 700;
}
.mission-head > span:first-child > span[aria-hidden] {
  font-size: 18px;
  color: var(--accent);
}
.mission-head > span:last-child {
  margin-left: auto;
  color: var(--accent);
}
.mission {
  padding: clamp(14px, 1.6vw, 24px);
  flex: 1;
  display: flex;
  flex-direction: column;
}
.blueprint {
  display: grid;
  place-items: center;
  position: relative;
  flex: 1;
  min-height: 120px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background-color: #121212;
  background-image:
    linear-gradient(#ffffff07 1px, transparent 1px),
    linear-gradient(90deg, #ffffff07 1px, transparent 1px);
  background-size: 12px 12px;
  padding: 40px 12px 24px 27px;
}
.bp-label,
.bp-scale {
  position: absolute;
  font-size: 10px;
  color: var(--muted);
}
.bp-label {
  left: 8px;
  top: 6px;
}
.bp-scale {
  bottom: 5px;
  right: 7px;
}
#pattern {
  width: 100%;
  max-width: 380px;
  aspect-ratio: var(--cols) / var(--floors);
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  grid-template-rows: repeat(var(--floors), minmax(0, 1fr));
  gap: 1px;
}
#pattern i {
  position: relative;
  background: #303031;
}
#pattern [data-floor-label]::before,
#pattern [data-col-label]::after {
  position: absolute;
  color: #a49aaa;
  font:
    8px/1 ui-monospace,
    monospace;
  pointer-events: none;
}
#pattern [data-floor-label]::before {
  content: attr(data-floor-label);
  right: calc(100% + 4px);
  top: 50%;
  transform: translateY(-50%);
}
#pattern [data-col-label]::after {
  content: attr(data-col-label);
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(100% + 4px);
}
#pattern .current-floor::before {
  color: var(--lime);
}
#pattern .on {
  background: var(--gold);
  box-shadow: inset 0 -1px #dca261;
}
.blueprint.unmarked {
  padding: 18px;
  background: #121212;
}
.unmarked #pattern { display: block; }
.unmarked canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.stats {
  justify-content: space-between;
  margin-top: 15px;
  gap: 6px;
}
.stats > span {
  font-size: 13px;
  color: #cbcac8;
  display: flex;
  align-items: center;
  gap: 7px;
}
.lamp-dot {
  width: 7px;
  height: 9px;
  border: 1px solid var(--gold);
  background: #cf9b553d;
  box-shadow: 0 3px 0 -1px #b9915a;
}
.stats strong {
  font-size: 17px;
  color: var(--gold);
}
.stats strong small,
.stats #target-count {
  color: var(--muted);
  font-size: 13px;
}
.light-meter {
  display: flex;
  gap: 3px;
  margin-top: 8px;
}
.light-meter i {
  height: 4px;
  flex: 1;
  background: #3d3c3b;
}
.light-meter .filled {
  background: var(--gold);
}
.tools {
  display: flex;
  gap: 6px;
  border-top: 1px solid var(--line);
  padding: 10px;
  flex-wrap: wrap;
}
.tools button {
  font-size: 12px;
  font-weight: 600;
  gap: 4px;
  justify-content: center;
  flex: 1;
  padding: 6px 4px;
  white-space: nowrap;
}
.tools button > span[aria-hidden] {
  color: var(--accent);
  font-size: 15px;
}
.tools button:disabled {
  opacity: 0.4;
}
.tools kbd {
  display: none;
}
.collection {
  margin-top: 16px;
  padding: 12px 15px 15px;
}
.shelf-head {
  justify-content: space-between;
  margin-bottom: 10px;
}
.shelf-head h2 {
  gap: 8px;
  font-size: 15px;
  letter-spacing: 0.04em;
}
.book {
  color: var(--accent);
  font-size: 21px;
  line-height: 1;
}
.shelf-head small {
  font-size: 12px;
}
.collection-status {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  align-items: center;
  justify-content: flex-end;
}
#finale-replay {
  padding: 6px 0;
  border: 0;
  background: transparent;
  color: var(--gold);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.shelf-head small,
.foot {
  letter-spacing: 0.03em;
}
#album {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
#album-pager {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--muted);
  font-size: 13px;
}
#album-pager button {
  min-height: 40px;
  padding: 4px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ivory);
}
#album-pager button:disabled { opacity: 0.4; }
#album-page { color: var(--accent); }
#album-jump {
  min-height: 40px;
  max-width: 100%;
  min-width: 0;
  padding: 4px;
  background: var(--accent-surface);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 4px;
  font: inherit;
}
.tile {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #212121;
  padding: 8px 10px;
  color: #bab8b4;
  min-height: 55px;
}
.tile.active {
  background: var(--accent-surface);
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: inset 2px 0 var(--accent);
}
.tile.earned:not(.active) { color: var(--ivory); }
.tile:not(:disabled):hover {
  border-color: var(--accent);
}
.tile b {
  display: block;
  font-size: 13px;
  line-height: 1.5;
}
.tile small {
  font:
    10px ui-monospace,
    monospace;
  color: #aeaca9;
}
.tile.active small {
  color: var(--accent);
}
.mini {
  flex: none;
  width: 36px;
  aspect-ratio: 24 / 16;
  image-rendering: pixelated;
}
.foot {
  justify-content: space-between;
  gap: 12px;
  font-size: 11px;
  color: #999793;
  margin: 13px 0 0;
}
.author-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  color: var(--muted);
  font: 13px ui-monospace, monospace;
  text-decoration: none;
}
.author-link > span:last-child { text-decoration: underline; text-underline-offset: 3px; }
.author-link:hover, .author-link:focus-visible { color: var(--accent); }
.foot > span {
  gap: 7px;
}
.foot > span:last-child {
  margin-left: auto;
}
.foot i {
  width: 5px;
  height: 5px;
}
.foot em {
  font-style: normal;
  color: var(--accent);
}
dialog {
  width: min(410px, calc(100% - 30px));
  color: var(--ivory);
  border: 1px solid var(--accent-edge);
  background: var(--panel);
  border-radius: 9px;
  padding: 0;
  box-shadow: 0 10px 80px #0009;
}
dialog::backdrop {
  background: #050505c5;
}
body:has(#finale[open]) { overflow: hidden; }
#finale {
  width: min(100%, 52vh);
  max-width: 100%;
  max-height: 100dvh;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: #ffeac8;
  background: #18202e;
}
#finale::backdrop { background: #080e17ed; }
.finale-poster { position: relative; }
.finale-art { position: relative; }
.finale-art img { display: block; width: 100%; height: auto; }
.finale-art canvas { position: absolute; image-rendering: pixelated; }
/* The window grid occupies this rectangle of the 1024 × 1536 street illustration. */
#finale-windows { left: 11.48%; top: 47.56%; width: 77.11%; height: 38.4%; }
#finale-sky { inset: 0; width: 100%; height: 100%; }
.finale-brand {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
}
.finale-brand span { color: #ffeac8; }
.finale-caption {
  position: relative;
  padding: 16px 20px max(28px, env(safe-area-inset-bottom));
  text-align: center;
}
.finale-caption h2 {
  margin: 0;
  font: 750 clamp(28px, 10.8vw, 46px)/1.18 'Songti SC', 'Noto Serif CJK SC', Georgia, serif;
  text-wrap: balance;
}
.finale-caption h2:focus { outline: none; }
.finale-caption p { margin: 10px 0 20px; font-size: clamp(16px, 4.5vw, 21px); }
#finale-album {
  justify-content: center;
  width: min(85%, 300px);
  min-height: 48px;
  margin: auto;
  border-radius: 10px;
}
@media (orientation: portrait) and (max-width: 600px) {
  #finale { width: 100%; height: 100dvh; }
  .finale-poster { min-height: 100%; display: flex; flex-direction: column; }
  .finale-art { width: min(100%, calc((100dvh - 170px) * 2 / 3)); margin-inline: auto; }
  .finale-art img { mask-image: linear-gradient(#000 94%, transparent); }
  .finale-caption { margin-block: auto; }
}
@media (orientation: portrait) and (max-height: 700px) {
  .finale-caption { padding-block: 10px max(12px, env(safe-area-inset-bottom)); }
  .finale-caption h2 { font-size: 28px; }
  .finale-caption p { margin: 6px 0 12px; }
}
@media (orientation: landscape) {
  #finale { width: min(960px, 96vw, 146dvh); border-radius: 10px; }
  .finale-poster { display: grid; grid-template-columns: 45% 55%; align-items: center; }
  .finale-caption { padding: 20px; }
  .finale-caption h2 { font-size: clamp(25px, 7dvh, 46px); }
}
dialog:has(.play-guide) { width: min(550px, calc(100% - 30px)); }
.play-guide { line-height: 1.65; }
.play-guide h3 { margin: 16px 0 4px; font-size: 16px; color: var(--accent); }
.play-guide strong { color: var(--ivory); }
.play-guide ol { margin: 4px 0 0; }
.dialog-inner {
  padding: 25px;
  position: relative;
}
.dialog-inner h2 {
  font-size: 23px;
  margin: 0 28px 12px 0;
}
.dialog-inner p,
.dialog-inner li {
  font-size: 15px;
  color: #d5d3cf;
}
.dialog-inner ol {
  padding-left: 21px;
}
.dialog-inner li {
  padding-bottom: 6px;
}
#dialog-close {
  position: absolute;
  right: 12px;
  top: 10px;
  background: transparent;
  color: var(--ivory);
  border: 0;
  font-size: 25px;
}
#dialog-actions {
  display: flex;
  gap: 8px;
  margin-top: 17px;
}
#dialog-actions button {
  padding: 7px 15px;
}
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
@media (min-width: 1300px) {
  .scene::before {
    aspect-ratio: 480/340;
  }
  .console {
    grid-template-columns: minmax(0, 2.18fr) minmax(300px, 0.91fr);
  }
}
@media (max-width: 960px) {
  .bar,
  main {
    width: calc(100% - 38px);
  }
  .console {
    grid-template-columns: minmax(0, 1.75fr) minmax(230px, 1fr);
    gap: 12px;
  }
  .scene::before {
    aspect-ratio: 480/340;
  }
  .tile {
    gap: 6px;
    padding: 7px;
  }
  .tools {
    gap: 4px;
    padding: 8px 5px;
  }
  .deck {
    gap: 7px;
    padding: 10px;
  }
  .pad {
    gap: 3px;
  }
  .pad button {
    min-width: 27px;
  }
  .primary {
    padding: 6px 10px;
  }
  .key {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
#pattern .here {
  outline: 2px solid #c6b7f6;
  outline-offset: 1px;
}
.scene-hint {
  position: absolute;
  left: 12px;
  bottom: 10px;
  padding: 3px 8px;
  border: 1px solid #9997935c;
  border-radius: 3px;
  background: #141414d9;
  color: #d5d3cf;
  font-size: 11px;
  letter-spacing: 0.04em;
  pointer-events: none;
}
#facility-prompt {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: max-content;
  max-width: calc(100% - 12px);
  padding: 4px;
  border: 1px solid #a48658;
  background: #252525f5;
  border-radius: 5px;
  white-space: nowrap;
}
#facility-prompt.at-door {
  /* The two interior doors start below their floor signs on the 480 × 340 canvas. */
  top: calc(50% - min(14.1667cqw, 20%));
  bottom: auto;
  padding: 0;
  border: 0;
  background: transparent;
}
#facility-prompt.at-door #facility-action {
  gap: 6px;
  padding-inline: 8px;
  font-size: 13px;
}
#lift-status { padding-inline: 5px; font-size: 13px; color: var(--gold); white-space: normal; }
.hall-call {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 44px;
  min-height: 44px;
  padding: 3px 8px;
  border: 2px solid #937d59;
  border-radius: 8px;
  background: linear-gradient(145deg, #4b4439, #292622);
  box-shadow: inset 0 0 0 1px #665b49;
  color: #eee1c6;
  font-size: 13px;
}
.hall-call:hover:enabled { border-color: #dfc28d; }
.hall-call[aria-pressed="true"] {
  border-color: #ffce79;
  color: #ffdc9c;
  box-shadow: inset 0 0 0 1px #a16c36, 0 0 5px #ffcb7688;
}
#facility-action { min-height: 44px; }
#scene-actions:has(#pad:not([hidden])) { flex-wrap: wrap; }
#pad button { height: auto; min-height: 44px; padding-inline: 8px; }
#pad { display: flex; }

.primary:disabled {
  opacity: 0.66;
  cursor: default;
}
.pad button {
  min-width: 38px;
  min-height: 40px;
}
#lift-panel {
  --screw: radial-gradient(circle, #634d35 1px, #d9c292 2px, transparent 3px);
  position: absolute;
  z-index: 1;
  right: 2.5%;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  gap: 13px;
  padding: 21px 17px;
  border: 2px solid #4e3b28;
  border-radius: 8px;
  background:
    var(--screw) left top / 13px 13px no-repeat,
    var(--screw) right top / 13px 13px no-repeat,
    var(--screw) left bottom / 13px 13px no-repeat,
    var(--screw) right bottom / 13px 13px no-repeat,
    repeating-linear-gradient(0deg, transparent 0 2px, #47321a12 2px 3px),
    linear-gradient(110deg, #a4865e, #cfb487 32%, #977a55 76%, #bba17a);
  box-shadow: inset 1px 1px 0 #eed7ac, inset -1px -1px 0 #806648, 2px 3px 0 #21191388;
}
.lift-readout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 43px;
  border: 2px inset #8d7757;
  border-radius: 4px;
  background: #211e1b;
  color: #ffd28b;
  font: 700 27px/1 ui-monospace, monospace;
  letter-spacing: 0.07em;
  text-shadow: 0 0 6px #dc922573;
}
#lift-arrow { width: 1em; font-size: 18px; }
.lift-keys {
  display: grid;
  grid-template-columns: repeat(4, 44px);
  gap: 6px;
}
.lift-keys button,
.lift-door-keys button {
  border: 2px solid #544331;
  background: linear-gradient(145deg, #554c42, #302d29 62%, #52483e);
  color: #f8edda;
  box-shadow: inset 0 0 0 1px #c5ac84, 0 1px 0 #ead0a6;
}
.lift-keys button {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  font: 650 16px/1 ui-monospace, monospace;
}
.lift-door-keys {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
.lift-door-keys button {
  display: grid;
  place-content: center;
  gap: 3px;
  min-height: 44px;
  padding: 4px;
  border-radius: 6px;
  font: 650 12px/1.2 system-ui, sans-serif;
}
.lift-door-keys [aria-hidden] { font: 16px/1 ui-monospace, monospace; }
.lift-door-keys button:disabled { color: #b8ad9d; box-shadow: none; }
.lift-keys button:hover:enabled,
.lift-door-keys button:hover:enabled { border-color: #f6d5a0; }
.lift-keys button[aria-pressed="true"] {
  border-color: #ffda8f;
  box-shadow: inset 0 0 0 2px #b57830, 0 0 6px #ffd887;
  color: #ffdb93;
}
@container (max-width: 716px) {
  #lift-panel {
    position: static;
    transform: none;
    grid-template-columns: minmax(45px, 82px) auto;
    justify-content: center;
    align-items: start;
    gap: 9px;
    margin: 6px auto;
    max-width: 100%;
    padding: 12px;
  }
  .lift-readout { gap: 2px; font-size: 22px; }
  #lift-arrow { font-size: 12px; }
  .lift-keys { gap: 4px; }
  .lift-door-keys { grid-column: 2; }
}
#dialog-actions .landing-key {
  min-height: 42px;
  background: #37312b;
  border-color: #877458;
  box-shadow: 0 2px 0 #191611;
  color: var(--ivory);
}
#dialog-actions .landing-key:hover:not(:disabled) {
  background: #514433;
}
#dialog-actions .landing-key:disabled {
  color: var(--gold);
  border-color: #ad8c62;
}

.hall-nav {
  gap: 8px;
  flex-wrap: wrap;
}
.hall-nav button {
  background: var(--accent-surface);
  border: 1px solid var(--accent-edge);
  border-radius: 4px;
  color: var(--accent);
  min-height: 44px;
  padding: 3px 10px;
  font-size: 13px;
}
.hall-nav button:focus-visible { outline-color: var(--accent); }
.hall-nav button:disabled { opacity: 0.55; }
.hall-nav button:hover:not(:disabled) {
  border-color: var(--accent);
}
.hall-nav #route {
  margin-left: auto;
}
.room-panel {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}
.room-panel .facility-key {
  grid-column: span 2;
}
#dialog-actions .room-panel button {
  padding-inline: 3px;
}
dialog {
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
}

.floor-board { width: 100%; }
.floor-all, .floor-room {
  cursor: pointer;
  accent-color: var(--lime);
}
.floor-all {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
}
.floor-rooms {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
}
.floor-room {
  display: grid;
  grid-template-columns: auto auto;
  align-content: center;
  justify-content: center;
  align-items: center;
  column-gap: 4px;
  min-height: 46px;
  border: 1px solid #575566;
  border-radius: 4px;
  background: #282936;
  font: 600 14px/1.25 system-ui, sans-serif;
}
.floor-room input, .floor-all input { margin: 0; }
.floor-room:has(:checked) { border-color: var(--lime); background: #373e30; }
.floor-room:focus-within { outline: 2px solid var(--gold); outline-offset: 1px; }
.floor-room small { grid-column: 1 / -1; color: var(--muted); text-align: center; }
.floor-room .on { color: var(--gold); }
.floor-actions { display: flex; gap: 6px; margin-top: 14px; }
#dialog-actions .floor-actions button { flex: 1; min-height: 44px; padding: 6px 3px; }
dialog:has(.floor-board) #dialog-close { display: none; }


#language {
  max-width: 9em;
  min-width: 0;
  min-height: 34px;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel);
  color: var(--ivory);
  font: inherit;
  font-size: 13px;
}
.tools button { white-space: normal; }

@media (max-width: 750px), (max-width: 1000px) and (max-height: 540px) {
  .bar, main { width: calc(100% - 24px); }
  .bar { height: auto; min-height: 56px; gap: 6px; }
  .brand { gap: 6px; min-width: 0; }
  .brand span { font-size: 16px; line-height: 1.1; }
  .brand canvas { width: 28px; height: 28px; }
  .top nav { gap: 4px; }
  .top nav button { justify-content: center; width: 44px; height: 44px; padding: 0; }
  .top nav b { width: 19px; height: 19px; line-height: 18px; }
  .soundbars {
    position: relative;
    width: 18px;
    height: 16px;
    font-size: 0;
    background:
      linear-gradient(currentColor, currentColor) left bottom / 4px 5px no-repeat,
      linear-gradient(currentColor, currentColor) center bottom / 4px 10px no-repeat,
      linear-gradient(currentColor, currentColor) right bottom / 4px 15px no-repeat;
  }
  #sound[aria-pressed="false"] .soundbars { color: var(--muted); }
  #sound[aria-pressed="false"] .soundbars::after {
    content: '';
    position: absolute;
    inset: 7px -2px auto;
    height: 2px;
    transform: rotate(-42deg);
    background: currentColor;
    box-shadow: 0 2px var(--panel);
  }
  #language { min-height: 44px; }
  #sound-label, #help span, .title-row h1 {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  h1 .title-stars { font-size: 14px; }
  main { padding: 12px 0 18px; }
  #mode-menu { min-height: calc(100svh - 56px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
  .entry-controls, .entry-goal, #play-screen kbd { display: none; }
  .entry-touch { display: block; margin-top: 10px; color: #d5d3cf; }
  .entry-options { padding: 18px; }
  .entry-options h2 { margin: 18px 0 8px; }
  #start-game { margin-top: 10px; }
  .title-row { margin-bottom: 8px; }
  .mode-row { width: 100%; gap: 4px 10px; }
  #exit-game { min-height: 44px; margin-inline-start: auto; }
  #choose-expert-level { display: inline-flex; align-items: center; min-height: 44px; }
  .primary, .tools button, .tile, #album-pager button, #album-jump,
  #dialog-close, #dialog-actions button { min-height: 44px; }
  #dialog-close { min-width: 44px; top: 4px; right: 4px; }
  .dialog-inner { padding: 18px; }
  #dialog-actions { flex-wrap: wrap; }
  .location { top: 8px; left: 8px; }
  .panel-head { height: 32px; padding-inline: 12px; }
  .deck { min-height: 0; padding: 8px; gap: 6px; }
  .hall-nav button { flex: 1 1 auto; }
  #room-action {
    display: flex;
    flex-basis: 100%;
    justify-content: center;
    background: var(--primary);
    color: #1b100a;
  }
  #scene-actions:has(#street-zoom:not([hidden])) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
  }
  #scene-actions:has(#street-zoom:not([hidden])) .scene-info { display: none; }
  #street-zoom { width: 100%; grid-template-columns: 1fr auto; gap: 0 6px; }
  #street-zoom label { grid-column: 1 / -1; }
  #street-zoom-range { grid-column: 1; grid-row: 2; height: 44px; }
  #street-zoom-reset { grid-column: 2; grid-row: 2; min-height: 44px; min-width: 44px; }
  #action { max-width: 9em; justify-content: center; }
  .tools { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding: 8px; }
  .collection { padding: 10px; }
  #album { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  #album-pager { flex-wrap: wrap; gap: 6px; }
  .foot { flex-wrap: wrap; }
}

@media (max-width: 750px) and (min-height: 541px), (max-width: 549px), (max-width: 750px) and (orientation: portrait) {
  .entry-card { grid-template-columns: 1fr; max-width: 448px; }
  #entry-art { border-bottom: 1px solid var(--accent-edge); }
  .console { grid-template-columns: minmax(0, 1fr); gap: 10px; }

  /* Keep the live target grid next to its progress, directly under the scene. */
  .side {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto auto 1fr auto;
    grid-template-areas: "art name" "art stats" "art meter" "tools tools";
    gap: 4px 12px;
    padding-top: 10px;
  }
  .mission { display: contents; }
  .mission-head {
    grid-area: name;
    align-self: center;
    flex-direction: column-reverse;
    align-items: flex-start;
    min-height: 0;
    padding: 0 10px 0 0;
    background: none;
    border: 0;
  }
  .mission-head > span:first-child { font-size: 15px; }
  .mission-head > span:last-child { margin: 0; color: var(--muted); letter-spacing: normal; }
  .blueprint {
    grid-area: art;
    align-self: start;
    margin-left: 10px;
    min-height: 0;
    padding: 32px 10px 12px 25px;
  }
  .side:not(.target-expanded) :is(.bp-count, .bp-scale) { display: none; }
  #pattern { max-width: 100%; }
  #target-size {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--ivory);
  }
  #target-size span {
    padding: 0 4px;
    border-radius: 3px 0;
    background: #363632;
    font: 16px/1.1 system-ui, sans-serif;
  }
  .stats { grid-area: stats; flex-wrap: wrap; justify-content: start; margin: 4px 10px 0 0; }
  .light-meter { grid-area: meter; align-self: start; margin: 0 10px 0 0; }
  .tools { grid-area: tools; margin-top: 5px; }
  .side.target-expanded {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "name" "art" "stats" "meter" "tools";
    grid-template-rows: auto;
  }
  .target-expanded .mission-head { flex-direction: row; justify-content: space-between; padding: 0 10px; }
  .target-expanded .blueprint { margin-inline: 10px; padding: 36px 14px 26px 30px; }
  .target-expanded .stats, .target-expanded .light-meter { margin-inline: 10px; }
  .target-expanded .bp-scale { right: 26px; }
  .blueprint.unmarked { padding: 10px; }
}

@media (max-width: 360px) {
  .brand span { font-size: 14px; }
  #entry-title:lang(en) { font-size: 27px; }
  .mode-picker button { font-size: 14px; }
}

@media (orientation: portrait) and (max-height: 630px) and (max-width: 750px) {
  #entry-art { max-height: 31svh; object-fit: contain; background: #171b20; }
  .entry-options { padding: 12px 15px; }
  .entry-touch { margin-top: 6px; font-size: 14px; }
  .entry-options h2 { margin: 10px 0 6px; }
}

@media (min-width: 550px) and (max-width: 1000px) and (max-height: 540px) and (orientation: landscape) {
  .entry-card { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); max-width: 900px; }
  #entry-art { border: 0; }
  body:has(#play-screen:not([hidden])) .bar .brand { display: none; }
  body:has(#play-screen:not([hidden])) .bar { justify-content: flex-end; }
  #play-screen .title-row {
    position: absolute;
    top: env(safe-area-inset-top);
    left: calc(12px + env(safe-area-inset-left));
    width: calc(100% - 225px - env(safe-area-inset-left) - env(safe-area-inset-right));
    min-height: 56px;
    margin: 0;
  }
  #exit-game { margin-inline-start: 0; }
  .console { grid-template-columns: minmax(0, 1.55fr) minmax(210px, 1fr); align-items: start; }
  .scene::before { height: clamp(120px, calc(100svh - 187px), 280px); aspect-ratio: auto; }
  .mission { padding: 8px; }
  .blueprint { padding-block: 30px 18px; }
  #pattern { max-width: 46svh; }
  .stats { margin-top: 8px; }
}
