/* Each SVG and its background share native image coordinates. Keep the whole
   image visible: cropping would disconnect buildings from their links. */
.home-town {
  --town-native-width: 1672px;
  --town-ratio: 1672 / 941;
  --town-fit-height: 177.6833156dvh;
  --town-landscape: url('/assets/img/town/landscape-light.png');
  --town-portrait: url('/assets/img/town/portrait-light.png');
}
:root[data-theme="dark"] .home-town {
  --town-landscape: url('/assets/img/town/landscape-dark.png');
  --town-portrait: url('/assets/img/town/portrait-dark.png');
}
@media(prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) .home-town {
    --town-landscape: url('/assets/img/town/landscape-dark.png');
    --town-portrait: url('/assets/img/town/portrait-dark.png');
  }
}
.page-home .home-hero { padding-bottom: 24px; }
.home-town { margin-block-start: clamp(10px, .75vw, 16px); padding-block: 0; border: 0; background: var(--bg); }
/* Above the scroll-expanded map; in fullscreen the same banner is moved into
   the viewer so it remains visible and is not made inert by the dialog. */
.page-home .measure-banner { z-index: 120; max-height: calc(100dvh - 40px); overflow-y: auto; overscroll-behavior: contain; }
.page-home .home-town ~ .home-gold { padding-top: 32px; }
.town-viewer { position: relative; isolation: isolate; }
.town-fullscreen { position: absolute; z-index: 2; top: max(14px,env(safe-area-inset-top)); right: max(14px,env(safe-area-inset-right)); display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 14px; border: 1px solid #78e8f0a6; border-radius: 10px; background: #031c30ed; color: #f1feff; box-shadow: 0 4px 18px #00132055; font: inherit; font-size: .85rem; font-weight: 600; line-height: 1.3; cursor: pointer; }
.town-fullscreen:hover { background: #07394c; border-color: #8cffff; }
.town-fullscreen:focus-visible { outline: 3px solid #00e3ee; outline-offset: 3px; }
.town-fullscreen[hidden] { display: none; }
.town-fullscreen svg { width: 18px; height: 18px; flex: none; }
.town-fullscreen-exit,.town-fullscreen[aria-pressed="true"] .town-fullscreen-enter { display: none; }
.town-fullscreen[aria-pressed="true"] .town-fullscreen-exit { display: block; }
.town-card { margin: 0; border: 1px solid var(--border-strong); border-radius: 20px; overflow: hidden; background: var(--surface); box-shadow: 0 18px 54px -32px #001b3655; }
.town-viewport { overflow: auto; overscroll-behavior-x: contain; scrollbar-color: #159eae #092637; scrollbar-width: thin; }
.town-viewport:focus-visible { outline: 3px solid var(--primary); outline-offset: -4px; }
.town-stage { position: relative; width: 100%; aspect-ratio: var(--town-ratio); background: #092637; }
.town-map { position: absolute; inset: 0; width: 100%; height: 100%; background-size: 100% 100%; background-repeat: no-repeat; }
.town-map-landscape { background-image: var(--town-landscape); }
.town-map-portrait { display: none; background-image: var(--town-portrait); }
.town-spot { cursor: pointer; outline: none; }
.town-area,.town-label { pointer-events: fill; stroke-linejoin: round; stroke-linecap: round; }
.town-area { fill: #00e3ee; fill-opacity: 0; stroke: #b9ffff; stroke-width: 2; stroke-opacity: 0; vector-effect: non-scaling-stroke; transition: fill-opacity .16s,stroke-opacity .16s; }
.town-label { fill: #04283bed; stroke: #9aebf4; stroke-width: 1; stroke-opacity: .75; vector-effect: non-scaling-stroke; transition: fill .16s,stroke-opacity .16s; }
.town-badge { filter: drop-shadow(0 3px 5px #00182570); transform-box: fill-box; transform-origin: center; transform: scale(.8); transition: transform .18s ease; }
.town-badge[data-town-align="bottom"] { transform-origin: center bottom; }
.town-badge[data-town-align="top"] { transform-origin: center top; }
.town-highlight .town-badge,.town-spot:hover .town-badge,.town-spot:focus-visible .town-badge { transform: scale(1); }
.town-leaders { pointer-events: none; fill: none; stroke: #e8fcff; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 1px 2px #001825); }
.town-leaders circle { fill: #e8fcff; stroke: none; }
.town-label-title,.town-label-subtitle { fill: #f2fcff; font-family: var(--font-sans); pointer-events: none; }
.town-label-title { font-size: 17px; font-weight: 600; }
.town-label-subtitle { font-size: 11.5px; font-weight: 400; fill: #cee4ef; }
.town-summary-subtitle { font-size: 10.5px; }
.town-symbol { fill: none; stroke: #63e8f6; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.town-badge-leaf .town-symbol { stroke: #a7ed8d; }
.town-badge-coins .town-symbol { stroke: #ffe183; }
.town-badge-cross .town-symbol { stroke: #ff8e94; }
.town-spot:hover .town-area,.town-spot:focus-visible .town-area,.town-highlight .town-area { fill-opacity: .18; stroke-opacity: .95; }
.town-spot:hover .town-label,.town-spot:focus-visible .town-label,.town-highlight .town-label { fill: #07516a; stroke: #d7ffff; stroke-opacity: 1; stroke-width: 2; }
.town-feedback { display: flex; align-items: center; gap: 16px; padding: 18px 22px; border-top: 1px solid var(--border); }
.town-feedback-icon { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border: 1px solid var(--border-strong); border-radius: 12px; color: var(--primary); background: var(--primary-soft); }
.town-feedback-icon svg { width: 21px; height: 21px; }
.town-feedback-copy { min-width: 0; flex: 1; }
.town-feedback strong { display: block; font-size: .95rem; }
.town-feedback p { margin: 3px 0 0; color: var(--text-2); font-size: .82rem; }
.town-active .town-feedback strong { color: var(--primary); }
.town-scroll-hint { display: none; }
/* The scroll track grows only as it is used. Disable browser anchoring on this
   page so resizing the track cannot counteract the user's scroll movement. */
body.town-scroll-page { overflow-x: clip; overflow-anchor: none; }
.home-town.town-scroll-measuring { height: var(--town-scroll-height,auto); }
body.town-scroll-page .home-hero { position: sticky; top: var(--town-hero-top,0px); z-index: 1; }
/* Keep the map above the pinned hero, below the sticky navigation and menus. */
.home-town.town-scroll-enabled { position: relative; z-index: 2; height: var(--town-scroll-height); padding: 0; border: 0; background: transparent; pointer-events: none; }
.town-scroll-enabled .town-container { position: sticky; top: var(--town-sticky-top,0px); display: flex; align-items: flex-start; justify-content: center; width: 100%; max-width: none; height: var(--town-card-height); padding: 0; }
.town-scroll-enabled .town-card { position: relative; flex: none; width: var(--town-card-width); height: var(--town-card-height); border-width: 0; border-radius: var(--town-radius); pointer-events: auto; }
.town-scroll-enabled .town-card > .town-viewer:not(:fullscreen) { height: calc(100% - var(--town-caption-height)); background: #021521; }
.town-scroll-enabled .town-card > .town-viewer:not(:fullscreen) .town-viewport { display: grid; grid-template: minmax(0,1fr) / minmax(0,1fr); place-items: center; width: 100%; height: 100%; overflow: hidden; }
/* Scale the image and SVG as one layer. Keeping their layout size fixed avoids
   recalculating every clickable path on every scroll-animation frame. */
.town-scroll-enabled .town-card > .town-viewer:not(:fullscreen) .town-stage { width: var(--town-native-width); min-width: 0; max-width: none; transform: scale(var(--town-image-scale,1)); transform-origin: center; will-change: transform; }
.town-scroll-enabled .town-feedback { position: absolute; inset: auto 0 0; opacity: var(--town-caption-opacity); pointer-events: none; }
@media(max-width: 640px) {
  .page-home .measure-banner { max-height: calc(100dvh - 24px); }
  .town-card { border-radius: 14px; }
  .town-fullscreen { top: max(10px,env(safe-area-inset-top)); right: max(10px,env(safe-area-inset-right)); padding-inline: 12px; font-size: .8rem; }
  .town-feedback { padding: 14px; gap: 10px; }
  .town-feedback-icon { width: 32px; height: 32px; border-radius: 9px; }
  .town-feedback strong { font-size: .88rem; }
  .town-scroll-hint { display: block; margin: 10px 0 0; color: var(--text-2); font-size: .78rem; }
}
/* Fullscreen fits the entire image and SVG together. The dialog provides the
   same view when the browser cannot enter native Fullscreen. */
.town-viewer:fullscreen,.town-fullscreen-dialog .town-viewer { width: 100%; height: 100%; background: #021521; }
.town-viewer:fullscreen .town-viewport,.town-fullscreen-dialog .town-viewport { display: grid; place-items: center; width: 100%; height: 100%; overflow: hidden; }
.town-viewer:fullscreen .town-stage,.town-fullscreen-dialog .town-stage { width: min(100vw,var(--town-fit-height)); min-width: 0; max-width: 100%; flex: none; }
.town-fullscreen-dialog { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: #021521; color: #f1feff; overflow: hidden; }
.town-fullscreen-dialog::backdrop { background: #021521; }
html.town-fullscreen-open { overflow: hidden; }
@media(orientation: portrait) {
  .home-town { --town-native-width: 941px; --town-ratio: 941 / 1672; --town-fit-height: 56.2799043dvh; }
  .town-map-landscape { display: none; }
  .town-map-portrait { display: block; }
  .town-label-title { font-size: 22px; }
  .town-label-subtitle { font-size: 15px; }
  .town-summary-subtitle { font-size: 13px; }
}
@media(prefers-reduced-motion: reduce) {
  .town-area,.town-label,.town-badge,.town-leader { transition: none; }
}
@media(forced-colors: active) {
  .town-spot:focus .town-area,.town-spot:hover .town-area { stroke: Highlight; }
}
