* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f5f2ea; color: #333; display: flex; flex-direction: column;
  min-height: 100vh; font-size: 14px; line-height: 1.5;
}

#topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; background: #fff; border-bottom: 1px solid #ece6d9;
}
.top-title { font-size: 16px; font-weight: 600; color: #5b7a3e; flex: 1; text-align: center; }
.top-stats { display: flex; gap: 14px; font-size: 14px; color: #555; }
.btn-back {
  background: none; border: none; font-size: 18px; cursor: pointer;
  color: #5b7a3e; padding: 4px 8px; font-family: inherit;
}
.btn-back.hidden { display: none; }
#top-nav { display: flex; gap: 4px; }
.nav-btn {
  background: none; border: none; font-size: 18px; cursor: pointer;
  padding: 4px 6px; border-radius: 8px; font-family: inherit;
}
.nav-btn:hover { background: #f0ede4; }
.nav-btn.active { background: #e8f0dd; }

#app { flex: 1; padding: 14px; overflow-y: auto; }
.page { display: none; }
.page.active { display: block; }

.member-list { display: flex; flex-direction: column; gap: 10px; }
.member-card {
  background: #fff; border-radius: 12px; padding: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  display: flex; gap: 12px; align-items: center;
}
.member-info { flex: 1; min-width: 0; }
.member-row1 { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.member-name { font-size: 15px; font-weight: 600; color: #333; }
.member-status { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: #f0f0f0; color: #888; }
.status-idle { background: #e8f0dd; color: #5b7a3e; }
.status-exploring { background: #e4eef7; color: #3f6b91; }
.status-dead { background: #f5e3e1; color: #b25048; }
.member-stats { font-size: 12px; color: #888; display: flex; flex-wrap: wrap; gap: 10px; }
.progress { height: 6px; background: #eee; border-radius: 3px; overflow: hidden; margin-top: 8px; }
.progress-inner {
  height: 100%; background: linear-gradient(90deg, #8ab661, #6e9a48);
  border-radius: 3px; transition: width 0.4s linear;
}

.btn {
  border: none; border-radius: 8px; padding: 8px 16px; font-size: 13px;
  cursor: pointer; background: #7a9e5a; color: #fff; font-family: inherit;
  transition: background 0.2s; white-space: nowrap;
}
.btn:hover { background: #6a8d4b; }
.btn:active { transform: scale(0.97); }
.btn.ghost { background: #f1efe8; color: #666; }
.btn.ghost:hover { background: #e6e3d9; }
.btn.danger { background: #c1554a; }
.btn.danger:hover { background: #a94840; }
.btn:disabled { background: #ddd; color: #999; cursor: not-allowed; }
.btn:disabled:hover { background: #ddd; }

#logbar {
  position: sticky; bottom: 0; background: #fff;
  border-top: 1px solid #ece6d9; padding: 10px 16px; z-index: 15;
}
.log-title { font-size: 12px; color: #999; margin-bottom: 6px; }
.log-list { display: flex; flex-direction: column; gap: 4px; max-height: 90px; overflow-y: auto; }
.log-item { display: flex; gap: 8px; font-size: 12px; }
.log-time { color: #aaa; flex-shrink: 0; }
.log-text { color: #555; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-empty { font-size: 12px; color: #bbb; }

#modal-root { position: fixed; inset: 0; z-index: 100; display: none; }
#modal-root.show { display: block; }
.modal-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,0.35);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: #fff; border-radius: 14px; padding: 20px;
  width: 100%; max-width: 340px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  animation: pop 0.18s ease;
}
@keyframes pop {
  from { transform: scale(0.94); opacity: 0.6; }
  to { transform: scale(1); opacity: 1; }
}
.modal-title { font-size: 16px; font-weight: 600; margin-bottom: 14px; color: #333; text-align: center; }
.modal-body { margin-bottom: 18px; }
.modal-row {
  display: flex; justify-content: space-between; padding: 8px 0;
  font-size: 13px; color: #666; border-bottom: 1px solid #f5f3ee;
}
.modal-row:last-child { border-bottom: none; }
.modal-row span:last-child { color: #333; font-weight: 500; }
.modal-row .gain { color: #5b7a3e; }
.modal-row .loss { color: #c1554a; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }

.empty { text-align: center; color: #bbb; padding: 40px 20px; font-size: 13px; }

.shop-section { margin-bottom: 22px; }
.shop-section-title {
  font-size: 13px; color: #888; margin-bottom: 10px;
  padding-left: 4px; font-weight: 600;
}
.shop-list { display: flex; flex-direction: column; gap: 10px; }
.shop-card {
  background: #fff; border-radius: 12px; padding: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.shop-info { flex: 1; min-width: 0; }
.shop-name { font-size: 15px; font-weight: 600; color: #333; margin-bottom: 6px; }
.shop-stats { font-size: 12px; color: #888; display: flex; flex-wrap: wrap; gap: 10px; }
.shop-price {
  font-size: 13px; color: #c9882c; font-weight: 600; margin-top: 6px;
}
.shop-action { flex-shrink: 0; }

.upgrade-section {
  background: #fff; border-radius: 12px; padding: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.upgrade-row {
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px;
}
.upgrade-info { font-size: 13px; color: #666; }
.upgrade-info .current { color: #333; font-weight: 600; }
.upgrade-cost { font-size: 12px; color: #c9882c; margin-top: 4px; }
.upgrade-max { text-align: center; font-size: 12px; color: #aaa; padding: 8px 0; }

.rank-tabs {
  display: flex; gap: 6px; margin-bottom: 14px;
  background: #fff; padding: 6px; border-radius: 10px;
}
.rank-tab {
  flex: 1; border: none; background: none; padding: 8px 4px;
  font-size: 12px; color: #888; cursor: pointer; border-radius: 8px;
  font-family: inherit;
}
.rank-tab.active { background: #e8f0dd; color: #5b7a3e; font-weight: 600; }

.rank-list { display: flex; flex-direction: column; gap: 6px; }
.rank-item {
  background: #fff; border-radius: 10px; padding: 10px 14px;
  display: flex; align-items: center; gap: 10px; font-size: 13px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.rank-item.top1 { background: linear-gradient(90deg, #fff8e0, #fff); }
.rank-item.top2 { background: linear-gradient(90deg, #f5f5f5, #fff); }
.rank-item.top3 { background: linear-gradient(90deg, #fbf0e2, #fff); }
.rank-pos { width: 40px; text-align: center; color: #999; font-weight: 600; flex-shrink: 0; }
.rank-name { flex: 1; color: #333; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-value { color: #5b7a3e; font-weight: 600; flex-shrink: 0; }
.rank-sub { color: #aaa; font-size: 11px; margin-left: 6px; }

.rank-self {
  position: sticky; bottom: 0; margin-top: 14px;
  background: #fff; border-radius: 10px; padding: 12px 14px;
  display: flex; align-items: center; gap: 10px; font-size: 13px;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
  border: 1px solid #e8f0dd;
}
.rank-self .rank-pos { color: #5b7a3e; font-weight: 700; }
.rank-self .rank-name { color: #333; font-weight: 600; }
.rank-self .rank-value { color: #5b7a3e; font-weight: 700; }

#activity-banner { margin-bottom: 16px; }
.activity-banner-card {
  background: linear-gradient(135deg, #ffe9c8, #ffd8a8);
  border-radius: 14px; padding: 18px; color: #7a4e1a;
  box-shadow: 0 2px 8px rgba(200,140,60,0.15);
}
.activity-banner-title { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.activity-banner-content { font-size: 13px; color: #8a5e2a; margin-bottom: 10px; }
.activity-banner-time { font-size: 12px; color: #b07a3a; }

.activity-list { display: flex; flex-direction: column; gap: 8px; }
.activity-item {
  background: #fff; border-radius: 10px; padding: 14px;
  display: flex; flex-direction: column; gap: 6px; cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
  transition: background 0.15s;
}
.activity-item:hover { background: #faf8f2; }
.activity-item.ended { opacity: 0.55; }
.activity-item-head { display: flex; align-items: center; gap: 8px; }
.activity-tag {
  font-size: 11px; padding: 2px 8px; border-radius: 8px;
  background: #f0f0f0; color: #888; flex-shrink: 0;
}
.activity-tag.event { background: #ffe9c8; color: #b07a3a; }
.activity-tag.notice { background: #e4eef7; color: #3f6b91; }
.activity-tag.update { background: #e8f0dd; color: #5b7a3e; }
.activity-title { flex: 1; font-size: 14px; color: #333; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-date { font-size: 11px; color: #bbb; flex-shrink: 0; }

.toast {
  position: fixed; left: 50%; bottom: 100px;
  transform: translateX(-50%) translateY(10px);
  background: rgba(50,50,50,0.9); color: #fff;
  padding: 10px 18px; border-radius: 20px; font-size: 13px;
  opacity: 0; transition: all 0.3s; z-index: 200; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.auth-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: #f5f2ea;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.auth-overlay.hidden { display: none; }
.auth-box {
  background: #fff; border-radius: 16px; padding: 28px 22px;
  width: 100%; max-width: 320px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.08);
}
.auth-title { font-size: 20px; font-weight: 700; color: #5b7a3e; text-align: center; margin-bottom: 20px; }
.auth-tabs {
  display: flex; gap: 4px; background: #f5f2ea; border-radius: 10px;
  padding: 4px; margin-bottom: 18px;
}
.auth-tab {
  flex: 1; border: none; background: none; padding: 8px; font-size: 14px;
  color: #888; cursor: pointer; border-radius: 8px; font-family: inherit;
}
.auth-tab.active { background: #fff; color: #5b7a3e; font-weight: 600; }
.auth-input {
  width: 100%; border: 1px solid #e0dcd0; border-radius: 10px;
  padding: 12px 14px; font-size: 14px; font-family: inherit;
  margin-bottom: 12px; outline: none; background: #faf8f3;
}
.auth-input:focus { border-color: #8ab661; background: #fff; }
.auth-error { color: #c1554a; font-size: 12px; min-height: 18px; margin-bottom: 8px; text-align: center; }
.auth-submit { width: 100%; padding: 12px; font-size: 15px; }

@media (max-width: 480px) {
  .member-card { flex-direction: column; align-items: stretch; }
  .member-action .btn { width: 100%; }
  .shop-card { flex-direction: column; align-items: stretch; }
  .shop-action .btn { width: 100%; }
}