* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #0b0f0d;
  --panel: rgba(13, 18, 15, .92);
  --line: #1e2a22;
  --green: #37e08b;
  --dim: #7d8f84;
  --text: #dce8df;
}
html, body { height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif; }
canvas#world { position: fixed; inset: 0; display: block; cursor: grab; }
canvas#world.building { cursor: crosshair; }
canvas#world.grabbing { cursor: grabbing; }

/* ---------- topbar ---------- */
#topbar { position: fixed; top: 0; left: 0; right: 0; height: 46px; display: flex; align-items: center;
  gap: 18px; padding: 0 16px; background: var(--panel); border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px); z-index: 20; user-select: none; }
.brand { font-family: ui-monospace, "Cascadia Mono", monospace; font-weight: 700; letter-spacing: 2px;
  font-size: 15px; color: var(--text); }
.brand span { color: var(--green); }
.stat { font-size: 13px; color: var(--dim); white-space: nowrap; }
.stat b { color: var(--text); font-variant-numeric: tabular-nums; }
#stat-money b { color: var(--green); }
.demand { display: flex; gap: 6px; align-items: flex-end; height: 26px; }
.dbar { width: 18px; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.dbar i { display: block; width: 10px; height: 2px; background: var(--dim); border-radius: 2px; transition: height .5s, background .5s; }
.dbar span { font-size: 9px; color: var(--dim); margin-top: 2px; }
.viewbtn { background: none; border: 1px solid var(--line); border-radius: 7px;
  color: var(--text); padding: 5px 12px; font-size: 12px; cursor: pointer; font-family: ui-monospace, monospace; }
.viewbtn:hover { border-color: var(--green); }
#rot-l { margin-left: auto; }
.rotbtn { padding: 5px 9px; font-size: 14px; line-height: 1; }
body.flat .rotbtn { opacity: .35; pointer-events: none; }
.conn { font-size: 12px; color: var(--dim); font-family: ui-monospace, monospace; }
.conn.ok { color: var(--green); }
.conn.err { color: #e5484d; }

/* ---------- toolbar ---------- */
#toolbar { position: fixed; left: 12px; top: 60px; display: flex; flex-direction: column; gap: 4px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px; z-index: 20; }
#toolbar button { display: grid; grid-template-columns: 26px 1fr auto; align-items: center; gap: 8px;
  background: none; border: 1px solid transparent; border-radius: 7px; color: var(--text);
  padding: 7px 10px; cursor: pointer; font-size: 13px; text-align: left; min-width: 150px; }
#toolbar button:hover { background: rgba(55, 224, 139, .08); }
#toolbar button.active { border-color: var(--green); background: rgba(55, 224, 139, .12); }
#toolbar button i { font-style: normal; font-size: 16px; }
#toolbar button b { font-weight: 500; }
#toolbar button s { text-decoration: none; color: var(--dim); font-size: 11px; font-variant-numeric: tabular-nums; }

/* ---------- side panel ---------- */
#sidepanel { position: fixed; right: 12px; top: 60px; bottom: 12px; width: 250px; display: flex;
  flex-direction: column; gap: 10px; z-index: 20; pointer-events: none; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  pointer-events: auto; display: flex; flex-direction: column; min-height: 0; }
.panel h3 { font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--dim); margin-bottom: 8px; }
#leaderboard { max-height: 38%; }
#lb-table { width: 100%; border-collapse: collapse; font-size: 12px; overflow: auto; }
#lb-table td { padding: 3px 2px; white-space: nowrap; }
#lb-table td.num { text-align: right; font-variant-numeric: tabular-nums; color: var(--dim); }
#lb-table .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
#lb-table .off { opacity: .45; }
#chatpanel { flex: 1; }
#feed { flex: 1; overflow-y: auto; font-size: 12px; line-height: 1.5; display: flex; flex-direction: column; gap: 2px; }
#feed .ev { color: var(--dim); font-style: italic; }
#feed .ch b { font-weight: 600; }
#chatform { display: flex; gap: 6px; margin-top: 8px; }
#chatform input { flex: 1; background: #0a0e0c; border: 1px solid var(--line); border-radius: 6px;
  color: var(--text); padding: 6px 9px; font-size: 12px; outline: none; }
#chatform input:focus { border-color: var(--green); }
#chatform button { background: var(--green); color: #06130c; border: 0; border-radius: 6px; width: 32px; cursor: pointer; }

/* ---------- minimap ---------- */
#minimap { position: fixed; left: 12px; bottom: 12px; width: 192px; height: 192px; border: 1px solid var(--line);
  border-radius: 8px; background: #000; z-index: 20; cursor: pointer; image-rendering: pixelated; }

/* ---------- toast & tooltip ---------- */
#toast { position: fixed; top: 56px; left: 50%; transform: translateX(-50%); z-index: 40;
  display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
#toast .t { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--green);
  border-radius: 7px; padding: 7px 14px; font-size: 13px; animation: fadeout 4s forwards; }
#toast .t.err { border-left-color: #e5484d; }
@keyframes fadeout { 0% { opacity: 0; transform: translateY(-6px); } 8% { opacity: 1; transform: none; }
  80% { opacity: 1; } 100% { opacity: 0; } }
#hovertip { position: fixed; z-index: 30; background: var(--panel); border: 1px solid var(--line);
  border-radius: 6px; padding: 4px 9px; font-size: 11.5px; pointer-events: none; display: none; white-space: nowrap; }

/* ---------- join modal ---------- */
#joinmodal { position: fixed; inset: 0; background: rgba(4, 8, 6, .82); backdrop-filter: blur(4px);
  z-index: 100; display: flex; align-items: center; justify-content: center; }
#joinmodal.hidden { display: none; }
#joinmodal .card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 34px 38px; max-width: 430px; text-align: center; }
#joinmodal .logo { font-family: ui-monospace, monospace; font-size: 26px; font-weight: 700; letter-spacing: 3px; margin-bottom: 14px; }
#joinmodal .logo span { color: var(--green); }
#joinmodal p { font-size: 13.5px; color: var(--dim); line-height: 1.6; margin-bottom: 20px; }
#joinmodal p b { color: var(--text); }
#joinform { display: flex; gap: 8px; }
#joinform input { flex: 1; background: #0a0e0c; border: 1px solid var(--line); border-radius: 8px;
  color: var(--text); padding: 10px 13px; font-size: 14px; outline: none; }
#joinform input:focus { border-color: var(--green); }
#joinform button { background: var(--green); color: #06130c; border: 0; border-radius: 8px;
  padding: 10px 16px; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; }
#joinform button:hover { filter: brightness(1.1); }
.hint { margin-top: 18px; font-size: 12px; color: var(--dim); }
.hint b { color: var(--text); }

@media (max-width: 900px) {
  #sidepanel { display: none; }
  #toolbar button { min-width: 0; grid-template-columns: 26px; }
  #toolbar button b, #toolbar button s { display: none; }
  .demand, #stat-jobs { display: none; }
}
