:root {
  color-scheme: dark;
  --ink: #241d14;
  --dark: #1e1a13;
  --deep: #17150f;
  --edge: #756041;
  --line: rgb(190 153 95 / .29);
  --gold: #d6b479;
  --gold-bright: #edcf94;
  --ivory: #f5e7c9;
  --muted: #c7b48f;
  --faint: #9e8b69;
  --sage: #b3ba89;
  --serif: 'Songti SC', 'Noto Serif CJK SC', SimSun, Georgia, serif;
  --sans: 'PingFang SC', 'Microsoft YaHei', 'Noto Sans CJK SC', system-ui, sans-serif;
  --side: clamp(14px, 2.05vw, 34px);
  --footer-height: 43px;
  --deck-width: min(772px, calc(100vw - 112px));
  --shadow: 0 7px 26px #16100a66, 0 2px 7px #100e0999, inset 0 0 0 1px #dbc2921a;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body { font-family: var(--sans); color: var(--ivory); background: #6b775a; }
button, select { color: inherit; font: inherit; }
button { border: 0; background: transparent; padding: 0; cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, select:focus-visible, canvas:focus-visible { outline: 2px solid #f5d098; outline-offset: 3px; }
svg { display: block; width: 100%; height: 100%; }
[data-icon] { display: inline-grid; place-items: center; }

#game { isolation: isolate; position: relative; width: 100%; height: 100vh; height: 100dvh; overflow: hidden; background: #697754 url('./assets/valley.webp') center / cover no-repeat; }
#world { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#world:active { cursor: grabbing; }
#world.is-placing { cursor: crosshair; }
#world.is-demolishing { cursor: crosshair; }
.world-shading { position: absolute; inset: 0; pointer-events: none; background: linear-gradient(180deg, #18170e66, #28251a13 16%, transparent 27%, transparent 70%, #17130c16 84%, #17130c75 100%); }

.hud-top { position: absolute; top: max(15px, env(safe-area-inset-top)); left: 0; right: 0; display: flex; justify-content: space-between; align-items: flex-start; padding: 0 var(--side); pointer-events: none; }
.hud-top > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 11px; margin-top: -3px; user-select: none; }
.brand-banner { width: 54px; height: 62px; filter: drop-shadow(0 2px 4px #141007aa); }
.brand-wordmark { margin-top: -4px; white-space: nowrap; text-shadow: 0 2px 5px #130f0be6, 0 0 14px #20181091; }
.brand h1 { font-family: var(--serif); font-size: 30px; line-height: 1.12; margin: 0 0 5px; letter-spacing: .085em; font-weight: 700; color: #fff2d5; }
.brand p { font: 600 12px/1 Georgia, serif; letter-spacing: .415em; color: #f8d496; margin: 0; }

.resources { position: absolute; left: 50%; transform: translateX(-50%); display: flex; align-items: stretch; min-height: 54px; border: 1px solid #a48555b8; background: linear-gradient(180deg, #30271ceb, #1e1b13ee); box-shadow: var(--shadow); padding: 5px 4px; border-radius: 3px; }
.resources::before, .resources::after { content: ''; width: 4px; height: 4px; rotate: 45deg; background: #d0ad70; box-shadow: 0 0 0 2px #33291d; position: absolute; top: calc(50% - 2px); }
.resources::before { left: -3px; }
.resources::after { right: -3px; }
.resource { position: relative; display: flex; gap: 10px; align-items: center; width: clamp(95px, 8.15vw, 122px); padding: 1px 9px 1px 14px; }
.resource + .resource::before { content: ''; position: absolute; inset: 4px auto 4px 0; width: 1px; background: linear-gradient(transparent, #bf9c5f60, transparent); }
.resource-symbol { width: 25px; height: 25px; color: var(--gold-bright); }
.resource-people .resource-symbol { color: #d9c6a5; }
.resource-food .resource-symbol { color: #cfb883; }
.resource-happiness .resource-symbol { color: #b7c293; }
.resource-label { display: block; margin-bottom: 3px; font-size: 9px; line-height: 1.05; color: var(--muted); letter-spacing: .13em; }
.resource strong { display: block; color: #f7e8c6; font: 600 20px/.95 Georgia, serif; font-variant-numeric: lining-nums tabular-nums; white-space: nowrap; }
.resource strong.is-low { color: #efaa82; }
.top-right { display: flex; align-items: center; gap: 10px; }
.date-card { height: 53px; min-width: 130px; display: flex; gap: 10px; align-items: center; padding: 0 12px; border: 1px solid #ab8a55a8; background: linear-gradient(180deg, #30271ce8, #201a12e9); border-radius: 3px; box-shadow: var(--shadow); white-space: nowrap; }
#season-icon { width: 25px; height: 25px; color: #e2bc79; }
.date-season { display: block; color: var(--gold); font: 700 13px/1.15 var(--serif); letter-spacing: .095em; margin-bottom: 4px; }
.date-card time { display: block; font-size: 10px; color: #ded0b1; line-height: 1.1; }
.circle-button { width: 44px; height: 44px; color: var(--gold); background: linear-gradient(150deg, #392f22, #1a180f); border: 1px solid #ae8b56af; border-radius: 50%; box-shadow: var(--shadow); transition: color 140ms, background 140ms; }
.circle-button svg { width: 20px; height: 20px; }

.panel { border: 1px solid var(--edge); border-radius: 3px; background: radial-gradient(ellipse at 50% 0%, #50402a39, transparent 75%), linear-gradient(#2a2319f5, #1d1a12f7); box-shadow: var(--shadow); }

.objectives { position: absolute; left: var(--side); top: calc(max(15px, env(safe-area-inset-top)) + 79px); width: 232px; padding: 0 13px 12px; }
.objectives::before, .inspection::before { content: ''; position: absolute; width: 28px; height: 1px; inset: -1px auto auto 11px; background: #e3be79; box-shadow: 0 0 8px #e3be794f; }
.objectives-title { display: flex; align-items: center; width: 100%; gap: 10px; padding: 10px 0; min-height: 48px; text-align: left; }
.objective-symbol { width: 25px; height: 28px; color: #e5bd79; border: 1px solid #8f704a; background: #c4a06b12; clip-path: polygon(0 0, 100% 0, 100% 83%, 50% 100%, 0 83%); }
.objective-symbol svg { width: 16px; height: 16px; }
.section-title { font: 700 17px/1 var(--serif); letter-spacing: .095em; color: #f5e7c5; white-space: nowrap; }
.objectives-toggle { width: 14px; height: 14px; margin-left: auto; color: var(--gold); transition: rotate 150ms; }
.objectives.is-collapsed { padding-bottom: 0; width: 172px; }
.objectives.is-collapsed .objectives-toggle { rotate: 180deg; }
.goal { padding-top: 11px; border-top: 1px solid var(--line); }
.goal + .goal { margin-top: 10px; }
.goal-heading { display: flex; align-items: center; gap: 7px; }
.goal-dot { display: grid; place-items: center; width: 12px; height: 12px; color: var(--gold); flex: 0 0 12px; }
.goal:not(.is-done):not(.is-locked) .goal-dot::before { content: ''; width: 5px; height: 5px; background: var(--gold); rotate: 45deg; }
.goal.is-done .goal-dot { color: var(--sage); }
.goal.is-locked .goal-dot { color: var(--faint); }
.goal-title { font-size: 12px; line-height: 1.35; color: #f1dfbb; }
.goal.is-locked .goal-title { color: var(--muted); }
.goal-meta { display: flex; gap: 8px; align-items: center; margin: 8px 0 0 19px; }
.progress-track { height: 4px; flex: 1; background: #12120c; border: 1px solid #b799633a; border-radius: 3px; overflow: hidden; }
.progress-value { display: block; height: 100%; min-width: 0; border-radius: 2px; background: linear-gradient(90deg, #a57942, #e3bc76); transition: width 360ms; }
.goal.is-done .progress-value { background: #aab17e; }
.goal-number { color: var(--gold); font: 600 11px/1 Georgia, serif; min-width: 30px; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

.camera { position: absolute; right: var(--side); bottom: calc(var(--footer-height) + 21px); display: flex; flex-direction: column; align-items: center; gap: 9px; }
.compass { display: block; width: 69px; height: 69px; filter: drop-shadow(0 3px 5px #1a130c8c); border-radius: 50%; transition: filter 150ms; }
.compass > span { display: block; width: 100%; height: 100%; }
.compass:hover { filter: drop-shadow(0 4px 8px #21170a99) brightness(1.18); }
.camera-stack { display: flex; flex-direction: column; align-items: stretch; border: 1px solid #a48655ab; background: linear-gradient(#322a1ce9, #1c1a13ef); box-shadow: var(--shadow); border-radius: 3px; padding: 3px; }
.icon-button { display: grid; place-items: center; width: 34px; height: 34px; color: #dab77d; transition: color 120ms, background-color 120ms; }
.icon-button svg { width: 18px; height: 18px; }
.camera-stack button + button { border-top: 1px solid var(--line); }
.icon-button:disabled { color: #b1a08269; }
.icon-button.is-active { color: var(--gold-bright); background-color: #c9964c2f; }
.icon-button.is-danger { color: #f1a386; background-color: #b44e3f28; }
.circle-button:hover, .icon-button:not(:disabled):hover, .subtle-button:hover, .objectives-title:hover .section-title, .build-heading:hover .section-title { color: #ffdfa6; }
.icon-button:not(:disabled):hover, .circle-button:hover { background-color: #c99a5b27; }

.construction { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(var(--footer-height) + 15px); width: var(--deck-width); pointer-events: none; }
.construction-toolbar { display: flex; align-items: end; gap: 8px; padding-inline: 6px; height: 39px; }
.build-heading, .construction-actions, .construction-body, .build-action-tip { pointer-events: auto; }
.build-heading { display: flex; position: relative; align-items: center; height: 38px; padding: 0 11px 0 10px; gap: 9px; border: 1px solid var(--edge); border-bottom: 0; border-radius: 3px 3px 0 0; background: linear-gradient(#3c3020f9, #2a2318f7); box-shadow: 0 -3px 12px #21170e48, inset 0 0 0 1px #dfbf861e; }
.build-heading::after { content: ''; position: absolute; width: calc(100% - 4px); height: 2px; background: #2a2318; left: 2px; bottom: -1px; z-index: 1; }
.build-heading-icon { width: 19px; height: 19px; color: var(--gold); }
.build-heading .section-title { font-size: 16px; }
.build-chevron { width: 12px; height: 12px; margin-left: 4px; color: var(--gold); transition: rotate 150ms; }
.construction-spacer { flex: 1; }
.construction-actions { display: flex; gap: 3px; padding: 2px; margin: 0 0 4px; border: 1px solid var(--edge); border-radius: 3px; background: #231d15e9; box-shadow: 0 2px 10px #21170e59; }
.construction-actions .icon-button { width: 29px; height: 27px; border-radius: 2px; }
.construction-actions .icon-button + .icon-button { border-left: 1px solid var(--line); border-radius: 0; }
.construction.is-collapsed .build-heading { border: 1px solid var(--edge); border-radius: 3px; }
.construction.is-collapsed .build-heading::after { display: none; }
.construction.is-collapsed .build-chevron { rotate: 180deg; }
.construction-body { padding: 0 9px 9px; }
.categories { display: flex; align-items: center; min-height: 37px; padding: 0 4px; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 8px; overflow: auto hidden; scrollbar-width: none; }
.categories::-webkit-scrollbar { display: none; }
.category { position: relative; display: flex; flex: 0 0 auto; gap: 6px; align-items: center; padding: 0 13px; min-height: 37px; color: #c3ae88; font-size: 11px; letter-spacing: .06em; white-space: nowrap; transition: color 120ms, background-color 120ms; }
.category [data-icon] { width: 13px; height: 13px; }
.category:hover { color: var(--gold-bright); }
.category.is-active { color: var(--gold-bright); background: linear-gradient(0deg, #ae844428, transparent 90%); }
.category.is-active::after { content: ''; position: absolute; height: 1px; inset: auto 3px 0; background: #e6bb72; box-shadow: 0 0 7px #e9b56466; }
.building-list { display: flex; gap: 7px; align-items: stretch; min-height: 126px; overflow: auto hidden; scrollbar-width: thin; scrollbar-color: #8e724a #1f1b13; padding-bottom: 1px; }
.building-card { position: relative; flex: 0 0 calc((100% - 35px) / 6); min-width: 104px; display: flex; flex-direction: column; justify-content: space-between; text-align: left; overflow: hidden; border: 1px solid #7e6746b3; border-radius: 2px; min-height: 126px; background: #131512; transition: border-color 130ms, box-shadow 130ms; }
.building-card:hover { border-color: #c9a568; box-shadow: inset 0 0 16px #c2a16f24; }
.building-card:focus-visible { outline-offset: -2px; }
.building-card.is-active { border-color: #f2ca86; box-shadow: inset 0 0 13px #f5ca7266, 0 0 5px #e0ad5866; }
.building-card.is-active::after { content: ''; position: absolute; right: 5px; top: 5px; height: 5px; width: 5px; rotate: 45deg; background: #f6d596; box-shadow: 0 0 7px #fac568; }
.card-art { display: grid; position: relative; place-items: center; flex: 1; min-height: 96px; width: 100%; overflow: hidden; }
.card-art > img { position: absolute; width: 100%; height: calc(100% - 4px); inset: 2px 0; object-fit: contain; mask-image: linear-gradient(#000 94%, transparent 97%); }
.card-art.is-missing::after { content: ''; width: 25px; height: 25px; border: 1px solid #c4a37151; rotate: 45deg; }
.card-meta { z-index: 1; position: relative; flex: none; width: 100%; height: 29px; display: flex; align-items: center; justify-content: space-between; gap: 3px; padding: 0 7px; border-top: 1px solid #b396602b; background: #241d14ed; }
.card-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; font: 700 13px/1 var(--serif); letter-spacing: .015em; white-space: nowrap; }
.card-price { display: flex; align-items: center; gap: 3px; color: var(--gold-bright); font: 600 13px/1 Georgia, serif; white-space: nowrap; }
.card-price svg { width: 11px; height: 11px; }
.building-card.is-expensive .card-price { color: #d9987c; }

.status-bar { position: absolute; inset: auto 0 0; height: var(--footer-height); padding: 0 var(--side); border-top: 1px solid #987c5166; background: linear-gradient(180deg, #2d2519f8, #1a180ff9); box-shadow: 0 -2px 15px #19130c45; display: grid; grid-template-columns: 1fr auto 1fr; }
.status-side { display: flex; align-items: center; gap: 12px; color: #c4b390; font-size: 10px; }
.status-right { justify-content: end; }
.subtle-button { display: flex; align-items: center; gap: 5px; height: 100%; white-space: nowrap; color: inherit; }
.subtle-button svg { width: 15px; height: 15px; color: var(--gold); }
.status-rule { width: 1px; height: 14px; background: var(--line); }
.gesture-hints { display: flex; gap: 9px; align-items: center; white-space: nowrap; }
kbd { display: inline-grid; place-items: center; min-width: 18px; border: 1px solid #bda47555; border-radius: 3px; min-height: 17px; padding: 0 3px; color: var(--gold); background: #332a1d; font: 10px/1 var(--sans); }
.playback { display: flex; height: 100%; align-items: center; gap: 2px; }
.play-button { display: grid; place-items: center; width: 35px; height: 29px; border-radius: 2px; color: #bba077; transition: background-color 130ms, color 130ms; font: 600 15px/1 Georgia, serif; }
.play-button svg { width: 15px; height: 15px; }
.play-button:hover { color: #f3d7a0; background-color: #bc945822; }
.play-button.is-active { color: #f6dba2; background-color: #caa1602f; box-shadow: inset 0 0 0 1px #d5ac6047; }
.playback-rule { width: 1px; height: 16px; margin: 0 4px; background: var(--line); }
#save-status { display: flex; gap: 6px; align-items: center; white-space: nowrap; }
#save-status i { width: 5px; height: 5px; transform: rotate(45deg); background: #b1b481; box-shadow: 0 0 6px #b2bf7780; }
#save-status.is-error i { background: #ddac83; box-shadow: none; }

.inspection { position: absolute; bottom: calc(var(--footer-height) + 234px); left: var(--side); width: 238px; padding: 12px; z-index: 2; }
.inspection-header { display: flex; align-items: center; gap: 9px; margin: 0 0 9px; }
.inspection-title { font: 700 18px/1.1 var(--serif); letter-spacing: .06em; margin: 0; flex: 1; }
.inspection-mark { width: 24px; height: 24px; color: var(--gold); }
.inspection .icon-button { width: 25px; height: 25px; margin-right: -4px; }
.inspection-status { margin: 0 0 8px; color: var(--gold-bright); font-size: 11px; line-height: 1.5; }
.inspection-description { margin: 0 0 9px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.inspection-details { display: grid; grid-template-columns: 1fr max-content; gap: 5px 10px; padding: 9px 0 0; margin: 9px 0 0; border-top: 1px solid var(--line); font-size: 11px; }
.inspection-details dt { color: var(--muted); }
.inspection-details dd { margin: 0; text-align: right; }

.tile-hint { position: absolute; z-index: 4; width: max-content; max-width: min(260px, 90vw); padding: 5px 8px; font-size: 11px; color: #ffe0bc; background: #2a1c13ed; box-shadow: 0 2px 12px #17100680; border: 1px solid #b98e58b8; border-radius: 2px; pointer-events: none; }
.toast { position: absolute; z-index: 5; left: 50%; bottom: calc(var(--footer-height) + 235px); translate: -50% 0; display: flex; align-items: center; gap: 8px; width: max-content; max-width: min(550px, 90vw); padding: 9px 13px; color: var(--ivory); font-size: 12px; line-height: 1.5; pointer-events: none; }
.toast [data-icon] { width: 17px; height: 17px; flex: 0 0 17px; color: var(--gold-bright); }
.toast.is-error [data-icon] { color: #ecaa88; }
.toast:not([hidden]) { animation: toast-in 140ms ease-out; }
@keyframes toast-in { from { opacity: 0; translate: -50% 5px; } }

.dialog { width: min(405px, calc(100vw - 30px)); max-height: calc(100dvh - 32px); color: var(--ivory); padding: 17px; }
.dialog::backdrop { background: #15130d85; backdrop-filter: blur(3px); }
.dialog-heading { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); padding-bottom: 8px; margin-bottom: 8px; }
.dialog-heading h2 { flex: 1; font: 700 23px/1 var(--serif); margin: 0; letter-spacing: .08em; }
.dialog-mark { width: 22px; height: 22px; color: var(--gold); }
.dialog-main { color: var(--muted); margin: 12px 0; font-size: 13px; line-height: 1.65; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; color: var(--muted); font-size: 13px; border-bottom: 1px solid var(--line); }
.settings-row select { color: var(--ivory); background: #392f21; padding: 5px 12px; border: 1px solid var(--edge); border-radius: 2px; }
.dialog-buttons { display: flex; flex-wrap: wrap; justify-content: end; gap: 7px; margin-top: 15px; }
.text-button { padding: 7px 12px; border: 1px solid #9b795066; border-radius: 2px; color: var(--gold-bright); background: #60462737; font-size: 12px; }
.text-button:hover:not(:disabled) { background: #8b61265d; border-color: var(--gold); }
.text-button:disabled { opacity: .58; }
.text-button.is-danger { color: #f2b59a; border-color: #b57a5e79; background: #5b302540; }
.help-list { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px 12px; margin: 13px 0 4px; font-size: 12px; color: var(--muted); }
.help-list dd { margin: 0; text-align: right; }
.boot-error { position: absolute; z-index: 10; inset: 50% auto auto 50%; translate: -50% -50%; display: grid; justify-items: start; gap: 10px; max-width: calc(100vw - 30px); padding: 20px; color: var(--ivory); }
.boot-error button { color: var(--gold-bright); border-bottom: 1px solid; }

@media (min-width: 1300px) {
  :root { --deck-width: 800px; }
  .building-list, .building-card { min-height: 139px; }
  .card-art { min-height: 108px; }
  .card-meta { padding-inline: 8px; }
  .inspection, .toast { bottom: calc(var(--footer-height) + 249px); }
}

@media (max-width: 890px) {
  .brand { gap: 5px; }
  .brand-banner { width: 44px; height: 52px; }
  .brand h1 { font-size: 24px; }
  .brand p { font-size: 10px; }
  .resource { gap: 6px; width: 82px; padding: 1px 6px 1px 9px; }
  .resource-symbol { width: 22px; height: 22px; }
  .resource strong { font-size: 18px; }
  .top-right { gap: 6px; }
  .date-card { min-width: 0; padding-inline: 7px; gap: 5px; }
  #season-icon { width: 21px; height: 21px; }
  .circle-button { width: 39px; height: 39px; }
  .compass { width: 58px; height: 58px; }
  .construction { width: calc(100% - 105px); }
  .building-card { flex-basis: calc((100% - 35px) / 6); }
}

@media (max-width: 660px) {
  :root { --side: 10px; --footer-height: calc(39px + env(safe-area-inset-bottom)); }
  .hud-top { top: max(8px, env(safe-area-inset-top)); }
  .brand { margin-top: 0; }
  .brand-banner { width: 37px; height: 44px; }
  .brand h1 { font-size: 22px; margin-bottom: 3px; }
  .brand p { font-size: 9px; }
  .date-card { height: 39px; }
  .date-season { font-size: 11px; margin-bottom: 3px; }
  .date-card time { font-size: 9px; }
  #season-icon { width: 17px; height: 17px; }
  .circle-button { width: 35px; height: 35px; }
  .circle-button svg { width: 17px; height: 17px; }
  .resources { top: 50px; width: min(calc(100vw - 25px), 395px); min-height: 44px; padding: 3px 1px; }
  .resource { width: 25%; padding: 1px 3px 1px 8px; gap: 4px; }
  .resource-symbol { width: 19px; height: 19px; }
  .resource strong { font-size: 16px; }
  .resource-label { font-size: 9px; }
  .objectives { top: calc(max(8px, env(safe-area-inset-top)) + 104px); width: min(209px, 68vw); padding-inline: 9px; }
  .objectives-title { min-height: 39px; padding: 7px 0; gap: 7px; }
  .objectives .section-title { font-size: 14px; }
  .objective-symbol { width: 20px; height: 23px; }
  .objective-symbol svg { width: 13px; height: 13px; }
  .objectives.is-collapsed { width: 124px; }
  .camera { right: 8px; bottom: calc(var(--footer-height) + 179px); gap: 5px; }
  .compass { width: 45px; height: 45px; }
  .camera-stack { padding: 2px; }
  .camera-stack .icon-button { width: 29px; height: 29px; }
  .construction { bottom: calc(var(--footer-height) + 6px); width: calc(100% - 16px); }
  .construction-toolbar { height: 32px; }
  .build-heading { height: 32px; padding-inline: 7px; gap: 5px; }
  .build-heading-icon { width: 16px; height: 16px; }
  .build-heading .section-title { font-size: 14px; }
  .build-chevron { width: 10px; height: 10px; }
  .construction-actions { margin-bottom: 2px; }
  .construction-actions .icon-button { width: 28px; height: 23px; }
  .construction-body { padding: 0 5px 5px; }
  .categories { min-height: 30px; padding-inline: 0; gap: 2px; margin-bottom: 5px; }
  .category { min-height: 30px; padding-inline: 7px; gap: 3px; font-size: 10px; }
  .category [data-icon] { width: 12px; height: 12px; }
  .building-list, .building-card { min-height: 94px; }
  .building-list { gap: 5px; }
  .building-card { flex-basis: 86px; min-width: 86px; }
  .card-art { min-height: 68px; }
  .card-meta { height: 24px; padding-inline: 4px; }
  .card-name { font-size: 11px; }
  .card-price { font-size: 11px; }
  .card-price svg { width: 9px; height: 9px; }
  .inspection { bottom: calc(var(--footer-height) + 181px); width: min(210px, 73vw); max-height: min(38vh, 245px); overflow: auto; padding: 9px; }
  .toast { bottom: calc(var(--footer-height) + 177px); padding: 7px 8px; max-width: calc(100vw - 80px); }
  .status-bar { padding-bottom: env(safe-area-inset-bottom); }
  .gesture-hints, .status-rule { display: none; }
  .status-side { gap: 3px; }
}

@media (max-width: 350px) {
  .status-text { display: none; }
  .resource-symbol { width: 16px; height: 16px; }
  .category { padding-inline: 5px; }
  .category [data-icon] { width: 10px; height: 10px; }
}

@media (min-width: 661px) and (max-height: 665px) {
  .objectives { top: 78px; }
  .construction { bottom: calc(var(--footer-height) + 7px); }
  .building-list, .building-card { min-height: 94px; }
  .card-art { min-height: 68px; }
  .card-meta { height: 26px; }
  .inspection, .toast { bottom: calc(var(--footer-height) + 188px); }
  .inspection { max-height: 155px; overflow: auto; }
}

@media (max-width: 660px) and (max-height: 590px) {
  .camera { bottom: calc(var(--footer-height) + 128px); }
  .compass { width: 38px; height: 38px; }
  .camera-stack .icon-button { width: 25px; height: 25px; }
  .building-list, .building-card { min-height: 73px; }
  .card-art { min-height: 51px; }
  .card-meta { height: 22px; }
  .inspection, .toast { bottom: calc(var(--footer-height) + 154px); }
}

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

.build-action-tip { display: flex; align-items: center; align-self: end; gap: 6px; margin-bottom: 5px; color: var(--ivory); font-size: 11px; white-space: nowrap; }
.build-action-tip:empty { display: none; }
.build-action-tip > span, .cancel-build { padding: 4px 6px; background: #2b2117e6; border: 1px solid #ab8a548f; border-radius: 2px; box-shadow: 0 2px 8px #241b124a; }
.cancel-build { color: var(--gold-bright); }
.cancel-build:hover { border-color: var(--gold-bright); }
@media (max-width: 660px) {
  .build-action-tip { gap: 3px; margin-bottom: 3px; font-size: 10px; }
  .build-action-tip > span, .cancel-build { padding: 3px 4px; }
}

/* A compact, searchable library keeps the city visible while browsing. */
.catalog-controls { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); }
.catalog-controls .categories { flex: 1; min-width: 0; border: 0; margin: 0; }
.catalog-search input { width: 120px; padding: 6px 8px; color: #f1dfb9; background: #171710; border: 1px solid #8e724a; border-radius: 3px; font: inherit; }
.catalog-search input:focus { outline: 1px solid #e6bb72; }
.catalog-count { color: #c3ae88; font-size: 10px; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.building-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); align-items: stretch; max-height: min(29vh, 280px); overflow: auto; padding-top: 8px; }
.building-card { min-width: 0; min-height: 126px; }
.building-card[hidden] { display: none; }
@media (max-width: 600px) {
  .catalog-controls { flex-wrap: wrap; gap: 2px 6px; }
  .catalog-controls .categories { flex-basis: 100%; }
  .catalog-search { flex: 1; }
  .catalog-search input { width: 100%; padding: 4px 7px; }
  .building-list { grid-template-columns: repeat(auto-fill, minmax(85px, 1fr)); max-height: 22vh; }
  .building-card { min-height: 94px; }
}
.trade-panel { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 9px; }
.trade-title { margin: 0 0 7px; color: var(--gold-bright); font-size: 12px; }
.trade-select { width: 100%; padding: 6px; color: #f1dfb9; background: #211d16; border: 1px solid #8e724a; }
.trade-actions { display: flex; gap: 6px; margin-top: 7px; }
.trade-actions button { flex: 1; }
.trade-reason { color: #d5bfa0; font-size: 11px; }
/* Keep the route back to roads visible while the other categories scroll. */
.categories .category:first-child { position: sticky; left: 0; z-index: 2; background: #292319; box-shadow: 5px 0 8px #17140eb0; }
.clear-tool { display: flex; align-items: center; gap: 4px; padding: 0 9px; color: #e6c79b; font-size: 12px; border-left: 1px solid var(--line); }
.clear-tool [data-icon] { width: 15px; height: 15px; }
.clear-tool.is-active { color: #ffd2b4; background: #754132; }
.clear-card { align-items: center; justify-content: center; gap: 5px; padding: 8px; text-align: center; color: #e7d2b2; background: #30241c; }
.clear-card-symbol { font: 32px/1 var(--serif); color: #d7a97f; }
.clear-card-title { font-weight: 700; }
.clear-card-description { font-size: 10px; color: #c1ad90; }
@media (max-width: 600px) { .clear-tool { min-height: 28px; padding: 0 7px; } }
.clear-tool { white-space: nowrap; flex-shrink: 0; }
