:root {
  --loam: #231d19;
  --bark: #2f2621;
  --bark-2: #3b302a;
  --linen: #efe6d2;
  --dim: #a89a86;
  --hearth: #e8a33d;
  --moss: #7fa06a;
  --ember: #c8553d;
  --river: #4f8fb0;
  --fell: 'IM Fell English', Georgia, serif;
  --body: 'Atkinson Hyperlegible', system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--loam); color: var(--linen); font: 15px/1.5 var(--body); -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--hearth); outline-offset: 2px; }
[hidden] { display: none !important; }

#app { display: grid; grid-template-rows: auto auto auto 1fr; height: 100dvh; max-width: 1400px; margin: 0 auto; }

#bar { display: flex; align-items: center; gap: 12px; padding: max(10px, env(safe-area-inset-top)) 14px 8px; }
#townName { font: 26px/1 var(--fell); margin: 0; letter-spacing: .01em; }
#clock { color: var(--dim); font-variant-numeric: tabular-nums; margin-left: auto; }
#time { color: var(--linen); }

.chip { background: var(--bark); border: 1px solid var(--bark-2); border-radius: 999px; padding: 4px 11px; font-size: 13px; color: var(--linen); }
.chip.on { background: var(--hearth); border-color: var(--hearth); color: var(--loam); font-weight: 700; }
#costChip { font-variant-numeric: tabular-nums; }
#costChip.warn { border-color: var(--ember); color: #f3b3a5; }

#stage { position: relative; background: #1a1512; }
#map { display: block; width: 100%; height: auto; touch-action: none; cursor: grab; }
#mapCtl { position: absolute; right: 8px; top: 8px; display: grid; gap: 6px; }
#mapCtl button { width: 34px; height: 34px; border-radius: 8px; border: 1px solid rgba(239,230,210,.25); background: rgba(35,29,25,.85); color: var(--linen); font-size: 18px; line-height: 1; }
#sndPop { position: absolute; right: calc(100% + 8px); top: 0; z-index: 5; width: 212px; display: grid; gap: 2px; padding: 6px; border-radius: 10px; border: 1px solid rgba(239,230,210,.25); background: rgba(35,29,25,.96); box-shadow: 0 6px 20px rgba(0,0,0,.45); }
#sndPop[hidden] { display: none; }
#mapCtl #sndPop button { width: 100%; height: auto; display: flex; align-items: center; gap: 9px; padding: 6px 8px; text-align: left; font-size: 14px; border: 1px solid transparent; background: none; }
#mapCtl #sndPop button[aria-checked="true"] { border-color: var(--hearth); background: rgba(232,163,61,.16); }
#sndPop .ic { font-size: 17px; width: 22px; text-align: center; }
#sndPop .tx { display: grid; line-height: 1.2; }
#sndPop small { color: rgba(239,230,210,.6); font-size: 11px; }
#sndPop .vol { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 8px; padding: 6px 8px 2px; font-size: 12px; color: rgba(239,230,210,.75); }
#sndPop .vol input { width: 100%; accent-color: var(--hearth); }
#banner { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); background: rgba(35,29,25,.92); border: 1px solid var(--hearth); color: var(--linen); padding: 4px 12px; border-radius: 6px; font-size: 12px; white-space: nowrap; max-width: 92%; overflow: hidden; text-overflow: ellipsis; }
#conn { position: absolute; right: 8px; bottom: 8px; background: var(--ember); color: #fff; font-size: 12px; padding: 3px 9px; border-radius: 4px; }

#tabs { display: flex; border-bottom: 1px solid var(--bark-2); background: var(--loam); position: sticky; top: 0; z-index: 2; }
#tabs button { flex: 1; background: none; border: 0; padding: 11px 4px 10px; color: var(--dim); font-size: 14px; border-bottom: 2px solid transparent; }
#tabs button[aria-selected="true"] { color: var(--linen); border-bottom-color: var(--hearth); }

#panel { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 14px calc(24px + var(--safe-b)); }
.pane { max-width: 720px; }

/* feed */
.filters { display: flex; gap: 6px; padding: 12px 0 6px; overflow-x: auto; }
#feed { list-style: none; margin: 0; padding: 0; }
#feed li { padding: 10px 0; border-bottom: 1px solid var(--bark); display: grid; grid-template-columns: 44px 1fr; gap: 8px; }
#feed .t { color: var(--dim); font-size: 12px; font-variant-numeric: tabular-nums; padding-top: 2px; }
#feed .x { overflow-wrap: anywhere; }
#feed li.thought .x { font: italic 16px/1.45 var(--fell); color: #d9ceb6; }
#feed li.thought .who { font: 700 13px var(--body); font-style: normal; color: var(--dim); margin-right: 4px; }
#feed li.big .x { color: #fff; }
#feed li.big { border-left: 3px solid var(--hearth); padding-left: 8px; margin-left: -11px; }
#feed li.theft.big, #feed li.event.big { border-left-color: var(--ember); }
#feed li.god .x { color: #cfc2f0; }
#feed .line { display: block; }
#feed .line b { font-weight: 700; }
#feed li.new { animation: glow 1.6s ease-out; }
@keyframes glow { from { background: rgba(232,163,61,.14); } to { background: transparent; } }

