/* Aussie Money Empire — mobile-first dark theme, gold accents */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  --bg: #12100d;
  --bg2: #1c1915;
  --card: #242019;
  --card2: #2e2920;
  --gold: #f5b83d;
  --gold-dim: #a97f24;
  --green: #5ec46a;
  --red: #e2574b;
  --text: #f0e9da;
  --muted: #9a8f7a;
  --border: #3a3326;
  --on-gold: #2a1f05;
  --on-green: #08230c;
  --click-bg1: #4a3c1d;
  --click-bg2: #2b2310;
  --radius: 14px;
  --tabs-h: 62px;
}
/* Light theme — toggled from Settings, persisted in the save */
body.light {
  --bg: #f6f1e4;
  --bg2: #efe7d3;
  --card: #fffdf6;
  --card2: #f4ecda;
  --gold: #9a6b00;
  --gold-dim: #c39a3a;
  --green: #2e8540;
  --red: #c0392b;
  --text: #2b2418;
  --muted: #7d7158;
  --border: #ddd2b4;
  --on-gold: #fffdf6;
  --on-green: #ffffff;
  --click-bg1: #f4e3b2;
  --click-bg2: #e3cd8d;
}
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  overflow-x: hidden;
  user-select: none; -webkit-user-select: none;
}
h2 { margin: 6px 0 10px; }
h3 { margin: 10px 0 8px; font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: 0.8rem; }
.center { text-align: center; }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea {
  font-family: inherit; font-size: 1rem; color: var(--text);
  background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; padding: 10px;
}
textarea { width: 100%; margin-top: 8px; user-select: text; -webkit-user-select: text; }
a { color: var(--gold); }

/* ===== HUD ===== */
#hud {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: max(8px, env(safe-area-inset-top)) 14px 6px;
}
.hud-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
#hud-cash-value { font-size: 1.7rem; font-weight: 800; color: var(--gold); line-height: 1.1; font-variant-numeric: tabular-nums; }
#hud-rate { color: var(--muted); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.hud-side { display: flex; gap: 6px; align-items: center; }
.chip {
  background: var(--card); border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 12px; font-size: 0.85rem; color: var(--text); font-weight: 600;
}
.chip-gold { background: var(--gold); color: var(--on-gold); border-color: var(--gold); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { transform: scale(1.06); } }
#buff-bar { display: flex; gap: 6px; flex-wrap: wrap; padding: 4px 0 2px; min-height: 4px; }
.buff {
  font-size: 0.75rem; font-weight: 700; border-radius: 999px; padding: 3px 10px;
  background: var(--card2); border: 1px solid var(--gold-dim); color: var(--gold);
}

/* ===== Screens & tabs ===== */
#screens { padding: 12px 14px calc(var(--tabs-h) + 24px); max-width: 680px; margin: 0 auto; }
.screen { display: none; }
.screen.active { display: block; }
#tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg2); border-top: 1px solid var(--border);
}
#tabs button {
  flex: 1; background: none; border: none; color: var(--muted);
  font-size: 0.7rem; font-weight: 600; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; position: relative;
  min-height: 44px;
}
#tabs button span:first-child { font-size: 1.3rem; }
#tabs button.active { color: var(--gold); }
.badge {
  position: absolute; top: 6px; right: 22%; background: var(--red); color: #fff;
  font-size: 0.65rem; border-radius: 999px; min-width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}

