/* Kinstead — late-90s desktop UI (beveled grey windows, navy title bars, pixel type) */
:root {
  --face: #c3c3c3;
  --face-2: #d6d3cc;
  --hi: #ffffff;
  --lo: #808080;
  --dk: #0a0a0a;
  --ink: #000000;
  --ink-2: #3c3c3c;
  --navy: #000080;
  --navy-2: #1084d0;
  --good: #006b00;
  --bad: #a00000;
  --tip: #ffffe1;
  --font: 'Pixelify Sans', 'MS Sans Serif', Tahoma, sans-serif;
  --small: 'Silkscreen', 'Pixelify Sans', monospace;
  --raised: inset -1px -1px var(--dk), inset 1px 1px var(--hi), inset -2px -2px var(--lo), inset 2px 2px #dfdfdf;
  --sunken: inset -1px -1px var(--hi), inset 1px 1px var(--lo), inset -2px -2px #dfdfdf, inset 2px 2px var(--dk);
  --field: inset -1px -1px var(--hi), inset 1px 1px var(--lo);
  --drop: 2px 2px 0 rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #6cb6ea; font-family: var(--font); font-size: 15px; color: var(--ink); -webkit-font-smoothing: none; }
button { font-family: inherit; color: inherit; font-size: inherit; }
.hidden { display: none !important; }

#sky { position: fixed; inset: 0; background: linear-gradient(#6cb6ea, #dff2fb); z-index: 0; }
#stars { position: fixed; inset: 0; z-index: 1; opacity: 0; pointer-events: none; }
#app { position: fixed; inset: 0; z-index: 2; }
#app canvas { display: block; outline: none; touch-action: none; }
body.pixel #app canvas { image-rendering: pixelated; }
#vignette { display: none; }

.ms {
  font-family: 'Material Symbols Sharp';
  font-weight: normal; font-style: normal; line-height: 1; letter-spacing: normal; text-transform: none;
  display: inline-block; white-space: nowrap; direction: ltr; vertical-align: -0.22em; font-size: 1.2em;
  -webkit-font-feature-settings: 'liga'; font-feature-settings: 'liga';
  font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 20;
}
.ms.coinico { color: #8a6400; }

#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
#hud > * { pointer-events: auto; }

.panel { background: var(--face); box-shadow: var(--raised), var(--drop); border-radius: 0; }

/* ------------------------------------------------------------- top bar */
.topbar { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; gap: 6px; align-items: stretch; pointer-events: none; flex-wrap: wrap; }
.topbar > .panel { pointer-events: auto; padding: 6px 10px; display: flex; align-items: center; gap: 10px; }
.town { flex-direction: column; align-items: flex-start !important; justify-content: center; gap: 1px !important; min-width: 150px; cursor: pointer; }
.town:hover .town-name { text-decoration: underline; }
.town-name { font-weight: 700; font-size: 18px; line-height: 1.05; color: var(--navy); }
.town-title { font-family: var(--small); font-size: 9px; color: var(--ink-2); letter-spacing: 0.04em; }
.clock #clockIcon { font-size: 18px; width: 22px; text-align: center; color: #9a6a00; }
.clock #clockTime { font-weight: 700; font-size: 18px; line-height: 1.05; font-variant-numeric: tabular-nums; }
.clock #clockDate { font-size: 12px; color: var(--ink-2); }
.clock #clockDate .ms { font-size: 1.05em; }
.speed { display: flex; gap: 2px; }
.speed button {
  border: 0; background: var(--face); box-shadow: var(--raised); min-width: 30px; height: 26px; padding: 0 5px; cursor: pointer;
  font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center;
}
.speed button .ms { font-size: 17px; vertical-align: 0; }
.speed button.on { box-shadow: var(--sunken); background: #b5b5b5; }

.stats { gap: 12px !important; }
.stat { display: grid; grid-template-columns: auto auto; grid-template-rows: auto auto; column-gap: 6px; align-items: center; }
.stat .ico { grid-row: 1 / 3; font-size: 20px; color: var(--ink-2); }
.stat b { font-weight: 700; font-size: 16px; line-height: 1.05; font-variant-numeric: tabular-nums; background: #fff; box-shadow: var(--field); padding: 1px 5px; }
.stat small { font-size: 11px; color: var(--ink-2); white-space: nowrap; margin-top: 1px; }
.stat small.pos { color: var(--good); }
.stat small.neg { color: var(--bad); }
.rci { display: flex; align-items: flex-end; gap: 3px; height: 38px; position: relative; padding-bottom: 12px; }
.rci .bar { width: 9px; height: 26px; background: #fff; box-shadow: var(--field); position: relative; overflow: hidden; }
.rci .bar i { position: absolute; left: 1px; right: 1px; bottom: 1px; height: 50%; transition: height 0.6s; }
.rci .r i { background: #00a000; } .rci .c i { background: #0050d0; } .rci .i i { background: #d0a000; }
.rci span { position: absolute; bottom: -1px; left: 0; font-family: var(--small); font-size: 8px; letter-spacing: 3px; color: var(--ink-2); }

.menu { margin-left: auto; gap: 2px !important; padding: 4px !important; }
.menu button, .zoom button {
  border: 0; background: var(--face); box-shadow: var(--raised); min-width: 32px; height: 30px; cursor: pointer;
  font-size: 13px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; padding: 0 6px;
}
.menu button .ms, .zoom button .ms { font-size: 20px; vertical-align: 0; }
.menu button:active, .zoom button:active, .speed button:active { box-shadow: var(--sunken); }
.menu button.on { box-shadow: var(--sunken); background: #b5b5b5; }

.zoom { position: absolute; right: 8px; bottom: 92px; display: flex; flex-direction: column; padding: 4px; gap: 2px; }

/* ------------------------------------------------------------- toolbar */
.toolbar { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); display: flex; gap: 2px; padding: 4px; max-width: calc(100vw - 16px); overflow-x: auto; scrollbar-width: thin; }
.toolbar > * { flex: none; }
.tool {
  position: relative; width: 56px; height: 56px; border: 0; background: var(--face); box-shadow: var(--raised); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.tool .e { font-size: 24px; line-height: 1; }
.tool .e .ms { font-size: 26px; vertical-align: 0; }
.tool .l { font-size: 11px; color: var(--ink); }
.tool .k { position: absolute; top: 2px; right: 4px; font-family: var(--small); font-size: 8px; color: var(--lo); }
.tool:active { box-shadow: var(--sunken); }
.tool.on { box-shadow: var(--sunken); background: #b0b0b0; }
.tool.on .e { transform: translate(1px, 1px); }
.toolbar .sep { width: 2px; margin: 4px 3px; box-shadow: inset 1px 0 var(--lo), inset -1px 0 var(--hi); }

.flyout { position: absolute; left: 50%; bottom: 80px; transform: translateX(-50%); padding: 6px; display: flex; gap: 4px; max-width: calc(100vw - 16px); overflow-x: auto; }
.card {
  flex: 0 0 auto; width: 112px; background: var(--face); box-shadow: var(--raised); padding: 6px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center;
}
.card:hover { background: #cfcfcf; }
.card.on { box-shadow: var(--sunken); background: #b0b0b0; }
.card img, .card .ph { width: 96px; height: 72px; background: #9fb383; box-shadow: var(--field); object-fit: cover; image-rendering: pixelated; display: flex; align-items: center; justify-content: center; font-size: 34px; }
.card .ph .ms { font-size: 40px; vertical-align: 0; color: #2e3a1e; }
.card .n { font-size: 12px; font-weight: 600; line-height: 1.1; margin-top: 2px; }
.card .c { font-size: 11px; color: var(--ink-2); }
.card.locked { opacity: 0.65; }
.card.locked img { filter: grayscale(1); }
.card .lock { font-size: 10px; color: var(--bad); }

.hint {
  position: absolute; left: 50%; bottom: 80px; transform: translateX(-50%); background: var(--tip); color: #000; padding: 3px 8px;
  border: 1px solid #000; font-size: 13px; white-space: nowrap; pointer-events: none;
}
.flyout:not(.hidden) ~ .hint { bottom: 214px; }
/* the kind of planting or monument to build, above the build menu */
.kindbar { position: absolute; left: 50%; bottom: 214px; transform: translateX(-50%); padding: 4px; display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; width: max-content; max-width: min(760px, calc(100vw - 16px)); }
.kindbar .kb-label { font-size: 12px; font-weight: 700; align-self: center; margin: 0 4px; }
.kindbar .btn .ms, .kinds .btn .ms { font-size: 14px; vertical-align: -2px; }

/* ------------------------------------------------------------ inspector */
.inspector { position: absolute; right: 8px; top: 96px; width: 300px; max-height: calc(100vh - 200px); max-height: calc(100dvh - 200px); overflow-y: auto; padding: 0 10px 10px; }
.inspector::before {
  content: 'Properties'; display: block; margin: 0 -10px 8px; padding: 4px 8px; font-weight: 700; font-size: 13px; color: #fff;
  background: linear-gradient(90deg, var(--navy), var(--navy-2)); position: sticky; top: 0; z-index: 1;
}
.inspector .close, .modal-card .x {
  position: absolute; width: 18px; height: 16px; border: 0; background: var(--face); box-shadow: var(--raised); cursor: pointer;
  font-size: 11px; line-height: 16px; padding: 0; z-index: 2; font-family: var(--font); font-weight: 700;
}
.inspector .close { top: 4px; right: 6px; position: sticky; float: right; margin-top: -26px; margin-right: -4px; }
.inspector .head { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.inspector .head img { width: 64px; height: 48px; background: #9fb383; box-shadow: var(--field); object-fit: cover; image-rendering: pixelated; }
.inspector .head .big { font-size: 32px; width: 48px; text-align: center; }
.inspector .head .big .ms { font-size: 36px; }
.inspector .head .pm-open { margin-left: 6px; vertical-align: middle; min-height: 20px; padding: 1px 6px; }
.inspector .head .pm-open .ms { font-size: 14px; vertical-align: -2px; }
.inspector h3 { margin: 0; font-weight: 700; font-size: 17px; line-height: 1.1; }
.inspector .sub { font-size: 12px; color: var(--ink-2); }
.stars { color: #9a6a00; letter-spacing: 1px; }
.sec { margin-top: 8px; }
.row { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; padding: 3px 0; border-bottom: 1px solid #a8a8a8; box-shadow: 0 1px 0 #e8e8e8; }
.row:last-child { border-bottom: 0; box-shadow: none; }
.row span:first-child { color: var(--ink-2); }
.row b { font-weight: 600; text-align: right; }
.sec h5 { margin: 0 0 4px; font-family: var(--small); font-size: 9px; font-weight: 400; color: var(--ink-2); }
.chips { display: flex; flex-wrap: wrap; gap: 3px; }
.chip { font-size: 12px; padding: 1px 6px; background: var(--face); box-shadow: var(--raised); }
.chip.ok { color: var(--good); }
.chip.no { color: var(--bad); }
.chip.link { cursor: pointer; text-decoration: underline; color: var(--navy); }
.chip .ms { font-size: 1.05em; }
.meter { height: 12px; background: #fff; box-shadow: var(--field); padding: 2px; margin-top: 4px; }
.meter i { display: block; height: 100%; background: repeating-linear-gradient(90deg, var(--navy) 0 8px, transparent 8px 10px); }
.actions { display: flex; gap: 4px; margin-top: 10px; flex-wrap: wrap; }
.btn {
  border: 0; background: var(--face); box-shadow: var(--raised); padding: 5px 12px; font-size: 13px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px; min-height: 26px;
}
.btn:active { box-shadow: var(--sunken); }
.btn:focus-visible { outline: 1px dotted #000; outline-offset: -4px; }
.btn.primary { font-weight: 700; box-shadow: 0 0 0 1px #000, var(--raised); }
.btn.gold { color: #6a4a00; font-weight: 700; }
.btn.danger { color: var(--bad); }
.btn:disabled { color: var(--lo); text-shadow: 1px 1px #fff; cursor: not-allowed; }
.btn.small { padding: 2px 7px; font-size: 12px; min-height: 22px; }
.req { font-size: 12px; margin-top: 6px; display: grid; gap: 2px; }
.req .ok::before { content: '✓ '; color: var(--good); font-weight: 700; }
.req .no::before { content: '✗ '; color: var(--bad); font-weight: 700; }
.req .no { color: var(--ink-2); }
.req .no.warn::before { content: '! '; color: #8a5a00; }
/* building panel: what it needs to work and what it lacks */
.sec.working { padding: 4px 6px 6px; background: #f3efe2; box-shadow: var(--field); }
.sec.working.stop { background: #f7dcd4; }
.sec.working.part { background: #f7ecc8; }
.sec.working h5 .ms { font-size: 14px; vertical-align: -2px; }
.sec.working.stop h5 { color: var(--bad); }
.needs-note { font-size: 12px; margin-top: 6px; color: #5a4300; }
.needs-note .ms { font-size: 14px; vertical-align: -2px; }

/* -------------------------------------------------------------- toasts */
#toasts { position: absolute; left: 8px; top: 104px; display: flex; flex-direction: column; gap: 4px; pointer-events: none; max-width: 340px; }
.toast { background: var(--tip); border: 1px solid #000; padding: 4px 8px; font-size: 13px; display: flex; gap: 6px; align-items: center; box-shadow: var(--drop); animation: toastIn 0.15s steps(3); pointer-events: auto; }
.toast.bad { color: var(--bad); }
.toast.good { color: #003c00; }
.toast.big { font-size: 15px; font-weight: 700; background: var(--face); box-shadow: var(--raised), var(--drop); border: 0; padding: 8px 10px; }
.toast.out { animation: toastOut 0.2s steps(3) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(-12px); } }
@keyframes toastOut { to { opacity: 0; } }

#popups { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.coin { position: absolute; font-weight: 700; font-size: 13px; color: #ffe066; text-shadow: 1px 1px 0 #000, -1px 0 0 #000, 0 -1px 0 #000; animation: coinUp 1.3s steps(12) forwards; white-space: nowrap; transform: translate(-50%, -50%); }
.coin .ms { color: #ffe066; }
@keyframes coinUp { 0% { opacity: 1; margin-top: 4px; } 100% { opacity: 0; margin-top: -30px; } }
.label3d { position: absolute; transform: translate(-50%, -100%); background: var(--tip); color: #000; border: 1px solid #000; padding: 1px 6px; font-size: 12px; white-space: nowrap; pointer-events: none; }
/* warning badges over buildings with no power, water, workers or road */
.blocked { position: absolute; transform: translate(-50%, -100%); display: flex; gap: 2px; pointer-events: none; }
.blocked .bi { width: 19px; height: 19px; display: flex; align-items: center; justify-content: center; background: #ffe7a0; color: #6a4a00; border: 1px solid #000; box-shadow: var(--drop); }
.blocked .bi.stop { background: #ffc8bc; color: var(--bad); }
.blocked .bi.prio { background: #fff3c4; color: #8a5a00; }
.blocked .ms { font-size: 14px; }

.tooltip { position: fixed; z-index: 30; pointer-events: none; background: var(--tip); color: #000; border: 1px solid #000; padding: 3px 7px; font-size: 12px; max-width: 260px; box-shadow: var(--drop); }
.tooltip .bad { color: var(--bad); }
.tooltip .good { color: var(--good); }

/* -------------------------------------------------------------- overlay */
.overlay-menu { position: absolute; right: 8px; top: 96px; padding: 3px; display: grid; gap: 0; min-width: 190px; max-height: calc(100dvh - 104px); overflow-y: auto; }
.overlay-menu button { border: 0; background: transparent; text-align: left; padding: 4px 10px; font-size: 13px; cursor: pointer; }
.overlay-menu button .ms { margin-right: 6px; }
.overlay-menu button:hover, .overlay-menu button.on { background: var(--navy); color: #fff; }
.legend { position: absolute; left: 50%; top: 96px; transform: translateX(-50%); padding: 4px 8px; font-size: 13px; display: flex; gap: 8px; align-items: center; }
.legend .grad { width: 110px; height: 10px; box-shadow: var(--field); }

/* --------------------------------------------------------------- modals */
#windows { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
#windows > .win { position: absolute; pointer-events: auto; box-shadow: var(--raised), 3px 3px 0 rgba(0, 0, 0, 0.25); }
.modal-card { width: min(680px, calc(100vw - 16px)); max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); overflow-y: auto; padding: 0 14px 14px; position: relative; }
.modal-card h2 {
  margin: 0 -14px 10px; padding: 5px 30px 5px 8px; font-size: 14px; font-weight: 700; color: #fff;
  background: linear-gradient(90deg, var(--navy), var(--navy-2));
}
.modal-card .x { top: 5px; right: 6px; }
.modal-card .lead { margin: 0 0 10px; color: var(--ink-2); font-size: 13px; }
.tabs { display: flex; gap: 0; margin: 6px 0 0; padding-left: 4px; }
.tabs button { border: 0; background: var(--face); box-shadow: var(--raised); padding: 5px 12px; font-size: 13px; cursor: pointer; position: relative; top: 2px; }
.tabs button.on { top: 0; padding-bottom: 7px; font-weight: 700; z-index: 1; }
#saveBody { box-shadow: var(--raised); padding: 10px; margin-bottom: 4px; }
.saves { display: grid; gap: 4px; }
.save { display: grid; grid-template-columns: 112px 1fr auto; gap: 10px; align-items: center; padding: 6px; background: #fff; box-shadow: var(--field); }
.save img, .save .ph { width: 112px; height: 63px; object-fit: cover; image-rendering: pixelated; background: #9fb383; display: flex; align-items: center; justify-content: center; font-size: 26px; }
.save .t { font-weight: 700; }
.save .m { font-size: 12px; color: var(--ink-2); }
.save .acts { display: flex; gap: 3px; flex-wrap: wrap; justify-content: flex-end; }
.field { display: grid; gap: 3px; margin: 8px 0; }
.field label { font-size: 13px; }
.field input:not([type=checkbox]):not([type=range]), .field select { font: inherit; font-size: 14px; padding: 4px 6px; border: 0; background: #fff; box-shadow: var(--sunken); color: #000; border-radius: 0; }
.field input[type=checkbox], .field input[type=range] { accent-color: var(--navy); }
.inline { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.note { font-size: 13px; color: #000; background: var(--tip); border: 1px solid #000; padding: 8px 10px; line-height: 1.4; }
.note code { background: #fff; padding: 0 4px; font-size: 12px; }
.empty { text-align: center; color: var(--ink-2); padding: 16px; font-size: 13px; }
table.budget { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; box-shadow: var(--field); }
table.budget td { padding: 3px 6px; border-bottom: 1px solid #e0e0e0; }
table.budget td:last-child { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
table.budget tr.tot td { border-bottom: 0; font-weight: 700; background: #e8e8e8; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.chart { width: 100%; height: 110px; display: block; background: #fff; box-shadow: var(--sunken); }
.kbd { display: inline-block; min-width: 22px; padding: 0 5px; background: var(--face); box-shadow: var(--raised); font-size: 11px; text-align: center; }
.help-grid { display: grid; grid-template-columns: auto 1fr; gap: 5px 10px; font-size: 13px; align-items: center; }
.lines-list { display: grid; gap: 4px; }
.line-item { display: grid; grid-template-columns: 14px 1fr auto; gap: 10px; align-items: center; padding: 6px 8px; background: #fff; box-shadow: var(--field); }
.line-item .dot { width: 14px; height: 14px; box-shadow: var(--field); }

/* --------------------------------------------------------- title screen */
.title-screen { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.title-card { pointer-events: auto; text-align: center; padding: 0 18px 14px; width: min(420px, calc(100vw - 32px)); max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); overflow-y: auto; }
.title-card .titlebar {
  margin: 0 -18px 16px; padding: 5px 8px; font-size: 14px; font-weight: 700; color: #fff; text-align: left;
  background: linear-gradient(90deg, var(--navy), var(--navy-2));
}
.logo { font-family: var(--font); font-weight: 700; font-size: 52px; line-height: 1; color: var(--navy); text-shadow: 3px 3px 0 #fff, 4px 4px 0 rgba(0, 0, 0, 0.25); }
.logo span { color: inherit; }
.tagline { margin: 8px 0 16px; color: var(--ink-2); font-size: 14px; }
.title-card .btn { width: 100%; justify-content: center; padding: 8px; font-size: 15px; margin-top: 6px; }
.title-foot { margin-top: 12px; font-size: 11px; color: var(--ink-2); }
.title-links { margin-top: 4px; font-size: 12px; color: var(--ink-2); }
.title-links a { color: var(--navy); }

@media (max-width: 900px) {
  .stats { gap: 8px !important; }
  .stat small { display: none; }
  .tool { width: 44px; height: 46px; }
  .tool .l { display: none; }
  /* along the bottom, wherever it was dragged to on a bigger screen (that comes back when the screen does) */
  .inspector { width: calc(100vw - 16px); left: 8px !important; right: auto !important; top: auto !important; bottom: 80px; max-height: 45vh !important; max-height: 45dvh !important; }
  .rci { display: none; }
}

/* construction progress */
.meter.build i { background: repeating-linear-gradient(135deg, #d8a630 0 6px, #2f2a24 6px 12px) !important; }
.actions.col { flex-direction: column; align-items: stretch; }
.inspector .note { font-size: 12px; line-height: 1.4; margin: 2px 0 6px; opacity: 0.85; }

/* style picker for upgrades */
.inspector .uprow { display: flex; gap: 6px; align-items: flex-start; margin: 2px 0 4px; }
.inspector .uprow .note { flex: 1; margin: 0; }
.inspector .preview { flex: none; width: 112px; height: 84px; image-rendering: auto; background: #9fb08a; box-shadow: var(--sunken); }
.inspector .styles { display: flex; flex-wrap: wrap; gap: 3px; align-items: center; margin: 4px 0 6px; clear: none; }
.inspector .styles > span { font-size: 12px; margin-right: 4px; }
.inspector .styles .style { font: inherit; font-size: 12px; padding: 2px 6px; background: var(--face); box-shadow: var(--raised); border: 0; cursor: pointer; color: inherit; }
.inspector .styles .style.on { box-shadow: var(--sunken); background: #e8e8e8; font-weight: bold; }

/* villager directory */
.modal-card.wide { width: min(980px, calc(100vw - 32px)); max-width: none; }
.pplbar { display: flex; gap: 8px; align-items: center; margin: 6px 0 8px; flex-wrap: wrap; }
.pplbar input { flex: 1; min-width: 180px; }
.pplbar #pplN { font-size: 12px; opacity: 0.8; }
.pplwrap { max-height: min(60vh, 560px); overflow: auto; background: #fff; box-shadow: var(--field); }
table.people { width: 100%; border-collapse: collapse; font-size: 13px; }
table.people th { position: sticky; top: 0; background: var(--face); box-shadow: var(--raised); text-align: left; padding: 4px 6px; cursor: pointer; white-space: nowrap; font-weight: 700; z-index: 1; }
table.people td { padding: 3px 6px; border-bottom: 1px solid #e4e4e4; white-space: nowrap; }
table.people td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.people td.traits { white-space: normal; font-size: 12px; color: #444; }
table.people td .ms { font-size: 15px; vertical-align: -3px; }
table.people tbody tr { cursor: pointer; }
table.people tbody tr:hover td { background: #ffffe1; }
table.people .bad, .inspector .neg { color: var(--brick, #a33); }
.inspector .chip i { font-style: normal; opacity: 0.65; font-size: 11px; margin-left: 2px; }
.inspector .muted { font-size: 12px; opacity: 0.7; }

/* ---------------------------------------------------------------------------
   Readability: running text uses the classic Windows UI faces (Tahoma /
   Verdana) at comfortable sizes; the pixel font stays for headings, title
   bars and the big numbers so the 90s look is unchanged. */
:root { --font: Tahoma, Verdana, 'Segoe UI', sans-serif; --display: 'Pixelify Sans', Tahoma, sans-serif; }
html, body { font-size: 14px; -webkit-font-smoothing: auto; }
.town-name, .clock #clockTime, .stat b, .logo, .modal-card h2, .inspector::before, .title-card .titlebar,
.inspector h3, .toast.big, .inspector .head .big { font-family: var(--display); }
.town-title { font-family: var(--font); font-size: 10px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.sec h5 { font-family: var(--font); font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-2); }
.sec h5 .sub { text-transform: none; letter-spacing: 0; font-weight: 400; }
.rci span { font-family: var(--font); font-size: 9px; font-weight: 700; }
.clock #clockDate, .stat small, .tool .l, .card .n, .card .c, .chip, .req, .inspector .sub, .save .m { font-size: 12px; }
.card .lock { font-size: 11px; }
.row, .tooltip, .label3d, .toast, .modal-card .lead, .help-grid, .field label, .overlay-menu button { font-size: 13px; }
.btn { font-size: 13px; }
.kbd { font-size: 12px; }
.title-foot { font-size: 12px; }
.inspector .note { font-size: 12px; opacity: 1; }

.checkrow { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 3px; }
.menu button.on { box-shadow: var(--sunken); background: #e0e0e0; }

/* Spacing for the wider UI font: nothing clips, icons sit on the text line. */
.ms { line-height: 1; }
.tool { width: auto; min-width: 60px; padding: 5px 7px 4px; }
.tool .l { font-size: 11px; line-height: 1.1; white-space: nowrap; }
.tool .k { top: 1px; right: 3px; font-size: 7px; }
.menu button { min-width: 34px; }
.speed button { min-width: 32px; }
.stat b { min-width: 2.2em; }
.chip { display: inline-flex; align-items: center; gap: 3px; line-height: 1.35; padding: 1px 6px 2px; }
.chip .ms { vertical-align: 0; }
.btn { line-height: 1.2; }
.btn .ms { vertical-align: 0; font-size: 1.15em; }
.row { align-items: baseline; }
.row b { display: inline-flex; align-items: center; gap: 3px; flex-wrap: wrap; justify-content: flex-end; }
.row b .ms { vertical-align: 0; }
.overlay-menu button { display: flex; align-items: center; gap: 6px; white-space: nowrap; padding: 5px 12px 5px 10px; }
.overlay-menu button .ms { margin-right: 0; }
.card { width: 118px; }
.card .n { min-height: 2.3em; display: flex; align-items: center; justify-content: center; overflow-wrap: anywhere; }
.card .c, .card .lock { display: inline-flex; align-items: center; gap: 3px; }
.toast { line-height: 1.35; }
.toast .ms { vertical-align: -0.15em; }
.clock #clockDate { white-space: nowrap; display: inline-flex; align-items: center; gap: 2px; }
.inspector h3 { overflow-wrap: anywhere; }
.inspector .styles .style { line-height: 1.3; }
.field label.inline { display: inline-flex; align-items: center; gap: 6px; }
.tabs button { display: inline-flex; align-items: center; gap: 4px; }
.hint { white-space: normal; max-width: min(720px, calc(100vw - 32px)); text-align: center; line-height: 1.35; }


.inspector .warnline { font-size: 12px; color: var(--bad); margin: -2px 0 4px 2px; line-height: 1.3; }
.btn.warn { color: #7a2a1a; }


/* upgrade paths: one card per path, each with its own colour */
.upgrades { margin-top: 10px; }
.up-head { display: flex; align-items: center; gap: 5px; margin: 0 0 6px; font-family: var(--display); font-size: 15px; }
.up-head .ms { font-size: 18px; }
.up-head .up-hint { margin-left: 4px; font-family: var(--font); font-size: 12px; color: var(--ink-2); }
.path { --accent: #3c6e3c; background: var(--face); box-shadow: var(--raised); border-left: 5px solid var(--accent); }
.path-tab { display: flex; align-items: center; gap: 6px; padding: 3px 6px 3px 7px; background: var(--accent); color: #fff; font-family: var(--display); font-size: 13px; }
.path-tab .ms { font-size: 16px; }
.path-tab .tag { margin-left: auto; padding: 0 6px; font-family: var(--font); font-size: 11px; font-weight: 700; background: rgba(0, 0, 0, 0.25); white-space: nowrap; }
.path-tab .tag.ok { background: #e9f6df; color: #2c6a1e; }
.path-body { padding: 7px 8px 8px; }
.path-top { display: flex; gap: 8px; align-items: flex-start; }
.path-top .preview { width: 96px; height: 72px; }
.path-name { font-weight: 700; font-size: 14px; color: var(--accent); line-height: 1.2; }
.path-desc { font-size: 12px; line-height: 1.35; color: var(--ink-2); margin-top: 2px; }
.chain { display: flex; flex-wrap: wrap; align-items: center; gap: 3px; margin: 7px 0 5px; font-size: 11px; }
.chain span { padding: 1px 5px; background: #fff; box-shadow: var(--field); color: var(--ink-2); white-space: nowrap; }
.chain span.now { background: #e4e4e4; font-style: italic; }
.chain span.next { background: var(--accent); color: #fff; font-weight: 700; box-shadow: none; }
.chain i { font-style: normal; color: #7a7a7a; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; margin: 5px 0 6px; }
.tile { background: #fff; box-shadow: var(--field); padding: 2px 6px 3px; min-width: 0; }
.tile small { display: block; font-size: 11px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile b { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tile b i { font-style: normal; color: #8a8a8a; }
.tile.up .to { color: var(--good); font-weight: 700; }
.tile.down .to { color: var(--bad); font-weight: 700; }
.tile .ms { font-size: 1em; vertical-align: -0.12em; }
.path .req { margin-top: 6px; }
.path .btn.path-go { width: 100%; justify-content: center; margin-top: 8px; }
.path-or { display: flex; align-items: center; gap: 8px; margin: 8px 0; font-family: var(--display); font-size: 13px; color: var(--ink-2); }
.path-or::before, .path-or::after { content: ''; flex: 1; border-top: 1px solid var(--lo); border-bottom: 1px solid var(--hi); }

/* town issues, lower left */
.issues { position: absolute; left: 8px; bottom: 8px; width: 290px; max-width: calc(100vw - 16px); padding: 0 !important; z-index: 6; }
.issues .ihead { display: flex; align-items: center; gap: 6px; padding: 3px 6px; background: var(--navy); color: #fff; font-family: var(--display); font-size: 13px; cursor: pointer; user-select: none; }
.issues .ihead .ms { font-size: 16px; }
.issues .ihead b { margin-left: 2px; min-width: 18px; padding: 0 5px; font-family: var(--font); font-size: 11px; text-align: center; background: #fff; color: #000; }
.issues .ihead b.bad { background: #ffd6d0; color: var(--bad); }
.issues .ihead b.warn { background: #fff1c6; color: #7a5a00; }
.issues .ihead .caret { margin-left: auto; }
#issueList { max-height: min(38vh, 300px); overflow-y: auto; padding: 3px; }
.issue { display: flex; align-items: flex-start; gap: 6px; padding: 4px 5px; font-size: 12px; line-height: 1.35; cursor: pointer; border-bottom: 1px solid #b0b0b0; box-shadow: 0 1px 0 #e8e8e8; }
.issue:last-child { border-bottom: 0; box-shadow: none; }
.issue:hover { background: #ffffe1; }
.issue > .ms { flex: none; font-size: 16px; margin-top: -1px; }
.issue > span:nth-child(2) { flex: 1; }
.issue .go { margin-left: auto; color: #888; }
.issue.bad > .ms:first-child { color: var(--bad); }
.issue.warn > .ms:first-child { color: #a07000; }
.issue.info > .ms:first-child { color: var(--navy); }
.issue.ok { cursor: default; } .issue.ok > .ms { color: var(--good); }
.issues.collapsed #issueList { display: none; }
@media (max-width: 1280px) { .issues { bottom: 84px; } }

.inspector .mergedesc { font-size: 11px; color: var(--ink-2); margin: -1px 0 5px 4px; line-height: 1.3; }

.inspector label.chk { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; margin: 2px 0 4px; cursor: pointer; }

/* research tree: rows are branches, columns are depth, lines show what needs what */
.ttree-wrap { overflow: auto; max-height: min(52vh, 520px); background: #fff; box-shadow: var(--field); padding: 8px; }
.ttree { position: relative; display: grid; column-gap: 30px; row-gap: 6px; align-items: center; }
.ttree .tlinks { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 0; overflow: visible; }
.tbranch { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-2); }
.tnode { position: relative; z-index: 1; display: flex; flex-direction: column; justify-content: center; min-height: 38px; border-left: 4px solid var(--hue, #888); padding: 2px 7px; background: var(--face); box-shadow: var(--raised); cursor: pointer; font-size: 12px; line-height: 1.2; overflow: hidden; }
.tnode b { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tnode span { font-size: 11px; color: var(--ink-2); }
.tnode i { position: absolute; left: 0; bottom: 0; height: 3px; background: #d8a630; }
.tnode.done { background: #d8ead2; }
.tnode.done span { color: var(--good); font-weight: 700; }
.tnode.can { background: #fff; }
.tnode.can span { color: var(--navy); font-weight: 700; }
.tnode.cur { box-shadow: 0 0 0 2px #d8a630, var(--raised); background: #fff8e0; }
.tnode.locked { opacity: 0.62; }
.tnode.sel { outline: 2px solid var(--navy); outline-offset: 1px; }
.tdetail { display: grid; grid-template-columns: minmax(180px, 1fr) 2fr auto; gap: 12px; align-items: start; margin-top: 8px; padding: 8px; background: var(--face); box-shadow: var(--raised); font-size: 12px; }
.tdetail b { font-size: 14px; }
.tdetail .tcost { color: var(--ink-2); margin-left: 4px; }
.tdetail .tdesc { color: var(--ink-2); margin-top: 3px; line-height: 1.35; }
.tdetail .tneeds { margin-top: 4px; } .tdetail .tneeds .ok { color: var(--good); } .tdetail .tneeds .no { color: var(--bad); }
.tdetail ul { margin: 0; padding-left: 16px; line-height: 1.4; }
.tdetail .tact { min-width: 180px; }
.tdetail .tdone { color: var(--good); font-weight: 700; }
.tdetail .tsub { font-size: 11px; color: var(--ink-2); margin-top: 3px; }
@media (max-width: 760px) { .tdetail { grid-template-columns: 1fr; } }

/* draggable windows */
.win h2 { cursor: move; user-select: none; touch-action: none; }
.win.inactive h2 { background: #808080 !important; color: #c0c0c0; }
.inspector::before { cursor: move; }
@media (max-width: 900px) { .inspector::before { cursor: default; } }
/* a phone: every window as wide as the screen */
@media (max-width: 600px) { .modal-card.wide { width: calc(100vw - 16px); } }

.tbranch { border-left: 4px solid var(--hue, #888); padding-left: 5px; }
.tnode .tx { display: flex; flex-wrap: wrap; gap: 0 4px; }
.tnode .tx em { font-style: normal; font-size: 10px; color: #8a2f2f; white-space: nowrap; }
.tnode .tx em.ok { color: var(--good); }
.tunlocks { display: flex; flex-wrap: wrap; gap: 6px; max-height: 150px; overflow-y: auto; }
.tu { width: 92px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; line-height: 1.2; text-align: center; }
.tu img, .tu-ph { width: 84px; height: 63px; background: #9fb08a; box-shadow: var(--sunken); object-fit: cover; display: flex; align-items: center; justify-content: center; }
.tu-ph .ms { font-size: 28px; color: #2e3a1e; }

/* happiness breakdowns */
table.hap { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 6px; background: #fff; box-shadow: var(--field); }
table.hap td, table.hap th { padding: 2px 6px; border-top: 1px solid #ececec; vertical-align: top; }
table.hap th { text-align: left; font-size: 11px; background: #e8e8e8; color: var(--ink-2); }
table.hap td .ms { font-size: 14px; vertical-align: -0.2em; margin-right: 4px; color: var(--ink-2); }
table.hap td.pts { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 700; }
table.hap td.pts em { font-style: normal; font-weight: 400; color: var(--ink-2); }
table.hap tr.ok td.pts { color: var(--good); }
table.hap tr.miss td.pts { color: #a07000; }
table.hap tr.bad td.pts { color: var(--bad); }
table.hap tr.tip td { border-top: 0; padding-top: 0; font-size: 11px; color: var(--ink-2); padding-left: 24px; }
table.hap .sub { font-size: 11px; color: var(--ink-2); }
table.hap.big td { padding: 4px 8px; }
.inspector .hh { font-size: 12px; font-weight: 700; margin: 6px 0 3px; }

/* ------------------------------------------------- new village: start from */
.starters { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px; }
.starter { display: flex; flex-direction: column; gap: 3px; text-align: left; padding: 5px; border: 0; background: var(--face); box-shadow: var(--raised); cursor: pointer; font: inherit; color: var(--ink); }
.starter:hover { background: #cfcfcf; }
.starter.on { box-shadow: var(--sunken); background: #b4b4b4; outline: 1px dotted #000; outline-offset: -4px; }
.starter:disabled { opacity: 0.6; cursor: default; }
.starter canvas { width: 100%; height: auto; aspect-ratio: 3 / 2; image-rendering: pixelated; box-shadow: var(--field); background: #9fb383; }
.starter b { font-size: 13px; }
.starter .d { font-size: 12px; color: var(--ink-2); line-height: 1.25; }
.starter .m { font-size: 11px; color: var(--navy); margin-top: auto; padding-top: 2px; }

/* ------------------------------------------------------------ multiplayer */
.netbox { cursor: pointer; gap: 6px !important; padding: 4px 8px !important; }
.netbox > .ms { font-size: 18px; color: var(--navy); }
.netbox b { font-family: var(--small); font-size: 11px; font-weight: 400; letter-spacing: 0.06em; }
.mp-dots { display: flex; }
.mp-dots i { width: 20px; height: 20px; margin-left: -4px; border: 2px solid var(--face); border-radius: 50%; color: #fff; font-style: normal; font-size: 11px; font-weight: 700; line-height: 16px; text-align: center; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.45); }
.mp-dots i:first-child { margin-left: 0; }
.mp-win h5 { margin: 12px 0 6px; font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-2); }
.mp-cols h5 { margin-top: 4px; }
.mp-p { margin: 0 0 8px; font-size: 13px; line-height: 1.35; }
.mp-cols .btn { margin: 0 4px 4px 0; }
.mp-code-in { width: 120px; font: inherit; font-size: 18px; letter-spacing: 0.12em; text-transform: uppercase; padding: 4px 6px; border: 0; background: #fff; box-shadow: var(--sunken); color: #000; border-radius: 0; }
.mp-code { margin: 4px 0 2px; padding: 10px; background: #fff; box-shadow: var(--sunken); text-align: center; font-family: var(--display); font-size: 40px; letter-spacing: 0.18em; user-select: all; }
.mp-status { display: flex; align-items: center; gap: 6px; margin: 10px 0; font-size: 13px; }
.mp-status.bad { color: var(--bad); font-weight: 700; }
.mp-status .spin { animation: mpspin 1s linear infinite; }
@keyframes mpspin { to { transform: rotate(360deg); } }
.mp-players { display: grid; gap: 2px; margin-bottom: 8px; }
.mp-player { display: flex; align-items: center; gap: 8px; padding: 3px 6px; background: #fff; box-shadow: var(--field); font-size: 14px; }
.mp-player i { width: 12px; height: 12px; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4); }
.mp-player span { margin-left: auto; font-size: 12px; color: var(--ink-2); }
.mp-win .note + .actions { margin-top: 10px; }
.netcur { position: absolute; transform: translate(-50%, -100%); display: flex; align-items: center; gap: 4px; padding: 1px 6px 1px 4px; background: #fff; border: 2px solid #000; font-size: 12px; font-weight: 700; white-space: nowrap; pointer-events: none; box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.3); }
.netcur i { width: 9px; height: 9px; border-radius: 50%; }
.netcur small { font-weight: 400; color: var(--ink-2); }
.netbox .mp-lock { font-size: 16px; color: var(--bad); }
.mp-code.locked { color: var(--ink-2); opacity: 0.6; }
.mp-flag { display: flex; align-items: center; gap: 6px; margin: 6px 0; padding: 4px 8px; background: var(--tip); box-shadow: var(--field); font-size: 13px; line-height: 1.35; }
.mp-flag .ms { font-size: 18px; }
.mp-player .btn.small { margin-left: 4px; }
.mp-player.mp-ask span { margin-left: 0; font-size: inherit; color: inherit; }
.mp-small { font-size: 12px; color: var(--ink-2); }
.mp-opt { display: flex; align-items: center; gap: 6px; margin: 4px 0; font-size: 13px; cursor: pointer; }
.mp-opt select { font: inherit; font-size: 13px; }
.mp-wait { display: flex; gap: 10px; align-items: flex-start; margin: 4px 0 8px; max-width: 420px; }
.mp-wait > .ms { font-size: 28px; }
.mp-wait b { font-size: 16px; }
.mp-wait .mp-p { margin-top: 6px; }
.mp-asks { position: absolute; top: 104px; left: 50%; transform: translateX(-50%); display: grid; gap: 4px; z-index: 5; max-width: calc(100vw - 16px); }
.mp-ask { display: flex; align-items: center; gap: 8px; padding: 6px 10px; font-size: 14px; }
.mp-ask > .ms { font-size: 20px; color: var(--navy); }
.mp-ask .mp-ask-who { margin-right: auto; }
@media (max-width: 900px) { .netbox b { display: none; } }

/* ------------------------------------------------------ building guide */
.tooltip .muted { opacity: 0.7; font-size: 12px; font-weight: 400; }
.tooltip:has(.bsum) { max-width: 300px; padding: 5px 8px; }
.bsum > b { font-size: 14px; }
.bsum-chain { font-size: 11px; color: var(--navy); margin: 1px 0 3px; }
.bsum-desc { font-size: 12px; margin-bottom: 4px; }
.bsum-stats { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; row-gap: 1px; font-size: 12px; }
.bsum-stats span { color: var(--ink-2); }
.bsum-foot { margin-top: 4px; font-size: 11px; color: var(--ink-2); }
.bsum-hint { margin-top: 4px; font-size: 11px; color: var(--navy); }
.guide { width: min(460px, calc(100vw - 16px)); }
.guide-head { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 8px; }
.guide-head img, .guide-level img { width: 72px; height: 54px; background: #9fb383; box-shadow: var(--field); object-fit: cover; image-rendering: pixelated; flex: none; }
.guide-head h3 { margin: 0 0 2px; font-size: 17px; }
.guide-desc { font-size: 13px; }
.guide-place { margin-top: 4px; font-size: 12px; color: var(--ink-2); }
.guide-lock { margin-top: 4px; font-size: 12px; color: var(--bad); font-weight: 700; }
.guide-level { display: flex; gap: 10px; padding: 6px; margin: 4px 0; background: #fff; box-shadow: var(--field); }
.guide-level img { width: 56px; height: 42px; }
.guide-level > div { flex: 1; min-width: 0; }
.guide-lname { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 2px; }
.guide-lname span { font-size: 12px; color: var(--ink-2); }
.guide-stats { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; font-size: 12px; }
.guide-stats span { color: var(--ink-2); }
.guide-needs { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 4px; }
.guide-needs span { font-size: 11px; padding: 0 5px; background: var(--face); box-shadow: var(--raised); }
.guide-needs span.ok { color: var(--good); }
.guide-needs span.no { color: var(--bad); }
.guide-from { font-size: 12px; color: var(--ink-2); margin-bottom: 2px; }
.guide-more h5, .guide-estates h5 { margin: 10px 0 4px; font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-2); }
.guide-more div { font-size: 12px; margin: 2px 0; }
.guide-more .btn { margin-top: 6px; }
/* Upgrades & joins: everything a building can become, as a tech tree */
.pm-legend { display: flex; flex-wrap: wrap; gap: 3px 14px; font-size: 11px; color: var(--ink-2); margin: 0 0 6px; }
.pm-legend > span { display: inline-flex; align-items: center; gap: 3px; }
.pm-legend .ms { font-size: 14px; color: var(--k, var(--ink-2)); }
.pm-wrap { overflow: auto; max-height: min(64vh, 640px); background: #fff; box-shadow: var(--field); padding: 8px 10px 10px; }
.pm-links { position: absolute; left: 0; top: 0; pointer-events: none; overflow: visible; z-index: 0; }
.tt-grid { position: relative; display: grid; column-gap: 26px; row-gap: 8px; align-items: center; min-width: max-content; }
.tt-row { position: relative; z-index: 1; display: flex; align-items: center; gap: 6px; cursor: pointer; padding: 2px 4px 2px 0; }
.tt-row img { width: 44px; height: auto; image-rendering: pixelated; flex: none; }
.tt-row b { font-size: 12px; line-height: 1.15; }
.tt-row.here b { color: #8a5a00; }
.tt-how { display: flex; flex-direction: column; gap: 0; font-size: 10.5px; line-height: 1.25; margin-top: 1px; }
.tt-how > span { display: inline-flex; align-items: center; gap: 2px; color: var(--k); font-weight: 700; }
.tt-how .ms { font-size: 12px; }
.tt-node { position: relative; z-index: 1; display: flex; flex-direction: column; justify-content: center; min-height: 36px; padding: 2px 7px; background: var(--face); box-shadow: var(--raised); cursor: pointer; font-size: 12px; line-height: 1.2; overflow: hidden; }
.tt-node b { font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 2px; }
.tt-node span { font-size: 10.5px; color: var(--ink-2); }
.tt-node .ms { font-size: 12px; }
.tt-node:hover { box-shadow: 0 0 0 2px var(--navy), var(--raised); }
.tt-node.done { background: #d8ead2; }
.tt-node.now { background: #fff1c0; box-shadow: 0 0 0 2px #d8a630, var(--raised); }
.tt-node.locked { background: #e9e9e9; color: var(--ink-2); }

/* merge villages */
.modal-card.merge-win { width: min(900px, calc(100vw - 16px)); }
.merge-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.merge-side { background: var(--face-2); box-shadow: var(--sunken); padding: 8px; display: grid; gap: 6px; align-content: start; }
.merge-side.over { background: var(--tip); }
.merge-side h3 { margin: 0; font-size: 14px; }
.merge-side h3 small { font-weight: 400; color: var(--ink-2); }
.merge-chosen { display: grid; grid-template-columns: 88px 1fr; gap: 8px; align-items: center; background: #fff; box-shadow: var(--field); padding: 5px; }
.merge-chosen .t { font-weight: 700; }
.merge-chosen .m { font-size: 12px; color: var(--ink-2); }
.merge-canvas, .merge-pic { width: 88px; height: 88px; image-rendering: pixelated; display: flex; align-items: center; justify-content: center; background: #9fb383; }
.merge-pic.ph .ms { font-size: 34px; color: #2e3a1e; }
.merge-list { display: grid; gap: 2px; max-height: 200px; overflow-y: auto; background: #fff; box-shadow: var(--field); padding: 2px; }
.merge-list button { text-align: left; border: 0; background: none; padding: 4px 6px; cursor: pointer; display: flex; gap: 6px; align-items: center; font-size: 13px; }
.merge-list button small { margin-left: auto; color: var(--ink-2); font-size: 11px; white-space: nowrap; }
.merge-list button:hover { background: #e8eef9; }
.merge-list button.on { background: var(--navy); color: #fff; }
.merge-list button.on small { color: #dfe6ff; }
.merge-drop { border: 1px dashed var(--lo); padding: 6px; text-align: center; font-size: 12px; color: var(--ink-2); }
.merge-arrange { display: grid; grid-template-columns: minmax(0, 520px) minmax(240px, 1fr); gap: 12px; align-items: start; }
.merge-arrange canvas { width: 100%; aspect-ratio: 1; box-shadow: var(--sunken); cursor: grab; image-rendering: pixelated; touch-action: none; display: block; }
.merge-arrange canvas.dragging { cursor: grabbing; }
.merge-tools .field { margin: 0 0 8px; }
.merge-info { font-size: 13px; margin: 4px 0 8px; display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.merge-info.bad { color: var(--bad); font-weight: 700; }
.merge-a { color: #1f56b8; }
.merge-b { color: #b25e00; }
.merge-sum { list-style: none; margin: 0; padding: 6px; display: grid; gap: 5px; font-size: 13px; background: #fff; box-shadow: var(--field); }
.merge-sum li { display: grid; grid-template-columns: 22px 1fr; gap: 4px; align-items: start; line-height: 1.35; }
.merge-sum li.h { display: block; font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-2); }
.merge-sum .ms { font-size: 18px; }
.modal-card h4 { margin: 12px 0 4px; font-size: 13px; display: flex; gap: 4px; align-items: center; }
.merge-detail { margin: 0; padding-left: 20px; font-size: 13px; display: grid; gap: 2px; max-height: 160px; overflow-y: auto; }
@media (max-width: 760px) {
  .merge-pick, .merge-arrange { grid-template-columns: 1fr; }
}
.merge-new { background: #fff; box-shadow: var(--field); padding: 4px 8px 8px; }
.merge-new .field { margin: 4px 0; }
.merge-place { position: fixed; top: 96px; right: 8px; z-index: 55; width: min(420px, calc(100vw - 16px)); max-height: calc(100dvh - 104px); overflow-y: auto; padding: 8px 10px 10px; pointer-events: auto; }
.merge-place .inline { gap: 3px; }
.merge-place .mp-head { display: flex; gap: 6px; align-items: center; font-size: 14px; margin-bottom: 6px; }
.merge-place .merge-sum { max-height: 128px; overflow-y: auto; margin-bottom: 6px; font-size: 12px; }
.merge-place .mp-hint { font-size: 12px; color: var(--ink-2); }

/* research points */
#resStat { cursor: pointer; }
.rhead { display: grid; grid-template-columns: auto auto 1fr; gap: 6px; margin-bottom: 4px; }
.rhead .rcell { display: flex; align-items: center; gap: 8px; background: #fff; box-shadow: var(--field); padding: 5px 9px; min-width: 0; }
.rhead .rcell > .ms { font-size: 24px; color: var(--ink-2); }
.rhead .rcell b { display: block; font-size: 15px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.rhead .rcell small { display: block; font-size: 11px; color: var(--ink-2); }
.rhead .rcell.wide > div { flex: 1; min-width: 0; }
.rhead .rcell .meter { margin: 3px 0 2px; }
.rhead .rcell.warn { background: #fff6dc; }
.rhead .rcell.warn > .ms { color: #a07000; }
.rsrc { font-size: 12px; color: var(--ink-2); margin-bottom: 8px; }
.rsrc b { color: var(--good); }
@media (max-width: 720px) { .rhead { grid-template-columns: 1fr 1fr; } .rhead .rcell.wide { grid-column: 1 / -1; } }
/* a farm: what it produces */
.sec.farm .produce { display: flex; flex-wrap: wrap; gap: 3px; margin-bottom: 4px; }
.sec.farm .produce .btn.on { background: #fff1c0; box-shadow: 0 0 0 2px #d8a630, var(--raised); font-weight: 700; }
.sec.farm h5 + .note, .sec.farm .note { margin-bottom: 4px; }

/* Settings: group boxes in two columns, rows of buttons for a choice of a few */
.modal-card.settings-win { width: min(760px, calc(100vw - 16px)); }
.set-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; align-items: start; }
.set-group { border: 1px solid var(--lo); box-shadow: 1px 1px 0 var(--hi), inset 1px 1px 0 var(--hi); margin: 0 0 10px; padding: 4px 10px 8px; min-width: 0; }
.set-group legend { font-size: 12px; font-weight: 700; padding: 0 4px; }
.set-check { display: grid; grid-template-columns: auto 1fr; gap: 0 7px; align-items: start; margin: 5px 0; font-size: 13px; cursor: pointer; }
.set-check input { margin: 1px 0 0; accent-color: var(--navy); }
.set-check small { display: block; font-size: 11px; color: var(--ink-2); line-height: 1.3; margin-top: 1px; }
.set-check:has(input:disabled) { opacity: 0.55; cursor: default; }
.set-row { display: grid; grid-template-columns: 7.6em 1fr; gap: 6px; align-items: center; margin: 6px 0; font-size: 13px; }
.set-row input[type=range] { width: 100%; margin: 0; accent-color: var(--navy); }
.set-hint { font-size: 12px; color: var(--ink-2); margin: 2px 0 6px; line-height: 1.35; }
.set-presets { display: flex; gap: 4px; flex-wrap: wrap; }
.seg { display: flex; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: var(--face); box-shadow: var(--raised); height: 24px; padding: 0 8px; font: inherit; font-size: 12px; cursor: pointer; flex: 1 1 auto; }
.seg button.on { box-shadow: var(--sunken); background: #b5b5b5; font-weight: 700; }
.seg button:disabled { color: #888; cursor: default; }
.set-actions { display: flex; align-items: center; }
@media (max-width: 640px) {
  .set-cols { grid-template-columns: 1fr; }
  .set-row { grid-template-columns: 1fr; gap: 3px; }
}

/* the interface hidden (V): just the town, and the way back in the corner */
.show-ui { display: none; }
body.ui-hidden #hud, body.ui-hidden #windows, body.ui-hidden #tooltip, body.ui-hidden .mp-asks, body.ui-hidden .merge-place { display: none !important; }
body.ui-hidden .show-ui {
  display: inline-flex; align-items: center; gap: 6px; position: fixed; top: 10px; right: 10px; z-index: 90;
  border: 0; background: var(--face); box-shadow: var(--raised); padding: 4px 10px; font: inherit; font-size: 13px; cursor: pointer;
  opacity: 0.5; transition: opacity 0.2s;
}
body.ui-hidden .show-ui:hover, body.ui-hidden .show-ui:focus-visible { opacity: 1; }
body.ui-hidden .show-ui:active { box-shadow: var(--sunken); }
