/* Sleep Income — dark, mobile-first flat UI. No external assets. */
:root {
  --bg: #0f1220;
  --card: #1b2138;
  --card2: #232a45;
  --line: #2c3554;
  --text: #f2f4fb;
  --muted: #9aa3bd;
  --accent: #ffd166;
  --green: #35d07f;
  --blue: #4da3ff;
  --radius: 14px;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: 8px 12px 48px;
  min-height: 100vh;
}

/* ---------- top bar ---------- */
#topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 10px 2px 12px;
  background: linear-gradient(180deg, var(--bg) 88%, transparent);
}

.app-name { font-size: 13px; color: var(--muted); letter-spacing: 1px; }

.coins-row { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.coin-ico { width: 26px; height: 26px; display: inline-flex; }
.coin-ico svg { width: 100%; height: 100%; }
.coins { font-size: 30px; font-weight: 800; color: var(--accent); line-height: 1.1; }
.income { color: var(--green); font-size: 14px; font-weight: 600; margin-top: 2px; }

.top-actions { display: flex; gap: 8px; }
.icon-btn {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  min-width: 44px;
  height: 40px;
  padding: 0 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:active { transform: scale(0.95); }

/* ---------- buy amount bar ---------- */
.buybar { display: flex; align-items: center; gap: 10px; margin: 2px 0 10px; }
.buybar-label { font-size: 13px; color: var(--muted); white-space: nowrap; }
.seg { display: flex; background: var(--card); border-radius: 10px; padding: 3px; gap: 2px; flex: 1; }
.seg button {
  flex: 1;
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 7px 4px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.seg button.active { background: var(--blue); color: #fff; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.tabs button {
  flex: 1;
  padding: 11px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.tabs button.active { background: var(--card2); color: var(--text); border-color: var(--blue); }

/* ---------- business cards ---------- */
.biz-card {
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
}
.biz-icon {
  width: 52px; height: 52px; flex: 0 0 52px;
  background: #10142a;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
}
.biz-icon svg { width: 38px; height: 38px; }
.biz-info { flex: 1; min-width: 0; }
.biz-name { font-weight: 700; font-size: 15px; }
.owned { color: var(--blue); font-weight: 800; margin-left: 4px; }
.biz-income { color: var(--green); font-size: 13px; margin-top: 3px; font-weight: 600; }

.buy-btn {
  background: var(--green);
  color: #06281a;
  border: 0;
  border-radius: 10px;
  padding: 9px 10px;
  font-weight: 800;
  font-size: 14px;
  min-width: 88px;
  cursor: pointer;
  line-height: 1.25;
}
.buy-btn .cost { display: block; font-size: 12px; font-weight: 700; }
.buy-btn:disabled { background: #2a3049; color: var(--muted); cursor: default; }
.buy-btn:not(:disabled):active { transform: scale(0.96); }
.buy-btn.small { min-width: 76px; padding: 8px 8px; }

/* ---------- upgrades ---------- */
.section-title { color: var(--muted); font-size: 13px; margin: 18px 4px 8px; font-weight: 700; }
.upg-card {
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
}
.upg-card.purchased { opacity: 0.55; }
.upg-info { flex: 1; min-width: 0; }
.upg-name { font-weight: 700; font-size: 14px; }
.upg-desc { color: var(--muted); font-size: 12px; margin-top: 3px; }
.empty-hint { color: var(--muted); font-size: 13px; padding: 4px 4px 8px; }

/* ---------- footer ---------- */
footer { text-align: center; color: var(--muted); font-size: 12px; margin-top: 28px; }
.foot-row { margin-top: 8px; }
.link-btn {
  background: none; border: 0; color: var(--muted);
  text-decoration: underline; font-size: 12px; cursor: pointer; padding: 0;
}

/* ---------- offline modal ---------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(5, 8, 18, 0.72);
  display: flex; align-items: center; justify-content: center;
  z-index: 50; padding: 20px;
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--card2);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 26px 22px;
  max-width: 380px;
  width: 100%;
  text-align: center;
}
.modal-card h2 { margin: 10px 0 8px; font-size: 20px; }
.modal-card p { color: var(--text); font-size: 15px; line-height: 1.6; }
.primary-btn {
  background: var(--accent);
  color: #4a3200;
  border: 0;
  border-radius: 12px;
  padding: 12px 40px;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  margin-top: 8px;
}
.primary-btn:active { transform: scale(0.96); }

[hidden] { display: none !important; }

/* ================= Phase 3: polish ================= */

/* Animated starfield background (pure CSS, no assets). */
.sky {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    radial-gradient(1.5px 1.5px at 20% 30%, rgba(255,255,255,.45), transparent),
    radial-gradient(1px 1px at 70% 60%, rgba(255,255,255,.3), transparent),
    radial-gradient(2px 2px at 40% 80%, rgba(255,209,102,.35), transparent),
    radial-gradient(1px 1px at 85% 15%, rgba(255,255,255,.35), transparent),
    radial-gradient(1.5px 1.5px at 55% 45%, rgba(77,163,255,.3), transparent),
    radial-gradient(1px 1px at 10% 70%, rgba(255,255,255,.25), transparent);
  animation: starDrift 70s linear infinite;
}
@keyframes starDrift {
  from { transform: translateY(0); }
  to { transform: translateY(-60px); }
}
#app { position: relative; z-index: 1; }

/* Fog-of-war for locked tiers. */
.biz-card { position: relative; }
.biz-card.locked .biz-icon { filter: grayscale(1) brightness(0.32); }
.biz-card.locked { opacity: 0.85; }
.biz-card.locked .biz-name-text,
.biz-card.locked .biz-income,
.biz-card.locked .buy-label { color: var(--muted); letter-spacing: 2px; }

/* Coin-fly "+n" on purchase. */
.coin-fly {
  position: absolute; right: 20px; top: 4px;
  color: var(--accent); font-weight: 800; font-size: 15px;
  pointer-events: none; z-index: 5;
  animation: coinFly 0.9s ease-out forwards;
}
@keyframes coinFly {
  0% { opacity: 0; transform: translateY(10px) scale(0.7); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-48px) scale(1.05); }
}

/* Toasts. */
#toastWrap {
  position: fixed; left: 0; right: 0; bottom: 24px; z-index: 80;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; padding: 0 16px;
}
.toast {
  background: var(--card2);
  border: 1px solid var(--accent);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 14px; font-weight: 700;
  max-width: 480px; text-align: center;
  animation: toastIn 0.25s ease-out;
  transition: opacity 0.4s, transform 0.4s;
}
.toast.out { opacity: 0; transform: translateY(10px); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
}

/* Prestige tab. */
.pres-desc { color: var(--muted); font-size: 13px; line-height: 1.6; margin: 0 4px 12px; }
.stat-row {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--card); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 8px; font-size: 14px;
}
.stat-label { color: var(--muted); }
.stat-value { font-weight: 800; color: var(--accent); }
.pres-btn { width: 100%; margin-top: 12px; }
.pres-btn:disabled { background: #2a3049; color: var(--muted); }
.pres-hint { color: var(--muted); font-size: 13px; margin: 10px 4px 0; text-align: center; }
.modal-btns { display: flex; gap: 10px; margin-top: 12px; }
.modal-btns .primary-btn { flex: 1; margin-top: 0; padding: 12px 8px; font-size: 15px; }
.ghost-btn {
  flex: 1; background: transparent;
  border: 1px solid var(--line); color: var(--text);
  border-radius: 12px; padding: 12px 8px;
  font-size: 15px; font-weight: 700; cursor: pointer;
}
.ghost-btn:active { transform: scale(0.96); }

/* Achievements tab. */
.ach-progress { color: var(--muted); font-size: 13px; font-weight: 700; margin: 4px 4px 10px; }
.ach-card {
  display: flex; gap: 12px; align-items: center;
  background: var(--card); border-radius: var(--radius);
  padding: 12px; margin-bottom: 8px; opacity: 0.55;
}
.ach-card.unlocked { opacity: 1; border: 1px solid #3a435f; }
.ach-ico { width: 36px; height: 36px; flex: 0 0 36px; }
.ach-ico svg { width: 100%; height: 100%; }
.ach-info { flex: 1; min-width: 0; }
.ach-name { font-weight: 700; font-size: 14px; }
.ach-desc { color: var(--muted); font-size: 12px; margin-top: 2px; }
.ach-meta { color: var(--accent); font-size: 12px; font-weight: 600; margin-top: 4px; }

/* Bonus line under income. */
.bonus-line { color: var(--blue); font-size: 12px; font-weight: 700; margin-top: 3px; }

/* Daily check-in. */
.streak-line { color: var(--accent); font-weight: 700; }
.checkin-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 8px; margin: 14px 0;
}
.checkin-day {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 4px;
  font-size: 11px; color: var(--muted); text-align: center;
}
.checkin-day.done { opacity: 0.55; border-color: var(--green); }
.checkin-day.active { border-color: var(--accent); color: var(--text); background: #2b2410; }
.cd-label { white-space: nowrap; }
.cd-reward { font-weight: 800; color: var(--accent); margin-top: 3px; font-size: 12px; }
.checkin-reward {
  font-size: 28px; font-weight: 800; color: var(--accent); margin: 2px 0 8px;
}

/* Four tabs fit nicely. */
.tabs button { font-size: 14px; padding: 11px 4px; }

/* ---- Phase 4: monetization ---- */
/* Rewarded-boost button in the header. */
.boost-btn { font-size: 12px; font-weight: 700; min-width: 52px; color: #ffd166; }
.boost-btn.active { color: #0f1220; background: #ffd166; }
.boost-btn.cooldown { color: #8a93ad; }
/* Second button inside the offline modal (double via rewarded ad). */
#offlineDoubleBtn { margin-top: 10px; width: 100%; }
/* Store tab: restore-purchases row. */
.store-restore-row { display: flex; justify-content: center; margin: 18px 0 8px; }