/* people */
#people { list-style: none; margin: 0; padding: 6px 0; }
#people li button { width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--bark); padding: 12px 0; display: grid; grid-template-columns: 38px 1fr auto; gap: 10px; align-items: start; }
.av { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 17px; border: 2px solid; background: var(--bark); }
.pname { font: 19px/1.1 var(--fell); }
.prole { color: var(--dim); font-size: 13px; }
.pdoing { font-size: 13px; color: #d7ccb7; margin-top: 2px; }
.pthought { font: italic 14px/1.4 var(--fell); color: var(--dim); margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mood { font-size: 12px; color: var(--dim); }
.mood.bad { color: #f3b3a5; }

#profile { padding: 10px 0 30px; }
.back { background: none; border: 0; color: var(--hearth); padding: 6px 0; }
.phead { display: flex; gap: 12px; align-items: center; margin: 6px 0 4px; }
.phead .av { width: 52px; height: 52px; font-size: 26px; }
.phead h2 { font: 30px/1 var(--fell); margin: 0; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
.tag { font-size: 12px; background: var(--bark); border-radius: 4px; padding: 2px 8px; color: var(--dim); }
.tag.model { color: var(--river); }
.tag.mayor { color: var(--hearth); }
.mind { background: var(--bark); border-radius: 10px; padding: 14px 16px; margin: 10px 0 16px; position: relative; }
.mind .doing { font-size: 13px; color: var(--dim); }
.mind blockquote { margin: 6px 0 0; font: italic 20px/1.4 var(--fell); color: var(--linen); }
.mind .said { margin-top: 10px; font-size: 14px; }
h3 { font: 20px/1.2 var(--fell); margin: 22px 0 8px; font-weight: 400; }
.hint { color: var(--dim); font-size: 13px; margin: 0 0 8px; }
.bars { display: grid; gap: 7px; }
.bar { display: grid; grid-template-columns: 110px 1fr 42px; gap: 8px; align-items: center; font-size: 13px; }
.bar .track { height: 8px; background: var(--bark-2); border-radius: 4px; overflow: hidden; }
.bar .fill { display: block; height: 100%; background: var(--moss); border-radius: 4px; transition: width .6s; }
.bar .fill.low { background: var(--ember); }
.bar .num { text-align: right; color: var(--dim); font-variant-numeric: tabular-nums; }
.decision .bar { grid-template-columns: 1fr 70px 42px; }
.decision .bar .lab { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.decision .bar.chosen .lab { color: var(--hearth); }
.decision .fill { background: var(--river); }
.decision .chosen .fill { background: var(--hearth); }
.rel { display: grid; grid-template-columns: 110px 1fr 42px; gap: 8px; align-items: center; font-size: 13px; }
.rel .track { height: 8px; background: var(--bark-2); border-radius: 4px; position: relative; }
.rel .track::after { content: ''; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--dim); opacity: .5; }
.rel .fill { display: block; position: absolute; top: 0; bottom: 0; border-radius: 4px; }
.inv { display: flex; gap: 16px; font-variant-numeric: tabular-nums; }
.summary { font: 17px/1.55 var(--fell); color: #e2d8c3; }
.mems { list-style: none; padding: 0; margin: 0; }
.mems li { padding: 7px 0; border-bottom: 1px solid var(--bark); font-size: 14px; }
.mems .when { color: var(--dim); font-size: 12px; margin-right: 6px; }
.mems .imp { color: var(--hearth); }

/* town */
.stock { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.stock div { background: var(--bark); border-radius: 8px; padding: 10px 12px; }
.stock b { display: block; font: 28px/1 var(--fell); }
.stock span { font-size: 12px; color: var(--dim); }
.blist { list-style: none; padding: 0; margin: 0; }
.blist li { display: grid; grid-template-columns: 30px 1fr auto; gap: 8px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--bark); font-size: 14px; }
.blist .ic { font-size: 20px; }
.blist .st { font-size: 12px; color: var(--dim); text-align: right; }
.costs { font-variant-numeric: tabular-nums; }
.costs td { padding: 4px 10px 4px 0; font-size: 14px; }
.costs td:last-child { text-align: right; color: var(--dim); }

/* crier */
.paper { border-bottom: 1px solid var(--bark-2); padding: 20px 0; }
.paper .issue { color: var(--dim); font-size: 13px; }
.paper h2 { font: 30px/1.1 var(--fell); margin: 4px 0 12px; }
.paper p { font: 18px/1.6 var(--fell); margin: 0 0 12px; max-width: 62ch; color: #e6dcc8; }
.empty { color: var(--dim); padding: 28px 0; }

/* god */
.god section { margin: 18px 0; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn { background: var(--bark); border: 1px solid var(--bark-2); border-radius: 8px; padding: 9px 14px; }
.btn.primary { background: var(--hearth); border-color: var(--hearth); color: var(--loam); font-weight: 700; }
.btn.danger { border-color: var(--ember); color: #f3b3a5; }
.events { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.events .btn { text-align: left; }
.events .btn small { display: block; color: var(--dim); font-size: 12px; }
input[type=text], input[type=password], input[type=number], select, textarea {
  background: var(--bark); border: 1px solid var(--bark-2); border-radius: 8px; padding: 9px 11px; width: 100%;
}
textarea { min-height: 70px; resize: vertical; }
label.f { display: block; font-size: 13px; color: var(--dim); margin: 10px 0 4px; }
.seg { display: inline-flex; border: 1px solid var(--bark-2); border-radius: 8px; overflow: hidden; }
.seg button { background: var(--bark); border: 0; padding: 8px 14px; border-right: 1px solid var(--bark-2); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--hearth); color: var(--loam); font-weight: 700; }
.status { font-size: 13px; color: var(--dim); }

#toast { position: fixed; left: 50%; bottom: calc(22px + var(--safe-b)); transform: translateX(-50%) translateY(20px); background: var(--linen); color: var(--loam); padding: 9px 16px; border-radius: 8px; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; max-width: 90vw; }
#toast.show { opacity: 1; transform: translateX(-50%); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- society: join, quiz, clans, government ---------- */
#bar { flex-wrap: wrap; row-gap: 6px; }
.chip.join { background: var(--hearth); border-color: var(--hearth); color: var(--loam); font-weight: 700; }
.chip.me { border-color: var(--moss); color: #cfe6bf; }
@media (max-width: 480px) { #townName { font-size: 22px; } #bar { gap: 8px; } .chip { padding: 4px 9px; } }

#quiz { position: fixed; inset: 0; z-index: 50; background: rgba(20,16,13,.86); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); display: grid; place-items: center; padding: max(14px, env(safe-area-inset-top)) 14px max(14px, var(--safe-b)); }
.qbox { width: min(560px, 100%); max-height: 100%; overflow-y: auto; background: var(--bark); border: 1px solid var(--bark-2); border-radius: 16px; padding: 20px 18px 18px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.qbox h2 { font: 26px/1.15 var(--fell); margin: 0 0 6px; }
.qbox .qx { float: right; background: none; border: 0; color: var(--dim); font-size: 22px; line-height: 1; margin: -6px -4px 0 0; }
.qprog { height: 6px; background: var(--loam); border-radius: 3px; overflow: hidden; margin: 12px 0 16px; }
.qprog i { display: block; height: 100%; background: var(--hearth); transition: width .25s; }
.qnum { color: var(--dim); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.qtext { font: 21px/1.3 var(--fell); margin: 6px 0 14px; }
.qopts { display: grid; gap: 8px; }
.qopts button { text-align: left; background: var(--loam); border: 1px solid var(--bark-2); border-radius: 10px; padding: 12px 14px; font-size: 15px; transition: border-color .15s, transform .1s; }
.qopts button:hover { border-color: var(--hearth); }
.qopts button:active { transform: scale(.99); }
.qopts button.on { border-color: var(--hearth); background: #3a2d1e; }
.qnav { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; }
.qbox input[type=text], .qbox textarea, .qbox select { width: 100%; background: var(--loam); border: 1px solid var(--bark-2); border-radius: 10px; padding: 11px 12px; font-size: 16px; }
.qbox textarea { min-height: 70px; resize: vertical; }
.qspin { width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--bark-2); border-top-color: var(--hearth); animation: qs 1s linear infinite; margin: 26px auto 14px; }
@keyframes qs { to { transform: rotate(360deg); } }
.pcard { background: var(--loam); border: 1px solid var(--bark-2); border-radius: 14px; padding: 16px; margin: 12px 0; }
.pcard .pe { font-size: 44px; line-height: 1; }
.pcard h3 { font: 24px var(--fell); margin: 8px 0 2px; }

.badge { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; vertical-align: 2px; margin-left: 4px; }
.badge.player { background: rgba(127,160,106,.18); color: #cfe6bf; border: 1px solid rgba(127,160,106,.5); }
.badge.pos { background: rgba(232,163,61,.15); color: #f3cf96; border: 1px solid rgba(232,163,61,.45); }
.badge.clan { color: #fff; border: 1px solid rgba(255,255,255,.25); }

.gov .seat { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--bark); }
.gov .seat .ic { font-size: 22px; text-align: center; }
.gov .seat small { display: block; color: var(--dim); font-size: 12px; }
.decree { font: italic 16px/1.4 var(--fell); color: #e5d9bd; border-left: 3px solid var(--hearth); padding: 4px 0 4px 12px; margin: 8px 0; }
.clans { display: grid; gap: 10px; }
.clancard { border: 1px solid var(--bark-2); border-left-width: 5px; border-radius: 10px; padding: 12px 14px; background: var(--bark); }
.clancard h4 { margin: 0; font: 20px var(--fell); }
.clancard .motto { color: var(--dim); font-style: italic; font-size: 13px; }
.clancard .mem { margin-top: 6px; font-size: 13px; }
.nudge { background: rgba(127,160,106,.08); border: 1px solid rgba(127,160,106,.35); border-radius: 12px; padding: 12px; margin: 12px 0; }
.nudge h3 { margin-top: 0 !important; }
#feed li.clan .x, #feed li.gov .x, #feed li.election .x { color: #f3e3c0; }

#map3d { position: relative; width: 100%; aspect-ratio: 1152 / 768; overflow: hidden; touch-action: none; background: #1a1512; }

/* ---------- Ages: era, stockpile, economy ---------- */
.era { margin-top: 14px; background: var(--bark); border: 1px solid var(--bark-2); border-radius: 12px; padding: 12px 14px; }
.eraName { font: 26px/1.1 var(--fell); color: #f3e3c0; }
.eraTrack { display: block; height: 8px; margin-top: 8px; background: var(--loam); border-radius: 4px; overflow: hidden; position: relative; }
.eraTrack .fill { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg, var(--hearth), #f3cf96); border-radius: 4px; }
.inv { display: flex; flex-wrap: wrap; gap: 6px; }
.inv span { background: var(--bark); border: 1px solid var(--bark-2); border-radius: 8px; padding: 4px 9px; font-size: 13px; }
.inv span small { color: var(--dim); font-size: 11px; }
.stockgrid span { min-width: 0; }
table.prices td { padding: 3px 0; }

/* elder interview chat */
.chatlog { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 12px; }
.chat { max-width: 85%; padding: 9px 12px; border-radius: 14px; font-size: 15px; line-height: 1.35; }
.chat.elder { align-self: flex-start; background: #3a2d1e; border: 1px solid #5a4630; font-family: var(--fell); font-size: 17px; }
.chat.me { align-self: flex-end; background: var(--hearth); color: var(--loam); }
.chat .dots { animation: qs 1s linear infinite; display: inline-block; }
/* look builder */
.lookbox .lprev { display: flex; justify-content: center; margin: 4px 0 2px; }
.lookbox .avatar { background: radial-gradient(circle at 50% 40%, #3a2f27, #221b16); border-radius: 50%; border: 2px solid var(--bark-2); }
.lchips { display: flex; flex-wrap: wrap; gap: 6px; }
.lchip { background: var(--loam); border: 1px solid var(--bark-2); border-radius: 999px; padding: 7px 12px; font-size: 14px; }
.lchip.on { border-color: var(--hearth); background: var(--hearth); color: var(--loam); font-weight: 700; }
.lsw { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 32px; height: 32px; border-radius: 50%; border: 2px solid rgba(255,255,255,.18); padding: 0; }
.swatch.on { border-color: var(--hearth); box-shadow: 0 0 0 3px rgba(232,168,56,.45); }

/* v4 */
.badge.life { background: #5a3d52; color: #f6dff0; }
.badge.sick { background: #5b6b2a; color: #eef5c8; }
.badge.feel { background: var(--bark-2); color: #d9ceb6; }
.why { font-size: 12px; color: var(--dim); margin: -2px 0 6px 0; padding-left: 4px; }
.why .grudge { color: #f3b3a5; }
.amb { background: var(--bark); border-radius: 8px; padding: 8px 10px; }
.amb .steps { margin: 6px 0 8px; padding-left: 4px; list-style: none; }
.amb .steps li { font-size: 14px; color: #d7ccb7; }
.amb .steps li.done { color: var(--moss); }
.amb .track { display: block; height: 6px; }
.bars.psy .bar span:first-child { min-width: 92px; }
.inner > div { margin: 4px 0; font-size: 14px; }
.inner details, details.folk { margin-top: 6px; }
.inner summary, details.folk summary { cursor: pointer; color: var(--hearth); font-size: 14px; }
.banner-card { background: var(--bark); border-left: 3px solid var(--hearth); border-radius: 6px; padding: 8px 10px; margin: 6px 0; font-size: 14px; }
.banner-card.sick { border-left-color: #9bb04a; }
.jevbar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--bark-2); margin: 8px 0 4px; }
.jevbar i { display: block; height: 100%; }
.jevbar i.j { background: var(--hearth); } .jevbar i.m { background: #b07fb0; } .jevbar i.l { background: var(--river); } .jevbar i.f { background: #6e6258; }
.jevlog li { font-size: 13px; }
.jevlog .pp { background: var(--bark-2); border-radius: 4px; padding: 0 5px; font-size: 12px; }
table.prices th { text-align: left; color: var(--dim); font-weight: 400; font-size: 12px; }

/* v4.1 join: builder chips, twin card */
.lchips.sugg { margin-top: 6px; }
.lchips.sugg .lchip { font-size: 12.5px; padding: 5px 10px; opacity: .85; }
details.more { margin-top: 14px; }
details.more summary { cursor: pointer; color: var(--dim); font-size: 14px; }
.pcard.twin .twinhead { display: flex; gap: 12px; align-items: center; }
.pcard.twin .twinhead h3 { margin: 0; }
.pcard .hello { font: 18px var(--fell); font-style: italic; margin: 10px 0; color: var(--hearth); }
.pcard.twin .bars.psy { margin: 10px 0 6px; }
.pcard.twin details summary { cursor: pointer; color: var(--dim); font-size: 14px; margin-top: 6px; }
#qRegen[disabled] { opacity: .45; }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 34px; margin: 8px 0; }
.spark i { flex: 1; background: var(--dim); opacity: .5; border-radius: 2px 2px 0 0; min-height: 3px; }
.spark i.bad { background: var(--hearth); opacity: 1; }

/* full-screen map */
body.mapfull { overflow: hidden; }
body.mapfull #stage { position: fixed; inset: 0; z-index: 60; background: #1a1512; margin: 0; border-radius: 0; }
body.mapfull #map3d, body.mapfull #map { width: 100vw !important; height: 100vh !important; height: 100dvh !important; aspect-ratio: auto !important; max-width: none; }
body.mapfull #mapCtl { top: max(10px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right)); }
body.mapfull #mapCtl button { width: 40px; height: 40px; }
body.mapfull #fullMap { background: rgba(232,163,61,.9); color: #1a1512; font-weight: 700; }

/* personal character codes */
.codebox { margin: 12px 0; padding: 12px; border: 1px dashed var(--hearth); border-radius: 12px; text-align: center; background: rgba(232,163,61,.08); }
.codebox .code { font: 700 28px/1.2 ui-monospace, Menlo, monospace; letter-spacing: .12em; color: var(--hearth); margin: 6px 0; user-select: all; -webkit-user-select: all; }
.code-inline { font-family: ui-monospace, Menlo, monospace; letter-spacing: .08em; color: var(--hearth); user-select: all; -webkit-user-select: all; }

/* folk tab */
.folklist { list-style: none; padding: 0; margin: 0; }
.folklist li { padding: 10px 4px; border-bottom: 1px solid var(--bark-2); cursor: pointer; }
.folklist .fl-ic { margin-right: 6px; }
.folklist .fl-now { color: var(--dim); font-size: 13px; margin-top: 2px; }
.folklist .fl-line { font: italic 14px/1.4 var(--fell, Georgia, serif); margin-top: 4px; }
.folklist .fl-more { margin-top: 6px; font-size: 13px; color: var(--dim); }
#tabs button { min-width: 0; }

.offices td { vertical-align: top; padding: 6px 4px; }
.offices td:first-child { width: 46%; }

.jobs td { vertical-align: top; padding: 5px 4px; }
.jobs .jobppl { font-size: 12px; }

.trends td { padding: 3px 4px; vertical-align: middle; }
.spark { display: block; }
.ledger { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ledger th { text-align: left; font-size: 12px; color: var(--dim); }

.wbar{display:inline-block;width:70px;height:7px;background:#0003;border-radius:4px;vertical-align:middle;overflow:hidden}.wbar i{display:block;height:100%;background:#c9a15a}
/* ---------- wave 2: stat sheet, stats table, world stats, feed history, chats, life story, townsfolk card ---------- */
.sheet { background: var(--bark); border: 1px solid var(--bark-2); border-radius: 12px; padding: 12px; margin: 10px 0 12px; }
.sh-top { display: flex; gap: 12px; align-items: stretch; }
.sh-coin { flex: 0 0 auto; background: var(--loam); border: 1px solid rgba(232,163,61,.45); border-radius: 10px; padding: 6px 12px; text-align: center; min-width: 84px; }
.sh-coin b { display: block; font: 26px/1.1 var(--fell); color: #f3cf96; font-variant-numeric: tabular-nums; }
.sh-coin span { font-size: 11px; color: var(--dim); }
.sh-kv { display: flex; flex-wrap: wrap; gap: 4px 6px; align-content: center; font-size: 13px; }
.sh-kv span { background: var(--loam); border-radius: 6px; padding: 2px 8px; }
.sh-kv small { color: var(--dim); }
.sh-bars { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; margin: 12px 0 4px; }
.sb { display: grid; grid-template-columns: 88px 1fr 26px; gap: 6px; align-items: center; font-size: 12.5px; }
.sb .sl { white-space: nowrap; }
.sb .track, .sh-act .track { height: 8px; background: var(--loam); border-radius: 4px; overflow: hidden; display: block; }
.sb .fill, .sh-act .fill { display: block; height: 100%; background: var(--moss); border-radius: 4px; transition: width .6s; }
.sb .fill.mid { background: var(--hearth); } .sb .fill.low { background: var(--ember); }
.sb .num, .sh-act .num { text-align: right; color: var(--dim); font-variant-numeric: tabular-nums; font-size: 12px; }
.sh-act { display: grid; grid-template-columns: 1fr 90px 36px; gap: 8px; align-items: center; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--bark-2); font-size: 13.5px; }
.sh-act > span:first-child { color: #f3e3c0; }
.sh-act > span:only-child { grid-column: 1 / -1; }
.sh-act small { color: var(--dim); }
.sh-act .fill { background: var(--hearth); }
.sh-sec { margin-top: 10px; }
.sh-sec h4 { margin: 0 0 5px; font: 700 11px var(--body); color: var(--dim); text-transform: uppercase; letter-spacing: .08em; }
.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 6px; }
.it { position: relative; background: var(--loam); border: 1px solid var(--bark-2); border-radius: 8px; padding: 5px 4px 3px; text-align: center; min-width: 0; }
.it i { display: block; font-style: normal; font-size: 20px; line-height: 1.1; }
.it b { position: absolute; top: 2px; right: 4px; font-size: 11px; color: #f3cf96; font-variant-numeric: tabular-nums; }
.it small { display: block; font-size: 10px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.it.invn { border-color: rgba(176,127,176,.6); }
.it.gear small:first-of-type { color: #f3cf96; }
.skl { display: flex; flex-wrap: wrap; gap: 5px; font-size: 12.5px; }
.skl > span { background: var(--loam); border-radius: 999px; padding: 2px 9px; }
.skl > span.on { color: #f3cf96; }
.skl b { color: #f3cf96; }
.seg.hseg { display: flex; margin: 0 0 6px; }
.seg.hseg button { flex: 1; }
#profHist:empty { display: none; }
#profHist { margin-bottom: 10px; }

#people li.pview { list-style: none; padding: 8px 0 4px; }
#people li.pview .seg { display: flex; width: 100%; }
#people li.pview .seg button { flex: 1; display: block; width: auto; padding: 8px 10px; background: var(--bark); border: 0; border-right: 1px solid var(--bark-2); text-align: center; font-size: 14px; }
#people li.pview .seg button:last-child { border-right: 0; }
#people li.pview .seg button.on { background: var(--hearth); color: var(--loam); font-weight: 700; }
#people li.ptable { list-style: none; }
#people li.ptable h3 { margin-top: 16px; }
.tscroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 6px -14px 6px 0; padding-right: 14px; }
table.stbl { border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; min-width: 100%; }
table.stbl th { position: sticky; top: 0; background: var(--loam); color: var(--dim); font-weight: 400; text-align: left; padding: 6px 6px; white-space: nowrap; cursor: pointer; border-bottom: 1px solid var(--bark-2); }
table.stbl th.on { color: var(--hearth); }
table.stbl td { padding: 7px 6px; border-bottom: 1px solid var(--bark); white-space: nowrap; }
table.stbl tr { cursor: pointer; }
table.stbl tr:active td { background: var(--bark); }
table.stbl td.n { text-align: right; }
table.stbl td.low { color: #f3b3a5; font-weight: 700; } table.stbl td.mid { color: #f3cf96; }
table.stbl td.nm { font-weight: 700; }
table.stbl td.jb { color: #d7ccb7; max-width: 110px; overflow: hidden; text-overflow: ellipsis; }
table.stbl td.dg { color: var(--dim); max-width: 160px; overflow: hidden; text-overflow: ellipsis; }

h4.wh { margin: 14px 0 6px; font: 700 11px var(--body); color: var(--dim); text-transform: uppercase; letter-spacing: .08em; }
h4.wh small { text-transform: none; letter-spacing: 0; font-weight: 400; }
.wgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 560px) { .wgrid { grid-template-columns: repeat(3, 1fr); } }
.wt { background: var(--bark); border-radius: 9px; padding: 8px 10px 4px; min-width: 0; }
.wl { font-size: 12px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wv { font: 24px/1.1 var(--fell); color: var(--linen); font-variant-numeric: tabular-nums; }
.ws { font-size: 11px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
svg.spk { display: block; width: 100%; height: 24px; margin-top: 2px; }

.fsearch { padding: 2px 0 6px; }
.fsearch input { width: 100%; background: var(--bark); border: 1px solid var(--bark-2); border-radius: 999px; padding: 8px 14px; font-size: 15px; }
#feedMore { padding: 12px 0 4px; text-align: center; }
#feedMore .btn { width: 100%; }
#feed .line.place { color: var(--dim); font-size: 12px; margin-top: 2px; }

.chatcard { background: var(--bark); border-radius: 10px; padding: 9px 12px; margin: 8px 0; }
.cc-h { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--dim); margin-bottom: 4px; }
.cc-l { font-size: 14.5px; line-height: 1.45; padding: 2px 0; }
.cc-l.me { color: #fff; }
#profHist > .btn { width: 100%; margin-top: 4px; }
ol.story { list-style: none; margin: 4px 0 0; padding: 0 0 0 14px; border-left: 2px solid var(--bark-2); }
ol.story li { position: relative; padding: 6px 0 8px 4px; font-size: 14px; }
ol.story li::before { content: ''; position: absolute; left: -20px; top: 12px; width: 10px; height: 10px; border-radius: 50%; background: var(--bark-2); border: 2px solid var(--loam); }
ol.story li.big::before { background: var(--hearth); }
ol.story .when { display: block; color: var(--dim); font-size: 11.5px; }
ol.story li.big .tx { color: #fff; }

#npcCard { position: fixed; inset: 0; z-index: 70; background: rgba(20,16,13,.55); display: flex; align-items: flex-end; justify-content: center; }
.nc-box { width: min(520px, 100%); max-height: 78vh; overflow-y: auto; background: var(--bark); border: 1px solid var(--bark-2); border-bottom: 0; border-radius: 16px 16px 0 0; padding: 16px 16px calc(18px + var(--safe-b)); box-shadow: 0 -12px 40px rgba(0,0,0,.45); animation: ncUp .2s ease-out; }
@keyframes ncUp { from { transform: translateY(30px); opacity: .4; } to { transform: none; opacity: 1; } }
.nc-box .qx { float: right; background: none; border: 0; color: var(--dim); font-size: 24px; line-height: 1; }
.nc-head { display: flex; gap: 12px; align-items: center; }
.nc-head .av { width: 46px; height: 46px; font-size: 22px; }
.nc-head h2 { font: 26px/1.1 var(--fell); margin: 0; }
.nc-kv { display: grid; gap: 4px; margin: 12px 0 4px; font-size: 14px; }
.nc-kv > div { display: grid; grid-template-columns: 100px 1fr; gap: 8px; align-items: center; }
.nc-kv > div > span:first-child { color: var(--dim); font-size: 12.5px; }
.nc-box h4 { margin: 12px 0 4px; font: 700 11px var(--body); color: var(--dim); text-transform: uppercase; letter-spacing: .08em; }
details.folk li.tap { cursor: pointer; }
details.folk li.tap:active { background: var(--bark); }

/* politics tab */
.jump { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 10px; }
.ptag { display: inline-block; font-size: 11.5px; border: 1px solid #ffffff30; border-left-width: 4px; border-radius: 6px; padding: 1px 6px; margin-left: 4px; color: var(--dim); }
.pollchart { display: block; background: var(--loam, #2a2118); border-radius: 8px; margin: 4px 0; height: 130px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--dim); margin-bottom: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }

/* population badge (top-left of the map) */
#popBadge { position: absolute; top: 8px; left: 8px; z-index: 5; background: rgba(20,16,12,.72); color: #efe6d2; border: 1px solid rgba(255,255,255,.14); border-radius: 10px; padding: 3px 8px; font: 600 12px/1.35 system-ui, sans-serif; text-align: left; backdrop-filter: blur(3px); max-width: 60%; }
#popBadge .pb-more { display: none; font-weight: 500; font-size: 11.5px; margin-top: 2px; color: #d8ccb4; }
#popBadge.open .pb-more { display: block; }

/* ---------- guinness wave: two villages ---------- */
#tabs { flex-wrap: wrap; }
#townSwitch { display: flex; gap: 6px; }
#townSwitch[hidden] { display: none; }
#townSwitch button { flex: 1; min-width: 0; background: var(--bark); border: 1px solid var(--bark-2); color: var(--dim); border-radius: 999px; padding: 5px 10px; font-size: 14px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#townSwitch button small { display: block; font-size: 11px; opacity: .8; overflow: hidden; text-overflow: ellipsis; }
#townSwitch button.on { background: var(--hearth); border-color: var(--hearth); color: var(--loam); font-weight: 700; }
.townfeed { padding-top: 4px; }
.townfeed[hidden] { display: none; }
#feed .ftown { display: block; font-size: 13px; line-height: 1.1; }
.towns-pick { display: flex; gap: 8px; margin: 4px 0 10px; }
.tpick { flex: 1; text-align: left; background: var(--bark); border: 1px solid var(--bark-2); color: var(--linen); border-radius: 10px; padding: 8px 10px; }
.tpick b { display: block; font-size: 15px; }
.tpick small { display: block; font-size: 12px; color: var(--dim); margin-top: 2px; }
.tpick.on { border-color: var(--hearth); box-shadow: 0 0 0 1px var(--hearth) inset; }
.tpick[disabled] { opacity: .45; }
.godtown { margin: 10px 0 4px; }

/* ---- reclaim + inner voice chat */
.ivrow { gap: 8px; margin: 10px 0; flex-wrap: wrap; }
#ivSheet { position: fixed; inset: 0; z-index: 55; background: rgba(20,16,13,.8); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); display: flex; align-items: flex-end; justify-content: center; }
#ivSheet[hidden] { display: none; }
.ivbox { width: min(560px, 100%); height: min(640px, 88dvh); display: flex; flex-direction: column; background: var(--bark); border: 1px solid var(--bark-2); border-radius: 16px 16px 0 0; padding: 12px 12px max(10px, var(--safe-b)); box-shadow: 0 -10px 40px rgba(0,0,0,.5); }
@media (min-width: 700px) { #ivSheet { align-items: center; } .ivbox { border-radius: 16px; } }
.ivhead { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 8px; border-bottom: 1px solid var(--bark-2); }
.ivhead b { font: 20px/1.2 var(--fell); }
.ivhead .qx { background: none; border: 0; color: var(--dim); font-size: 24px; line-height: 1; }
.ivmsgs { flex: 1; overflow-y: auto; padding: 10px 2px; display: flex; flex-direction: column; gap: 8px; }
.ivempty { text-align: center; margin: auto 12px; font-style: italic; }
.ivb { max-width: 82%; padding: 9px 12px; border-radius: 14px; line-height: 1.35; white-space: pre-wrap; word-wrap: break-word; }
.ivme { align-self: flex-end; background: rgba(232,163,61,.18); border: 1px solid rgba(232,163,61,.35); border-bottom-right-radius: 4px; }
.ivthem { align-self: flex-start; background: var(--loam); border: 1px solid var(--bark-2); border-bottom-left-radius: 4px; font-style: italic; }
.ivdid { font-style: normal; font-size: 13px; color: var(--hearth); margin-top: 4px; }
.ivtyping { display: flex; gap: 4px; padding: 12px 14px; }
.ivtyping span { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); animation: ivdot 1s infinite ease-in-out; }
.ivtyping span:nth-child(2) { animation-delay: .15s; } .ivtyping span:nth-child(3) { animation-delay: .3s; }
@keyframes ivdot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.ivform { display: flex; gap: 8px; align-items: flex-end; padding-top: 8px; border-top: 1px solid var(--bark-2); }
.ivform textarea { flex: 1; resize: none; background: var(--loam); border: 1px solid var(--bark-2); border-radius: 10px; padding: 10px 12px; font-size: 16px; color: inherit; font-family: inherit; }
.ivleft { text-align: center; margin-top: 6px; }

/* =====================================================================================
   Layout v5: side panel on desktop, map + bottom sheet + bottom nav on phones
   ===================================================================================== */
#bar { flex-wrap: nowrap; min-width: 0; }
#townName { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#clock { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#barMenu { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
#barMenu .mlabel, #barMenu .menu-only, #menuBtn, .more-only, #moreMenu { display: none; }
#menuBtn { position: relative; }
#menuBtn.dot::after { content: ''; position: absolute; top: 8px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--hearth); box-shadow: 0 0 0 2px var(--loam); }

/* section tabs: icon over label */
#tabs { flex-wrap: nowrap; gap: 0; }
#tabs button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; line-height: 1.15; }
#tabs .ti { font-size: 17px; line-height: 1.1; filter: grayscale(.65); opacity: .8; }
#tabs .tl { font-size: 12.5px; letter-spacing: .01em; }
#tabs button[aria-selected="true"] .ti { filter: none; opacity: 1; }
#tabs button[aria-selected="true"] .tl { font-weight: 700; }
#tabs .more-only { display: none; }

/* sticky section header inside the panel */
#sheetHead { position: sticky; top: 0; z-index: 4; background: var(--loam); margin: 0 -14px; padding: 8px 14px 8px; border-bottom: 1px solid var(--bark); }
#sheetHead:has(#townSwitch[hidden]) { display: none; }
#grab { display: none; }
.shrow { display: flex; align-items: center; gap: 10px; min-width: 0; }
#secTitle { display: none; font: 22px/1.1 var(--fell); margin: 0; white-space: nowrap; }
.shrow #townSwitch { flex: 1; min-width: 0; }

/* Town / Politics sub-sections */
.subnav { position: sticky; top: var(--shH, 0px); z-index: 3; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; background: var(--loam); margin: 0 -14px; padding: 10px 14px 8px; scroll-behavior: smooth; }
#sheetHead:has(#townSwitch[hidden]) ~ .pane .subnav { top: 0; }
.subnav::-webkit-scrollbar { display: none; }
.subnav::after { content: ''; position: sticky; right: -14px; flex: 0 0 36px; margin-left: -30px; background: linear-gradient(90deg, rgba(35,29,25,0), var(--loam) 85%); pointer-events: none; }
.subnav button { flex: 0 0 auto; background: var(--bark); border: 1px solid var(--bark-2); color: var(--linen); border-radius: 999px; padding: 7px 13px; font-size: 14px; white-space: nowrap; }
.subnav button.on { background: var(--hearth); border-color: var(--hearth); color: var(--loam); font-weight: 700; }
.subsec > h3:first-child, .subsec > .era:first-child { margin-top: 12px; }
h2.subh { font: 24px/1.2 var(--fell); margin: 26px 0 0; padding-top: 12px; border-top: 2px solid var(--bark-2); color: #f3e3c0; }
.subsec:first-of-type h2.subh { border-top: 0; margin-top: 8px; }
.subsec h3 { scroll-margin-top: 110px; }
details > summary { min-height: 32px; display: list-item; padding: 4px 0; }
.filters { scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filters .chip { flex: 0 0 auto; white-space: nowrap; }
@media (min-width: 821px) { .filters { flex-wrap: wrap; overflow: visible; } }

/* people list + profile */
#people li button { padding: 12px 4px; border-radius: 8px; }
#people li button:hover { background: rgba(255,255,255,.025); }
.back { position: sticky; top: var(--shH, 0px); z-index: 3; background: var(--loam); width: calc(100% + 28px); margin: 0 -14px; padding: 10px 14px; text-align: left; font-size: 15px; min-height: 44px; border-bottom: 1px solid var(--bark); }
#sheetHead:has(#townSwitch[hidden]) ~ .pane .back { top: 0; }
.ivrow .btn { min-height: 44px; }
#toast { z-index: 90; }

/* ------------------------------------------------------------------ desktop / tablet landscape */
@media (min-width: 821px) {
  #app { grid-template-columns: minmax(0, 1fr) 420px; grid-template-rows: auto auto minmax(0, 1fr); max-width: 1600px; }
  #bar { grid-column: 1 / -1; padding: max(10px, env(safe-area-inset-top)) 18px 10px; gap: 14px; }
  #stage { grid-row: 2 / 4; margin: 0 0 16px 16px; border-radius: 12px; overflow: hidden; height: auto; min-height: 0; box-shadow: 0 6px 24px rgba(0,0,0,.3); }
  #map3d, #map { width: 100%; height: 100%; aspect-ratio: auto; }
  #tabs { grid-column: 2; margin: 0 16px 0 16px; position: static; border-bottom: 1px solid var(--bark-2); }
  #tabs button { padding: 8px 2px 7px; }
  #panel { grid-column: 2; margin: 0 16px 0 16px; padding: 0 16px calc(28px + var(--safe-b)); background: rgba(47,38,33,.35); border-radius: 0 0 12px 12px; min-height: 0; }
  #sheetHead { margin: 0 -16px; padding: 10px 16px; }
  .subnav { margin: 0 -16px; padding: 10px 16px 8px; }
  .back { width: calc(100% + 32px); margin: 0 -16px; padding: 10px 16px; }
  .pane { max-width: none; }
  #feed li { padding: 11px 2px; }
}
@media (min-width: 1280px) { #app { grid-template-columns: minmax(0, 1fr) 470px; } }
/* touch screens in the wide layout (landscape phones, tablets): bigger header taps */
@media (min-width: 821px) and (pointer: coarse) { #bar .chip { min-height: 44px; padding: 6px 14px; } #townSwitch button { min-height: 44px; } #tabs button { min-height: 50px; } }

/* ------------------------------------------------------------------ phones */
@media (max-width: 820px) {
  html, body { overflow: hidden; overscroll-behavior: none; }
  body { font-size: 15.5px; }
  #app { display: block; height: 100dvh; }
  /* compact header: town, day/time, one menu button */
  #bar { position: fixed; top: 0; left: 0; right: 0; z-index: 30; gap: 8px; padding: max(4px, env(safe-area-inset-top)) 4px 4px 14px; background: var(--loam); border-bottom: 1px solid var(--bark); }
  #townName { font-size: 23px; flex: 0 1 auto; }
  #clock { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; font-size: 12px; flex: 0 1 auto; }
  #clock #day { max-width: 46vw; overflow: hidden; text-overflow: ellipsis; }
  #time { font-size: 15px; font-weight: 700; }
  #menuBtn { display: grid; place-items: center; flex: 0 0 auto; width: 46px; height: 46px; border: 0; border-radius: 12px; background: none; color: var(--linen); font-size: 22px; }
  #menuBtn[aria-expanded="true"] { background: var(--bark); }
  #barMenu { display: none; position: fixed; top: calc(var(--topH, 56px) + 4px); right: 8px; z-index: 45; flex-direction: column; align-items: stretch; gap: 6px; width: min(300px, calc(100vw - 16px)); padding: 10px; background: var(--bark); border: 1px solid var(--bark-2); border-radius: 14px; box-shadow: 0 14px 40px rgba(0,0,0,.55); }
  #barMenu.open { display: flex; }
  #barMenu .chip { min-height: 46px; border-radius: 10px; padding: 10px 14px; font-size: 15px; text-align: left; background: var(--loam); }
  #barMenu .chip.join { background: var(--hearth); }
  #barMenu .mlabel, #barMenu .menu-only { display: inline; }
  #barMenu .chip[hidden] { display: none; }

  /* the map fills the space above the sheet */
  #stage { position: fixed; left: 0; right: 0; top: var(--topH, 56px); height: var(--mapH, 45vh); z-index: 1; overflow: hidden; }
  #map3d, #map { width: 100%; height: 100%; aspect-ratio: auto; }
  #mapCtl { right: 8px; top: 8px; grid-template-columns: repeat(2, 42px); direction: rtl; }
  #mapCtl > * { direction: ltr; }
  #mapCtl button { width: 42px; height: 42px; border-radius: 10px; }
  #banner { bottom: 26px; font-size: 12.5px; }
  #conn { bottom: 26px; }
  #popBadge { font-size: 12.5px; padding: 5px 9px; }

  /* bottom navigation */
  #tabs { position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 35; border-top: 1px solid var(--bark-2); border-bottom: 0; background: #1d1815; padding: 0 4px var(--safe-b); box-shadow: 0 -4px 18px rgba(0,0,0,.35); }
  #tabs button { flex: 1 1 0; min-height: 58px; padding: 6px 2px 5px; border-bottom: 0; border-top: 3px solid transparent; }
  #tabs button[aria-selected="true"] { border-top-color: var(--hearth); color: var(--linen); }
  #tabs .ti { font-size: 21px; }
  #tabs .tl { font-size: 11.5px; }
  #tabs button.extra { display: none; }
  #tabs .more-only { display: flex; }
  #moreMenu:not([hidden]) { display: grid; position: fixed; right: 8px; bottom: calc(var(--navH2, 62px) + 8px); z-index: 45; width: min(290px, calc(100vw - 16px)); gap: 4px; padding: 8px; background: var(--bark); border: 1px solid var(--bark-2); border-radius: 14px; box-shadow: 0 14px 40px rgba(0,0,0,.55); }
  #moreMenu button { display: flex; align-items: center; gap: 12px; min-height: 54px; padding: 8px 12px; text-align: left; font-size: 22px; background: none; border: 1px solid transparent; border-radius: 10px; color: var(--linen); }
  #moreMenu button span { display: grid; font-size: 15.5px; line-height: 1.2; }
  #moreMenu button small { color: var(--dim); font-size: 12.5px; }
  #moreMenu button.on { border-color: var(--hearth); background: rgba(232,163,61,.12); }

  /* the sheet */
  #panel { position: fixed; left: 0; right: 0; bottom: var(--navH2, 62px); height: var(--sheetH, 50vh); z-index: 20; background: var(--loam); border-radius: 18px 18px 0 0; box-shadow: 0 -8px 30px rgba(0,0,0,.45); padding: 0 14px 28px; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; }
  body.sheet-anim #panel { transition: height .24s cubic-bezier(.2,.8,.2,1); }
  #sheetHead, #sheetHead:has(#townSwitch[hidden]) { display: block; padding: 0 14px 8px; border-radius: 18px 18px 0 0; touch-action: none; }
  #grab { display: block; width: 100%; height: 20px; border: 0; background: none; padding: 0; cursor: grab; }
  #grab span { display: block; width: 44px; height: 5px; margin: 7px auto 0; border-radius: 3px; background: #5a4a3f; }
  #secTitle { display: block; font-size: 22px; flex: 0 0 auto; cursor: pointer; }
  .shrow { min-height: 44px; }
  #townSwitch button { min-height: 44px; padding: 4px 8px; font-size: 13.5px; }
  #townSwitch button small { font-size: 10.5px; }
  .subnav, #sheetHead:has(#townSwitch[hidden]) ~ .pane .subnav { top: var(--shH, 0px); }
  #sheetHead:has(#townSwitch[hidden]) ~ .pane .back { top: var(--shH, 0px); }
  .subnav button { min-height: 44px; padding: 8px 14px; font-size: 14.5px; }
  body[data-sheet="peek"] #panel { overflow: hidden; }
  body[data-sheet="peek"] .pane { opacity: .55; }

  /* comfier content on small screens */
  .pane { max-width: none; }
  .chip { min-height: 36px; padding: 6px 13px; font-size: 14px; }
  .filters { padding: 8px 0 6px; scrollbar-width: none; }
  .filters .chip { flex: 0 0 auto; }
  .fsearch input { font-size: 16px; padding: 10px 14px; }
  .btn { min-height: 44px; }
  input[type=text], input[type=password], input[type=number], select, textarea { font-size: 16px; }
  #feed li { grid-template-columns: 42px minmax(0, 1fr); }
  #feed li.big { margin-left: -10px; }
  .hint { font-size: 13.5px; }
  .stock { grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); }
  .bar, .rel { grid-template-columns: minmax(80px, 34%) minmax(0, 1fr) 40px; }
  .sh-bars { grid-template-columns: 1fr; }
  .sh-top { flex-wrap: wrap; }
  .ledger { grid-template-columns: 1fr; }
  .pane table:not(.stbl) { display: block; max-width: 100%; overflow-x: auto; }
  .offices td:first-child { width: auto; }
  .phead h2 { font-size: 27px; }
  .mind blockquote { font-size: 18px; }
  .paper h2 { font-size: 26px; }
  .paper p { font-size: 17px; }
  .clancard { padding: 11px 12px; }
  .tscroll { margin-right: -14px; }
  .events { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  #people li button { grid-template-columns: 38px minmax(0, 1fr) auto; }
  #toast { bottom: calc(var(--navH2, 62px) + 12px); }

  /* full-screen map sits above everything */
  body.mapfull #stage { top: 0; height: 100dvh; }
  body.mapfull #mapCtl { grid-template-columns: repeat(2, 44px); }
}
@media (max-width: 360px) { #townName { font-size: 20px; } #clock #day { max-width: 40vw; } #tabs .tl { font-size: 10.5px; } }
