:root {
  --town-ink:#173d34; --town-green:#145949; --town-paper:#fbf3de; --town-line:#e3d4b7;
  --town-surface:#fffdf5; --town-muted:#4d5b48; --town-gold:#f8d37b; --town-orange:#b3482f;
}
body:has(.town-shell) {background:#f5e9cf}
.town-shell {color:var(--town-ink); min-height:100dvh}
.town-shell .panel,.town-shell .card,.town-shell .item {
  background:var(--town-surface);border-color:var(--town-line);color:var(--town-ink)
}
.town-shell .btn {color:var(--town-ink);border-color:#bdcbb7}
.town-shell .btn.quiet {background:#e9efdf;color:#1d4d3d;border-color:#cfdbc8}
.town-shell .btn.primary {background:var(--town-green);color:#fff9e9;border-color:var(--town-green)}
.town-shell :is(small,.muted) {color:var(--town-muted)}
.town-top {display:flex;flex-wrap:wrap;justify-content:space-between;align-items:center;gap:12px;
  padding:12px max(20px,calc((100vw - 1450px)/2));min-height:64px;background:#fff8e6;border-bottom:1px solid #e3d3a9}
.town-top-brand,.town-top-values {display:flex;flex-wrap:wrap;align-items:center;gap:10px}
.town-top-brand strong {font-size:1.13rem}
.town-crest {display:grid;place-items:center;width:39px;height:39px;background:var(--town-green);color:#ffe3a5;
  border-radius:12px;font-size:1.45rem;border:2px solid #3f8268}
.town-top .btn {min-height:40px;padding:.35rem .7rem}
.town-xp {line-height:1.15;font-size:.84rem;font-weight:700;min-width:110px}
.town-xp progress {display:block;margin-top:5px;height:9px;accent-color:var(--town-green)}
.town-preferences {position:relative}
.town-preferences summary {cursor:pointer;font-weight:700;padding:8px 3px}
.town-preferences[open] .actions {position:absolute;right:0;top:42px;z-index:5;min-width:195px;
  display:grid;gap:5px;background:var(--town-surface);padding:10px;border:1px solid var(--town-line);border-radius:12px;box-shadow:0 10px 24px #63462230}
.town-content {max-width:1500px;width:100%;margin:0 auto;padding:25px 25px 42px}
.town-intro {margin:0 0 16px}
.town-intro h1,.district-guide h1 {font-family:Georgia,'Times New Roman',serif;font-size:clamp(2rem,5vw,3.55rem);margin-bottom:4px;
  color:#224637;letter-spacing:-.045em}
.town-intro p {color:var(--town-muted);margin:0}
.town-grid {display:grid;grid-template-columns:minmax(0,1fr) minmax(245px,310px);gap:16px;align-items:start}
.town-scene {display:grid;grid-template-columns:repeat(4,minmax(0,1fr));grid-template-rows:repeat(2,minmax(0,1fr));aspect-ratio:3/2;
  background:#b9c58e url('/town-map.webp') center/cover no-repeat;isolation:isolate;border:3px solid #fff3d3;outline:1px solid #cab78d;
  overflow:hidden;border-radius:21px;box-shadow:0 13px 30px #61491c21}
.town-pin {display:flex;align-items:end;justify-content:center;position:relative;border:2px solid transparent;min-width:0;
  width:100%;height:100%;background:transparent;padding:5px 6px 25%;color:#fffbee;transition:background-color .18s,border-color .18s}
.town-pin:nth-child(n+5) {padding-bottom:20%}
.town-pin:hover,.town-pin:focus-visible {background:#fff7cc3b;border-color:#ffde89;outline-offset:-5px;z-index:1}
.town-pin-label {display:flex;align-items:center;justify-content:center;gap:.42rem;background:#173d35eF;color:#fff7df;border:1px solid #f7d68a;
  min-height:35px;max-width:100%;padding:5px 10px;border-radius:8px;box-shadow:0 4px 0 #1c2e27a6;
  font-size:clamp(.81rem,1.16vw,1.1rem);font-weight:800;line-height:1.14;text-align:center}
.town-pin-label i {width:8px;height:8px;flex:none;background:#ffcc59;border-radius:50%;animation:town-signal 2.5s ease-in-out infinite}
.town-pin-label b {color:#b8f2ba}
@keyframes town-signal {50% {box-shadow:0 0 0 4px #ffcc5950}}
.town-quests {border:1px solid var(--town-line);border-radius:20px;background:#fff9eb;padding:18px;box-shadow:0 6px 20px #61491c10}
.town-quests h2 {margin:0 0 15px}
.town-quests article {display:grid;grid-template-columns:50px 1fr;gap:10px;padding:14px 0;border-top:1px solid var(--town-line);align-items:start}
.town-quests h3,.town-quests p {margin:0 0 6px;overflow-wrap:anywhere}
.town-quests .btn {font-size:.86rem;padding:4px 8px;min-height:37px}
.portrait {display:block;aspect-ratio:1;background:url('/town-guides.webp') no-repeat;background-size:400% 200%;
  image-rendering:auto;border-radius:50%;outline:1px solid #b59a67}
.portrait-school {background-position:0 0}
.portrait-life {background-position:33.333% 0}
.portrait-finance {background-position:66.667% 0}
.portrait-books {background-position:100% 0}
.portrait-knowledge {background-position:0 100%}
.portrait-arcade {background-position:33.333% 100%}
.portrait-maker {background-position:66.667% 100%}
.portrait-hall {background-position:100% 100%}
.district-guide {display:flex;align-items:center;gap:22px;min-height:145px;
  margin:0 0 20px;background:#fff6e4;border:1px solid #e0cc9e;border-radius:19px;padding:18px 24px}
.district-guide .portrait {width:105px;flex:0 0 105px}
.district-guide p {margin:.15rem 0;color:var(--town-muted)}
.district-guide strong {color:var(--town-ink)}
.district-links {margin:0 0 18px}
.district-lessons {display:grid;grid-template-columns:repeat(auto-fit,minmax(min(250px,100%),1fr));gap:12px}
.town-card {background:#fbf0d8;border:1px solid var(--town-line);padding:16px;border-radius:15px;overflow-wrap:anywhere}
.town-card h3 {margin:.42rem 0 .3rem}
.town-card details {margin:.5rem 0 .75rem}
.bank-chapter {display:flex;align-items:center;justify-content:space-between;gap:20px;background:#faf0cb;border-radius:19px;
  padding:20px 26px;margin:0 0 20px;border:1px solid #d8b66c}
.bank-chapter ol {padding-left:22px;margin:.6rem 0 1rem}
.step-done {color:#16604c;font-weight:740}
.bank-medal {flex:none;display:grid;place-items:center;border-radius:50%;width:108px;height:108px;
  background:#ffd579;border:8px double #ad7831;color:#64412f;font-size:3.6rem;font-weight:800;box-shadow:0 7px 0 #d9b46b}
.town-collection {display:flex;gap:14px;flex-wrap:wrap}
.town-collection article {background:#fbf0d8;padding:10px 12px;border-radius:10px}
.town-collection span {font-size:1.5rem}
.town-lesson-intro {color:var(--town-muted);font-size:1.1rem}
.town-video {max-width:720px;margin:0 0 14px}
.town-video video {display:block;width:100%;aspect-ratio:16/9;border-radius:14px;background:#183633}
.town-video figcaption {font-size:.86rem;color:var(--town-muted);padding-top:.3rem}
.lesson-diagram {display:flex;flex-wrap:wrap;margin:12px 0 18px;gap:8px;padding:0;list-style:none}
.lesson-diagram li {padding:.55rem .72rem;background:#deead3;border:1px solid #b8caaa;border-radius:10px;font-weight:700}
.town-safety {background:#fff1cd;border-left:4px solid #b78832;border-radius:5px;padding:8px 12px}
.town-earned {color:#176451;font-weight:750}
.solution-card {padding:12px 15px;margin:10px 0;background:#f4efcf;color:#293b30;border:1px solid #d1c88c;border-radius:13px}
.solution-card :is(ol,p) {margin:.4rem 0 .55rem}
.solution-card summary {cursor:pointer;font-weight:700}
.town-shell .guide-card {margin-top:15px}
:root[data-theme=dark] body:has(.town-shell) {background:#1f2b29}
:root[data-theme=dark] .town-shell {--town-ink:#f7eacb;--town-surface:#263a32;--town-muted:#dad5b7;--town-line:#50604f}
:root[data-theme=dark] :is(.town-top,.town-quests,.district-guide,.town-card,.town-collection article,.bank-chapter) {background:#2c4037;border-color:#50604f}
:root[data-theme=dark] :is(.town-intro h1,.district-guide h1) {color:#ffe7af}
:root[data-theme=dark] .town-shell .btn:not(.primary,.quiet) {background:#283a34;color:#fff3d4;border-color:#92a89a}
:root[data-theme=dark] .town-shell .btn.quiet {background:#385449;color:#f0edd5;border-color:#668076}
:root[data-theme=dark] :is(.lesson-diagram li,.town-safety) {color:#183630}
:root[data-theme=dark] .step-done,:root[data-theme=dark] .town-earned {color:#b8ead0}
.town-shell :is(.solution-card,.arcade-ticket,.arcade-entry,.wardrobe-stage) :is(small,.muted) {color:inherit}
@media(max-width:980px){
  .town-grid {grid-template-columns:minmax(0,1fr)}
  .town-quests {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}
  .town-quests h2 {grid-column:1/-1;margin:0}
}
@media(max-width:620px){
  .town-top {padding:8px 12px;gap:8px}
  .town-top-values {gap:5px 8px}
  .town-top .btn {min-height:38px;padding:.22rem .5rem;font-size:.83rem}
  .town-preferences[open] .actions {left:auto;right:0}
  .town-content {padding:15px 12px 30px}
  .town-scene {aspect-ratio:auto;grid-template-columns:repeat(2,minmax(0,1fr));grid-template-rows:none;gap:3px;
    background:#e3cc98;border-radius:16px}
  .town-pin,.town-pin:nth-child(n+5) {min-height:125px;aspect-ratio:1.24;align-items:end;padding:3px;
    background-image:url('/town-map.webp');background-size:400% 200%;border-radius:6px}
  .town-pin:nth-child(4n+1) {background-position-x:0}
  .town-pin:nth-child(4n+2) {background-position-x:33.333%}
  .town-pin:nth-child(4n+3) {background-position-x:66.667%}
  .town-pin:nth-child(4n+4) {background-position-x:100%}
  .town-pin:nth-child(n+5) {background-position-y:100%}
  .town-pin-label {font-size:.8rem;min-height:31px;padding:3px 6px}
  .town-quests {display:block;padding:13px}
  .town-quests h2 {margin:0 0 8px}
  .district-guide {padding:13px;gap:12px}
  .district-guide .portrait {width:62px;flex-basis:62px}
  .district-guide h1 {font-size:1.8rem}
  .bank-chapter {padding:14px}
  .bank-medal {width:49px;height:49px;border-width:4px;font-size:1.55rem;align-self:flex-start}
  .district-links > .btn {min-height:44px}
}
@media(prefers-reduced-motion:reduce) {.town-pin,.town-pin-label i {transition:none;animation:none}}
:root[data-reduced=true] .town-pin,:root[data-reduced=true] .town-pin-label i {transition:none;animation:none}

