:root {
  --bg: #0b0d14;
  --panel: rgba(14, 17, 28, 0.86);
  --border: rgba(160, 170, 210, 0.18);
  --text: #e6e8f2;
  --muted: #9aa0b8;
  --accent: #e2c46b;
  --danger: #e0645a;
  --good: #7fd18b;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font: 13px/1.4 var(--font); }
canvas#scene { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
button { background: #2b3150; color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 6px 12px; cursor: pointer; font: inherit; }
button:hover { background: #3a4170; }
button:disabled { opacity: 0.45; cursor: default; }
button.small { padding: 3px 8px; font-size: 12px; }
button.ghost { background: transparent; border: none; }
button.on { background: #5c4f22; border-color: var(--accent); }
input, select { background: #151a2b; color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 4px 6px; font: inherit; }
input.num { width: 70px; }
h1 { margin: 0 0 8px; font-weight: 600; letter-spacing: 0.02em; }
h4 { margin: 10px 0 4px; font-size: 12px; }
.muted { color: var(--muted); }
.small-text { font-size: 11px; margin-top: 4px; }
.invite { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin: 12px 0 0; }
.invite.bad { color: var(--muted); }
.err { color: var(--danger); min-height: 1.2em; }
.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 4px 0; }
.overlay { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(circle at 50% 40%, #1b2140, #05060b); z-index: 10; }
.card { width: min(420px, calc(100vw - 32px)); background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 24px; }
.card label { display: grid; gap: 4px; margin: 16px 0 12px; }
.panel { position: fixed; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; backdrop-filter: blur(6px); }
#status { top: 12px; left: 12px; width: 280px; }
#travel { top: 12px; left: 304px; width: 330px; }
#inspect { top: 12px; right: 12px; width: 340px; max-height: calc(100vh - 24px); overflow-y: auto; }
#chat { left: 12px; bottom: 12px; width: 440px; height: 300px; display: flex; flex-direction: column; }
#chat-log { flex: 1; overflow-y: auto; font-size: 12px; padding: 4px 0; }
#chat-log .m { margin: 1px 0; word-wrap: break-word; }
#chat-log .ch { font-size: 10px; text-transform: uppercase; padding: 0 4px; border-radius: 3px; margin-right: 4px; }
.ch-world { background: #2c3a63; } .ch-nearby { background: #2c5e3d; } .ch-guild { background: #5c3d6b; } .ch-system { background: #6b4b22; } .ch-event { background: #3b3b3b; } .ch-council { background: #7a6420; }
#chat-log .m.overseer { background: rgba(120,180,230,0.12); border-left: 2px solid #9fd0f0; padding-left: 4px; white-space: pre-wrap; }
#chat-form input { flex: 1; }
.tabs { display: flex; gap: 2px; margin-bottom: 4px; }
.tabs button { padding: 2px 8px; font-size: 11px; background: transparent; }
.tabs button.on { background: #2b3150; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--border); }
.tag { font-size: 10px; padding: 1px 6px; border-radius: 8px; background: #2b3150; text-transform: uppercase; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; margin: 4px 0; }
.chip { font-size: 11px; padding: 1px 6px; border-radius: 8px; background: #1d2238; border: 1px solid var(--border); }
.bar { height: 6px; background: #1b1f33; border-radius: 3px; overflow: hidden; margin: 2px 0 6px; }
.bar > div { height: 100%; background: var(--accent); }
.kv { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px 8px; font-size: 12px; margin: 4px 0; }
.kv span { color: var(--muted); }
.needs { display: grid; grid-template-columns: 70px 1fr; gap: 0 8px; align-items: center; font-size: 11px; }
.plan-node { border: 1px solid var(--border); border-radius: 6px; padding: 4px 6px; margin: 4px 0; }
.plan-node .row { margin: 2px 0; }
.tooltip { position: fixed; pointer-events: none; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; font-size: 12px; z-index: 5; }
#toast { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--border); padding: 8px 14px; border-radius: 8px; z-index: 6; max-width: 80vw; }
#toast.bad { border-color: var(--danger); }
#bubbles { position: fixed; inset: 0; pointer-events: none; z-index: 1; overflow: hidden; }
.bubble-anchor { position: absolute; transform-origin: 50% 100%; }
.bubble { position: relative; background: #fffdf6; color: #2a1a10; border: 2px solid #2a1a10; border-radius: 16px; padding: 5px 10px; font: 600 13px/1.25 "Segoe UI", system-ui, sans-serif; white-space: nowrap; max-width: 220px; margin-bottom: 18px; animation: bubble-in 0.28s cubic-bezier(.34,1.56,.64,1) both; }
.bubble::before, .bubble::after { content: ""; position: absolute; background: #fffdf6; border: 2px solid #2a1a10; border-radius: 50%; }
.bubble::before { width: 10px; height: 10px; left: 50%; bottom: -12px; margin-left: -8px; }
.bubble::after { width: 6px; height: 6px; left: 50%; bottom: -20px; margin-left: -2px; }
.bubble.pop { animation: bubble-pop 0.25s ease-in forwards; }
@keyframes bubble-in { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes bubble-pop { to { transform: scale(1.35); opacity: 0; } }
#bookmarks { top: 228px; left: 12px; width: 280px; max-height: calc(100vh - 560px); min-height: 80px; overflow-y: auto; }
#bm-list .bm { display: flex; gap: 6px; align-items: center; padding: 4px 6px; border-radius: 6px; cursor: pointer; user-select: none; }
#bm-list .bm:hover { background: #22284a; }
#bm-list .bm .k { font-size: 10px; text-transform: uppercase; color: var(--muted); width: 64px; }
#bm-list .bm .l { flex: 1; }
#edge { top: 150px; left: 50%; transform: translateX(-50%); width: min(460px, calc(100vw - 24px)); text-align: center; border-color: var(--accent); }
#edge-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.ctx { position: fixed; z-index: 20; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 4px; min-width: 200px; }
.ctx button { display: block; width: 100%; text-align: left; background: transparent; border: none; padding: 6px 10px; }
.ctx button:hover { background: #2b3150; }
.ctx .t { padding: 4px 10px; color: var(--muted); font-size: 11px; }
#chat-log .m.link { cursor: pointer; }
#chat-log .m.link:hover { background: rgba(255,255,255,0.06); }
.card.wide { width: min(760px, calc(100vw - 32px)); }
.gods { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin-top: 12px; }
.gods button { display: grid; gap: 6px; text-align: left; padding: 14px; }
#map { position: fixed; inset: 0; z-index: 15; display: grid; place-items: center; background: rgba(5,6,12,0.55); }
.map-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 12px; width: min(92vmin, 920px); }
#map-canvas { width: 100%; height: auto; display: block; border-radius: 8px; margin: 6px 0; }
#profile { top: 12px; left: 304px; width: 330px; z-index: 3; }
.banned-reason { border-left: 3px solid var(--danger); padding: 8px 12px; background: rgba(224,100,90,0.08); white-space: pre-wrap; }
#banned { z-index: 30; }
a { color: var(--accent); }
#friends { top: 12px; left: 304px; width: 340px; max-height: calc(100vh - 340px); display: flex; flex-direction: column; z-index: 3; }
#fr-list { overflow-y: auto; max-height: 40vh; }
.fr { display: flex; align-items: center; gap: 6px; padding: 4px; border-radius: 6px; }
.fr:hover { background: #22284a; }
.fr .dot { width: 8px; height: 8px; border-radius: 50%; background: #555; }
.fr .dot.on { background: var(--good); }
.fr .n { flex: 1; }
.fr .st { font-size: 10px; color: var(--muted); text-transform: uppercase; }
#dm-log { overflow-y: auto; height: 300px; font-size: 12px; padding: 4px 0; }
#dm-log .dm { margin: 3px 0; max-width: 85%; padding: 4px 8px; border-radius: 10px; background: #22284a; word-wrap: break-word; }
#dm-log .dm.mine { margin-left: auto; background: #3a4170; }
.badge { background: var(--danger); color: #fff; border-radius: 8px; padding: 0 5px; font-size: 10px; }
.emoji-pop { position: fixed; z-index: 25; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 6px; display: grid; grid-template-columns: repeat(8, 28px); gap: 2px; }
.emoji-pop button { background: transparent; border: none; padding: 2px; font-size: 18px; }
.emoji-pop button:hover { background: #2b3150; }
#maint { top: 12px; left: 50%; transform: translateX(-50%); z-index: 40; border-color: var(--accent); max-width: min(560px, calc(100vw - 24px)); text-align: center; }
#bview { top: 12px; right: 12px; width: 340px; max-height: calc(100vh - 24px); overflow-y: auto; z-index: 4; }
.ctx .t { white-space: normal; }
img.icon { vertical-align: middle; margin-right: 3px; image-rendering: auto; }
.portrait { float: right; margin: 0 0 4px 8px; }
.portrait img { border-radius: 8px; background: #1d2238; border: 1px solid var(--border); }
#controls { top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow-y: auto; z-index: 30; }
table.keys { width: 100%; border-collapse: collapse; font-size: 12px; }
table.keys td { padding: 3px 4px; vertical-align: top; border-bottom: 1px solid var(--border); }
table.keys td:first-child { white-space: nowrap; width: 1%; }
kbd { display: inline-block; min-width: 18px; padding: 1px 6px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; background: #1d2238; font: 600 11px/1.5 var(--font); text-align: center; }
body.hud-off #hud > .panel:not(#maint), body.hud-off #bubbles, body.hud-off .tooltip, body.hud-off #toast, body.hud-off .ctx { display: none !important; }
.ui-hint { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px; z-index: 50; font-size: 12px; }
#settings { top: 12px; left: 304px; width: 300px; z-index: 4; }
button.danger { background: #6a2a2a; border-color: var(--danger); }
button.danger:hover { background: #8a3434; }
#idtags { position: fixed; inset: 0; pointer-events: none; z-index: 2; }
#idtags div { position: absolute; transform: translate(-50%, -100%); font: 10px ui-monospace, monospace; color: #ffe9a8; background: rgba(10, 12, 20, 0.7); padding: 0 3px; border-radius: 3px; white-space: nowrap; }
#idtags div.c { color: #a8e0ff; } #idtags div.s { color: #d8b8ff; }
#ledger { top: 12px; left: 304px; width: 380px; max-height: calc(100vh - 340px); overflow-y: auto; z-index: 3; }
#ledger .lg-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 6px 4px; border-bottom: 1px solid rgba(255,255,255,0.07); cursor: pointer; }
#ledger .lg-row:hover { background: rgba(255,255,255,0.05); }
#ledger .lg-felt { grid-column: 1 / -1; font-size: 11px; opacity: 0.8; font-style: italic; }
#ledger .tabs button.on { background: rgba(255,215,107,0.2); }
#inspect .mem { font-size: 11px; margin: 2px 0; padding-left: 6px; border-left: 2px solid rgba(255,255,255,0.15); }
#inspect .mem.good { border-color: #7fd18b; } #inspect .mem.bad { border-color: #e0645a; } #inspect .mem.mine { background: rgba(255,215,107,0.08); }
#questboard { top: 12px; left: 304px; width: 360px; max-height: calc(100vh - 340px); overflow-y: auto; z-index: 3; }
@media (max-width: 900px) {
  #travel { top: auto; bottom: 324px; left: 12px; width: calc(100vw - 24px); }
  #chat { width: calc(100vw - 24px); height: 220px; }
  #inspect { width: calc(100vw - 24px); left: 12px; top: 140px; max-height: 50vh; }
}

/* Authenticator setup (Profile). The QR needs a white surround to scan in dark mode. */
.qr { background: #fff; display: inline-block; padding: 6px; border-radius: 8px; margin: 4px 0; }
.qr svg { display: block; width: 180px; height: 180px; }
.recovery pre { background: rgba(127, 127, 127, 0.15); padding: 8px; border-radius: 6px; font-size: 13px; columns: 2; user-select: all; }
