:root {
  --bg: #0f1420;
  --panel: #1a2233;
  --panel2: #222c42;
  --text: #eef2f8;
  --muted: #8b96ad;
  --accent: #3aa0ff;
  --green: #2ecc71;
  --gold: #f1c40f;
  --danger: #e74c3c;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* top bar */
#topbar {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  background: var(--panel);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  z-index: 500;
}
.stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 10px;
  background: var(--panel2);
  border-radius: 10px;
}
.stat-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.stat-value { font-size: 15px; font-weight: 700; }
#stat-balance .stat-value { color: var(--green); }
#stat-rent .stat-value { color: var(--gold); }
#stat-level .stat-value { color: var(--accent); }

/* map */
#map { flex: 1; min-height: 0; z-index: 1; }
.leaflet-container { background: #d4dadc; font: inherit; }

/* property popup */
.prop-popup { font-size: 13px; line-height: 1.45; }
.prop-popup .prop-name { font-weight: 700; font-size: 14px; }
.prop-popup .prop-type { color: var(--muted); font-size: 11px; text-transform: uppercase; }
.prop-popup .prop-price { margin: 6px 0; }
.prop-popup .prop-owner { font-size: 12px; }
.prop-popup button {
  width: 100%; margin-top: 8px; padding: 9px; border: none; border-radius: 8px;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 14px; cursor: pointer;
}
.prop-popup button:disabled { background: #3a4153; color: #7c869c; }

/* bottom bar */
#bottombar {
  display: flex;
  background: var(--panel);
  border-top: 1px solid rgba(255,255,255,0.06);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 500;
}
.action {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 4px; background: none; border: none; color: var(--text); cursor: pointer;
}
.action-icon { font-size: 20px; }
.action-text { font-size: 11px; color: var(--muted); }
.action:active { background: var(--panel2); }
#btn-work { position: relative; }
#btn-work .action-text { color: var(--green); font-weight: 700; }

/* bonus toast */
#bonus-toast {
  position: fixed; left: 50%; top: 74px; transform: translateX(-50%);
  background: var(--gold); color: #1a1a1a; font-weight: 700; font-size: 13px;
  padding: 10px 16px; border-radius: 20px; z-index: 900; box-shadow: 0 4px 16px rgba(0,0,0,.4);
  transition: opacity .25s;
}
.hidden { display: none !important; }

/* bottom sheet */
#sheet { position: fixed; inset: 0; z-index: 800; }
#sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.55); }
#sheet-body {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: 82%; background: var(--panel); border-radius: 20px 20px 0 0;
  display: flex; flex-direction: column; overflow: hidden;
}
#sheet-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px 10px; border-bottom: 1px solid rgba(255,255,255,0.07);
}
#sheet-title { font-weight: 700; font-size: 16px; }
#sheet-close { background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer; }
#sheet-content { padding: 14px 16px 20px; overflow-y: auto; }

/* generic list rows */
.row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 12px; background: var(--panel2); border-radius: 10px; margin-bottom: 8px;
}
.row .r-left { display: flex; flex-direction: column; gap: 3px; }
.row .r-title { font-weight: 700; font-size: 14px; }
.row .r-sub { font-size: 12px; color: var(--muted); }
.row .r-right { text-align: right; font-weight: 700; white-space: nowrap; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: var(--accent); color: #fff; }

.btn {
  display: block; width: 100%; padding: 12px; border: none; border-radius: 10px;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 15px; cursor: pointer; margin-top: 4px;
}
.btn.ghost { background: var(--panel2); color: var(--text); }
.btn.danger { background: var(--danger); }
.btn:disabled { background: #3a4153; color: #7c869c; }

.note { font-size: 12px; color: var(--muted); line-height: 1.5; margin: 8px 0; }
.sep { height: 1px; background: rgba(255,255,255,0.08); margin: 14px 0; }
h3 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin: 12px 0 6px; }

/* market up/down colors */
.up { color: var(--green); }
.down { color: var(--danger); }

/* small inline action buttons (courses, items) */
button.mini {
  display: inline-block; margin: 2px 0; padding: 6px 10px; border: none; border-radius: 8px;
  background: #2c3a57; color: var(--text); font-size: 12px; font-weight: 600; cursor: pointer; text-align: left;
}
button.mini:active { background: var(--accent); }
.r-sub .ok, .r-sub span { color: var(--green); }

/* number input inside rows */
.row input {
  background: #0d1320; color: var(--text); border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px; padding: 10px 12px; font-size: 14px; outline: none; min-width: 0;
}
.row input:focus { border-color: var(--accent); }

/* web login overlay (browser) */
#web-login {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); padding: 24px;
}
.web-login-card {
  width: 100%; max-width: 360px; text-align: center;
  background: var(--panel); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px; padding: 28px 24px;
}
.web-login-logo { font-size: 56px; }
.web-login-title { font-size: 26px; font-weight: 800; margin: 10px 0 4px; }
.web-login-sub { color: var(--muted); font-size: 14px; margin-bottom: 20px; }
.web-login-code-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; margin-top: 16px; }
.web-login-code { font-size: 32px; font-weight: 800; letter-spacing: 8px; color: var(--accent); margin: 6px 0 14px; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.web-login-status { color: var(--muted); font-size: 13px; margin-top: 14px; }
#web-login-steps .btn { text-decoration: none; margin-top: 12px; }
#web-login-widget { display: flex; justify-content: center; margin-bottom: 6px; }
.web-login-divider { color: var(--muted); font-size: 12px; margin: 2px 0 10px; }

/* profile */
.profile-head { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.avatar { width: 64px; height: 64px; border-radius: 50%; flex-shrink: 0; object-fit: cover; }
.avatar-sm { width: 34px; height: 34px; }
.avatar-emoji, .avatar-initial { display: flex; align-items: center; justify-content: center; font-size: 30px; }
.avatar-sm.avatar-emoji, .avatar-sm.avatar-initial { font-size: 17px; }
.avatar-initial { color: #fff; font-weight: 800; }
.profile-head-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.profile-name { font-weight: 800; font-size: 17px; word-break: break-word; }
.profile-title { font-size: 13px; color: var(--gold); font-weight: 700; }
.profile-meta { font-size: 12px; color: var(--muted); }
.profile-bio { font-size: 13px; color: var(--text); margin-top: 4px; }

.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.badge-chip {
  font-size: 11px; padding: 4px 9px; border-radius: 20px; background: var(--panel2);
  border: 1px solid rgba(255,255,255,0.1); white-space: nowrap;
}

.seg { display: flex; gap: 6px; }
.seg-btn {
  flex: 1; padding: 9px; border: 1px solid rgba(255,255,255,0.12); border-radius: 9px;
  background: var(--panel2); color: var(--text); font-weight: 600; cursor: pointer;
}
.seg-btn.on { background: var(--accent); border-color: var(--accent); }

.emoji-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.emoji-pick {
  font-size: 22px; padding: 6px 0; border: 1px solid transparent; border-radius: 9px;
  background: var(--panel2); cursor: pointer;
}
.emoji-pick.on { border-color: var(--accent); background: #2c3a57; }
