:root {
  --bg: #0b0b12;
  --bg2: #14141f;
  --panel: #1a1a28;
  --panel2: #20202f;
  --line: #2c2c40;
  --text: #f2f2f7;
  --muted: #9a9ab0;
  --accent: #b15cff;
  --accent2: #7d3cff;
  --eur: #4ade80;
  --crypto: #ffb84d;
  --danger: #ff5c7a;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 600px at 50% -10%, #1c1030 0%, var(--bg) 60%);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

/* ── Auth page ─────────────────────────────────────────── */
.auth-page { display: grid; place-items: center; }
.auth-card {
  width: min(92vw, 380px);
  margin-top: 12vh;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 32px 28px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
  text-align: center;
}
.auth-card h1 { margin: 0 0 4px; font-size: 28px; }
.auth-card .tag { margin: 0 0 22px; color: var(--muted); font-size: 14px; }
.tabs { display: flex; gap: 6px; background: var(--bg2); border-radius: 12px; padding: 5px; margin-bottom: 18px; }
.tab {
  flex: 1; padding: 9px; border: 0; border-radius: 9px; cursor: pointer;
  background: transparent; color: var(--muted); font-weight: 600; font-size: 14px;
}
.tab.active { background: var(--accent); color: #fff; }
#auth-form { display: flex; flex-direction: column; gap: 12px; }
#auth-form input {
  padding: 13px 14px; border-radius: 11px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--text); font-size: 15px;
}
#auth-form input:focus { outline: none; border-color: var(--accent); }
#submit {
  margin-top: 4px; padding: 13px; border: 0; border-radius: 11px; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; font-weight: 700; font-size: 15px;
}
#submit:disabled { opacity: .6; cursor: default; }
.msg { min-height: 18px; margin: 4px 0 0; color: var(--danger); font-size: 13px; }

/* ── Top bar ───────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 12px 20px;
  background: rgba(16, 16, 26, .85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { font-size: 20px; font-weight: 800; }
.wallet { display: flex; gap: 14px; margin-left: auto; }
.coin {
  display: flex; align-items: baseline; gap: 6px;
  background: var(--panel); border: 1px solid var(--line);
  padding: 7px 14px; border-radius: 12px; font-weight: 700; font-size: 17px;
}
.coin b { font-variant-numeric: tabular-nums; }
.coin small { font-size: 11px; color: var(--muted); font-weight: 600; }
.coin.eur b { color: var(--eur); }
.coin.crypto b { color: var(--crypto); }
.ghost {
  padding: 8px 14px; border: 1px solid var(--line); border-radius: 10px;
  background: transparent; color: var(--muted); cursor: pointer; font-weight: 600;
}
.ghost:hover { color: var(--text); border-color: var(--accent); }

/* ── Game layout ───────────────────────────────────────── */
.game { max-width: 1100px; margin: 0 auto; padding: 20px; display: grid; gap: 20px; }
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 18px 20px;
}
.panel h2 { margin: 0 0 4px; font-size: 18px; }
.hint { margin: 0 0 14px; color: var(--muted); font-size: 13px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }

.card {
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: 13px; padding: 14px; display: flex; flex-direction: column; gap: 6px;
}
.card-title { font-weight: 700; font-size: 15px; }
.card-sub { color: var(--muted); font-size: 12px; }
.card-owned { color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.card button {
  margin-top: auto; padding: 9px; border: 0; border-radius: 9px; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; font-weight: 700; font-size: 13px;
}
.card button:disabled { opacity: .4; cursor: default; filter: grayscale(.4); }

.stepper { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; }
.stepper button {
  width: 34px; height: 34px; padding: 0; border-radius: 9px; font-size: 18px;
  background: var(--bg2); color: var(--text); border: 1px solid var(--line);
}
.stepper span { font-weight: 700; font-variant-numeric: tabular-nums; }

.build-bar {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line);
}
#build-power { font-weight: 700; }
#build-btn {
  padding: 11px 22px; border: 0; border-radius: 11px; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; font-weight: 700;
}
#build-btn:disabled { opacity: .4; cursor: default; }

