:root {
  --bg: #09080f;
  --panel: rgba(21, 18, 31, .84);
  --panel2: rgba(35, 28, 49, .86);
  --gold: #f5c76b;
  --red: #ff4d6d;
  --green: #52ffb8;
  --blue: #64a6ff;
  --purple: #a855f7;
  --text: #fff7df;
  --muted: #b9a98f;
  --line: rgba(245, 199, 107, .22);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100svh;
  color: var(--text);
  background:
    radial-gradient(circle at 20% -10%, rgba(168, 85, 247, .35), transparent 34rem),
    radial-gradient(circle at 90% 10%, rgba(245, 199, 107, .18), transparent 24rem),
    linear-gradient(180deg, #09080f 0%, #130d18 55%, #07060b 100%);
  overflow-x: hidden;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.02) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(to bottom, black, transparent 85%);
  pointer-events: none;
}

#app {
  width: min(560px, 100%);
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 14px calc(90px + env(safe-area-inset-bottom));
}

.topbar, .resource-grid, .actions, .tabs, .ticker, .switch-row, .section-title, .card-head {
  display: flex;
  align-items: center;
}
.topbar { justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.eyebrow { margin: 0 0 2px; color: var(--gold); letter-spacing: .18em; text-transform: uppercase; font-size: 11px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 24px; text-shadow: 0 0 18px rgba(245,199,107,.3); }
.ghost-btn, button {
  border: 1px solid var(--line);
  color: var(--text);
  background: linear-gradient(180deg, rgba(245,199,107,.18), rgba(245,199,107,.06));
  border-radius: 16px;
  padding: 11px 13px;
  font-weight: 800;
  box-shadow: 0 10px 26px rgba(0,0,0,.28), inset 0 1px rgba(255,255,255,.08);
}
button:active { transform: translateY(1px) scale(.99); }
button:disabled { opacity: .43; filter: grayscale(1); }

.resource-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.resource-card, .hero-card, .panel, .asset-card {
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: 0 18px 50px rgba(0,0,0,.32), inset 0 1px rgba(255,255,255,.07);
}
.resource-card {
  border-radius: 20px;
  padding: 12px;
  min-width: 0;
}
.resource-card span { display: block; color: var(--muted); font-size: 12px; }
.resource-card strong { display: block; margin-top: 4px; font-size: 19px; overflow: hidden; text-overflow: ellipsis; }
.cash strong { color: var(--green); }
.debt strong, .karma strong { color: var(--red); }
.ceiling strong { color: var(--gold); }

.hero-card {
  position: relative;
  overflow: hidden;
  min-height: 220px;
  margin: 12px 0;
  border-radius: 28px;
  padding: 18px;
}
.city {
  position: absolute;
  inset: auto -20px 0 -20px;
  height: 145px;
  background:
    linear-gradient(to top, rgba(9,8,15,1), transparent 55%),
    repeating-linear-gradient(90deg, #191426 0 22px, #251a32 22px 38px, #0f0c18 38px 64px);
  clip-path: polygon(0 100%,0 54%,7% 54%,7% 30%,16% 30%,16% 62%,24% 62%,24% 18%,34% 18%,34% 48%,43% 48%,43% 8%,54% 8%,54% 58%,63% 58%,63% 26%,73% 26%,73% 67%,81% 67%,81% 38%,91% 38%,91% 18%,100% 18%,100% 100%);
  opacity: .9;
}
.city::after {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 15%, rgba(245,199,107,.55), transparent 35%), linear-gradient(90deg, transparent, rgba(255,77,109,.12), transparent);
  mix-blend-mode: screen;
}
.hero-copy { position: relative; z-index: 1; max-width: 88%; }
.badge {
  display: inline-flex;
  padding: 5px 10px;
  border-radius: 999px;
  color: #110a0a;
  background: var(--gold);
  font-weight: 900;
  font-size: 12px;
  margin-bottom: 10px;
}
.hero-copy h2 { font-size: 24px; }
.hero-copy p:last-child { margin-top: 8px; color: var(--muted); line-height: 1.55; }
.ticker {
  position: absolute;
  z-index: 2;
  left: 12px;
  right: 12px;
  bottom: 12px;
  justify-content: space-between;
  gap: 8px;
  padding: 10px;
  border-radius: 18px;
  background: rgba(0,0,0,.38);
  border: 1px solid rgba(255,255,255,.08);
  font-size: 12px;
}
.ticker b { color: var(--gold); }

.actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.actions button { padding-inline: 6px; }

.tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  padding: 7px;
  border: 1px solid rgba(245,199,107,.16);
  border-radius: 20px;
  background: rgba(9,8,15,.76);
  backdrop-filter: blur(16px);
}
.tabs button { padding: 10px 4px; border-radius: 14px; background: transparent; color: var(--muted); }
.tabs button.active { color: #120b08; background: linear-gradient(180deg, #ffe19a, #c98f30); }

.panel { display: none; margin-top: 12px; border-radius: 24px; padding: 14px; }
.panel.active { display: block; }
.section-title { justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-title h3 { font-size: 18px; }
.section-title span, .hint, .card p, .cost, .owned { color: var(--muted); font-size: 12px; line-height: 1.45; }
.section-title.small { margin-top: 18px; }
.card-list { display: grid; gap: 10px; }
.asset-card {
  border-radius: 20px;
  padding: 13px;
  background: linear-gradient(135deg, rgba(35,28,49,.92), rgba(14,12,21,.88));
}
.card-head { justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.icon {
  width: 42px; height: 42px; border-radius: 15px;
  display: grid; place-items: center;
  background: radial-gradient(circle at 35% 20%, #ffe7a4, #9d5cff 48%, #21152f);
  box-shadow: 0 0 24px rgba(168,85,247,.28);
  flex: 0 0 auto;
}
.card-title { flex: 1; min-width: 0; }
.card-title h4 { margin: 0 0 2px; }
.card-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.pill { border-radius: 12px; background: rgba(255,255,255,.05); padding: 8px; color: var(--muted); font-size: 12px; }
.pill b { color: var(--text); }
.buy-btn, .skill-btn, #prestigeBtn { width: 100%; margin-top: 4px; }
.switch-row { justify-content: space-between; padding: 14px; border-radius: 18px; background: rgba(255,255,255,.05); }
input[type="checkbox"] { width: 46px; height: 26px; accent-color: var(--gold); }
.meter { height: 16px; margin: 14px 0 10px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.08); }
.meter i { display: block; height: 100%; width: 0%; border-radius: inherit; background: linear-gradient(90deg, var(--green), var(--gold), var(--red)); transition: width .2s; }
.prestige-box {
  padding: 16px;
  border-radius: 22px;
  background: radial-gradient(circle at 80% 10%, rgba(255,77,109,.25), transparent 50%), rgba(255,255,255,.05);
  border: 1px solid rgba(255,77,109,.22);
}
.prestige-box strong { display: block; margin: 8px 0 12px; color: var(--gold); font-size: 24px; }
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(30px);
  opacity: 0;
  max-width: min(520px, calc(100% - 28px));
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(0,0,0,.82);
  border: 1px solid var(--line);
  color: var(--text);
  transition: .25s;
  pointer-events: none;
  z-index: 20;
}
.toast.show { opacity: 1; transform: translateX(-50%); }
.danger { animation: danger .8s ease-in-out infinite alternate; }
@keyframes danger {
  from { box-shadow: 0 0 0 rgba(255,77,109,0); }
  to { box-shadow: 0 0 45px rgba(255,77,109,.36); border-color: rgba(255,77,109,.55); }
}

@media (min-width: 520px) {
  .resource-grid { grid-template-columns: repeat(4, 1fr); }
}

.userbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
#userBadge { max-width: 92px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--gold); font-size: 12px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 999px; background: rgba(0,0,0,.22); }
.userbar .ghost-btn { padding: 9px 10px; border-radius: 13px; }
.modal { position: fixed; inset: 0; z-index: 50; display: none; place-items: center; padding: 18px; background: rgba(0,0,0,.62); backdrop-filter: blur(10px); }
.modal.show { display: grid; }
.auth-card { width: min(420px, 100%); border: 1px solid var(--line); border-radius: 26px; padding: 18px; background: linear-gradient(135deg, rgba(35,28,49,.98), rgba(9,8,15,.98)); box-shadow: 0 30px 90px rgba(0,0,0,.55); }
.auth-card h3 { margin: 0 0 8px; }
.auth-card p { color: var(--muted); font-size: 13px; line-height: 1.5; margin-bottom: 12px; }
.auth-card input { width: 100%; margin: 7px 0; padding: 13px 14px; border-radius: 16px; border: 1px solid rgba(245,199,107,.25); background: rgba(255,255,255,.06); color: var(--text); outline: none; }
.auth-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin: 10px 0; }
#logoutBtn, #authCloseBtn { width: 100%; margin-top: 8px; }

.danger-btn { border-color: rgba(255,77,109,.38); background: linear-gradient(180deg, rgba(255,77,109,.18), rgba(255,77,109,.06)); }
