:root {
  --ink: #2b2b33; --paper: #fbf7ef; --card: #ffffff; --muted: #7a7680; --line: #ebe4d6;
  --accent: #d9822b; --accent-2: #6d8ea0; --good: #4f9d69; --bad: #c4453a;
  --radius: 14px; --shadow: 0 8px 30px rgba(30, 25, 40, .18);
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, Segoe UI, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #c9d6df; color: var(--ink); }
canvas#world { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.muted { color: var(--muted); } .small { font-size: 12.5px; }
.hidden { display: none !important; }
h1, h2, h3 { margin: 0 0 6px; } h3 { font-size: 15px; }

.btn { border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 9px 14px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { border-color: #d5cab3; } .btn:focus-visible, input:focus-visible, textarea:focus-visible, button:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.small { padding: 5px 9px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: default; }
input, textarea { width: 100%; font: inherit; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--ink); }
label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 6px; }

/* enter */
.enter { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(43, 43, 51, .35); backdrop-filter: blur(3px); z-index: 50; padding: 16px; }
.enter-card { background: var(--paper); border-radius: 20px; padding: 26px; max-width: 380px; width: 100%; box-shadow: var(--shadow); }
.enter-kicker { text-transform: uppercase; letter-spacing: .12em; font-size: 11px; color: var(--accent); font-weight: 700; }
.enter-card h1 { font-size: 40px; font-family: Georgia, serif; margin: 6px 0 8px; }
.enter-card p { line-height: 1.5; margin: 0 0 4px; }
.enter-card .btn { width: 100%; margin: 14px 0 8px; padding: 12px; }

/* hud */
.hud { position: fixed; top: max(10px, env(safe-area-inset-top)); left: 10px; right: 10px; display: flex; justify-content: space-between; gap: 10px; pointer-events: none; z-index: 5; }
.hud > div { background: rgba(251, 247, 239, .92); border-radius: 12px; padding: 8px 12px; box-shadow: 0 2px 12px rgba(0,0,0,.08); }
.hud .name { font-weight: 800; font-size: 17px; }
.hud-right { text-align: right; } .time { font-weight: 800; font-size: 20px; font-variant-numeric: tabular-nums; }
.chip { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: #efe6d4; color: #6b5a3a; vertical-align: middle; }
.thought { position: fixed; z-index: 4; max-width: 230px; background: #fff; border-radius: 14px; padding: 8px 11px; font-size: 13.5px; box-shadow: 0 4px 16px rgba(0,0,0,.15); transform: translate(-50%, -100%); pointer-events: none; line-height: 1.35; }
.thought::after { content: ''; position: absolute; left: 50%; bottom: -7px; width: 12px; height: 12px; background: #fff; transform: translateX(-50%) rotate(45deg); }
.cam-bar { position: fixed; z-index: 6; left: 12px; bottom: max(14px, env(safe-area-inset-bottom)); display: flex; gap: 8px; flex-wrap: wrap; pointer-events: none; }
.cam-btn { pointer-events: auto; border: 0; border-radius: 99px; padding: 9px 14px; font: inherit; font-weight: 700; font-size: 13.5px; background: rgba(251,247,239,.95); color: var(--ink); box-shadow: 0 2px 12px rgba(0,0,0,.15); cursor: pointer; }
.watch-chip { position: fixed; z-index: 6; left: 50%; transform: translateX(-50%); top: calc(max(10px, env(safe-area-inset-top)) + 66px); background: rgba(251,247,239,.95); border-radius: 12px; padding: 7px 12px; font-size: 13.5px; box-shadow: 0 2px 12px rgba(0,0,0,.12); max-width: 92vw; text-align: center; }
@media (max-width: 760px) { .watch-chip { top: calc(max(10px, env(safe-area-inset-top)) + 114px); } }
.cam-btn.free { background: var(--ink); color: #fff; }
@media (max-width: 760px) { .cam-bar { bottom: auto; top: calc(max(10px, env(safe-area-inset-top)) + 68px); left: 10px; right: 10px; } .cam-btn { padding: 7px 12px; font-size: 12.5px; } }

/* Wall mockup preview */
.wall-mockup { background: linear-gradient(180deg, #eae3d5 0%, #dcd3c2 100%); border-radius: 14px; padding: 28px 24px 32px; display: flex; flex-direction: column; align-items: center; margin-bottom: 10px; position: relative; box-shadow: inset 0 2px 12px rgba(0,0,0,.06); }
.wall-mockup .mat { background: #fffdf8; padding: 14px; border: 10px solid #352b22; box-shadow: 0 14px 28px rgba(30,22,18,.28), inset 0 1px 4px rgba(0,0,0,.12); max-width: 310px; width: 100%; }
.wall-mockup .mat img { width: 100%; display: block; border-radius: 2px; }
.wall-mockup .ledge { width: 82%; height: 8px; background: #b89872; border-radius: 4px; margin-top: 22px; box-shadow: 0 4px 10px rgba(0,0,0,.15); }
.kpi-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0; }
.kpi { background: #f8f4ec; border: 1px solid var(--line); border-radius: 10px; padding: 8px; text-align: center; }
.kpi .num { font-size: 18px; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; }
.kpi .lbl { font-size: 11px; color: var(--muted); }
.toast { position: fixed; left: 50%; top: 74px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 9px 14px; border-radius: 10px; z-index: 30; font-size: 14px; max-width: 90vw; }

/* panel */
.panel { position: fixed; z-index: 10; right: 12px; top: 84px; bottom: 12px; width: 400px; background: rgba(251, 247, 239, .97); border-radius: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; }
.panel.collapsed .tab-body { display: none; } .panel.collapsed { bottom: auto; }
.tabs { display: flex; gap: 2px; overflow-x: auto; padding: 8px 8px 0; border-bottom: 1px solid var(--line); scrollbar-width: none; flex-shrink: 0; }
.tabs button { border: 0; background: none; font: inherit; font-size: 13px; font-weight: 700; color: var(--muted); padding: 8px 9px 10px; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.active { color: var(--ink); border-color: var(--accent); }
.tabs .toggle { margin-left: auto; }
.tabs .public-only:not(.hidden) + .toggle { margin-left: 0; }
.tab-body { flex: 1; overflow: hidden; position: relative; }
.tab-body > section { display: none; height: 100%; overflow-y: auto; padding: 12px; }
.tab-body > section.active { display: block; }
.tab-body > section[data-pane="chat"].active { display: flex; flex-direction: column; }

@media (max-width: 760px) {
  .panel { left: 8px; right: 8px; width: auto; top: auto; height: 52vh; bottom: max(8px, env(safe-area-inset-bottom)); }
  .panel.collapsed { height: auto; }
  .hud .name { font-size: 15px; } .time { font-size: 17px; }
}

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; }
.card p { margin: 6px 0; line-height: 1.5; }
.row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; align-content: start; }
.art-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.art-card img { width: 100%; aspect-ratio: 1; display: block; background: #f3efe6; }
.art-card.framed .frame { background: linear-gradient(#e9e4da, #d9d2c4); padding: 14px; }
.art-card.framed .frame img { padding: 10px; background: #fffdf8; border: 7px solid #3b3026; box-shadow: 0 6px 14px rgba(0,0,0,.25); }
.art-card .meta { padding: 8px; font-size: 13px; }
.art-card .title { font-weight: 700; line-height: 1.25; }
.price { font-weight: 800; font-size: 15px; }

/* bars */
.bar { height: 8px; background: #efe9dd; border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent-2); border-radius: 99px; transition: width .6s ease; }
.stat { display: grid; grid-template-columns: minmax(96px, 122px) 1fr auto; align-items: center; gap: 8px; font-size: 13px; margin: 6px 0; }
.stat .v { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tag { display: inline-block; padding: 3px 9px; border-radius: 99px; background: #eef3f6; font-size: 12.5px; margin: 2px 3px 2px 0; }
.tag.no { background: #f8e9e6; }
.check { color: var(--good); font-weight: 800; } .lock { color: var(--muted); }

/* chat */
.chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding-bottom: 8px; }
.msg { max-width: 82%; padding: 8px 11px; border-radius: 14px; line-height: 1.4; font-size: 14px; }
.msg.me { align-self: flex-end; background: var(--ink); color: #fff; border-bottom-right-radius: 4px; }
.msg.cat { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.sys { align-self: center; color: var(--muted); font-size: 12.5px; background: none; text-align: center; }
.chat-form { display: flex; gap: 6px; flex-shrink: 0; }
.offerings { display: flex; gap: 6px; overflow-x: auto; padding: 6px 0 8px; flex-shrink: 0; scrollbar-width: none; }
.offerings .btn { white-space: nowrap; font-size: 12.5px; padding: 6px 10px; }

.log-item { font-size: 13.5px; padding: 7px 0; border-bottom: 1px dashed var(--line); display: grid; grid-template-columns: 52px 1fr; gap: 8px; }
.log-item .t { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; padding-top: 1px; }
.log-item.sale { background: #eef7f0; } .log-item.level, .log-item.stage, .log-item.ambition { background: #fff6e6; }
.filters { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 8px; }
.filters button { border: 1px solid var(--line); background: #fff; border-radius: 99px; font: inherit; font-size: 12px; padding: 4px 10px; cursor: pointer; }
.filters button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.journal-entry { font-family: Georgia, serif; line-height: 1.65; font-size: 15px; white-space: pre-wrap; }
.money { font-variant-numeric: tabular-nums; }
.money.pos { color: var(--good); } .money.neg { color: var(--bad); }
a { color: #3e6d8e; }
/* Computers: wrap the tab bar so every tab (incl. Owner) is always reachable. */
@media (hover: hover) and (pointer: fine) { .tabs { flex-wrap: wrap; overflow-x: visible; row-gap: 0; } .tabs button { padding: 7px 8px 8px; } }

/* Command Center overlay: the CRT page in a same-origin frame over the town (app.js, "Command Center overlay") */
.cc-overlay { --cc-bg: #040704; --cc-fg: #5dfc8a; position: fixed; inset: 0; z-index: 1000; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); background: var(--cc-bg); color: var(--cc-fg); outline: none; color-scheme: dark; }
.cc-overlay[data-phosphor="amber"] { --cc-bg: #080502; --cc-fg: #ffb642; }
.cc-overlay[hidden] { display: none; }
.cc-frame { display: block; width: 100%; height: 100%; border: 0; background: var(--cc-bg); visibility: hidden; }
.cc-overlay.ready .cc-frame { visibility: visible; }
.cc-wait { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; padding: 16px; text-align: center; font: 14px/1.5 ui-monospace, "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace; text-transform: uppercase; letter-spacing: .08em; }
.cc-overlay.ready .cc-wait { display: none; }
.cc-wait p { margin: 0; max-width: 46ch; }
.cc-wait-text, .cc-wait-btns { opacity: 0; animation: cc-show 0s .5s forwards; } /* only a slow load ever shows them */
.cc-wait-stuck { display: none; }
.cc-overlay.stuck .cc-wait-stuck { display: block; }
.cc-overlay.stuck .cc-wait-text { display: none; }
.cc-overlay.stuck .cc-wait-btns { opacity: 1; animation: none; }
.cc-wait a, .cc-wait button { display: inline-block; min-height: 44px; padding: 10px 6px; border: 0; border-radius: 0; background: none; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; text-decoration: none; cursor: pointer; }
.cc-wait a:hover, .cc-wait button:hover { background: var(--cc-fg); color: var(--cc-bg); }
.cc-wait a:focus-visible, .cc-wait button:focus-visible { outline: 2px solid var(--cc-fg); outline-offset: 2px; }
@keyframes cc-show { to { opacity: 1; } }
html.cc-open, html.cc-open body { overflow: hidden; overscroll-behavior: none; }
