:root {
  --bg: #141a24; --panel: #1b2230ee; --panel-solid: #1b2230; --line: #2c3547; --text: #e8e4d8; --muted: #9aa3b5;
  --brass: #d9a441; --brass-2: #f0c46a; --good: #4cc38a; --bad: #e5676b; --info: #5aa9e6;
  --radius: 10px; --nav-w: 74px; --top-h: 54px;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
small { color: var(--muted); }
h2, h3, h4 { margin: 0 0 8px; font-weight: 650; }
h3 { font-size: 15px; color: var(--brass-2); margin-top: 14px; }
a { color: var(--brass-2); }

/* auth */
.auth { position: fixed; inset: 0; display: grid; place-items: center;
  background: radial-gradient(ellipse at 30% 20%, #2b3a55 0%, #141a24 60%), #141a24; }
.auth-card { width: min(420px, 92vw); background: var(--panel-solid); border: 1px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: 0 20px 60px #0008; }
.logo { margin: 0; font-size: 40px; letter-spacing: -1px; }
.logo span, .brand span { color: var(--brass); }
.tagline { color: var(--muted); margin: 4px 0 18px; }
.tabs { display: flex; gap: 4px; margin-bottom: 14px; }
.tabs button { flex: 1; padding: 8px; border: 1px solid var(--line); background: transparent; border-radius: 8px; }
.tabs button.active { background: var(--brass); color: #1b1404; border-color: var(--brass); font-weight: 600; }
form label { display: block; margin-bottom: 10px; font-size: 13px; color: var(--muted); }
input, select { width: 100%; padding: 8px 10px; margin-top: 4px; background: #10151e; border: 1px solid var(--line); border-radius: 8px; }
input:focus, select:focus { outline: 2px solid var(--brass); outline-offset: -1px; }
input[type=checkbox], input[type=range] { width: auto; margin: 0 6px 0 0; padding: 0; }
input[type=range] { width: 100%; accent-color: var(--brass); }
.primary, .btn { padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: #253047; font-weight: 600; }
.primary { background: var(--brass); color: #1b1404; border-color: var(--brass); width: 100%; padding: 10px; }
.btn:hover { background: #2f3c58; }
.btn.gold { background: var(--brass); color: #1b1404; border-color: var(--brass); }
.btn.red { background: #5a2a2e; border-color: #7a3a3e; }
.btn.green { background: #1f5a42; border-color: #2a7a5a; }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.error { color: var(--bad); min-height: 1.2em; font-size: 13px; }
.pitch { margin: 18px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.auth .reg-only { display: none; }
.auth.register .reg-only { display: block; }

/* game layout */
#game { position: fixed; inset: 0; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#view.building { cursor: crosshair; }
.topbar { position: absolute; top: 0; left: 0; right: 0; height: var(--top-h); display: flex; align-items: center; gap: 14px; padding: 0 14px;
  background: linear-gradient(#141a24f2, #141a24d8); border-bottom: 1px solid var(--line); z-index: 5; }
.brand { font-weight: 800; font-size: 20px; letter-spacing: -.5px; }
#companySwitch { width: auto; max-width: 200px; margin: 0; padding: 5px 8px; }
.stat { display: flex; flex-direction: column; line-height: 1.1; min-width: 70px; }
.stat small { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
.stat b { font-size: 15px; font-variant-numeric: tabular-nums; }
.stat.tier { min-width: 150px; }
.bar { height: 7px; background: #0d1118; border-radius: 4px; overflow: hidden; margin-top: 4px; border: 1px solid var(--line); }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--brass), var(--brass-2)); transition: width .4s; }
.clock { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--brass-2); font-weight: 600; }
.icon-btn { background: transparent; border: 1px solid var(--line); border-radius: 8px; width: 34px; height: 34px; }
.pos { color: var(--good); } .neg { color: var(--bad); }

.sidenav { position: absolute; top: var(--top-h); left: 0; bottom: 30px; width: var(--nav-w); display: flex; flex-direction: column; gap: 2px; padding: 8px 6px;
  background: #141a24d8; border-right: 1px solid var(--line); z-index: 5; overflow-y: auto; }
.sidenav button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 2px; border: 0; border-radius: 8px; background: transparent; font-size: 20px; }
.sidenav button span { font-size: 10.5px; color: var(--muted); }
.sidenav button:hover, .sidenav button.active { background: #253047; }
.sidenav button.active span { color: var(--brass-2); }
.sidenav button .badge { position: absolute; }

.drawer { position: absolute; top: var(--top-h); left: var(--nav-w); bottom: 30px; width: min(440px, calc(100vw - var(--nav-w))); background: var(--panel); backdrop-filter: blur(8px);
  border-right: 1px solid var(--line); z-index: 4; display: flex; flex-direction: column; box-shadow: 8px 0 30px #0006; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 6px; }
.drawer-head h2 { margin: 0; font-size: 18px; }
.drawer-body { padding: 4px 14px 20px; overflow-y: auto; flex: 1; font-size: 14px; }

.buildbar { position: absolute; top: calc(var(--top-h) + 10px); left: 50%; transform: translateX(-50%); z-index: 6; background: var(--panel-solid);
  border: 1px solid var(--brass); border-radius: 999px; padding: 6px 8px 6px 16px; display: flex; gap: 12px; align-items: center; box-shadow: 0 6px 20px #0008; font-size: 14px; }
.buildbar button { border: 0; background: #5a2a2e; border-radius: 999px; padding: 5px 12px; }
.buildbar label { font-size: 12px; color: var(--muted); display: flex; align-items: center; }

.layers { position: absolute; right: 12px; bottom: 140px; display: flex; flex-direction: column; gap: 4px; z-index: 5; }
.layers button { width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line); background: #141a24d8; font-size: 16px; }
.layers button.active { border-color: var(--brass); background: #3a3020; }
#minimap { position: absolute; right: 12px; bottom: 38px; border: 1px solid var(--line); border-radius: 8px; background: #0d1520; z-index: 5; cursor: pointer; }

.tooltip { position: absolute; z-index: 8; pointer-events: none; background: var(--panel-solid); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font-size: 12.5px; max-width: 260px; box-shadow: 0 6px 20px #0009; }
.tooltip b { color: var(--brass-2); }

.ticker { position: absolute; left: 0; right: 0; bottom: 0; height: 30px; background: #0d1118; border-top: 1px solid var(--line); overflow: hidden; z-index: 5; font-size: 13px; }
#tickerInner { white-space: nowrap; position: absolute; top: 6px; left: 100%; animation: ticker 70s linear infinite; color: var(--muted); }
#tickerInner span { margin-right: 48px; }
#tickerInner b { color: var(--brass-2); font-weight: 600; }
@keyframes ticker { from { transform: translateX(0); } to { transform: translateX(-100%) translateX(-100vw); } }

.toasts { position: absolute; right: 14px; top: calc(var(--top-h) + 10px); display: flex; flex-direction: column; gap: 6px; z-index: 9; width: min(340px, 90vw); }
.toast { background: var(--panel-solid); border: 1px solid var(--line); border-left: 4px solid var(--info); border-radius: 8px; padding: 9px 12px; font-size: 13px;
  box-shadow: 0 6px 20px #0008; animation: slidein .25s ease-out; }
.toast.error { border-left-color: var(--bad); } .toast.success { border-left-color: var(--good); } .toast.gold { border-left-color: var(--brass); }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } }

.modal { position: fixed; inset: 0; background: #0009; display: grid; place-items: center; z-index: 20; }
.modal-card { width: min(560px, 92vw); max-height: 86vh; overflow-y: auto; background: var(--panel-solid); border: 1px solid var(--line); border-radius: 14px; padding: 22px; }
.modal-card h2 { font-size: 22px; }

/* panel content */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }
.row .shrink { flex: 0 0 auto; }
.card { background: #10151ecc; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 8px; }
.card.click { cursor: pointer; }
.card.click:hover { border-color: var(--brass); }
.card.disabled { opacity: .5; }
.card h4 { margin: 0 0 4px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.kv { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px dashed #2c354799; font-size: 13px; }
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--muted); }
.pill { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11px; background: #253047; color: var(--muted); }
.pill.ind { color: #111; font-weight: 600; }
.pill.gold { background: var(--brass); color: #1b1404; }
.pill.green { background: #1f5a42; color: #bff0d8; } .pill.red { background: #5a2a2e; color: #ffd0d2; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 4px 4px; border-bottom: 1px solid var(--line); }
td { padding: 5px 4px; border-bottom: 1px solid #2c354766; font-variant-numeric: tabular-nums; }
td.num, th.num { text-align: right; }
.goodicon { width: 20px; height: 20px; vertical-align: -5px; }
.goodgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; margin-bottom: 10px; }
.goodgrid button { background: #10151e; border: 1px solid var(--line); border-radius: 8px; padding: 6px; font-size: 11.5px; text-align: left; }
.goodgrid button.active { border-color: var(--brass); background: #2a2418; }
.goodgrid button img { width: 22px; height: 22px; float: left; margin-right: 5px; }
.goodgrid button b { display: block; font-size: 12px; }
.book { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: 12.5px; }
.book .bids td:first-child { color: var(--good); } .book .asks td:first-child { color: var(--bad); }
.chart { width: 100%; height: 140px; display: block; background: #0d1118; border-radius: 8px; border: 1px solid var(--line); }
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-bottom: 10px; }
.seg button { flex: 1; padding: 6px; background: transparent; border: 0; font-size: 13px; }
.seg button.active { background: var(--brass); color: #1b1404; font-weight: 600; }
.bcat { margin: 10px 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.bcat i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.btile { display: flex; gap: 10px; align-items: center; }
.btile canvas { flex: 0 0 64px; }
.btile .meta { flex: 1; font-size: 12.5px; color: var(--muted); }
.btile .meta b { color: var(--text); font-size: 14px; display: block; }
.effbar { height: 5px; background: #0d1118; border-radius: 3px; overflow: hidden; margin-top: 4px; }
.effbar i { display: block; height: 100%; background: var(--good); }
.note { font-size: 12px; color: #f0b86a; margin-top: 3px; }
.ach { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; }
.ach div { background: #10151e; border: 1px solid var(--line); border-radius: 8px; padding: 8px; font-size: 12px; text-align: center; }
.ach div.got { border-color: var(--brass); background: #2a2418; }
.ach div b { display: block; font-size: 12.5px; margin: 4px 0 2px; }
.ach div:not(.got) { opacity: .55; filter: grayscale(1); }
.newsitem { padding: 6px 0; border-bottom: 1px solid #2c354766; font-size: 13px; }
.newsitem small { margin-right: 6px; }
.checklist li { margin: 4px 0; } .checklist li.done { color: var(--good); text-decoration: line-through; }
.muted { color: var(--muted); }
.mt { margin-top: 10px; }
.right { text-align: right; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: 0; }

@media (max-width: 760px) {
  :root { --nav-w: 0px; --top-h: 50px; }
  .hide-sm { display: none; }
  .topbar { gap: 8px; padding: 0 8px; overflow-x: auto; }
  .brand { display: none; }
  .stat.tier { min-width: 90px; }
  .clock { font-size: 12px; }
  .sidenav { top: auto; bottom: 30px; left: 0; right: 0; width: auto; height: 58px; flex-direction: row; padding: 4px; border-right: 0; border-top: 1px solid var(--line); overflow-x: auto; }
  .sidenav button { min-width: 58px; font-size: 18px; }
  .drawer { left: 0; top: auto; bottom: 88px; width: 100vw; height: 62vh; border-radius: 14px 14px 0 0; z-index: 7; }
  .layers { bottom: 200px; }
  #minimap { display: none; }
}