/* ===== Click zone ===== */
#click-zone { position: relative; display: flex; justify-content: center; padding: 18px 0 10px; }
#btn-click {
  width: min(62vw, 230px); height: min(62vw, 230px); border-radius: 50%;
  border: 5px solid var(--gold-dim);
  background: radial-gradient(circle at 35% 30%, var(--click-bg1), var(--click-bg2) 70%);
  color: var(--gold); font-weight: 800; font-size: 1.1rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  box-shadow: 0 6px 30px rgba(245, 184, 61, 0.15);
  transition: transform 0.05s;
  touch-action: manipulation;
}
#btn-click:active { transform: scale(0.96); }
.click-emoji { font-size: 3.2rem; }
.click-combo { font-size: 0.8rem; color: var(--text); min-height: 1em; }
body.heater #btn-click { border-color: var(--gold); box-shadow: 0 0 40px rgba(245,184,61,0.55); }
#gum-tree { position: absolute; bottom: 0; right: 2px; font-size: 1.6rem; opacity: 0.5; cursor: pointer; }
.float-num {
  position: absolute; pointer-events: none; font-weight: 800; color: var(--gold);
  animation: floatUp 0.9s ease-out forwards; z-index: 15; text-shadow: 0 1px 4px #000;
}
@keyframes floatUp { to { transform: translateY(-70px); opacity: 0; } }

