/* ============ EMPIRE — mobile-first dark theme ============ */
:root {
  --bg: #0d1117;
  --bg2: #161b22;
  --card: #1c2330;
  --card2: #232c3d;
  --border: #2e3a4e;
  --text: #e6edf3;
  --dim: #8b98a9;
  --accent: #4cc38a;
  --accent-dim: #2c7a54;
  --gold: #e3b341;
  --red: #f47067;
  --blue: #539bf5;
  --purple: #b083f0;
  --radius: 12px;
  --tabbar-h: 62px;
  --topbar-h: 64px;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

/* ---------- Top bar ---------- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  background: linear-gradient(180deg, #131a24, #0f141c);
  border-bottom: 1px solid var(--border);
  padding: calc(8px + env(safe-area-inset-top)) 14px 8px;
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
}
.topbar-row { display: flex; justify-content: space-between; align-items: center; }
.cash { font-size: 22px; font-weight: 800; color: var(--accent); letter-spacing: 0.3px; }
.income { font-size: 12px; color: var(--dim); }
.networth-block { text-align: right; }
.nw-label { font-size: 9px; color: var(--dim); letter-spacing: 1.2px; }
.networth { font-size: 15px; font-weight: 700; color: var(--gold); }
.legacy-chip {
  background: #4d3d12; border: 1px solid var(--gold); color: var(--gold);
  border-radius: 20px; padding: 4px 10px; font-size: 12px; font-weight: 700; cursor: pointer;
}
.sit-bell {
  position: relative;
  background: var(--card2); border: 1px solid var(--border); color: var(--text);
  border-radius: 50%; width: 38px; height: 38px; font-size: 16px; cursor: pointer;
}
.sit-bell.alert { border-color: var(--red); }
.sit-count {
  position: absolute; top: -5px; right: -5px;
  background: var(--red); color: #fff; border-radius: 50%;
  min-width: 17px; height: 17px; font-size: 10.5px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- Main view ---------- */
#view {
  padding: calc(var(--topbar-h) + env(safe-area-inset-top) + 10px) 12px
           calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
  max-width: 560px;
  margin: 0 auto;
}
h2.section { font-size: 13px; color: var(--dim); text-transform: uppercase; letter-spacing: 1.5px; margin: 18px 2px 8px; }
h2.section:first-child { margin-top: 4px; }

/* ---------- Tab bar ---------- */
#tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  display: flex;
  background: #10151d;
  border-top: 1px solid var(--border);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
}
.tab-btn {
  flex: 1; background: none; border: none; color: var(--dim);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 10px; cursor: pointer; padding-top: 6px;
  position: relative;
}
.tab-btn .tab-ico { font-size: 20px; filter: grayscale(0.7); }
.tab-btn.active { color: var(--accent); }
.tab-btn.active .tab-ico { filter: none; }
.tab-lbl { font-weight: 600; }
.tab-btn.alert::after {
  content: ""; position: absolute;
  top: 7px; left: calc(50% + 8px);
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 6px var(--red);
}

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
}
.card.locked { opacity: 0.7; }
.card-head { display: flex; align-items: center; gap: 10px; }
.card-ico { font-size: 26px; width: 36px; text-align: center; }
.card-title { font-weight: 700; font-size: 15px; flex: 1; }
.card-sub { font-size: 12px; color: var(--dim); margin-top: 1px; }
.card-right { text-align: right; font-size: 13px; margin-left: auto; white-space: nowrap; flex-shrink: 0; }

