:root {
  --ink: #f3ede1; --ink2: #c9c0ad; --muted: #968d7c; --panel: rgba(22, 20, 17, 0.72); --panel2: rgba(34, 31, 26, 0.85); --line: rgba(255, 240, 210, 0.12);
  --accent: #e6b35a; --good: #8cc084; --bad: #e0795f; --water: #7fb3d5;
  --serif: 'Fraunces', Georgia, serif; --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; touch-action: none; background: #0e0d0b; color: var(--ink); font: 13px/1.45 var(--sans); }
#view { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; }
button { font: inherit; color: var(--ink); background: rgba(255, 255, 255, 0.07); border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; cursor: pointer; transition: background .15s; }
button:hover { background: rgba(255, 255, 255, 0.14); }
button.on { background: var(--accent); color: #1b1611; border-color: transparent; }
a { color: var(--accent); cursor: pointer; text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }

#top { position: fixed; top: calc(10px + env(safe-area-inset-top)); left: 12px; right: 12px; display: flex; align-items: center; gap: 12px; padding: 7px 8px 7px 14px; background: var(--panel); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid var(--line); border-radius: 16px; z-index: 5; box-shadow: 0 6px 24px rgba(0,0,0,.18); }
#top .brand { display: flex; align-items: center; gap: 8px; font-family: var(--serif); font-size: 17px; letter-spacing: .2px; white-space: nowrap; }
#top .brand .sub { font-family: var(--sans); font-size: 12px; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); display: inline-block; flex: none; }
.dot.live { background: #6fd07a; box-shadow: 0 0 0 0 rgba(111, 208, 122, .7); animation: pulse 2s infinite; }
.dot.reconnecting { background: var(--bad); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(111, 208, 122, .6); } 70% { box-shadow: 0 0 0 8px rgba(111, 208, 122, 0); } 100% { box-shadow: 0 0 0 0 rgba(111, 208, 122, 0); } }
#top .chips { margin-left: auto; display: flex; gap: 6px; min-width: 0; }
.chip { font-variant-numeric: tabular-nums; white-space: nowrap; padding: 4px 10px; border-radius: 20px; background: rgba(255,255,255,.06); color: var(--ink2); font-size: 12.5px; }
#clock.chip { color: var(--ink); }
#actions { position: fixed; top: calc(17px + env(safe-area-inset-top)); right: 20px; z-index: 6; display: flex; gap: 4px; }
#top { padding-right: 385px; }
#actions button { display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 11px; border-radius: 11px; }
#actions button i { font-style: normal; font-size: 14px; line-height: 1; }

#cast { touch-action: pan-x; position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden; padding: 8px; background: var(--panel); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid var(--line); border-radius: 18px; z-index: 4; scrollbar-width: none; scroll-snap-type: x proximity; box-shadow: 0 6px 24px rgba(0,0,0,.2); }
#cast::-webkit-scrollbar { display: none; }
.person { flex: none; width: 188px; display: grid; grid-template-columns: 60px 1fr; gap: 9px; align-items: center; padding: 6px 10px 6px 6px; border-radius: 14px; background: rgba(255,255,255,.04); cursor: pointer; scroll-snap-align: start; border: 1px solid transparent; transition: background .15s, border-color .15s, transform .15s; }
.person:hover { background: rgba(255,255,255,.08); }
.person.sel { border-color: var(--accent); background: rgba(230,179,90,.14); }
.person.dead { opacity: .45; filter: grayscale(.7); }
.person .pic { position: relative; width: 60px; height: 60px; }
.person .pic img, .person .pic svg { width: 60px; height: 60px; border-radius: 13px; display: block; object-fit: cover; box-shadow: 0 2px 8px rgba(0,0,0,.35), inset 0 0 0 1px rgba(255,255,255,.1); }
.person .pic .mood { position: absolute; right: -3px; bottom: -3px; width: 18px; height: 18px; border-radius: 50%; background: #2a2620; display: grid; place-items: center; font-size: 11px; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.person .who { min-width: 0; }
.person .nm { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person .age { color: var(--muted); font-weight: 400; font-size: 11px; margin-left: 3px; }
.person .act { font-size: 11.5px; color: var(--ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.person .mini { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; margin-top: 5px; }
.person .ai { display: inline-block; font-size: 9.5px; padding: 0 5px; margin-left: 4px; border-radius: 6px; background: rgba(140,192,132,.25); color: #cfe8c8; vertical-align: 1px; }
.portrait, .ipic { border-radius: 12px; flex: none; }
.ipic { width: 58px; height: 58px; object-fit: cover; box-shadow: 0 2px 8px rgba(0,0,0,.35); }
.bar { height: 5px; background: rgba(255, 255, 255, 0.08); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 3px; background: var(--ink2); }
.bar.hunger i { background: #d9a05b; } .bar.thirst i { background: var(--water); } .bar.energy i { background: #b9a4e0; } .bar.warmth i { background: #e0795f; }
.bar.social i { background: #e6c96a; } .bar.mood i { background: #8cc084; } .bar.health i { background: #d65d5d; } .bar.skill i { background: var(--accent); } .bar.trait i { background: #8aa7c9; }

#inspector { position: fixed; top: 74px; right: 12px; width: 360px; max-height: calc(100vh - 74px - 112px); overflow-y: auto; background: var(--panel2); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid var(--line); border-radius: 14px; z-index: 4; scrollbar-width: thin; }
.ihead { display: flex; gap: 10px; align-items: center; padding: 12px 12px 8px; position: sticky; top: 0; background: var(--panel2); z-index: 1; }
.ihead .nm { font-family: var(--serif); font-size: 19px; }
.ihead .btns { margin-left: auto; display: flex; gap: 6px; }
.sicon { font-size: 28px; width: 52px; text-align: center; }
.tabs { display: flex; gap: 4px; padding: 0 12px 8px; }
.tabs button { flex: 1; padding: 4px; font-size: 12px; }
.ibody { padding: 0 14px 14px; }
.thought { font-family: var(--serif); font-size: 15.5px; line-height: 1.4; padding: 10px 12px; background: rgba(255, 255, 255, 0.05); border-left: 3px solid var(--accent); border-radius: 4px 10px 10px 4px; margin-bottom: 10px; }
.kv { margin: 5px 0; color: var(--ink2); }
.kv b { color: var(--ink); font-weight: 600; margin-right: 4px; }
.sec { margin: 14px 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.sec.clickable { cursor: pointer; }
.needs { display: grid; grid-template-columns: 90px 1fr; gap: 5px 10px; align-items: center; }
.needs label { color: var(--ink2); font-size: 12px; text-transform: capitalize; }
.needs .bar { height: 7px; }
.weigh div { display: grid; grid-template-columns: 1fr 90px; align-items: center; gap: 8px; font-size: 12px; color: var(--ink2); margin: 3px 0; }
.weigh i { height: 5px; background: var(--accent); border-radius: 3px; display: block; opacity: .8; }
.rels div, .beliefs div { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; border-bottom: 1px solid var(--line); }
.beliefs em { font-style: normal; color: var(--ink2); font-size: 12px; }
.aff { color: var(--muted); font-size: 12px; } .aff.pos { color: var(--good); } .aff.neg { color: var(--bad); }
.mem div { padding: 4px 0; border-bottom: 1px solid var(--line); color: var(--ink2); }
.mem .collapse, .mem .grief { color: #f0a58f; } .mem .achievement, .mem .learning { color: #b7dca9; }
.when { color: var(--muted); font-size: 11px; margin-right: 6px; font-variant-numeric: tabular-nums; }
.tags { display: flex; flex-wrap: wrap; gap: 5px; }
.tags span { background: rgba(255, 255, 255, 0.07); border: 1px solid var(--line); padding: 2px 8px; border-radius: 20px; font-size: 12px; }
.progress { position: relative; height: 22px; background: rgba(255, 255, 255, 0.07); border-radius: 8px; overflow: hidden; margin: 4px 0 8px; }
.progress i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #a07a3e, var(--accent)); }
.progress span { position: relative; padding: 0 10px; line-height: 22px; font-size: 12px; }
.perf { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.perf div { background: rgba(255, 255, 255, 0.05); border-radius: 10px; padding: 8px 4px; text-align: center; }
.perf b { display: block; font-family: var(--serif); font-size: 18px; }
.perf span { font-size: 10.5px; color: var(--muted); }
.prog { padding: 6px 0; border-bottom: 1px solid var(--line); color: var(--ink2); }
.prog b { color: var(--ink); }
pre.code { display: none; max-height: 260px; overflow: auto; background: rgba(0, 0, 0, 0.35); padding: 8px; border-radius: 8px; font-size: 10.5px; color: #cfe0c3; white-space: pre-wrap; }
pre.code.open { display: block; }

#chronicle { position: fixed; left: 12px; top: 74px; width: 340px; max-height: calc(100vh - 74px - 124px); display: flex; flex-direction: column; background: var(--panel); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: 14px; z-index: 4; }
#chronicle .head { font-family: var(--serif); font-size: 14px; padding: 8px 8px 6px 12px; display: flex; justify-content: space-between; color: var(--ink2); cursor: default; align-items: center; }
#chronicle .x, .ihead .x { border: 0; background: transparent; padding: 2px 6px; color: var(--muted); }
#chronicle.closed { display: none; }
#chronicle .list { overflow-y: auto; padding: 0 10px 8px; scrollbar-width: thin; }
#chronicle.collapsed .list { display: none; }
.ev { padding: 4px 0; border-bottom: 1px solid var(--line); color: var(--ink2); cursor: pointer; }
.ev:hover { color: var(--ink); }
.ev.fresh { animation: flash 2.5s ease-out; }
.ev.collapse, .ev.death { color: #f0a58f; } .ev.build { color: #e8d2a0; } .ev.learning { color: #b7dca9; } .ev.plan { color: #d9c9ef; }
@keyframes flash { from { background: rgba(230, 179, 90, 0.25); } to { background: transparent; } }

#labels { position: fixed; inset: 0; pointer-events: none; z-index: 3; overflow: hidden; }
.label { position: absolute; left: 0; top: 0; display: flex; flex-direction: column; align-items: center; gap: 3px; pointer-events: auto; cursor: pointer; will-change: transform; }
.label .tag { font-size: 11px; padding: 1px 7px; border-radius: 10px; background: rgba(15, 13, 10, 0.55); color: var(--ink); white-space: nowrap; }
.label .tag.sel { background: var(--accent); color: #1b1611; }
.label .say { max-width: 220px; font-size: 12px; padding: 5px 9px; background: rgba(250, 244, 230, 0.94); color: #2a2218; border-radius: 12px 12px 12px 3px; box-shadow: 0 4px 14px rgba(0, 0, 0, .25); }

#loading { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(ellipse at center, #22201b, #0e0d0b); z-index: 10; transition: opacity .8s; }
#loading.gone { opacity: 0; pointer-events: none; }
#loading .t { font-family: var(--serif); font-size: 24px; text-align: center; }
#loading .s { color: var(--muted); text-align: center; margin-top: 6px; }

.modal { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, 0.5); z-index: 20; padding: 16px; }
.modal .card { position: relative; display: block; max-width: 560px; max-height: 86vh; overflow-y: auto; background: #1d1b17; border: 1px solid var(--line); border-radius: 16px; padding: 20px 24px; cursor: default; }
.modal h2 { font-family: var(--serif); margin: 0 0 8px; }
.modal h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); margin: 16px 0 4px; }
.modal p, .modal li { color: var(--ink2); }
.modal .close-x { position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; padding: 0; border-radius: 50%; font-size: 14px; }

@media (max-width: 760px) {
  #top { top: calc(8px + env(safe-area-inset-top)); left: 8px; right: 8px; gap: 8px; padding: 6px 6px 6px 12px; border-radius: 14px; }
  #top .brand { font-size: 15px; }
  #top .brand .sub { display: none; }
  #top .chips { gap: 4px; }
  .chip { padding: 3px 8px; font-size: 12px; }
  #top { padding-right: 12px; }
  #actions { top: calc(62px + env(safe-area-inset-top)); right: 8px; flex-direction: column; gap: 8px; }
  #actions button { width: 42px; height: 42px; padding: 0; justify-content: center; border-radius: 50%; background: var(--panel); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); box-shadow: 0 3px 12px rgba(0,0,0,.25); }
  #actions button.on { background: var(--accent); }
  #actions button span { display: none; }
  #actions button i { font-size: 17px; }
  #clock .season, #weather .wind { display: none; }
  #top .chips { margin-left: auto; }
  #cast { left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); padding: 6px; gap: 6px; border-radius: 16px; }
  .person { width: 158px; grid-template-columns: 50px 1fr; gap: 7px; padding: 5px 8px 5px 5px; }
  .person .pic, .person .pic img, .person .pic svg { width: 50px; height: 50px; }
  #chronicle { top: auto; left: 8px; right: 8px; width: auto; bottom: calc(96px + env(safe-area-inset-bottom)); max-height: 42vh; }
  #chronicle:not(.open) { display: none; }
  #inspector { top: auto; bottom: calc(96px + env(safe-area-inset-bottom)); left: 8px; right: 8px; width: auto; max-height: 50vh; z-index: 7; }
}
@media (max-width: 360px) { #top .brand b { display: none; } }
@media (max-width: 1100px) and (min-width: 761px) { #top .brand .sub { display: none; } #actions button span { display: none; } #actions button { width: 36px; padding: 0; justify-content: center; } #top { padding-right: 230px; } }

#freshness { position: fixed; top: 112px; left: 50%; transform: translateX(-50%); z-index: 6; padding: 6px 14px; border-radius: 20px; background: rgba(120, 40, 30, 0.9); color: #fff; font-weight: 600; font-size: 12.5px; }
.dot.catching { background: var(--accent); }
body.stale #view { filter: grayscale(0.6) brightness(0.8); transition: filter .6s; }
body.stale #clock { opacity: .5; }

#fps { position: fixed; left: 8px; bottom: 8px; z-index: 50; font: 12px ui-monospace, monospace; color: #fff; background: rgba(0,0,0,.55); padding: 2px 6px; border-radius: 4px; pointer-events: none; }

/* Panels that scroll keep vertical scrolling; nothing zooms the page. */
#chronicle .list, #inspector, .modal .card { touch-action: pan-y; }

/* ideas, origins and made things */
.origin { display: inline-block; font-size: 10.5px; padding: 1px 7px; border-radius: 10px; margin-left: 4px; vertical-align: 1px; border: 1px solid var(--line); color: var(--ink2); }
.origin.proc { background: rgba(120, 170, 255, .12); }
.origin.social { background: rgba(140, 220, 150, .14); }
.origin.model { background: rgba(230, 170, 90, .16); }
.origin.fixture { background: rgba(255, 110, 110, .14); }
.idea { margin: 8px 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.03); }
.idea.dropped { opacity: .6; }
.idea.solved { border-color: rgba(140, 220, 150, .45); }
.waiting { margin-top: 6px; font-size: 12px; color: #e8c88a; }
.waiting code, .rule b { font-family: ui-monospace, monospace; font-size: 11.5px; }
.rule { margin: 6px 0; font-size: 12.5px; }

/* speech bubbles: what villagers actually say, with how they feel */
.label .say { position: relative; display: flex; align-items: flex-start; gap: 5px; max-width: 230px; font: 500 13px/1.35 var(--sans); padding: 6px 11px 7px; margin-bottom: 5px; background: rgba(252, 247, 236, 0.97); color: #251d13; border-radius: 14px; box-shadow: 0 4px 16px rgba(0, 0, 0, .3); text-wrap: pretty; }
.label .say::after { content: ''; position: absolute; left: 50%; bottom: -6px; margin-left: -6px; border: 6px solid transparent; border-bottom: 0; border-top-color: rgba(252, 247, 236, 0.97); }
.label .say i { font-style: normal; font-size: 15px; line-height: 1.2; flex: none; }
.label .say.pop { animation: saypop .28s cubic-bezier(.3, 1.5, .6, 1); transform-origin: 50% 100%; }
@keyframes saypop { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
@media (max-width: 760px) { .label .say { max-width: 180px; font-size: 12.5px; padding: 5px 9px 6px; } }

/* daily recap: yesterday's most notable chronicle entries */
#recap { position: fixed; top: 74px; left: 50%; transform: translateX(-50%); width: min(430px, calc(100vw - 24px)); z-index: 6; background: var(--panel2); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .3); animation: recapin .4s ease-out; touch-action: pan-y; }
#recap.hidden { display: none; }
#recap .head { display: flex; justify-content: space-between; align-items: center; padding: 8px 8px 2px 14px; font-family: var(--serif); font-size: 15px; }
#recap .head b { font-weight: 650; color: var(--accent); }
#recap .head .muted { font-family: var(--sans); font-size: 12px; }
#recap .x { border: 0; background: transparent; color: var(--muted); width: 34px; height: 34px; padding: 0; border-radius: 50%; }
#recap ul { list-style: none; margin: 0; padding: 2px 8px 8px; }
#recap li { display: flex; gap: 9px; align-items: baseline; padding: 6px; border-radius: 8px; color: var(--ink2); line-height: 1.35; }
#recap li i { font-style: normal; flex: none; width: 18px; text-align: center; }
#recap li.go { cursor: pointer; }
#recap li.go:hover, #recap li.go:active { background: rgba(255, 255, 255, .07); color: var(--ink); }
@keyframes recapin { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; transform: translateX(-50%); } }
@media (max-width: 760px) { #recap { top: calc(62px + env(safe-area-inset-top)); left: 8px; right: 58px; width: auto; transform: none; animation: none; max-height: 46vh; overflow-y: auto; } #recap li { padding: 7px 4px; font-size: 13px; } }

/* ---- site: welcome card, cost meter, donate (client/ui/site.js) ---- */
@media (min-width: 1101px) { #top { padding-right: 480px; } }
@media (max-width: 1100px) and (min-width: 761px) { #top { padding-right: 230px; } }
.site-modal .card { max-width: 440px; width: 100%; padding: 20px 20px 18px; }
.site-modal h2 { padding-right: 36px; font-size: 22px; line-height: 1.25; }
.site-modal p { font-size: 14px; margin: 0 0 10px; }
.site-modal b { color: var(--ink); }
.site-modal .row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: 14px; }
.site-modal .row a { font-size: 14px; }
.site-modal .go { background: var(--accent); color: #1b1611; border-color: transparent; font-weight: 600; padding: 9px 16px; border-radius: 10px; }
.site-modal .donate { display: inline-block; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--accent); color: var(--accent); font-weight: 600; }
.site-modal .donate:hover { background: rgba(230, 179, 90, .12); text-decoration: none; }
.costs { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 12px 0; font-size: 14px; font-variant-numeric: tabular-nums; }
.costs dt { color: var(--muted); }
.costs dd { margin: 0; color: var(--ink); }
.site-modal .meter { height: 10px; border-radius: 6px; background: rgba(255, 255, 255, .08); overflow: hidden; margin: 12px 0 6px; }
.site-modal .meter i { display: block; height: 100%; background: var(--good); border-radius: 6px; }
.site-modal .covered { color: var(--ink2); }
@media (max-width: 760px) { .site-modal { place-items: end center; padding: 10px; } .site-modal .card { max-height: 82vh; border-radius: 16px; } }

/* Preview label beside the name, shown until the full launch (Kyle, Sept 30). */
.preview-tag { font-family: var(--sans); font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #1b1611; background: var(--accent); padding: 2px 7px; border-radius: 6px; }
