:root {
  --bg: #070403;
  --ink: #f3e7dc;
  --muted: #b89f91;
  --line: rgba(243, 220, 202, 0.17);
  --surface: rgba(20, 10, 7, 0.7);
  --surface-strong: rgba(18, 9, 6, 0.94);
  --mars: #ad6248;
  --signal: #ff9368;
  --danger: #b44435;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 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; }
#mars-scene { position: fixed; inset: 0; cursor: grab; background: var(--bg); }
#mars-scene:active { cursor: grabbing; }
#mars-scene canvas { display: block; width: 100%; height: 100%; }
.atmosphere { position: fixed; inset: 0; z-index: 2; pointer-events: none; background: radial-gradient(circle at 52% 52%,rgba(176,57,35,.08),transparent 34%,rgba(0,0,0,.1) 76%,rgba(0,0,0,.34) 125%); }

.interface { position: fixed; inset: 0; z-index: 5; isolation: isolate; display: grid; grid-template-columns: minmax(0,1fr) 318px; grid-template-rows: auto 1fr auto; gap: 24px; padding: 26px; pointer-events: none; }
.mission-header, .left-rail, .right-rail, .mission-footer { pointer-events: none; }
.brand, .header-actions, .colony-search, .rail-tabs button, .payout-row, .comms-compose, .message-stream { pointer-events: auto; }
.mission-header { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; min-height: 58px; }
.brand { display: flex; align-items: center; min-width: 0; text-decoration: none; }
.brand-mark, .brand small, .mission-state { display: none; }
.brand strong { display: block; font-size: clamp(25px,2.7vw,38px); line-height: 1; letter-spacing: -.035em; font-weight: 780; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.text-button, .icon-button, .contract-button, .language-toggle { display: inline-flex; align-items: center; justify-content: center; height: 34px; border: 1px solid var(--line); border-radius: 8px; background: rgba(19,10,7,.58); 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 11px; font: 800 10px/1 var(--mono); }
.icon-button { width: 34px; }
.contract-button { gap: 8px; padding: 0 11px; font: 700 12px/1 var(--mono); }
.contract-button span { display: none; }
.contract-button b { font-weight: 700; }
.language-toggle { gap: 7px; padding: 0 9px; color: var(--muted); font: 800 9px/1 var(--mono); }
.language-toggle i { width: 1px; height: 11px; background: var(--line); }
.language-toggle span.active { color: var(--signal); }
.text-button:hover, .icon-button:hover, .contract-button:hover, .language-toggle:hover { transform: translateY(-1px); background: rgba(122,49,31,.34); border-color: rgba(243,220,202,.34); }

.left-rail { grid-column: 1; grid-row: 2; align-self: start; width: min(680px,100%); }
.mission-intro { display: none; }
.telemetry { display: grid; grid-template-columns: repeat(4,minmax(105px,1fr)); gap: 10px; }
.telemetry-row { min-width: 0; border-top: 1px solid var(--line); padding-top: 10px; }
.telemetry-row span { display: block; color: var(--muted); font-size: 10px; font-weight: 780; letter-spacing: .08em; }
.telemetry-row strong { display: block; margin-top: 4px; font-size: 19px; line-height: 1; white-space: nowrap; }
.telemetry-row strong small { color: var(--muted); font-size: 10px; }
.telemetry-row.accent-row strong { color: var(--signal); }
.colony-search { position: fixed; left: 26px; bottom: 58px; width: min(420px,calc(100vw - 52px)); }
.colony-search label { display: none; }
.colony-search > div { display: grid; grid-template-columns: 1fr 38px; gap: 8px; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: rgba(19,10,7,.72); box-shadow: 0 12px 30px rgba(0,0,0,.2),inset 0 0 0 1px rgba(255,255,255,.025); backdrop-filter: blur(16px); }
.colony-search input { width: 100%; min-width: 0; height: 36px; padding: 0 6px; border: 0; outline: 0; background: transparent; font: 720 12px/1 var(--mono); }
.colony-search input::placeholder { color: rgba(184,159,145,.7); }
.colony-search button { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 8px; background: var(--ink); color: #180b08; }
.colony-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: 2; grid-row: 2 / 4; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.rail-tabs { display: flex; align-items: center; gap: 15px; padding-bottom: 12px; }
.rail-tabs button { padding: 0 0 6px; border: 0; border-bottom: 1px solid transparent; background: none; color: var(--muted); font-size: 11px; font-weight: 780; letter-spacing: .04em; }
.rail-tabs button.active { color: var(--ink); border-bottom-color: var(--mars); }
.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; }
.payout-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 9px 0; border-bottom: 1px solid rgba(33,29,25,.08); 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(--mars); box-shadow: 0 0 0 4px rgba(173,98,72,.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; }

.mission-footer { position: fixed; left: 26px; right: 368px; bottom: 22px; display: flex; gap: 34px; }
.mission-footer > div { display: flex; gap: 7px; align-items: baseline; }
.mission-footer span { color: var(--muted); font-size: 10px; font-weight: 700; }
.mission-footer strong { font-size: 11px; }
.footer-signal { margin-left: auto; }
.footer-signal i { display: none; }

.colony-inspector { position: fixed; z-index: 12; left: 50%; bottom: 76px; width: min(310px,calc(100vw - 32px)); padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-strong); box-shadow: 0 16px 44px rgba(0,0,0,.32),inset 0 0 0 1px rgba(255,255,255,.025); backdrop-filter: blur(16px); transform: translateX(-50%); }
.colony-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; }
.colony-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: 14px; background: var(--surface-strong); box-shadow: 0 24px 80px rgba(0,0,0,.42),inset 0 0 0 1px rgba(255,255,255,.025); 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(--mars); }
#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; }
  .mission-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; }
  .mission-footer { left: 14px; right: 14px; bottom: 12px; gap: 18px; }
  .mission-footer > div:nth-child(2), .mission-footer > div:nth-child(3) { display: none; }
  .footer-signal { margin-left: auto; }
  .colony-search { left: 14px; bottom: 48px; width: min(420px,calc(100vw - 28px)); }
}

@media (max-width: 560px) {
  .atmosphere { background: radial-gradient(circle at 50% 55%,rgba(176,57,35,.08),transparent 42%,rgba(0,0,0,.26)); }
  .interface { pointer-events: none; }
  .mission-header, .left-rail, .right-rail, .mission-footer { pointer-events: none; }
  .brand, .header-actions, .rail-tabs button, .payout-row, .comms-compose, .message-stream { pointer-events: auto; }
  .header-actions { gap: 6px; }
  .language-toggle { padding: 0 7px; }
  .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; }
  .colony-search { display: none; }
  .colony-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; } }