/* ---------- Buttons ---------- */
button.btn {
  background: var(--card2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.05s;
}
button.btn:active { transform: scale(0.97); }
button.btn.primary { background: var(--accent-dim); border-color: var(--accent); }
button.btn.gold { background: #4d3d12; border-color: var(--gold); color: var(--gold); }
button.btn.danger { background: #4a2320; border-color: var(--red); color: #ffb4ac; }
button.btn.small { padding: 7px 10px; font-size: 12px; border-radius: 8px; }
button.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
button.btn.wide { width: 100%; }
.btn-row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
.btn-row .btn { flex: 1; min-width: 110px; }
.cost { color: var(--gold); font-weight: 700; }
.cost.cant { color: var(--red); }

/* ---------- Hustle tab ---------- */
.hustle-hero { text-align: center; padding: 22px 14px 18px; }
.hustle-title { font-size: 17px; font-weight: 800; }
.hustle-desc { color: var(--dim); font-size: 12.5px; margin-top: 4px; }
#tap-btn {
  margin: 16px auto 6px;
  width: 168px; height: 168px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  background: radial-gradient(circle at 35% 30%, #2a4838, #17301f);
  color: var(--text);
  font-size: 15px; font-weight: 800;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  box-shadow: 0 0 28px rgba(76, 195, 138, 0.25);
  transition: transform 0.06s;
  touch-action: manipulation;
}
#tap-btn:active { transform: scale(0.94); }
#tap-btn.pulse .tap-emoji { animation: tapPop 0.18s ease-out; }
@keyframes tapPop {
  0% { transform: scale(1); }
  40% { transform: scale(1.25) rotate(-6deg); }
  100% { transform: scale(1); }
}
#tap-btn .tap-emoji { font-size: 42px; }
#tap-btn .tap-val { color: var(--accent); font-size: 14px; }
.tap-auto-note { font-size: 11.5px; color: var(--dim); margin-top: 6px; }
.float-cash {
  position: fixed; pointer-events: none; z-index: 90;
  color: var(--accent); font-weight: 800; font-size: 16px;
  animation: floatUp 0.9s ease-out forwards;
  text-shadow: 0 1px 4px rgba(0,0,0,0.7);
}
@keyframes floatUp {
  0% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-64px); }
}

/* ---------- Upgrade rows ---------- */
.upg-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 2px;
  border-bottom: 1px solid rgba(46, 58, 78, 0.5);
}
.upg-row:last-child { border-bottom: none; }
.upg-row.locked { opacity: 0.55; }
.upg-ico { font-size: 20px; width: 28px; text-align: center; }
.upg-info { flex: 1; min-width: 0; }
.upg-name { font-weight: 600; font-size: 13.5px; }
.upg-name .lvl { color: var(--blue); font-size: 11.5px; margin-left: 5px; }
.upg-desc { font-size: 11.5px; color: var(--dim); }
.upg-row .btn { flex-shrink: 0; }

/* ---------- Business cards ---------- */
.biz-stat-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px;
  margin: 10px 0 4px; font-size: 12.5px;
}
.biz-stat { color: var(--dim); }
.biz-stat b { color: var(--text); font-weight: 600; }
.mech-panel {
  background: rgba(13, 17, 23, 0.55);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: 10px;
  font-size: 12.5px;
}
.mech-title { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px; }
.bar-outer { background: #0d1117; border-radius: 6px; height: 10px; overflow: hidden; margin: 5px 0; border: 1px solid var(--border); }
.bar-inner { height: 100%; background: var(--accent); border-radius: 6px; transition: width 0.3s; }
.bar-inner.gold { background: var(--gold); }
.bar-inner.red { background: var(--red); }
.bar-inner.blue { background: var(--blue); }
.bar-inner.purple { background: var(--purple); }
.badge {
  display: inline-block; font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 20px; margin-left: 6px;
  vertical-align: 2px;
}
.badge.lvl { background: #1d3a5f; color: var(--blue); }
.badge.warn { background: #4a2320; color: #ffb4ac; }
.badge.gold { background: #4d3d12; color: var(--gold); }

/* contract / project rows */
.job-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--card2); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 10px; margin-top: 7px; font-size: 12.5px;
}
.job-row.locked { opacity: 0.55; }
.job-info { flex: 1; min-width: 0; }
.job-name { font-weight: 600; }
.job-meta { color: var(--dim); font-size: 11.5px; }

/* ---------- Market ---------- */
.stock-row { display: flex; align-items: center; gap: 10px; }
.stock-tick { font-weight: 800; font-size: 14px; width: 52px; }
.stock-name { font-size: 11px; color: var(--dim); }
.stock-price { font-weight: 700; font-size: 14px; text-align: right; }
.stock-chg { font-size: 11px; text-align: right; }
.up { color: var(--accent); }
.down { color: var(--red); }
.spark { width: 90px; height: 34px; flex-shrink: 0; }
.holding-note { font-size: 11.5px; color: var(--blue); margin-top: 6px; }

/* ---------- Modal ---------- */
#modal-root:empty { display: none; }
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(5, 8, 12, 0.78);
  display: flex; align-items: center; justify-content: center;
  padding: 18px;
}
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%; max-width: 420px;
  max-height: 82vh; overflow-y: auto;
  padding: 20px;
  animation: modalIn 0.18s ease-out;
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: scale(1); } }
.modal h3 { font-size: 17px; margin-bottom: 8px; }
.modal p { color: var(--dim); font-size: 13px; line-height: 1.5; margin-bottom: 8px; }
.modal .big { font-size: 26px; color: var(--accent); font-weight: 800; text-align: center; margin: 14px 0; }
.modal .spark { width: 100%; height: 80px; }

/* ---------- Toasts ---------- */
/* Bottom of the screen, above the tab bar: toasts can never cover the quest banner,
   which always sits at the top of the view. */