.card.pc.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
#pcs { grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); }
.pc-jobline { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 2px; }
.card-job { font-size: 13px; color: var(--muted); }
.card-job b { color: var(--text); }
.pc-out { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pc-out.eur { color: var(--eur); }
.pc-out.crypto { color: var(--crypto); }
.pc-out.idle { color: var(--muted); }
.job-btns { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 6px; margin-top: 10px; }
.job-btns button {
  margin: 0; padding: 9px 6px; font-size: 12px; border-radius: 8px; cursor: pointer;
  background: var(--bg2); color: var(--muted); border: 1px solid var(--line);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.job-btns button:hover { color: var(--text); border-color: var(--accent); }
.job-btns button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.job-btns button.stop { grid-column: 1 / -1; }
.job-btns button.stop.on { background: var(--danger); color: #fff; border-color: var(--danger); }

/* ── Prestige chip in wallet ───────────────────────────── */
.coin.prestige b { color: var(--accent); }

/* ── Tab navigation ────────────────────────────────────── */
.tabs-nav {
  position: sticky; top: 57px; z-index: 9;
  display: flex; gap: 6px; flex-wrap: wrap;
  padding: 10px 20px; background: rgba(13, 13, 22, .9); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.tabbtn {
  padding: 8px 14px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel); color: var(--muted); cursor: pointer; font-weight: 600; font-size: 13px;
}
.tabbtn:hover { color: var(--text); }
.tabbtn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.tab.hidden { display: none; }

/* ── Shop categories & stat chips ──────────────────────── */
.cat-h { margin: 14px 0 8px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.cat-h:first-child { margin-top: 0; }
.stat {
  display: inline-block; background: var(--bg2); border: 1px solid var(--line);
  border-radius: 7px; padding: 2px 7px; margin: 1px 3px 1px 0; font-size: 12px; font-weight: 600;
}
.card-sub .stat { color: var(--text); }

/* ── Scrap button on PC cards ──────────────────────────── */
.scrap {
  float: right; cursor: pointer; color: var(--muted); font-size: 13px;
  width: 20px; height: 20px; line-height: 20px; text-align: center; border-radius: 6px;
}
.scrap:hover { color: #fff; background: var(--danger); }

/* ── Market / coins ────────────────────────────────────── */
#market { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.coin-card { gap: 8px; }
.coin-head { display: flex; justify-content: space-between; align-items: baseline; }
.coin-name { font-weight: 800; font-size: 15px; }
.coin-price { font-weight: 700; font-variant-numeric: tabular-nums; }
.spark { width: 100%; height: 34px; display: block; background: var(--bg2); border-radius: 8px; }
.coin-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.coin-meta b { color: var(--text); font-variant-numeric: tabular-nums; }
.trend { font-weight: 700; }
.trend.up { color: var(--eur); }
.trend.down { color: var(--danger); }
.trade { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 4px; }
.trade input {
  grid-column: 1 / -1; padding: 9px 10px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--bg2); color: var(--text); font-size: 14px;
}
.trade button {
  margin: 0; padding: 9px 6px; font-size: 12px; border-radius: 8px; cursor: pointer; font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; border: 0;
}
.trade button.ghost { background: var(--bg2); color: var(--muted); border: 1px solid var(--line); }
.trade button.ghost:hover { color: var(--text); border-color: var(--accent); }
.trade [data-sellall] { grid-column: 1 / -1; }

/* ── Prestige ──────────────────────────────────────────── */
.prestige-box { display: flex; flex-direction: column; gap: 10px; max-width: 460px; }
.pstat {
  display: flex; justify-content: space-between; align-items: center;
  padding: 11px 14px; background: var(--panel2); border: 1px solid var(--line); border-radius: 11px;
}
.pstat span { color: var(--muted); font-size: 14px; }
.pstat b { font-size: 16px; font-variant-numeric: tabular-nums; }
.pstat.highlight { border-color: var(--accent); }
.pstat.highlight b { color: var(--accent); }
#prestige-btn {
  margin-top: 4px; padding: 14px; border: 0; border-radius: 12px; cursor: pointer; font-weight: 800; font-size: 15px;
  background: linear-gradient(135deg, #ff8a3c, var(--accent)); color: #fff;
}
#prestige-btn:disabled { opacity: .4; cursor: default; filter: grayscale(.5); }

/* ── Leaderboard ───────────────────────────────────────── */
.lb { width: 100%; border-collapse: collapse; }
.lb th, .lb td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
.lb th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
.lb td:nth-child(3) { color: var(--eur); font-weight: 700; font-variant-numeric: tabular-nums; }
.lb tr.me { background: rgba(177, 92, 255, .12); }
.lb tr.me td:nth-child(2) { color: var(--accent); font-weight: 700; }

/* ── Toast ─────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 30px);
  background: var(--panel2); border: 1px solid var(--accent); color: var(--text);
  padding: 12px 20px; border-radius: 12px; font-weight: 600; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; z-index: 50;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