/* ===== Generators ===== */
.gen-header { display: flex; justify-content: space-between; align-items: center; }
.bulk-toggle { display: flex; gap: 4px; }
.bulk-toggle button {
  background: var(--card); border: 1px solid var(--border); color: var(--muted);
  border-radius: 8px; padding: 6px 10px; font-size: 0.8rem; font-weight: 700; min-height: 32px;
}
.bulk-toggle button.active { background: var(--gold-dim); color: #fff; border-color: var(--gold-dim); }
.gen {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; margin-bottom: 8px;
}
.gen.locked { opacity: 0.55; }
.gen.mystery { opacity: 0.4; filter: grayscale(1); }
.gen-icon { font-size: 1.8rem; width: 42px; text-align: center; }
.gen-info { flex: 1; min-width: 0; }
.gen-name { font-weight: 700; }
.gen-flavour { font-size: 0.72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gen-rate { font-size: 0.8rem; color: var(--green); font-variant-numeric: tabular-nums; }
.gen-count { font-size: 1.1rem; font-weight: 800; color: var(--gold); min-width: 36px; text-align: right; }
.gen-buy {
  min-width: 92px; min-height: 48px; border-radius: 10px; border: none;
  background: var(--green); color: var(--on-green); font-weight: 800; font-size: 0.85rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.gen-buy:disabled { background: var(--card2); color: var(--muted); }
.gen-buy .buy-n { font-size: 0.7rem; opacity: 0.8; }

/* ===== Upgrades ===== */
#upgrade-strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; }
.upg {
  flex: 0 0 auto; width: 150px; text-align: left;
  background: var(--card2); border: 1px solid var(--gold-dim); border-radius: 12px;
  padding: 8px 10px; color: var(--text);
}
.upg:disabled { border-color: var(--border); opacity: 0.6; }
.upg .upg-name { font-weight: 700; font-size: 0.82rem; }
.upg .upg-effect { font-size: 0.72rem; color: var(--green); }
.upg .upg-cost { font-size: 0.78rem; color: var(--gold); font-weight: 700; }

/* ===== Cards / boardroom ===== */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 12px;
}
.card.danger { border-color: #5d2c27; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 6px 0; }
.row input { flex: 1; min-width: 120px; }
.btn {
  background: var(--card2); border: 1px solid var(--gold-dim); color: var(--gold);
  border-radius: 10px; padding: 10px 16px; font-weight: 700; min-height: 44px;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
}
.btn-danger { border-color: var(--red); color: var(--red); }
.btn-big {
  width: 100%; padding: 14px; font-size: 1.05rem; font-weight: 800;
  border-radius: 12px; border: none; margin-top: 10px; min-height: 52px;
}
.btn-gold { background: var(--gold); color: var(--on-gold); }
.btn-gold:disabled { background: var(--card2); color: var(--muted); }
.prestige-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.prestige-stats div { display: flex; flex-direction: column; }
.prestige-stats b { font-size: 1.15rem; color: var(--gold); }
.shop-item { display: flex; align-items: center; gap: 10px; }
.shop-item .gen-info { flex: 1; }
.shop-buy { min-width: 92px; min-height: 44px; border-radius: 10px; border: none; background: var(--gold); color: var(--on-gold); font-weight: 800; }
.shop-buy:disabled { background: var(--card2); color: var(--muted); }
#shop-list .gen { margin-bottom: 8px; }

/* ===== Achievements ===== */
#ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.ach {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; background: var(--card); border: 1px solid var(--border); border-radius: 10px;
}
.ach.unlocked { background: var(--card2); border-color: var(--gold-dim); }
.ach.locked { filter: grayscale(1); opacity: 0.35; }

/* ===== Leaderboards / races ===== */
.lb-tabs { justify-content: space-between; }
.lb-row { display: flex; align-items: center; gap: 8px; padding: 7px 4px; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.lb-row .lb-rank { width: 26px; color: var(--muted); font-weight: 700; }
.lb-row .lb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-row .lb-val { font-weight: 700; color: var(--gold); }
.lb-row.me { background: rgba(245,184,61,0.08); border-radius: 8px; }
.race { background: var(--card2); border-radius: 10px; padding: 10px; margin-top: 8px; }
.race .race-head { display: flex; justify-content: space-between; font-weight: 700; font-size: 0.9rem; }
.race .bar { height: 8px; background: var(--bg); border-radius: 99px; margin: 6px 0 2px; overflow: hidden; }
.race .bar i { display: block; height: 100%; background: var(--green); border-radius: 99px; }
.race .bar.opp i { background: var(--red); }
.race .race-actions { display: flex; gap: 8px; margin-top: 8px; }
.trophy { display: inline-block; font-size: 1.6rem; margin: 4px; }

/* ===== Golden Roo ===== */
#roo-layer { position: fixed; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; }
.roo {
  position: absolute; pointer-events: auto; font-size: 2.6rem; cursor: pointer;
  filter: drop-shadow(0 0 12px rgba(245,184,61,0.9));
  animation: hop 1.1s ease-in-out infinite alternate;
  border: none; background: none; padding: 10px;
}
.roo.wombat { font-size: 2.2rem; animation: waddle 2s ease-in-out infinite alternate; filter: drop-shadow(0 0 16px rgba(245,184,61,1)); }
@keyframes hop { from { transform: translateY(0) scaleX(-1); } to { transform: translateY(-26px) scaleX(-1); } }
@keyframes waddle { from { transform: rotate(-6deg); } to { transform: rotate(6deg); } }

/* ===== Toasts / modal ===== */
#toasts {
  position: fixed; top: calc(70px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  z-index: 60; display: flex; flex-direction: column; gap: 6px; width: min(92vw, 420px); pointer-events: none;
}
.toast {
  background: var(--card2); border: 1px solid var(--gold-dim); border-radius: 12px;
  padding: 10px 14px; font-size: 0.9rem; box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  animation: toastIn 0.25s ease-out;
}
.toast b { color: var(--gold); }
@keyframes toastIn { from { transform: translateY(-12px); opacity: 0; } }
#modal-root:not(:empty) {
  position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,0.65);
  display: flex; align-items: center; justify-content: center; padding: 18px;
}
.modal {
  background: var(--card); border: 1px solid var(--gold-dim); border-radius: 16px;
  padding: 20px; width: min(94vw, 420px); max-height: 86dvh; overflow-y: auto;
}
.modal h2 { margin-top: 0; }
.modal .btn-big { margin-top: 14px; }

/* Confetti for jackpots */
.confetti { position: fixed; top: -10px; font-size: 1.2rem; z-index: 65; pointer-events: none; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110dvh) rotate(720deg); } }

/* Corner Office cosmetic */
body.corner-office #hud { border-bottom: 2px solid var(--gold); }
body.corner-office #hud-cash-value { text-shadow: 0 0 14px rgba(245,184,61,0.6); }

@media (min-width: 700px) {
  #tabs { max-width: 680px; left: 50%; transform: translateX(-50%); border-radius: 16px 16px 0 0; border: 1px solid var(--border); border-bottom: none; }
  #btn-click { width: 200px; height: 200px; }
}
