:root {
  --bg: #060708;
  --ink: #eaecef;
  --muted: #9b958a;
  --line: rgba(240, 185, 11, 0.2);
  --surface: rgba(8, 10, 12, 0.7);
  --surface-strong: rgba(10, 12, 14, 0.96);
  --town: #f0b90b;
  --signal: #f0b90b;
  --danger: #e06d4f;
  --sans: "Barlow Condensed", "Arial Narrow", ui-sans-serif, system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { background: var(--bg); color: var(--ink); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
button, input, textarea, a { color: inherit; font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
#town-scene { position: fixed; inset: 0; cursor: grab; background: var(--bg); }
#town-scene:active { cursor: grabbing; }
#town-scene canvas { display: block; width: 100%; height: 100%; }
.atmosphere { position: fixed; inset: 0; z-index: 2; pointer-events: none; background: radial-gradient(circle at 51% 48%,rgba(224,165,68,.035),transparent 37%,rgba(0,0,0,.08) 72%,rgba(0,0,0,.5) 125%); }

.interface { position: fixed; inset: 0; z-index: 5; isolation: isolate; display: grid; grid-template-columns: 236px minmax(0,1fr) 344px; grid-template-rows: 64px minmax(0,1fr) 48px; gap: 20px 28px; padding: 22px 28px; pointer-events: none; }
.town-header, .left-rail, .right-rail, .town-footer { pointer-events: none; }
.brand, .header-actions, .home-search, .rail-tabs button, .payout-row, .comms-compose, .message-stream { pointer-events: auto; }
.town-header { grid-column: 1 / -1; display: flex; align-items: flex-start; justify-content: space-between; min-height: 58px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; min-width: 0; text-decoration: none; }
.brand-mark, .brand small, .town-state { display: none; }
.brand strong { display: block; font-size: clamp(29px,2.7vw,42px); line-height: .88; letter-spacing: .015em; font-weight: 600; text-transform: uppercase; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.text-button, .icon-button, .contract-button { display: inline-flex; align-items: center; justify-content: center; height: 36px; border: 1px solid var(--line); border-radius: 2px; background: rgba(8,10,12,.66); text-decoration: none; backdrop-filter: blur(12px); transition: transform 180ms ease,background 180ms ease,border-color 180ms ease; }
.contract-button[hidden] { display: none !important; }
.text-button { padding: 0 14px; font: 600 10px/1 var(--mono); letter-spacing: .07em; }
.icon-button { width: 36px; }
.contract-button { gap: 8px; padding: 0 11px; font: 700 12px/1 var(--mono); }
.contract-button span { display: none; }
.contract-button b { font-weight: 700; }
.text-button:hover, .icon-button:hover, .contract-button:hover { transform: translateY(-1px); background: rgba(86,61,27,.42); border-color: rgba(240,195,108,.54); }

.left-rail { grid-column: 1; grid-row: 2; align-self: start; width: 100%; padding-top: 6px; }
.town-intro { display: none; }
.telemetry { display: grid; grid-template-columns: 1fr; gap: 0; border-left: 1px solid var(--line); }
.telemetry-row { position: relative; min-width: 0; padding: 13px 0 15px 17px; border-bottom: 1px solid rgba(218,183,119,.11); }
.telemetry-row::before { content: ""; position: absolute; left: -2px; top: 18px; width: 3px; height: 10px; background: var(--line); }
.telemetry-row.accent-row::before { background: var(--signal); box-shadow: 0 0 12px rgba(240,195,108,.45); }
.telemetry-row span { display: block; color: var(--muted); font: 500 9px/1 var(--mono); letter-spacing: .11em; }
.telemetry-row strong { display: block; margin-top: 7px; font: 600 25px/.9 var(--sans); letter-spacing: .01em; white-space: nowrap; }
.telemetry-row strong small { color: var(--muted); font-size: 10px; }
.telemetry-row.accent-row strong { color: var(--signal); }
.home-search { position: fixed; left: 28px; bottom: 72px; width: 236px; }
.home-search label { display: block; margin-bottom: 8px; color: var(--muted); font: 500 9px/1 var(--mono); letter-spacing: .1em; }
.home-search > div { display: grid; grid-template-columns: 1fr 38px; gap: 0; padding: 0; border: 1px solid var(--line); border-radius: 2px; background: rgba(8,10,12,.78); box-shadow: 0 14px 34px rgba(0,0,0,.24); backdrop-filter: blur(16px); }
.home-search input { width: 100%; min-width: 0; height: 40px; padding: 0 12px; border: 0; outline: 0; background: transparent; font: 500 10px/1 var(--mono); }
.home-search input::placeholder { color: rgba(184,159,145,.7); }
.home-search button { width: 40px; height: 40px; border: 0; border-left: 1px solid var(--line); border-radius: 0; background: var(--signal); color: #17120a; }
.home-search > span { display: block; min-height: 16px; margin-top: 6px; color: var(--muted); font: 720 10px/1.4 var(--mono); }
.view-controls, .center-reticle { display: none; }

.right-rail { grid-column: 3; grid-row: 2 / 4; min-height: 0; display: flex; flex-direction: column; overflow: hidden; padding: 16px 0 0 18px; border-left: 1px solid var(--line); background: linear-gradient(90deg,rgba(8,10,12,.42),rgba(8,10,12,.08)); }
.rail-tabs { display: flex; align-items: center; gap: 17px; padding: 0 12px 14px 0; border-bottom: 1px solid rgba(218,183,119,.12); }
.rail-tabs button { padding: 0 0 7px; border: 0; border-bottom: 1px solid transparent; background: none; color: var(--muted); font: 600 10px/1 var(--mono); letter-spacing: .06em; }
.rail-tabs button.active { color: var(--ink); border-bottom-color: var(--town); }
.rail-tabs span { margin-left: auto; color: var(--muted); font: 700 9px/1 var(--mono); }
.payouts-panel, .comms-panel { flex: 1; min-height: 0; }
.payouts-panel[hidden], .comms-panel[hidden] { display: none !important; }
.payout-list { height: 100%; overflow: hidden; padding-right: 12px; }
.payout-row { display: grid; grid-template-columns: 1fr auto; gap: 5px 10px; padding: 11px 0; border-bottom: 1px solid rgba(218,183,119,.1); color: var(--ink); text-decoration: none; animation: rowIn 360ms cubic-bezier(.16,1,.3,1) both; }
.payout-row span { overflow: hidden; color: var(--muted); font: 700 10px/1 var(--mono); text-overflow: ellipsis; white-space: nowrap; }
.payout-row strong { color: var(--signal); font: 800 11px/1 var(--mono); }
.payout-row small { grid-column: 1 / -1; overflow: hidden; color: var(--muted); font: 650 9px/1 var(--mono); text-overflow: ellipsis; white-space: nowrap; }
.payout-empty { color: var(--muted); font-size: 12px; }
.comms-panel { flex-direction: column; }
.comms-panel.active { display: flex; }
.message-stream { flex: 1; min-height: 0; overflow-y: auto; }
.system-message, .chat-message { padding: 10px 0; border-bottom: 1px solid rgba(33,29,25,.08); }
.system-message span, .chat-message header strong { color: var(--signal); font: 800 10px/1 var(--mono); }
.system-message p, .chat-message p { margin: 6px 0 0; color: var(--ink); font-size: 12px; line-height: 1.4; overflow-wrap: anywhere; }
.chat-message header { display: flex; justify-content: space-between; gap: 10px; }
.chat-message header time { color: var(--muted); font: 700 9px/1 var(--mono); }
.comms-compose { padding-top: 10px; }
.wallet-line { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.wallet-line[hidden] { display: none; }
.wallet-line button { background: none; }
#connectWallet { display: flex; align-items: center; gap: 7px; font: 800 10px/1 var(--mono); }
#connectWallet { padding: 0; border: 0; }
#editNickname { height: 28px; padding: 0 9px; border: 1px solid var(--line); border-radius: 7px; color: var(--muted); font: 750 9px/1 var(--mono); }
#editNickname:hover { color: var(--ink); border-color: rgba(243,220,202,.32); }
.wallet-led { width: 7px; height: 7px; border-radius: 50%; background: #aaa39b; }
.wallet-led.connected { background: var(--town); box-shadow: 0 0 0 4px rgba(185,135,61,.12); }
.chat-gate[hidden], .comms-compose form[hidden] { display: none; }
.chat-gate button { display: flex; width: 100%; min-height: 58px; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid rgba(255,147,104,.42); border-radius: 10px; background: rgba(113,45,29,.26); color: var(--ink); text-align: left; transition: background 160ms ease,border-color 160ms ease,transform 160ms ease; }
.chat-gate button:hover:not(:disabled) { transform: translateY(-1px); border-color: var(--signal); background: rgba(136,52,31,.38); }
.chat-gate button:disabled { border-color: var(--line); background: rgba(255,255,255,.025); }
.chat-gate-icon { display: grid; width: 34px; height: 34px; flex: 0 0 auto; place-items: center; border-radius: 7px; background: var(--signal); color: #180b08; font-size: 18px; }
.chat-gate button:disabled .chat-gate-icon { background: var(--muted); }
.chat-gate b, .chat-gate small { display: block; }
.chat-gate b { font: 800 11px/1 var(--mono); }
.chat-gate small { margin-top: 6px; color: var(--muted); font: 700 8px/1.2 var(--mono); letter-spacing: .04em; }
.comms-compose form { display: grid; grid-template-columns: 1fr 38px; gap: 8px; }
.comms-compose textarea { min-height: 38px; max-height: 86px; resize: none; border: 1px solid var(--line); border-radius: 8px; background: rgba(19,10,7,.7); padding: 9px 10px; outline: 0; font-size: 12px; }
.comms-compose form button { width: 38px; height: 38px; border: 0; border-radius: 8px; background: var(--ink); color: #180b08; }
.comms-error { display: block; margin-top: 6px; color: var(--danger); font-size: 10px; }

.town-footer { grid-column: 1 / 3; grid-row: 3; position: static; display: flex; align-items: end; gap: 28px; border-top: 1px solid var(--line); padding-top: 13px; }
.town-footer > div { display: flex; gap: 7px; align-items: baseline; }
.town-footer span { color: var(--muted); font-size: 10px; font-weight: 700; }
.town-footer strong { font-size: 11px; }
.footer-signal { margin-left: auto; }
.footer-signal i { display: none; }

.home-inspector { position: fixed; z-index: 12; left: 50%; bottom: 76px; width: min(330px,calc(100vw - 32px)); padding: 17px; border: 1px solid var(--line); border-radius: 2px; background: var(--surface-strong); box-shadow: 0 20px 54px rgba(0,0,0,.42); backdrop-filter: blur(16px); transform: translateX(-50%); }
.home-inspector[hidden] { display: none; }
.inspector-close { position: absolute; right: 10px; top: 8px; border: 0; background: none; font-size: 18px; }
.eyebrow { margin: 0; color: var(--signal); font: 800 9px/1.2 var(--mono); letter-spacing: .08em; }
.home-inspector h2 { margin: 7px 0 12px; font-size: 18px; }
.inspector-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); }
.inspector-grid > div { padding: 9px; background: rgba(20,10,7,.92); }
.inspector-grid span { display: block; color: var(--muted); font: 700 8px/1 var(--mono); }
.inspector-grid strong { display: block; margin-top: 5px; font: 750 10px/1 var(--mono); }
.boost-readout { margin: 10px 0; color: var(--signal); font: 750 9px/1 var(--mono); }
.inspector-actions { display: flex; align-items: center; gap: 14px; }
.inspector-actions button { height: 32px; padding: 0 11px; border: 0; border-radius: 7px; background: var(--ink); color: #180b08; font: 800 9px/1 var(--mono); }
.inspector-actions a { color: var(--muted); font: 700 9px/1 var(--mono); text-decoration: none; }

.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 22px; background: rgba(0,0,0,.48); backdrop-filter: blur(8px); }
.modal[hidden] { display: none; }
.modal-dialog { width: min(680px,100%); max-height: min(760px,calc(100vh - 44px)); overflow: hidden; border: 1px solid var(--line); border-radius: 2px; background: var(--surface-strong); box-shadow: 0 24px 80px rgba(0,0,0,.5); animation: modalIn 240ms cubic-bezier(.16,1,.3,1) both; }
.modal-dialog > header { display: flex; justify-content: space-between; align-items: center; padding: 20px; border-bottom: 1px solid var(--line); }
.modal-dialog h2 { margin: 4px 0 0; font-size: 26px; }
.modal-dialog header button { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 8px; background: transparent; }
.registry-head, .registry-row { display: grid; grid-template-columns: minmax(150px,1.5fr) 1fr .7fr .8fr; gap: 12px; align-items: center; padding: 10px 20px; }
.registry-head { color: var(--muted); font: 750 9px/1 var(--mono); }
.registry-list { max-height: 58vh; overflow-y: auto; }
.registry-row { width: 100%; border: 0; border-top: 1px solid var(--line); background: transparent; text-align: left; font: 700 10px/1.2 var(--mono); }
.registry-row:hover { background: rgba(173,98,72,.07); }
.registry-wallet { display: flex; gap: 10px; }
.registry-rank { color: var(--muted); font-style: normal; }
.registry-reward { color: var(--signal); }
.modal-copy { margin: 0; padding: 18px 20px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.boost-tiers { display: grid; grid-template-columns: repeat(3,1fr); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.boost-tier { min-height: 110px; padding: 16px; border: 0; border-right: 1px solid var(--line); background: transparent; text-align: left; }
.boost-tier:last-child { border-right: 0; }
.boost-tier.active, .boost-tier:hover { background: rgba(173,98,72,.08); }
.boost-tier span, .boost-tier small { display: block; color: var(--muted); font: 700 9px/1.3 var(--mono); }
.boost-tier strong { display: block; margin: 13px 0 7px; font-size: 23px; }
.boost-invoice { padding: 20px; }
.boost-invoice > div:first-child { display: flex; justify-content: space-between; }
.boost-invoice span { color: var(--muted); font-size: 9px; }
#boostDeposit { display: grid; width: 100%; margin-top: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.035); text-align: left; }
#boostDeposit b { overflow: hidden; margin-top: 5px; font: 700 10px/1 var(--mono); text-overflow: ellipsis; }
.boost-progress { display: grid; grid-template-columns: repeat(4,1fr); gap: 5px; margin-top: 13px; }
.boost-progress i { height: 3px; background: var(--line); }
.boost-progress i.done { background: var(--town); }
#boostStatus { color: var(--muted); font-size: 10px; }
.nickname-dialog { width: min(430px,100%); }
.nickname-dialog form { display: grid; gap: 12px; padding: 20px; }
.nickname-dialog label { color: var(--muted); font-size: 11px; }
.nickname-dialog input { height: 40px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.035); outline: 0; }
.nickname-dialog form button { height: 38px; border: 0; border-radius: 8px; background: var(--ink); color: #180b08; font: 800 10px/1 var(--mono); }
.nickname-error { min-height: 14px; color: var(--danger); font-size: 10px; }
.toast { position: fixed; z-index: 30; left: 50%; bottom: 26px; padding: 10px 13px; border-radius: 999px; background: rgba(33,29,25,.92); color: #fffaf0; font-size: 12px; opacity: 0; pointer-events: none; transform: translate(-50%,16px); transition: 180ms ease; }
.toast.visible { opacity: 1; transform: translate(-50%,0); }
@keyframes rowIn { from { opacity: 0; transform: translateY(-8px); } }
@keyframes modalIn { from { opacity: 0; transform: translateY(8px) scale(.985); } }

@media (max-width: 900px) {
  .interface { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr auto; padding: 14px; gap: 12px; }
  .town-header { grid-column: 1; min-height: 44px; align-items: flex-start; }
  .brand strong { font-size: 28px; }
  .text-button { display: none; }
  .left-rail { grid-column: 1; grid-row: 2; width: 100%; }
  .telemetry { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px 12px; width: min(360px,100%); }
  .telemetry-row strong { font-size: 18px; }
  .right-rail { grid-column: 1; grid-row: 3; justify-self: end; width: min(100%,330px); max-height: 34vh; align-self: start; }
  .town-footer { left: 14px; right: 14px; bottom: 12px; gap: 18px; }
  .town-footer > div:nth-child(2), .town-footer > div:nth-child(3) { display: none; }
  .footer-signal { margin-left: auto; }
  .home-search { left: 14px; bottom: 48px; width: min(420px,calc(100vw - 28px)); }
}

@media (max-width: 560px) {
  .atmosphere { background: radial-gradient(circle at 50% 55%,rgba(201,143,52,.045),transparent 42%,rgba(0,0,0,.26)); }
  .interface { pointer-events: none; }
  .town-header, .left-rail, .right-rail, .town-footer { pointer-events: none; }
  .brand, .header-actions, .rail-tabs button, .payout-row, .comms-compose, .message-stream { pointer-events: auto; }
  .header-actions { gap: 6px; }
  .contract-button { max-width: 116px; }
  .rail-tabs { padding-bottom: 8px; }
  .right-rail { padding: 8px 10px 12px; background: linear-gradient(180deg,rgba(12,6,4,.74),rgba(12,6,4,.28) 72%,transparent); backdrop-filter: blur(5px); }
  .payout-row { padding: 7px 0; }
  .home-search { display: none; }
  .home-inspector { bottom: 50px; }
  .registry-head, .registry-row { grid-template-columns: minmax(120px,1.5fr) .8fr .7fr; }
  .registry-head span:nth-child(4), .registry-row span:nth-child(4) { display: none; }
  .boost-tiers { grid-template-columns: 1fr; }
  .boost-tier { min-height: 76px; border-right: 0; border-bottom: 1px solid var(--line); }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* Flat city theme */
.stock-breakdown { display: grid; grid-template-columns: 1fr; gap: 4px; font: 11px var(--mono); }
.stock-breakdown small { color: #f0b90b; }
.home-inspector { max-height: 75vh; overflow-y: auto; }
.brand strong { color: #f0b90b; letter-spacing: -.015em; }
.brand small { display: block; margin-top: 9px; color: #848e9c; font: 9px var(--mono); letter-spacing: .2em; }
.right-rail { background: linear-gradient(90deg,rgba(11,14,17,.87),rgba(11,14,17,.65)); backdrop-filter: blur(8px); }
.telemetry { background: rgba(11,14,17,.65); }
.view-controls { display: flex; gap: 8px; pointer-events: auto; margin-top: 12px; }
.atmosphere { background: radial-gradient(ellipse at center, transparent 40%, rgba(11,14,17,.45)); }
.town-state { display: block; color: #848e9c; font: 9px var(--mono); }
.view-controls { flex-direction: column; align-items: flex-start; }
.view-controls button { padding: 9px 12px; background: #181a20; border: 1px solid var(--line); color: #f0b90b; font: 10px var(--mono); }
.view-controls > span { max-width: 210px; color: #848e9c; font: 9px/1.7 var(--mono); }
@media (max-width: 700px) { .brand strong { font-size: 27px; } .brand small { font-size: 8px; } }
@media (max-width: 700px) {
  .town-state { max-width: 140px; text-align: right; font-size: 8px; line-height: 1.6; }
  .header-actions:empty { display: none; }
  .right-rail { position: fixed; left: 14px; right: 14px; bottom: 105px; width: auto; height: 150px; max-height: 150px; }
  .view-controls > span { display: none; }
  .home-search { display: block; bottom: 35px; width: calc(100vw - 28px); }
  .home-search > label, .home-search > span { display: none; }
  .home-inspector { bottom: 110px; z-index: 10; }
  .text-button { display: inline-flex; font-size: 8px; padding: 0 7px; }
  .town-header { gap: 8px; }
}
:root .reward-catalog { margin: 12px 0; font-size: 10px; line-height: 1.5; color: #929aa5; }
:root .reward-catalog p { margin: 7px 0; }
#rewardAssetList { display: flex; flex-wrap: wrap; gap: 5px; }
#rewardAssetList a { padding: 3px 6px; border: 1px solid #45412b; border-radius: 3px; color: #f0b90b; text-decoration: none; }
#rewardAssetList { pointer-events: auto; }

@media (min-width: 701px) {
  .left-rail { max-height: calc(100vh - 180px); overflow-y: auto; scrollbar-width: thin; pointer-events: auto; padding-right: 4px; }
  .left-rail .home-search { position: static; width: 100%; margin-top: 18px; }
}
@media (max-width: 700px) {
  .reward-catalog p:not(.eyebrow) { display: none; }
}