#toasts {
  position: fixed; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px);
  left: 0; right: 0; z-index: 95;
  display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px;
  pointer-events: none;
}
.toast {
  background: var(--card2);
  border: 1px solid var(--accent);
  color: var(--text);
  border-radius: 24px;
  padding: 9px 18px;
  font-size: 13px; font-weight: 600;
  box-shadow: 0 4px 18px rgba(0,0,0,0.5);
  animation: toastIn 0.25s ease-out;
  max-width: 88vw;
}
.toast.bad { border-color: var(--red); }
.toast.gold { border-color: var(--gold); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.toast.out { animation: toastOut 0.3s ease-in forwards; }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px); } }

/* Out-of-stock strip (top of every tab) */
.stock-alert {
  display: flex; align-items: center; gap: 10px;
  border-radius: 10px; padding: 8px 10px; margin-bottom: 10px; font-size: 12.5px;
  border: 1px solid var(--gold); background: #3a2f10;
}
.stock-alert.empty { border-color: var(--red); background: #4a2320; animation: alertPulse 1.6s ease-in-out infinite; }
.stock-alert-txt { flex: 1; min-width: 0; }
.stock-alert .btn { flex-shrink: 0; min-width: 0; }
@keyframes alertPulse { 50% { box-shadow: 0 0 12px rgba(244, 112, 103, 0.55); } }

/* ---------- Misc ---------- */
.hq-card { border-color: var(--gold); background: linear-gradient(160deg, #2a2410, var(--card)); }
.quest-card { border-color: var(--blue); }
.gold-text { color: var(--gold); }
.ach-done { border-color: var(--accent-dim); }
.ach-done .card-title::after { content: " ✓"; color: var(--accent); }
.muted { color: var(--dim); }
.center { text-align: center; }
.stat-line { display: flex; justify-content: space-between; padding: 6px 2px; font-size: 13px; border-bottom: 1px solid rgba(46,58,78,0.4); }
.stat-line span:last-child { font-weight: 600; }

/* ---------- Software House pools ---------- */
.pool-line { display: flex; align-items: center; gap: 8px; }
.pool-line .bar-outer { flex: 1; }
.pool-name { width: 92px; font-size: 12px; flex-shrink: 0; }
.pool-val { width: 34px; text-align: right; font-size: 12px; font-weight: 700; }
.job-row .spark { width: 100%; max-width: 200px; height: 22px; }

/* ---------- Phase 8: City tab, quests, golden can, casino ---------- */
.subnav { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.subnav::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; background: var(--card2); color: var(--dim);
  border: 1px solid var(--border); border-radius: 20px;
  padding: 6px 12px; font-size: 12px; font-weight: 600; cursor: pointer;
}
.chip.active { color: var(--accent); border-color: var(--accent); background: #17301f; }
.quest-tip { font-size: 11.5px; color: var(--blue); margin-top: 6px; }
.you-row { color: var(--accent); font-weight: 700; }
.done-row { opacity: 0.7; }
.buff-dot { color: var(--gold); }
.golden-can {
  position: fixed; z-index: 80;
  width: 64px; height: 64px; border-radius: 50%;
  border: 2px solid var(--gold);
  background: radial-gradient(circle at 35% 30%, #fff3b0, #e3b341 55%, #8a6510);
  font-size: 30px; cursor: pointer;
  box-shadow: 0 0 24px rgba(227, 179, 65, 0.8);
  animation: goldenBob 1.1s ease-in-out infinite;
  display: flex; align-items: center; justify-content: center;
  touch-action: manipulation;
}
.golden-t { white-space: nowrap;
  position: absolute; bottom: -18px; left: 50%; transform: translateX(-50%);
  font-size: 11px; font-weight: 800; color: var(--gold); text-shadow: 0 1px 3px #000;
}
@keyframes goldenBob {
  0%, 100% { transform: translateY(0) rotate(-8deg); }
  50% { transform: translateY(-8px) rotate(8deg); }
}
.collect-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 8px; }
.collect-item { text-align: center; background: var(--card2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 4px; }
.collect-item.missing { opacity: 0.45; }
.collect-ico { font-size: 24px; }
.collect-name { font-size: 10.5px; color: var(--dim); margin: 2px 0 4px; }
.collect-item .btn { min-width: 0; padding: 4px 6px; font-size: 10px; }
.log-line { font-size: 12px; padding: 5px 0; border-bottom: 1px solid rgba(46,58,78,0.4); }
.log-line.bad { color: #ffb4ac; }
.log-line.gold { color: var(--gold); }
.save-box {
  width: 100%; height: 110px; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px;
  font-family: monospace; font-size: 11px; resize: none; user-select: text; -webkit-user-select: text;
}
.tab-btn .tab-lbl { font-size: 9.5px; }
