:root {
  --ink: #0f1f1e;
  --ink-2: #4a5a59;
  --ink-3: #8a9897;
  --paper: #f6f3ee;
  --card: #ffffff;
  --line: #e7e1d8;
  --brand: #0b3b3a;
  --brand-2: #135e5b;
  --accent: #e8743b;
  --accent-soft: #fdebe1;
  --tx: #2a6f6b;
  --tx-soft: #e4f1ef;
  --radius: 18px;
  --shadow: 0 1px 2px rgb(15 31 30 / 0.05), 0 6px 24px rgb(15 31 30 / 0.05);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Noto Sans", "Noto Sans Arabic",
    "Noto Sans JP", "Noto Sans SC", "Noto Sans Devanagari", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
.boot { display: grid; place-items: center; height: 100vh; font-size: 48px; animation: spin 3s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 240px minmax(0, 640px) 280px; gap: 28px; justify-content: center; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; padding: 24px 8px; display: flex; flex-direction: column; gap: 4px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; letter-spacing: -0.02em; padding: 8px 14px 22px; color: var(--brand); }
.logo span { font-size: 26px; }
.nav a { display: flex; align-items: center; gap: 14px; padding: 11px 14px; border-radius: 14px; color: var(--ink-2); font-weight: 600; }
.nav a:hover { background: #ece7df; }
.nav a.on { background: var(--brand); color: #fff; }
.nav .ico { font-size: 19px; width: 22px; text-align: center; }
.side .me { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 14px; }
.side .me:hover { background: #ece7df; }
.main { padding: 24px 0 100px; min-width: 0; }
.rail { position: sticky; top: 0; height: 100vh; padding: 24px 0; display: flex; flex-direction: column; gap: 16px; }
.page-title { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; margin: 4px 4px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }

@media (max-width: 1100px) { .shell { grid-template-columns: 220px minmax(0, 640px); } .rail { display: none; } }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; gap: 0; }
  .main { padding: 12px 12px 90px; }
  .side { position: fixed; z-index: 20; bottom: 0; top: auto; left: 0; right: 0; height: auto; flex-direction: row; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: rgb(255 255 255 / 0.92); backdrop-filter: blur(12px); border-top: 1px solid var(--line); }
  .side .logo, .side .me, .nav .label { display: none; }
  .nav { display: flex; flex: 1; justify-content: space-around; }
  .nav a { flex-direction: column; gap: 0; padding: 8px 12px; }
}

/* ---------- primitives ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.avatar { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-size: 21px; flex: none; color: #fff; }
.avatar.sm { width: 32px; height: 32px; font-size: 16px; }
.avatar.lg { width: 84px; height: 84px; font-size: 42px; }
.btn { border: 0; border-radius: 999px; padding: 9px 18px; font-weight: 700; background: var(--brand); color: #fff; transition: transform .1s, background .2s; }
.btn:hover { background: var(--brand-2); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.ghost { background: transparent; color: var(--ink-2); border: 1px solid var(--line); }
.btn.ghost:hover { background: #f1ede6; }
.btn.accent { background: var(--accent); }
.btn.sm { padding: 6px 13px; font-size: 13px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--ink-2); font-weight: 600; font-size: 13px; }
.chip:hover { background: #f4f0ea; }
.chip.rec { background: #fee2e2; border-color: #fca5a5; color: #b91c1c; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .6; } }
.muted { color: var(--ink-3); font-size: 13px; }
.field { width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 14px; padding: 11px 14px; outline: none; }
.field:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgb(19 94 91 / .12); }
textarea.field { resize: vertical; min-height: 60px; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.empty { text-align: center; color: var(--ink-3); padding: 48px 16px; }
.empty .big { font-size: 40px; display: block; margin-bottom: 8px; }

/* ---------- translated text ---------- */
.tx-wrap { display: block; }
.tx { white-space: pre-wrap; word-wrap: break-word; unicode-bidi: plaintext; }
.tx.loading { color: var(--ink-3); }
.tx-meta { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12px; color: var(--tx); background: var(--tx-soft); padding: 3px 9px; border-radius: 999px; }
.tx-meta button { border: 0; background: none; padding: 0; color: var(--tx); font-weight: 700; text-decoration: underline; text-underline-offset: 2px; font-size: 12px; }
.tx-meta .dot { opacity: .5; }

/* ---------- composer ---------- */
.composer { padding: 16px; margin-bottom: 16px; }
.composer textarea { border: 0; outline: none; resize: none; width: 100%; font-size: 17px; min-height: 56px; background: transparent; }
.composer .tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 12px; margin-top: 6px; }
.composer select { border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px; background: #fff; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.preview { margin: 8px 0; position: relative; }
.preview img, .preview video { max-width: 100%; max-height: 320px; border-radius: 14px; display: block; }
.preview .x { position: absolute; top: 8px; inset-inline-end: 8px; border: 0; background: rgb(0 0 0 / .6); color: #fff; width: 28px; height: 28px; border-radius: 50%; }

/* ---------- post ---------- */
.post { padding: 16px 18px; margin-bottom: 14px; }
.post-head { display: flex; align-items: center; gap: 11px; margin-bottom: 10px; }
.post-head .name { font-weight: 700; }
.post-head .sub { font-size: 12.5px; color: var(--ink-3); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.flag { display: inline-flex; align-items: center; gap: 4px; background: #f1ede6; color: var(--ink-2); padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.post-body { font-size: 16px; }
.post-media { margin-top: 12px; border-radius: 14px; overflow: hidden; background: #000; }
.post-media img, .post-media video { width: 100%; display: block; max-height: 560px; object-fit: contain; }
.voice { margin-top: 10px; background: linear-gradient(135deg, #eef6f5, #fbf3ec); border-radius: 14px; padding: 12px; }
.voice audio { width: 100%; height: 38px; }
.voice .label { font-size: 12px; color: var(--ink-3); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; margin: 8px 0 4px; }
.actions { display: flex; gap: 6px; margin-top: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
.act { border: 0; background: none; padding: 7px 12px; border-radius: 999px; color: var(--ink-2); font-weight: 600; display: inline-flex; gap: 6px; align-items: center; font-size: 14px; }
.act:hover { background: #f4f0ea; }
.act.on { color: var(--accent); }
.comments { margin-top: 8px; display: flex; flex-direction: column; gap: 10px; }
.comment { display: flex; gap: 9px; }
.comment .bubble { background: #f4f1ec; border-radius: 14px; padding: 8px 12px; flex: 1; min-width: 0; }
.comment .who { font-weight: 700; font-size: 13px; }
.channel-tag { font-size: 12px; font-weight: 700; color: var(--brand-2); }


/* ---------- channels ---------- */
.channels { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.ch { padding: 18px; display: flex; flex-direction: column; gap: 8px; }
.ch .emoji { font-size: 34px; }
.ch h3 { margin: 0; font-size: 17px; }
.ch-hero { padding: 22px; margin-bottom: 16px; display: flex; gap: 16px; align-items: flex-start; background: linear-gradient(135deg, #0b3b3a, #135e5b); color: #fff; border: 0; }
.ch-hero .emoji { font-size: 48px; }
.ch-hero h2 { margin: 0 0 4px; }
.ch-hero .tx-meta { background: rgb(255 255 255 / .15); color: #dff; }
.ch-hero .tx-meta button { color: #fff; }
.ch-hero .btn { background: #fff; color: var(--brand); }

/* ---------- chats ---------- */
.chat { display: grid; grid-template-columns: 260px 1fr; height: calc(100vh - 48px); overflow: hidden; }
.chat-list { border-inline-end: 1px solid var(--line); overflow-y: auto; }
.chat-item { display: flex; gap: 10px; padding: 12px 14px; align-items: center; border-bottom: 1px solid #f1ece4; }
.chat-item:hover { background: #faf8f4; }
.chat-item.on { background: var(--tx-soft); }
.chat-item .last { font-size: 13px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread { display: flex; flex-direction: column; min-width: 0; }
.thread-head { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.msgs { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; background: #fbfaf7; }
.msg { max-width: 76%; padding: 9px 13px; border-radius: 18px; background: #fff; border: 1px solid var(--line); align-self: flex-start; }
.msg.mine { align-self: flex-end; background: var(--brand); color: #fff; border-color: transparent; }
.msg.mine .muted { color: rgb(255 255 255 / .6); }
.msg audio { max-width: 240px; height: 36px; display: block; }
.msg .tx-meta { margin-top: 4px; }
.thread-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); align-items: center; }
@media (max-width: 760px) {
  .chat { grid-template-columns: 1fr; height: calc(100vh - 100px); }
  .chat.open .chat-list { display: none; }
  .chat:not(.open) .thread { display: none; }
}

/* ---------- profile ---------- */
.profile { padding: 24px; margin-bottom: 16px; display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.profile h2 { margin: 0; }

/* ---------- rail ---------- */
.rail .card { padding: 16px; }
.rail h4 { margin: 0 0 10px; font-size: 14px; color: var(--ink-2); }
.villager { display: flex; align-items: center; gap: 10px; padding: 6px 0; }

/* ---------- onboarding ---------- */
.welcome { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #dfe9e6; }
.welcome .card { width: min(460px, 100%); padding: 32px; }
.welcome h1 { font-size: 32px; letter-spacing: -0.03em; margin: 8px 0 4px; color: var(--brand); }
.welcome .hello { display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0 22px; }
.welcome .hello span { background: #f1ede6; border-radius: 999px; padding: 4px 10px; font-size: 13px; color: var(--ink-2); }
.welcome label { display: block; font-weight: 700; font-size: 13px; margin: 14px 0 6px; color: var(--ink-2); }
.avatars { display: flex; flex-wrap: wrap; gap: 6px; }
.avatars button { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font-size: 20px; }
.avatars button.on { border-color: var(--brand); background: var(--tx-soft); box-shadow: 0 0 0 2px var(--brand); }
.demo { margin-top: 22px; border-top: 1px dashed var(--line); padding-top: 16px; }
.demo .row { flex-wrap: wrap; gap: 6px; }

/* ---------- modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgb(15 31 30 / .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { width: min(480px, 100%); padding: 22px; display: flex; flex-direction: column; gap: 12px; }
.modal h3 { margin: 0; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; z-index: 60; font-weight: 600; font-size: 14px; }
@media (max-width: 760px) { .toast { bottom: 90px; } }

/* =================== themed threads =================== */
.persona { display: inline-flex; align-items: center; gap: 4px; margin-inline-start: 8px; font-size: 12px; font-weight: 700; color: var(--accent); background: var(--tx-soft); padding: 1px 9px; border-radius: 999px; }
.mutating { font-size: 13px; font-weight: 700; color: var(--accent); margin-bottom: 8px; animation: pulse 1.4s infinite; }
.frame { font-style: italic; color: var(--accent); font-family: var(--theme-font, inherit); margin: 2px 0; }
.theme-toggle { margin-top: 10px; }
.themed-img { position: relative; min-height: 120px; }
.themed-img.loading { min-height: 300px; background: linear-gradient(110deg, var(--card) 30%, var(--tx-soft) 50%, var(--card) 70%); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; }
.themed-img.loading img { opacity: 0; }
.themed-img img { transition: opacity .6s; }
@keyframes shimmer { to { background-position: -200% 0; } }
.ai-badge { position: absolute; top: 10px; inset-inline-start: 10px; background: rgb(0 0 0 / .55); color: #fff; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; backdrop-filter: blur(4px); }
.theme-line { margin-top: 10px; font-size: 13.5px; opacity: .92; }
.theme-badge { align-self: flex-start; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent); }
.ch-themed { background: var(--pattern), linear-gradient(135deg, var(--paper), var(--bg2)); color: var(--ink); border-color: var(--line); }
.ch-themed h3 { font-family: var(--theme-font); }
.ch-themed .muted { color: var(--ink-2); }
.ch-themed .flag { background: var(--soft); color: var(--ink); }

/* The whole shell takes on the theme. */
.shell.themed { background: var(--pattern), radial-gradient(ellipse at top, var(--bg2), var(--paper) 70%); background-attachment: fixed; color: var(--ink); }
.themed .logo, .themed .page-title, .themed h2, .themed h3, .themed .name, .themed .btn, .themed .nav a { font-family: var(--theme-font); letter-spacing: .01em; }
.themed .post-body, .themed .comment .tx { font-family: var(--body-font); }
.themed .post-body { font-size: 16.5px; }
.themed .logo { color: var(--accent); }
.themed .nav a { color: var(--ink-2); }
.themed .nav a:hover, .themed .side .me:hover { background: var(--soft); }
.themed .nav a.on { background: var(--accent); color: var(--card); }
.themed .card { background: var(--card); border-color: var(--line); box-shadow: 0 2px 30px rgb(0 0 0 / .25); }
.themed .chip, .themed .field, .themed .composer select { background: var(--soft); border-color: var(--line); color: var(--ink); }
.themed .composer textarea::placeholder, .themed .field::placeholder { color: var(--ink-3); }
.themed .flag, .themed .comment .bubble { background: var(--soft); color: var(--ink); }
.themed .act { color: var(--ink-2); }
.themed .act:hover { background: var(--soft); }
.themed .voice { background: var(--soft); }
.themed .btn { background: var(--accent); color: var(--card); }
.themed .btn.ghost { background: transparent; color: var(--ink-2); }
.themed .ch-hero { background: var(--pattern), linear-gradient(135deg, var(--bg2), var(--paper)); color: var(--ink); border: 1px solid var(--line); }
.themed .ch-hero .btn { background: var(--accent); color: var(--card); }
.themed .ch-hero .tx-meta { background: var(--soft); color: var(--ink-2); }
.themed .ch-hero .tx-meta button { color: var(--accent); }
.themed .post-media { background: #000; }
@media (max-width: 760px) { .themed .side { background: color-mix(in srgb, var(--card) 92%, transparent); border-color: var(--line); } }
.tx-wrap.inline { display: inline; }
.themed-img.painting { min-height: 220px; background: linear-gradient(110deg, var(--card) 30%, var(--tx-soft) 50%, var(--card) 70%); background-size: 200% 100%; animation: shimmer 1.6s infinite linear; }
.themed-img.painting img { opacity: .55; }

/* =================== villages & the Village AI =================== */
.gov-line { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 13.5px; opacity: .92; }
.ai-line { margin-top: 6px; font-size: 13px; font-weight: 700; opacity: .85; }
.ai-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--tx-soft); color: var(--tx); }
.role { display: inline-flex; align-items: center; gap: 3px; font-size: 11.5px; font-weight: 700; padding: 1px 8px; border-radius: 999px; margin-inline-start: 6px; background: var(--soft, #f1ede6); color: var(--ink-2); }
.role-governor { background: #fdf0c8; color: #8a5a00; }
.role-elder { background: #e6eefc; color: #2a4f8f; }
.verdict { margin-top: 10px; padding: 12px 14px; border-radius: 14px; background: #fff4ef; border: 1px solid #f6c9b4; color: #6b2e12; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.verdict-head { font-weight: 800; }
.verdict-rule { font-size: 13px; font-weight: 600; }
.verdict .muted { color: #9a5a3c; }
.strike-bar { margin: -6px 0 14px; padding: 8px 14px; border-radius: 12px; background: #fff7e6; color: #8a5a00; font-weight: 700; font-size: 13px; border: 1px solid #f5dfae; }
.ai-note { margin-top: 10px; font-size: 13px; padding: 8px 12px; border-radius: 12px; background: #fff7e6; color: #7a5200; border: 1px solid #f5dfae; }
.removed-banner { margin-bottom: 10px; padding: 10px 12px; border-radius: 12px; background: #fdecec; color: #8f1d1d; border: 1px solid #f3c2c2; font-size: 13.5px; }
.post.is-hidden > :not(.removed-banner):not(.post-head) { opacity: .45; }
.rules ol { margin: 0; padding-inline-start: 22px; display: flex; flex-direction: column; gap: 10px; }
.rules li { font-weight: 600; }
.needs-claude { display: inline-block; margin-top: 4px; font-size: 11.5px; font-weight: 700; color: #8a5a00; background: #fff7e6; padding: 1px 8px; border-radius: 999px; }
.charter { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); font-size: 13.5px; }
.charter ul { margin: 6px 0 0; padding-inline-start: 20px; color: var(--ink-2); }
.rules-edit { display: flex; flex-direction: column; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.rules-edit label .field { margin-top: 4px; }
.modal { max-height: 88vh; overflow-y: auto; }
.log { display: flex; flex-direction: column; gap: 2px; max-height: 60vh; overflow-y: auto; }
.log-row { display: flex; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--line); font-size: 14px; }
.log-icon { font-size: 18px; width: 26px; text-align: center; }
.log-reason { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.log-excerpt { font-size: 12.5px; color: var(--ink-3); margin-top: 4px; padding-inline-start: 10px; border-inline-start: 3px solid var(--line); }
.villagers { display: flex; flex-direction: column; }
.villager-row { display: flex; align-items: center; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.themed .verdict, .themed .strike-bar, .themed .ai-note { background: var(--soft); color: var(--ink); border-color: var(--accent); }
.themed .verdict .muted { color: var(--ink-2); }
.themed .role { background: var(--soft); color: var(--accent); }
.themed .modal { color: var(--ink); }

/* =================== 2D village scene =================== */
.scene-card { padding: 0; overflow: hidden; margin-bottom: 16px; position: relative; background: #3f6f2a; }
canvas.scene { display: block; width: 100%; aspect-ratio: 960 / 640; image-rendering: auto; touch-action: manipulation; }
.scene-hint { position: absolute; bottom: 8px; inset-inline-start: 10px; font-size: 12px; font-weight: 700; color: #fff; background: rgb(0 0 0 / .45); padding: 4px 10px; border-radius: 999px; backdrop-filter: blur(4px); pointer-events: none; }
.my-char { width: 64px; height: 84px; display: grid; place-items: end center; background: radial-gradient(ellipse at 50% 92%, rgb(0 0 0 / .18) 0 30%, transparent 32%), #e9f3df; border-radius: 16px; padding-bottom: 6px; }
.my-char img { height: 64px; image-rendering: pixelated; }
.char-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 6px; max-height: 240px; overflow-y: auto; padding: 4px; border: 1px solid var(--line); border-radius: 14px; background: #eef5e6; }
.char-grid button { border: 2px solid transparent; background: transparent; border-radius: 10px; padding: 3px; height: 54px; display: grid; place-items: center; }
.char-grid button.on { border-color: var(--brand); background: #fff; }
.char-grid img { max-height: 44px; image-rendering: pixelated; }
.npc-head { display: flex; gap: 12px; align-items: center; }
.npc-img { height: 64px; image-rendering: pixelated; background: #eef5e6; border-radius: 12px; padding: 6px; }
.npc-line { font-size: 16px; padding: 12px 14px; border-radius: 14px; background: #f3efff; border: 1px solid #d9cffd; }
.modal-post { width: min(620px, 100%); }
.modal-post .post { box-shadow: none; margin: 0; }

/* =================== pixel avatars & icons =================== */
.avatar.char { position: relative; overflow: hidden; border: 2px solid rgb(255 255 255 / .7); box-shadow: 0 0 0 1px var(--line); }
.avatar.char img { position: absolute; left: 50%; top: 8%; height: 138%; transform: translateX(-50%); image-rendering: pixelated; pointer-events: none; }
.avatar.xs { width: 22px; height: 22px; font-size: 12px; border-width: 1px; }
.chip .avatar.xs { margin-inline-end: 2px; }
.ico { width: max(22px, 1.75em); height: max(22px, 1.75em); vertical-align: -0.5em; margin-block: -0.2em; object-fit: contain; image-rendering: pixelated; display: inline-block; }
.ico-emoji { display: inline-block; }
.logo-ico.ico { width: 1.6em; height: 1.6em; }
.emoji .ico.emblem { width: 1.3em; height: 1.3em; }
.nav-ico { font-size: 19px; width: 24px; text-align: center; display: inline-grid; place-items: center; }
.my-char { width: 84px; height: 84px; border-radius: 50%; overflow: hidden; position: relative; display: block; padding: 0; border: 3px solid #fff; box-shadow: 0 0 0 1px var(--line), var(--shadow); }
.my-char img { position: absolute; left: 50%; top: 8%; height: 136%; transform: translateX(-50%); }
.welcome .char-grid { max-height: 200px; }

/* =====================================================================
   Village page: side panel (35% of the screen) + the living village
   ===================================================================== */
.shell.vmode-shell { grid-template-columns: 76px minmax(0, 1fr); gap: 0; justify-content: stretch; }
.vmode-shell .side { padding: 14px 8px; align-items: center; border-inline-end: 1px solid var(--line); background: var(--card); }
.vmode-shell .side .logo { padding: 4px 0 16px; font-size: 0; gap: 0; }
.vmode-shell .side .logo .logo-ico { font-size: 28px; }
.vmode-shell .nav { display: flex; flex-direction: column; gap: 4px; }
.vmode-shell .nav a { justify-content: center; padding: 12px; }
.vmode-shell .nav .label, .vmode-shell .side .me .grow { display: none; }
.vmode-shell .side .me { padding: 6px; }
.vmode-shell .main { padding: 0; height: 100vh; height: 100dvh; overflow: hidden; }
.vmode { display: grid; grid-template-columns: clamp(320px, 35vw, 700px) minmax(0, 1fr); height: 100%; }

/* ---- panel ---- */
.vpanel { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--paper); border-inline-end: 1px solid var(--line); }
.vpanel-head { display: flex; gap: 10px; align-items: center; padding: 14px 16px 10px; }
.vback { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; border: 1px solid var(--line); background: var(--card); flex: none; }
.vpanel-emblem { font-size: 28px; line-height: 1; }
.vpanel-name { font-weight: 800; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--theme-font, inherit); }
.vpanel-sub { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vpanel-head .vjoin { display: none; }
.vtabs { display: flex; gap: 4px; padding: 0 12px 10px; border-bottom: 1px solid var(--line); }
.vtabs button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; background: transparent; padding: 9px 6px; border-radius: 12px; font-weight: 700; font-size: 13px; color: var(--ink-2); white-space: nowrap; min-width: 0; }
.vtabs button:hover { background: var(--soft, #efeae1); }
.vtabs button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.vtab-label { overflow: hidden; text-overflow: ellipsis; }
.vtab-badge { font-size: 11px; background: var(--soft, #ece6dc); color: var(--ink-2); padding: 0 7px; border-radius: 999px; }
.vtab-badge.new { background: var(--accent); color: #fff; animation: pulse 1.2s 3; }
.vtab-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.vtab-scroll { flex: 1; overflow-y: auto; padding: 14px 14px 40px; }
.vtab-scroll .composer, .vtab-scroll .post { margin-bottom: 12px; }
.vtab-scroll .post .act.locate { margin-inline-start: auto; }

/* chat */
.vtab-chat { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.vchat-list { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.vchat-input { padding: 10px 12px 12px; border-top: 1px solid var(--line); background: var(--card); }
.vchat-input .row { gap: 8px; }
.vchat-input .verdict { margin: 0 0 8px; }
.vchat-mic.rec { background: #fee2e2; border-color: #fca5a5; animation: pulse 1.2s infinite; }
.vchat-join { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line); background: var(--tx-soft); font-weight: 600; font-size: 13.5px; }
.vchat-join.card { border-radius: var(--radius); margin-bottom: 12px; border: 1px solid var(--line); }
.vmsg { display: flex; gap: 9px; align-items: flex-start; border-radius: 14px; }
.vmsg-av { border: 0; background: none; padding: 0; cursor: pointer; flex: none; }
.vmsg-av:hover .avatar { box-shadow: 0 0 0 2px var(--accent); }
.vmsg-main { min-width: 0; max-width: 86%; }
.vmsg-who { display: flex; gap: 6px; align-items: center; font-size: 12.5px; flex-wrap: wrap; }
.vmsg-who .role { margin: 0; }
.vmsg-bubble { margin-top: 3px; background: var(--card); border: 1px solid var(--line); padding: 8px 12px; border-radius: 4px 16px 16px 16px; font-size: 14.5px; }
.vmsg.mine { flex-direction: row-reverse; }
.vmsg.mine .vmsg-main { display: flex; flex-direction: column; align-items: flex-end; }
.vmsg.mine .vmsg-who { flex-direction: row-reverse; }
.vmsg.mine .vmsg-bubble { background: var(--brand); color: #fff; border-color: transparent; border-radius: 16px 4px 16px 16px; }
.vmsg.flash .vmsg-bubble { animation: flash 1.6s; }
@keyframes flash { 0%, 50% { box-shadow: 0 0 0 4px rgb(232 164 23 / .65); } 100% { box-shadow: none; } }
.vmsg audio { width: 220px; max-width: 100%; height: 36px; display: block; }
.vchat-img { max-width: 220px; border-radius: 10px; display: block; }

.vabout .card { margin-bottom: 12px; }
.vabout-emblem { font-size: 32px; }

/* ---- stage: the village fills the rest of the screen ---- */
.vstage { position: relative; min-width: 0; min-height: 0; overflow: hidden; container-type: size;
  background: radial-gradient(ellipse at 50% 45%, #4d8034 0%, #2f5420 55%, #1b3112 100%); }
.vstage::after { content: ""; position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 120px rgb(0 0 0 / .45); }
.vstage-frame { position: absolute; inset: 0; display: grid; place-items: center; }
.vstage canvas.scene { width: min(100cqw, 150cqh); height: auto; aspect-ratio: 3 / 2; border-radius: 0; }
.themed .vstage { background: radial-gradient(ellipse at 50% 45%, var(--bg2), var(--paper) 90%); }

/* ---- HUD: wooden signs over the village ---- */
.hud { position: absolute; display: flex; gap: 8px; z-index: 3; pointer-events: none; }
.hud > * { pointer-events: auto; }
.hud-tl { top: 14px; inset-inline-start: 14px; max-width: 62%; }
.hud-tr { top: 14px; inset-inline-end: 14px; flex-wrap: wrap; justify-content: flex-end; max-width: 36%; }
.hud-bottom { bottom: 14px; left: 14px; right: 14px; flex-wrap: wrap; justify-content: center; }
.hud-plate, .hud-pill, .hud-btn {
  background: linear-gradient(#7d522c, #5a391d); border: 2px solid #2b1d12; color: #fbecd0; border-radius: 10px;
  box-shadow: inset 0 2px 0 rgb(255 220 170 / .35), inset 0 -2px 0 rgb(0 0 0 / .25), 0 3px 0 rgb(0 0 0 / .35), 0 8px 20px rgb(0 0 0 / .25); }
.hud-plate { display: flex; gap: 10px; align-items: center; padding: 8px 14px 8px 8px; min-width: 0; }
.hud-plate > div:last-child { min-width: 0; }
.hud-emblem { font-size: 28px; width: 46px; height: 46px; flex: none; display: grid; place-items: center; background: #f3e3bf; border: 2px solid #2b1d12; border-radius: 8px; box-shadow: inset 0 -3px 0 rgb(0 0 0 / .12); }
.hud-title { font-weight: 800; font-size: 17px; text-shadow: 0 2px 0 rgb(0 0 0 / .4); font-family: var(--theme-font, inherit); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-sub { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 12px; margin-top: 3px; opacity: .95; }
.hud-ai { border: 0; background: rgb(255 255 255 / .14); color: inherit; border-radius: 999px; padding: 2px 9px; font-size: 11.5px; font-weight: 700; cursor: pointer; }
.hud-ai:hover { background: rgb(255 255 255 / .25); }
.hud-pill, .hud-btn { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; font-weight: 700; font-size: 13px; cursor: pointer; transition: transform .1s, filter .15s; white-space: nowrap; }
.hud-pill:hover, .hud-btn:hover { transform: translateY(-2px); filter: brightness(1.08); }
.hud-pill:active, .hud-btn:active { transform: translateY(1px); box-shadow: inset 0 2px 0 rgb(0 0 0 / .25); }
.hud-pill.on { background: linear-gradient(#f6e7c6, #e2c993); color: #3b2412; }
.hud-n { background: rgb(0 0 0 / .3); padding: 0 8px; border-radius: 999px; font-size: 12px; line-height: 20px; }
.hud-pill.on .hud-n { background: rgb(0 0 0 / .12); }
.hud-gov { display: inline-flex; align-items: center; gap: 6px; }
.hud-gov .avatar { border-color: #f2b33d; }
.hud-live { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: #c8f7b2; }
.hud-pill.on .hud-live { color: #2f7d2f; }
.hud-live i { width: 8px; height: 8px; border-radius: 50%; background: #5be35b; animation: live 1.8s infinite; }
@keyframes live { 0% { box-shadow: 0 0 0 0 rgb(91 227 91 / .7); } 70%, 100% { box-shadow: 0 0 0 7px rgb(91 227 91 / 0); } }
.hud .vjoin { background: linear-gradient(#ffc95a, #e59e1d); color: #2b1d12; border: 2px solid #2b1d12; border-radius: 10px; box-shadow: inset 0 2px 0 rgb(255 255 255 / .5), 0 3px 0 rgb(0 0 0 / .35); padding: 7px 14px; }
.hud .vjoin.joined { background: linear-gradient(#a8e087, #6fb84a); }
.hud-hint { position: absolute; top: 78px; left: 50%; transform: translateX(-50%); background: rgb(0 0 0 / .58); color: #fff; padding: 6px 14px; border-radius: 999px; font-size: 12.5px; font-weight: 700; transition: opacity .8s; pointer-events: none; z-index: 2; white-space: nowrap; }
.hud-hint.gone { opacity: 0; }

/* notice board pop-up */
.hud-pop { position: absolute; bottom: 70px; left: 50%; transform: translateX(-50%); width: min(430px, calc(100% - 28px)); max-height: 62%; overflow-y: auto; z-index: 4;
  background: #f6ead0; color: #3b2412; border: 3px solid #2b1d12; border-radius: 12px; padding: 14px 16px 12px;
  box-shadow: inset 0 0 0 3px #c9a46a, 0 14px 40px rgb(0 0 0 / .45); animation: popIn .18s ease-out; }
@keyframes popIn { from { opacity: 0; transform: translate(-50%, 8px); } }
.pop-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 15px; }
.hud-pop-x { border: 0; background: none; font-size: 16px; cursor: pointer; color: inherit; padding: 4px; }
.pop-list { display: flex; flex-direction: column; }
.pop-row { border-bottom: 1px dashed #c9a46a; }
.pop-person { display: flex; gap: 10px; align-items: center; width: 100%; border: 0; background: none; padding: 8px 4px; text-align: start; cursor: pointer; color: inherit; border-radius: 8px; }
.pop-person:hover { background: rgb(201 164 106 / .2); }
.online { color: #2f8f2f; font-weight: 700; }
.pop-gov { display: flex; gap: 14px; align-items: flex-start; }
.pop-gov h3 { margin: 0; }
.hud-pop .muted { color: #7a6243; }
.hud-pop .chip { background: #fff8e6; border-color: #c9a46a; color: #3b2412; }
.hud-pop .role { background: #fff3d6; }

/* themed villages use the theme's colors for the HUD */
.themed .hud-plate, .themed .hud-pill, .themed .hud-btn { background: linear-gradient(color-mix(in srgb, var(--bg2) 85%, #fff 15%), var(--paper)); border-color: var(--accent); color: var(--ink); }
.themed .hud-pill.on { background: var(--accent); color: var(--card); }
.themed .hud-emblem { background: var(--card); border-color: var(--accent); }
.themed .hud-pop { background: var(--card); color: var(--ink); border-color: var(--accent); box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--accent) 40%, transparent), 0 14px 40px rgb(0 0 0 / .5); }
.themed .hud-pop .muted { color: var(--ink-2); }
.themed .hud-pop .chip { background: var(--soft); color: var(--ink); border-color: var(--line); }
.themed .vmode-shell .side, .themed.vmode-shell .side { background: var(--card); }

/* ---- tablets & small laptops ---- */
@media (max-width: 1100px) {
  .shell.vmode-shell { grid-template-columns: 64px minmax(0, 1fr); }
  .vmode { grid-template-columns: clamp(300px, 40vw, 520px) minmax(0, 1fr); }
  .vtabs button:not(.on) .vtab-label { display: none; }
  .hud-label { display: none; }
  .hud-tl { max-width: 70%; }
  .hud-hint { top: auto; bottom: 64px; }
}
/* short screens (landscape phones, small laptops) */
@media (max-height: 560px) {
  .hud-sub, .hud-hint { display: none; }
  .hud-emblem { width: 34px; height: 34px; font-size: 20px; }
  .hud-title { font-size: 14px; }
  .hud-pill, .hud-btn, .hud .vjoin { padding: 4px 9px; font-size: 12px; }
  .hud-label { display: none; }
  .vpanel-head { padding: 8px 12px 6px; }
}
/* ---- phones: the village on top, the panel below ---- */
@media (max-width: 760px) {
  .shell.vmode-shell { grid-template-columns: 1fr; }
  .vmode-shell .main { height: calc(100dvh - 64px - env(safe-area-inset-bottom)); }
  .vmode { display: flex; flex-direction: column; height: 100%; }
  .vstage { order: -1; flex: 0 0 min(64vw, 46dvh); }
  .vpanel { flex: 1; border: 0; }
  .vpanel-head { padding: 10px 12px 6px; }
  .vpanel-head .vjoin { display: inline-flex; }
  .hud-tr .vjoin { display: none; }
  .hud-tl { top: 8px; inset-inline-start: 8px; max-width: 75%; }
  .hud-tr { top: 8px; inset-inline-end: 8px; }
  .hud-plate { padding: 5px 10px 5px 5px; gap: 8px; }
  .hud-sub, .hud-hint { display: none; }
  .hud-emblem { width: 32px; height: 32px; font-size: 18px; }
  .hud-title { font-size: 14px; }
  .hud-bottom { left: 8px; right: 8px; bottom: 8px; flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; scrollbar-width: none; padding-bottom: 2px; }
  .hud-bottom::-webkit-scrollbar { display: none; }
  .hud-pill, .hud-btn { padding: 5px 9px; font-size: 12px; flex: none; }
  .hud-pill, .hud-btn { gap: 3px; padding: 4px 7px; }
  .hud-bottom { gap: 5px; left: 4px; right: 4px; }
  .hud-pill img.ico, .hud-btn img.ico { width: 19px; height: 19px; margin: 0; }
  .hud-gov .avatar { display: none; }
  .hud-pop { position: fixed; left: 0; right: 0; bottom: calc(64px + env(safe-area-inset-bottom)); top: auto; transform: none; width: auto; max-height: 58dvh; border-radius: 18px 18px 0 0; z-index: 30; animation: sheetIn .2s ease-out; }
  .vtabs { padding: 0 8px 8px; }
  .vtabs button { padding: 8px 4px; }
  .vtabs button:not(.on) .vtab-label { display: none; }
}
@keyframes sheetIn { from { transform: translateY(30px); opacity: 0; } }
/* very wide screens: a little more breathing room in the HUD */
@media (min-width: 1600px) {
  .hud-tl, .hud-tr { top: 20px; }
  .hud-tl { inset-inline-start: 20px; }
  .hud-tr { inset-inline-end: 20px; }
  .hud-bottom { bottom: 20px; }
  .hud-pill, .hud-btn { font-size: 14px; padding: 8px 14px; }
}
/* phones: keep the normal bottom menu bar on the village page */
@media (max-width: 760px) {
  .vmode-shell .side { padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); border-inline-end: 0; align-items: stretch; background: rgb(255 255 255 / .92); }
  .vmode-shell .nav { flex-direction: row; gap: 0; }
  .vmode-shell .nav a { padding: 8px 12px; }
  .themed.vmode-shell .side { background: color-mix(in srgb, var(--card) 92%, transparent); }
}
@media (max-width: 760px) {
  /* no size containment here, so the bottom sheet can sit above the panel */
  .vstage { container-type: normal; }
  .vstage canvas.scene { width: min(100vw, 96vw, 69dvh); }
}
@media (max-height: 560px) and (min-width: 761px) {
  .vmode-shell .side .logo { display: none; }
  .vmode-shell .nav a { padding: 9px; }
}

/* =====================================================================
   Always-split layout: left panel 35% (tabs) | right 65% (villages)
   The panel stays on the left in every language; the content inside
   still reads right-to-left for Arabic, Persian, Urdu and Hebrew.
   ===================================================================== */
.split { display: grid; grid-template-columns: clamp(320px, 35vw, 700px) minmax(0, 1fr); height: 100vh; height: 100dvh; direction: ltr; background: var(--paper); color: var(--ink); }
html[dir="rtl"] .split > .left { direction: rtl; }
html[dir="rtl"] .split > .right .hud, html[dir="rtl"] .split > .right .hud-pop, html[dir="rtl"] .split > .right .world-list-body { direction: rtl; }
.left { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--paper); border-right: 1px solid var(--line); box-shadow: 4px 0 24px rgb(0 0 0 / .06); z-index: 2; }
.lhead { display: flex; align-items: center; gap: 10px; padding: 12px 16px 6px; }
.lhead .logo { padding: 0; font-size: 18px; gap: 8px; }
.lhead .logo .logo-ico { font-size: 24px; }
.lme { display: inline-flex; }
.lhead-leave { font-size: 12.5px; padding: 6px 11px; }
.ltabs { display: flex; gap: 4px; padding: 6px 10px 10px; border-bottom: 1px solid var(--line); }
.ltab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 8px 6px; border-radius: 12px; font-size: 12px; font-weight: 700; color: var(--ink-2); min-width: 0; transition: background .15s; }
.ltab:hover { background: var(--soft, #ece7df); }
.ltab > .ico, .ltab > .ico-emoji { font-size: 20px; }
.ltab > img.ico { width: 34px; height: 34px; margin: 0; }
.ltab.on { background: var(--brand); color: #fff; }
.ltab-village { flex: 1.4; background: var(--tx-soft); color: var(--tx); }
.ltab-village.on { background: var(--accent); color: #fff; }
.ltab-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lbody { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 14px 40px; }
.lbody-village { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.lbody-village > .vpanel { flex: 1; border: 0; }
.lbody-village .vpanel-head { padding-top: 10px; }
.lbody .page-title { font-size: 19px; margin: 2px 2px 12px; }
.lbody .composer, .lbody .post { margin-bottom: 12px; }
/* chats inside the panel: one column at a time (list, or the open conversation) */
.lbody-chats { padding: 10px; }
.lbody .chat { grid-template-columns: 1fr; height: calc(100dvh - 150px); }
.lbody .chat.open .chat-list { display: none; }
.lbody .chat:not(.open) .thread { display: none; }
.lbody .profile { padding: 18px; }

.right { position: relative; min-width: 0; min-height: 0; overflow: hidden; }
.right > .vstage { position: absolute; inset: 0; }
.right-loading { position: absolute; inset: 0; display: grid; place-items: center; background: radial-gradient(ellipse at 50% 45%, #4d8034, #1b3112); font-size: 44px; }
.right-loading .boot { height: auto; }
.themed .split, .split.themed { background: var(--paper); }

/* world map */
.world .hud-btn.on { background: linear-gradient(#f6e7c6, #e2c993); color: #3b2412; }
.world .vcreate { background: linear-gradient(#ffc95a, #e59e1d); color: #2b1d12; border: 2px solid #2b1d12; border-radius: 10px; box-shadow: inset 0 2px 0 rgb(255 255 255 / .5), 0 3px 0 rgb(0 0 0 / .35); }
.world-card { bottom: auto; top: 50%; transform: translate(-50%, -50%); width: min(400px, calc(100% - 28px)); animation: none; }
.wc-emblem { font-size: 24px; }
.wc-desc { font-size: 14px; margin: 2px 0 8px; }
.wc-stats { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; margin: 8px 0 12px; }
.wc-stats span { display: inline-flex; align-items: center; gap: 4px; }
.wc-enter { width: 100%; padding: 11px; font-size: 15px; background: linear-gradient(#7d522c, #5a391d); border: 2px solid #2b1d12; }
.wc-enter:hover { background: linear-gradient(#8d5f35, #6a4423); }
.world-list { overflow: hidden; }
.world-list-body { position: absolute; inset: 0; overflow-y: auto; padding: 96px 24px 30px; }
.world-list-body .channels { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.world-list-body .ch { color: var(--ink); }
.world-list .hud-tl, .world-list .hud-tr { position: absolute; }

/* tablets */
@media (max-width: 1100px) {
  .split { grid-template-columns: clamp(300px, 40vw, 520px) minmax(0, 1fr); }
  .ltab:not(.on):not(.ltab-village) .ltab-label { display: none; }
  .lhead-leave { padding: 6px 9px; }
}
/* phones: villages on top, the panel below, tabs as the bottom bar */
@media (max-width: 760px) {
  .split { display: flex; flex-direction: column; }
  .right { order: -1; flex: 0 0 min(64vw, 44dvh); }
  .left { flex: 1; border-right: 0; box-shadow: 0 -4px 18px rgb(0 0 0 / .08); }
  .lhead { padding: 8px 12px 4px; }
  .lhead .logo { font-size: 15px; }
  .ltabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; background: color-mix(in srgb, var(--card) 94%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--line); border-bottom: 0; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
  .ltab .ltab-label { display: none; }
  .ltab.on .ltab-label, .ltab-village .ltab-label { display: block; font-size: 11px; }
  .lbody { padding-bottom: 90px; }
  .lbody-village { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .lbody .chat { height: calc(100dvh - min(64vw, 44dvh) - 150px); }
  .right .vstage canvas.scene { width: min(96vw, 66dvh); }
  .right .vstage { container-type: normal; }
  .world-list-body { padding: 64px 10px 16px; }
  .world-list-body .channels { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .world-card { position: fixed; top: auto; bottom: calc(64px + env(safe-area-inset-bottom)); left: 0; right: 0; transform: none; width: auto; border-radius: 18px 18px 0 0; z-index: 30; }
  .hud-pop { bottom: calc(64px + env(safe-area-inset-bottom)); }
  .hud-tr .hud-leave { display: none; }
}
.ltab-label .tx { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ltab-label .tx-wrap { display: inline; }
@media (max-width: 760px) {
  .ltab { padding: 6px 4px; gap: 2px; max-width: 26%; }
  .ltab-village { max-width: 32%; }
  .ltab-label { max-width: 100%; }
  .lbody-village { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  .lhead .logo { font-size: 0; }
  .lhead .logo .logo-ico { font-size: 22px; }
}
@media (max-height: 560px) and (min-width: 761px) {
  .lhead { padding: 4px 12px; }
  .ltabs { padding: 2px 8px 6px; }
  .ltab { padding: 5px 4px; flex-direction: row; gap: 6px; }
  .lbody-village .vpanel-head { display: none; }
  .vtabs { padding-top: 6px; }
}
/* the world map grows taller as villages are added; keep its own proportions */
.vstage canvas.world-canvas { aspect-ratio: var(--ar, 1.5); width: min(100cqw, calc(var(--ar, 1.5) * 100cqh)); }
@media (max-width: 760px) {
  .right .vstage canvas.world-canvas { width: min(96vw, calc(var(--ar, 1.5) * min(64vw, 44dvh))); }
}

/* ---------- Realm (the game) ---------- */
.realm { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.realm-season { padding: 12px 14px; }
.realm-season-name { font-weight: 800; }
.realm-phase { color: var(--ink-2); font-size: 13px; margin: 2px 0 8px; }
.realm-track { display: flex; gap: 3px; height: 6px; }
.realm-seg { background: var(--line); border-radius: 3px; }
.realm-seg.on { background: var(--accent); }
.realm-h { margin: 4px 0 0; font-size: 15px; }
.realm-res { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.realm-r { padding: 8px; text-align: center; font-variant-numeric: tabular-nums; }
.realm-r.full { box-shadow: inset 0 0 0 2px #e0a33a; }
.realm-r-ico { display: block; font-size: 20px; }
.realm-r-rate { font-size: 11px; }
.realm-note { margin: 0; }
@media (max-width: 1100px) { .realm-res { grid-template-columns: repeat(2, 1fr); } }

/* ---------- zoom buttons, entering and leaving ---------- */
.zoom-ctl { position: absolute; right: 14px; bottom: 14px; z-index: 6; display: flex; flex-direction: column; gap: 6px; }
.zoom-btn { width: 38px; height: 38px; padding: 0; justify-content: center; font-size: 18px; font-weight: 800; }
html[dir="rtl"] .zoom-ctl { right: auto; left: 14px; }
.vstage.enter-in .vstage-frame { animation: village-in .55s cubic-bezier(.2, .8, .3, 1); }
.vstage.leave-out { animation: village-out .22s ease-in forwards; }
@keyframes village-in { from { opacity: 0; transform: scale(1.18); filter: brightness(1.6); } to { opacity: 1; transform: none; filter: none; } }
@keyframes village-out { to { opacity: 0; transform: scale(.94); } }
@media (prefers-reduced-motion: reduce) { .vstage.enter-in .vstage-frame, .vstage.leave-out { animation: none; } }

/* ---------- sign-in and the account page ---------- */
.auth { margin-top: 18px; display: flex; flex-direction: column; gap: 12px; }
.auth-tabs { display: flex; gap: 4px; background: #f1ede6; border-radius: 999px; padding: 4px; }
.auth-tabs a { flex: 1; text-align: center; padding: 8px 10px; border-radius: 999px; font-weight: 700; font-size: 14px; color: var(--ink-2); text-decoration: none; }
.auth-tabs a.on { background: #fff; color: var(--brand); }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-row { display: flex; flex-direction: column; gap: 5px; margin: 0 !important; }
.auth-row > span { font-weight: 700; font-size: 13px; color: var(--ink-2); }
.auth-row small { font-size: 12px; font-weight: 400; }
.auth-go { width: 100%; padding: 12px; }
.auth-or { text-align: center; color: var(--ink-3); font-size: 12px; }
.auth-err { color: #b42318; font-size: 13.5px; font-weight: 600; }
.auth-err:empty { display: none; }
.auth-link { background: none; border: 0; padding: 0; color: var(--brand); font-size: 13.5px; font-weight: 600; text-align: start; cursor: pointer; text-decoration: none; align-self: flex-start; }
.auth-link:hover { text-decoration: underline; }
.auth-h { margin: 0; font-size: 20px; }
.auth-check { display: flex !important; gap: 9px; align-items: flex-start; font-weight: 500 !important; font-size: 13.5px !important; margin: 0 !important; color: var(--ink) !important; }
.auth-check input { margin-top: 3px; width: 16px; height: 16px; flex: none; }
.auth-charter { font-size: 13px; color: var(--ink-2); background: #f7f4ee; border-radius: 12px; padding: 8px 12px; }
.auth-charter summary { cursor: pointer; font-weight: 700; }
.auth-charter ul { margin: 8px 0 2px; padding-inline-start: 18px; }
.legal-text { margin: 8px 0 2px; max-height: 40vh; overflow-y: auto; white-space: pre-wrap; text-align: left; }
.auth-dev { font-size: 12.5px; background: #fff6d9; border: 1px solid #f0dfa3; border-radius: 10px; padding: 8px 10px; margin: 0; }
.welcome .card { max-height: calc(100vh - 32px); overflow-y: auto; }
.verify-bar { display: flex; align-items: center; gap: 10px; margin: 6px 14px 0; padding: 9px 12px; background: #fff6d9; border: 1px solid #f0dfa3; border-radius: 12px; font-size: 13px; color: #5c4a00; }
.acct { display: flex; flex-direction: column; gap: 12px; }
.acct-card { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.acct-card h3 { margin: 0; }
.acct-card p { margin: 0; }
.acct-kv { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.acct-kv .muted { min-width: 84px; }
.acct-inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.acct-inline .field { flex: 1 1 140px; width: auto; }
.acct-inline .acct-vis { flex: 0 0 132px; padding: 9px 10px; font-size: 13px; }
.acct-field { display: flex; flex-direction: column; gap: 4px; }
.acct-sub { font-weight: 800; font-size: 14px; margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.acct-item { display: flex; gap: 10px; align-items: center; padding: 8px 10px; background: #f7f4ee; border-radius: 12px; font-size: 13.5px; }
.acct-tag { font-size: 11.5px; font-weight: 700; border-radius: 999px; padding: 2px 8px; margin-inline-start: 6px; }
.acct-tag.ok { background: #dff3e4; color: #17603a; }
.acct-tag.warn { background: #fff0c9; color: #7a5600; }
.acct-note { font-size: 13px; background: #eef5f4; border-radius: 10px; padding: 8px 10px; }
.acct-secret { display: block; font-size: 16px; letter-spacing: .06em; background: #f7f4ee; border-radius: 10px; padding: 10px 12px; word-break: break-all; user-select: all; }
.acct-qr { display: block; width: 200px; max-width: 100%; margin: 0 auto; border-radius: 10px; }
.acct-codes { font-size: 15px; background: #f7f4ee; border-radius: 10px; padding: 12px; margin: 0; columns: 2; user-select: all; }
.btn.danger { background: #b42318; color: #fff; }
.btn.ghost.danger { background: transparent; color: #b42318; border-color: #e6b8b3; }
.themed .acct-item, .themed .acct-secret, .themed .acct-codes, .themed .auth-charter { background: var(--soft); }


/* ---- UI review 2026-11-15 ---- */
.hud[hidden] { display: none !important; }
/* one Leave village button: the one in the panel header, at every width */
.hud-tr .hud-leave { display: none; }
/* village panel header: the name column may shrink; the name never wraps mid-word */
.vpanel-head .grow { min-width: 0; }
.vpanel-name .tx { white-space: nowrap; }
@media (max-width: 760px) {
  .vpanel-head { flex-wrap: wrap; }
  .vpanel-head .vjoin { order: 3; flex: 1 0 100%; justify-content: center; }
  /* the HUD pill row stops before the zoom buttons */
  .hud-bottom { right: 62px; }
}
.realm-r-name { font-size: 12px; font-weight: 600; color: var(--ink-2); margin: 2px 0; }
.lme.on .avatar { outline: 2px solid var(--brand); outline-offset: 2px; }
/* profile header in the side panel: the name keeps its column; the actions go on their own row */
.profile > .grow { flex: 1 1 160px; min-width: 0; }
.profile h2 { overflow-wrap: anywhere; }
.lbody .profile > div:last-child:not(.grow) { flex: 1 0 100%; flex-direction: row !important; flex-wrap: wrap; }

/* ---------- plots: the building card, the build menu and the Buildings list ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.plot-card { display: flex; flex-direction: column; gap: 8px; font-size: 13.5px; }
.plot-top, .plot-opt { display: flex; gap: 10px; align-items: flex-start; }
.plot-art { width: 64px; height: 64px; flex: none; image-rendering: pixelated; }
.plot-art.sm { width: 48px; height: 48px; }
.plot-job { font-size: 12.5px; }
.plot-line { font-variant-numeric: tabular-nums; }
.plot-menu { display: flex; flex-direction: column; }
.plot-opt { padding: 8px 0; border-top: 1px dashed #c9a46a; }
.plot-opt .btn { margin-top: 4px; }
.plot-cost { display: flex; flex-wrap: wrap; gap: 8px; font-variant-numeric: tabular-nums; }
.plot-cost .short { color: #b42318; font-weight: 700; }
.plot-why { color: #7a5600; margin-top: 2px; }
.plot-err { color: #b42318; font-weight: 600; }
.plot-mod { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-top: 8px; border-top: 1px dashed #c9a46a; }
.plot-keep select { font: inherit; padding: 4px 6px; border-radius: 8px; }
.plot-card .btn { align-self: flex-start; }
.plots-list { display: flex; flex-direction: column; }
.plots-item { border-bottom: 1px dashed #c9a46a; }
.plots-row { display: flex; gap: 10px; align-items: center; width: 100%; min-height: 44px; border: 0; background: none; padding: 6px 4px; text-align: start; cursor: pointer; color: inherit; font: inherit; border-radius: 8px; }
.plots-row:hover, .plots-row[aria-expanded="true"] { background: rgb(201 164 106 / .2); }
.plots-row:focus-visible { outline: 2px solid #2b1d12; outline-offset: -2px; }
.plots-n { min-width: 26px; height: 26px; display: grid; place-items: center; border-radius: 6px; background: #5a391d; color: #fbecd0; font-weight: 800; font-size: 12px; }
.plots-slot:not(:empty) { padding: 4px 4px 12px; }
.themed .plots-n { background: var(--accent); color: var(--card); }
/* the HUD pill row (now with Buildings) stays clear of the zoom buttons on either side */
@media (min-width: 761px) { .hud-bottom { right: 62px; } html[dir="rtl"] .hud-bottom { left: 62px; right: 14px; } }
.plot-card:focus { outline: none; }
