@font-face {
  font-family: 'Lilita One';
  src: url('vendor/fonts/lilita-one-latin.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Nunito';
  src: url('vendor/fonts/nunito-latin.woff2') format('woff2');
  font-weight: 200 1000;
  font-display: swap;
}
@font-face {
  font-family: 'Fredoka';
  src: url('vendor/fonts/fredoka-latin.woff2') format('woff2');
  font-weight: 300 700;
  font-display: swap;
}
:root {
  --ink: #3b2416;
  --paper: #fff8ec;
  --paper2: #fdf0da;
  --muted: #8a6f5c;
  --accent: #e07a1f;
  --warm: #f6b26b;
  --teal: #2a9d8f;
  --line: #ead9c3;
  --shadow: 0 4px 0 rgba(59, 36, 22, 0.28), 0 8px 22px rgba(59, 36, 22, 0.18);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #9fd8f5; }
body { font: 600 15px/1.45 'Nunito', ui-rounded, system-ui, sans-serif; color: var(--ink); -webkit-tap-highlight-color: transparent; user-select: none; }
canvas#world { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; outline: none; }
button { font: inherit; color: inherit; }

.card { background: var(--paper); border: 2.5px solid var(--ink); border-radius: 18px; box-shadow: var(--shadow); }
.hud { position: fixed; z-index: 5; }
.tl { top: max(12px, env(safe-area-inset-top)); left: 12px; }
.tc { top: max(10px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.tr { top: max(12px, env(safe-area-inset-top)); right: 12px; display: flex; gap: 8px; align-items: center; }
.bc { bottom: max(16px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); }

#minimap { width: 110px; height: 110px; border-radius: 50%; border: 2.5px solid var(--ink); box-shadow: var(--shadow); background: #b7e3a0; }

.needs { padding: 6px 12px 8px; display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; align-items: center; }
.who { display: flex; gap: 6px; align-items: center; }
.tag { font-weight: 600; font-size: 0.78rem; background: var(--paper2); border: 2px solid var(--ink); border-radius: 999px; padding: 0 8px; }
.tag.pip { background: #e9e6ee; }
.lvl { font-size: 0.72rem; color: var(--muted); white-space: nowrap; }
.bars { display: flex; gap: 10px; }
.bar { display: flex; flex-direction: column; gap: 2px; min-width: 62px; }
.bar label { font-size: 0.74rem; display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.bar label i { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--ink); display: inline-block; }
.bar .track { height: 7px; border-radius: 6px; background: #efe2cc; border: 1.5px solid var(--ink); overflow: hidden; }
.bar .fill { height: 100%; border-radius: 4px; transition: width 1s; }
.bars.small .track { height: 5px; }
.bars.small label { display: none; }
.who.small { opacity: 0.85; }

.whatson { background: #2b1a10; color: #fff3dc; font-size: 0.82rem; padding: 5px 14px; border-radius: 10px; max-width: min(560px, 92vw); box-shadow: var(--shadow); font-style: italic; }
.whatson::before { content: '● '; color: #c77dff; font-style: normal; }

.chip { background: #3d3a6b; color: #fff; border-radius: 999px; padding: 6px 12px; font-weight: 600; box-shadow: var(--shadow); }
.pill { border: 2.5px solid var(--ink); border-radius: 999px; padding: 8px 16px; background: var(--paper); cursor: pointer; font-weight: 600; box-shadow: var(--shadow); }
.pill.warm { background: var(--warm); }
.pill:active { transform: translateY(2px); }
.round { width: 44px; height: 44px; border-radius: 50%; border: 2.5px solid var(--ink); background: var(--paper); font-size: 1.15rem; cursor: pointer; box-shadow: var(--shadow); }
.round.small { width: 36px; height: 36px; font-size: 0.95rem; box-shadow: none; }
.link { background: none; border: 0; color: #6a4fbf; text-decoration: underline; cursor: pointer; padding: 0; font-size: 0.88rem; }
.muted { color: var(--muted); font-size: 0.88em; }

.now { position: fixed; z-index: 5; left: 12px; top: 140px; width: min(290px, calc(100vw - 24px)); padding: 10px 14px 12px; }
.now .x { position: absolute; right: 8px; top: 6px; border: 2px solid var(--ink); background: var(--paper); border-radius: 50%; width: 24px; height: 24px; line-height: 16px; cursor: pointer; }
.now.min > *:not(.dot-label):not(.x) { display: none; }
.dot-label { font-size: 0.75rem; color: var(--muted); }
.dot-label i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #9b5de5; margin-right: 4px; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }
.now h3 { margin: 2px 0 4px; font-size: 1.05rem; }
.italic { font-style: italic; margin: 0 0 6px; font-size: 0.9rem; }
.thought { margin: 0 0 6px; color: var(--teal); font-size: 0.9rem; }
.thought:not(:empty)::before { content: ''; }
.recent { font-size: 0.8rem; color: var(--muted); border-top: 1.5px dashed var(--line); padding-top: 6px; margin-bottom: 4px; }
.recent div { margin: 2px 0; }

.finder { display: flex; gap: 8px; align-items: center; max-width: 92vw; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.arrow { display: inline-block; color: var(--accent); transition: transform 0.25s linear; }

.bubble { position: fixed; z-index: 4; max-width: min(260px, 70vw); padding: 7px 12px; font-size: 0.88rem; background: #fff; border: 2.5px solid var(--ink); border-radius: 14px; transform: translate(-50%, -100%); pointer-events: none; box-shadow: 0 3px 0 rgba(59,36,22,0.25); }
.bubble::after { content: ''; position: absolute; left: 50%; bottom: -10px; border: 8px solid transparent; border-top-color: var(--ink); border-bottom: 0; transform: translateX(-50%); }

.prompt { position: fixed; z-index: 6; left: 50%; bottom: 76px; transform: translateX(-50%); font-weight: 700; padding: 10px 18px; border-radius: 999px; border: 2.5px solid var(--ink); background: var(--paper); cursor: pointer; box-shadow: var(--shadow); }
.prompt kbd { background: var(--accent); color: #fff; border-radius: 6px; padding: 1px 7px; margin-right: 4px; font: inherit; }
.help { position: fixed; z-index: 3; left: 50%; bottom: 130px; transform: translateX(-50%); background: rgba(43,26,16,0.75); color: #fff; padding: 6px 14px; border-radius: 999px; font-size: 0.82rem; transition: opacity 1.2s; text-align: center; max-width: calc(100vw - 32px); }
.help.fade { opacity: 0; pointer-events: none; }
.help .touch { display: none; }
.joystick { display: none; position: fixed; z-index: 6; left: 22px; bottom: max(22px, env(safe-area-inset-bottom)); width: 120px; height: 120px; border-radius: 50%; background: rgba(255,255,255,0.25); border: 2.5px solid rgba(255,255,255,0.7); touch-action: none; }
.joystick .knob { position: absolute; left: 35px; top: 35px; width: 50px; height: 50px; border-radius: 50%; background: var(--paper); border: 2.5px solid var(--ink); }

.panel { position: fixed; z-index: 10; right: 14px; top: 70px; bottom: 14px; width: min(480px, calc(100vw - 28px)); background: var(--paper); border: 3px solid var(--ink); border-radius: 20px; display: flex; flex-direction: column; box-shadow: var(--shadow); user-select: text; }
.panel header { display: flex; gap: 8px; align-items: center; padding: 10px; border-bottom: 2px solid var(--line); }
.panel header h2 { margin: 0 0 0 6px; flex: 1; font-size: 1.15rem; }
#tabs { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
#tabs button { font-size: 0.82rem; padding: 3px 10px; border-radius: 999px; border: 2px solid var(--line); background: #fff; cursor: pointer; }
#tabs button[aria-selected='true'] { background: var(--accent); border-color: var(--ink); color: #fff; }
.panel-body { overflow-y: auto; padding: 6px 18px 18px; }
.panel h2 { margin: 12px 0 6px; }
.panel h3 { margin: 14px 0 6px; font-size: 1rem; }
.quote { font-size: 1.05rem; color: var(--teal); }
dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; }
dt { font-weight: 600; color: var(--accent); }
dd { margin: 0; }
.xp { display: inline-block; width: 100px; height: 9px; background: var(--line); border-radius: 6px; overflow: hidden; vertical-align: middle; border: 1.5px solid var(--ink); }
.xp span { display: block; height: 100%; background: var(--accent); }
.diary { list-style: none; padding: 0; margin: 0; }
.diary li { padding: 10px 0; border-bottom: 1.5px dashed var(--line); }
.diary h3 { margin: 0; }
.diary p { margin: 4px 0 0; white-space: pre-wrap; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; padding-top: 10px; }
.gallery figure { margin: 0; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; object-position: top; border-radius: 10px; border: 2px solid var(--ink); background: #fff; }
.gallery figcaption { font-size: 0.8rem; }
.track-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1.5px dashed var(--line); }
.btn { display: inline-block; padding: 8px 16px; border-radius: 999px; background: var(--accent); color: #fff; text-decoration: none; font-weight: 600; border: 2.5px solid var(--ink); box-shadow: 0 3px 0 var(--ink); margin: 4px 6px 4px 0; cursor: pointer; }
.btn.alt { background: #ff90e8; color: var(--ink); }
.wish { border: 2px solid var(--line); border-radius: 14px; padding: 8px 12px; margin: 8px 0; background: #fff; }
.wish b { display: block; }
.wish .st { font-size: 0.78rem; border-radius: 999px; padding: 1px 8px; border: 1.5px solid var(--ink); background: var(--paper2); }
.feed .msg { border: 2px solid var(--line); border-radius: 14px; padding: 8px 12px; margin: 8px 0; background: #fff; }
.feed .msg .who { font-weight: 600; font-size: 0.85rem; }
.feed .msg .kept { font-size: 0.72rem; color: var(--teal); margin-left: 6px; }
.feed .msg img { max-width: 100%; border-radius: 10px; margin-top: 6px; }
.feed .msg .reply { margin-top: 6px; padding: 6px 10px; border-left: 3px solid var(--accent); background: var(--paper2); border-radius: 6px; font-size: 0.9rem; }
.feed .msg .reply b { color: var(--accent); }
.offer textarea { width: 100%; font: inherit; border: 2.5px solid var(--ink); border-radius: 14px; padding: 10px; background: #fff; resize: vertical; }
.offer .file { display: inline-block; margin: 8px 0; cursor: pointer; }
.offer .file input { display: none; }
.offer .file span { border: 2px dashed var(--ink); border-radius: 999px; padding: 4px 12px; display: inline-block; }
.offer img#offer-preview { max-width: 160px; border-radius: 10px; border: 2px solid var(--ink); display: block; margin: 4px 0; }
.row { display: flex; gap: 10px; align-items: center; margin: 6px 0; }
.you { font-size: 0.9rem; }

.loading { position: fixed; inset: 0; z-index: 20; display: grid; place-content: center; text-align: center; background: radial-gradient(circle at 50% 40%, #fff3dc, #f6d6a8); color: var(--ink); }
.loading h1 { margin: 6px 0; font-size: 2.2rem; }
.loading .paw { font-size: 2.6rem; animation: hop 0.8s infinite alternate ease-in-out; }
@keyframes hop { to { transform: translateY(-12px); } }

@media (pointer: coarse) {
  .joystick { display: block; }
  .help .desk { display: none; }
  .help .touch { display: inline; }
  .prompt kbd { display: none; }
  .prompt { left: auto; right: 16px; transform: none; bottom: max(40px, env(safe-area-inset-bottom)); }
}
@media (max-width: 760px) {
  #minimap { width: 74px; height: 74px; }
  .tc { top: 92px; }
  .needs { transform: scale(0.82); transform-origin: top center; }
  .bar { min-width: 44px; }
  .bar label { font-size: 0.62rem; }
  #offer-btn { font-size: 0; padding: 8px 12px; }
  #offer-btn::before { content: 'Leave a note'; font-size: 0.85rem; }
  .now { top: auto; bottom: 150px; width: min(260px, calc(100vw - 24px)); }
  .panel { top: 60px; }
  .bc { bottom: 90px; }
  .prompt { bottom: 140px; }
}

#minimap { cursor: zoom-in; }
#fly-btn.on { background: #8ecae6; }
.bigmap { left: 50%; right: auto; top: 50%; bottom: auto; transform: translate(-50%, -50%); width: min(1100px, 96vw); height: min(760px, 90vh); }
.map-body { display: flex; gap: 12px; flex: 1; min-height: 0; padding: 10px; }
#map-canvas { flex: 1; min-width: 0; height: 100%; border-radius: 14px; border: 2.5px solid var(--ink); cursor: pointer; }
.map-side { width: 280px; overflow-y: auto; font-size: 0.9rem; }
.map-side h3 { margin: 6px 0; }
.map-side ul { padding-left: 18px; margin: 0 0 8px; }
.newtag { background: #e63946; color: #fff; border-radius: 999px; padding: 0 6px; font-size: 0.7rem; }
@media (max-width: 760px) { .map-body { flex-direction: column; } .map-side { width: auto; max-height: 30%; } #fly-btn { padding: 8px 10px; } }

.btn.small { padding: 4px 12px; font-size: 0.82rem; margin-top: 6px; }

html, body { touch-action: manipulation; -webkit-text-size-adjust: 100%; }

/* ---------- other people in town ---------- */
.pill.small { padding: 4px 11px; font-size: 0.82rem; box-shadow: 0 2px 0 rgba(59,36,22,0.25); }
.online { display: inline-flex; align-items: center; gap: 7px; background: #fff; }
.online i { width: 10px; height: 10px; border-radius: 50%; background: #2ecc71; border: 1.5px solid var(--ink); box-shadow: 0 0 0 3px rgba(46,204,113,0.25); animation: pulse 2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(46,204,113,0); } }
.people { position: fixed; z-index: 9; right: 14px; top: 70px; width: min(320px, calc(100vw - 28px)); max-height: 60vh; overflow: auto; padding: 10px 14px; user-select: text; }
.people header { display: flex; justify-content: space-between; align-items: center; }
.people h3, .peer-menu h3 { margin: 0; }
.person { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1.5px dashed var(--line); }
.peer-menu { position: fixed; z-index: 9; left: 50%; bottom: 128px; transform: translateX(-50%); width: min(420px, calc(100vw - 28px)); padding: 12px 14px; }
.peer-menu #peer-x { position: absolute; right: 8px; top: 8px; width: 30px; height: 30px; }
.peer-menu .acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.peer-menu .note { margin: 8px 0 0; }
.toasts { position: fixed; z-index: 12; left: 50%; top: 120px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 10px; align-items: center; background: var(--paper); border: 2.5px solid var(--ink); border-radius: 999px; padding: 7px 8px 7px 16px; box-shadow: var(--shadow); font-weight: 600; animation: toastIn 0.25s ease-out; transition: opacity 0.6s, transform 0.6s; max-width: calc(100vw - 28px); }
.toast.out { opacity: 0; transform: translateY(-10px); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-12px) scale(0.95); } }
#panel-x:empty::before, #map-x:empty::before, #offer-x:empty::before, #people-x:empty::before, #peer-x:empty::before { content: '×'; }

.hero { width: 100%; border-radius: 14px; border: 2.5px solid var(--ink); background: #fff; display: block; margin: 6px 0; }
.hero.pixel { image-rendering: pixelated; }
.painted { aspect-ratio: 1 / 1; object-fit: cover; object-position: top; }
.gallery img.pixel { image-rendering: pixelated; }
@media (max-width: 760px) {
  .online { padding: 8px 11px; }
  .online span { display: none; }
  .online::after { content: attr(data-n); font-weight: 700; }
  .peer-menu { bottom: 150px; }
  .toasts { top: 150px; }
}

/* typography: Lilita One for headings and signs, Nunito for reading */
h1, h2, h3, .tag, .chip, #tabs button, .prompt, .loading h1, .bubble { font-family: 'Lilita One', 'Nunito', sans-serif; font-weight: 400; letter-spacing: 0.2px; }
.pill, .btn, button { font-family: 'Nunito', sans-serif; font-weight: 800; }
.panel-body p, .panel-body li, .feed, .thought, .quote { font-family: 'Nunito', sans-serif; }
