/* ═══════════════════════ STARFORGE — style.css ═══════════════════════ */
:root {
  --bg0: #05060f;
  --bg1: #0b0e23;
  --panel: rgba(17, 21, 48, 0.82);
  --panel-border: rgba(122, 140, 255, 0.16);
  --gold: #ffd76a;
  --gold-deep: #ff9d3c;
  --cyan: #6ae6ff;
  --violet: #9a6aff;
  --text: #e8ecff;
  --text-dim: #8a93c4;
  --good: #5effa6;
  --bad: #ff5e7a;
  --radius: 14px;
  font-size: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  background: radial-gradient(1200px 800px at 20% 10%, #141a3f 0%, var(--bg1) 45%, var(--bg0) 100%);
  color: var(--text);
  font-family: "Inter", system-ui, sans-serif;
  overflow: hidden;
  user-select: none;
}

#bg {
  position: fixed;
  inset: 0;
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.hidden { display: none !important; }

/* ─────────────────────────── Top bar ─────────────────────────── */
#topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 20px;
  background: rgba(8, 10, 26, 0.7);
  border-bottom: 1px solid var(--panel-border);
  backdrop-filter: blur(12px);
}

.brand {
  font-family: "Orbitron", sans-serif;
  font-weight: 900;
  font-size: 1.25rem;
  letter-spacing: 0.14em;
  color: var(--gold);
  text-shadow: 0 0 18px rgba(255, 215, 106, 0.55);
}
.brand span { color: var(--cyan); text-shadow: 0 0 18px rgba(106, 230, 255, 0.55); }

.top-stats {
  display: flex;
  gap: 10px;
  flex: 1;
  justify-content: center;
  flex-wrap: wrap;
}

.chip {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 16px;
  border-radius: 999px;
  background: rgba(122, 140, 255, 0.08);
  border: 1px solid var(--panel-border);
  font-family: "Orbitron", sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
}
.chip-dust .chip-num { color: var(--gold); text-shadow: 0 0 12px rgba(255, 215, 106, 0.6); }
.chip-cores .chip-num { color: var(--violet); text-shadow: 0 0 12px rgba(154, 106, 255, 0.6); }
.chip-unit { color: var(--text-dim); font-size: 0.75rem; }

.top-actions { display: flex; gap: 8px; }

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: rgba(122, 140, 255, 0.08);
  cursor: pointer;
  font-size: 1rem;
  transition: transform 0.12s, background 0.12s, box-shadow 0.12s;
}
.icon-btn:hover { background: rgba(122, 140, 255, 0.2); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(0,0,0,0.4); }
.icon-btn.off { opacity: 0.35; filter: grayscale(0.8); }
.icon-btn.danger:hover { background: rgba(255, 94, 122, 0.2); }

/* ─────────────────────────── Layout ─────────────────────────── */
main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 420px;
  min-height: 0;
}

/* ─────────────────────────── Stage (star) ─────────────────────────── */
#stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 26px;
  overflow: hidden;
}

#star-wrap {
  position: relative;
  width: 320px;
  height: 320px;
  display: grid;
  place-items: center;
}

#star-aura {
  position: absolute;
  inset: -70px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 200, 80, 0.28) 0%, rgba(255, 140, 60, 0.1) 42%, transparent 70%);
  animation: auraBreathe 4s ease-in-out infinite;
  pointer-events: none;
}
@keyframes auraBreathe {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.12); opacity: 1; }
}

#star {
  position: relative;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  cursor: pointer;
  z-index: 3;
  transition: transform 0.08s ease-out;
  animation: starFloat 6s ease-in-out infinite;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}
@keyframes starFloat {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -12px; }
}

#star-core {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 38% 34%, #fffbe8 0%, #ffe89a 18%, #ffbe4e 42%, #ff7a2f 68%, #c9401f 100%);
  box-shadow:
    0 0 40px rgba(255, 190, 78, 0.9),
    0 0 110px rgba(255, 140, 50, 0.55),
    0 0 200px rgba(255, 110, 40, 0.3),
    inset -18px -22px 60px rgba(160, 30, 10, 0.55),
    inset 10px 12px 40px rgba(255, 255, 230, 0.35);
  animation: coreChurn 5s linear infinite;
}
@keyframes coreChurn {
  0%, 100% { filter: brightness(1) saturate(1); }
  50% { filter: brightness(1.14) saturate(1.15); }
}

#star.pulse { animation: starPulse 0.18s ease-out, starFloat 6s ease-in-out infinite; }
@keyframes starPulse {
  0% { transform: scale(1); }
  35% { transform: scale(0.92); }
  100% { transform: scale(1); }
}

#star-ring, #star-ring2 {
  position: absolute;
  border-radius: 50%;
  border: 1px dashed rgba(255, 215, 106, 0.28);
  pointer-events: none;
}
#star-ring { width: 290px; height: 290px; animation: spin 26s linear infinite; }
#star-ring2 { width: 330px; height: 330px; border-color: rgba(106, 230, 255, 0.18); animation: spin 40s linear infinite reverse; }
#star-ring::before, #star-ring2::before {
  content: "";
  position: absolute;
  top: -4px; left: 50%;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 10px var(--gold);
}
#star-ring2::before { background: var(--cyan); box-shadow: 0 0 10px var(--cyan); }
@keyframes spin { to { transform: rotate(360deg); } }

#click-power {
  font-family: "Orbitron", sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.08em;
}
#click-power b { color: var(--gold); }

/* Combo */
#combo-wrap {
  position: absolute;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  width: 240px;
  text-align: center;
  z-index: 5;
}
#combo-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(122, 140, 255, 0.12);
  border: 1px solid var(--panel-border);
  overflow: hidden;
}
#combo-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold), #fff3c4);
  box-shadow: 0 0 12px rgba(255, 190, 78, 0.8);
  transition: width 0.1s linear;
}
#combo-label {
  margin-top: 6px;
  font-family: "Orbitron", sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--gold);
  text-shadow: 0 0 10px rgba(255, 215, 106, 0.7);
}

/* Floating click numbers */
#float-layer { position: absolute; inset: 0; pointer-events: none; z-index: 6; overflow: hidden; }
.float-num {
  position: absolute;
  font-family: "Orbitron", sans-serif;
  font-weight: 900;
  font-size: 1.15rem;
  color: var(--gold);
  text-shadow: 0 0 12px rgba(255, 190, 78, 0.9), 0 2px 6px rgba(0,0,0,0.6);
  animation: floatUp 1.1s ease-out forwards;
  will-change: transform, opacity;
}
.float-num.crit { color: #fff3c4; font-size: 1.45rem; }
@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, 0) scale(0.6); }
  12% { opacity: 1; transform: translate(-50%, -14px) scale(1.05); }
  100% { opacity: 0; transform: translate(-50%, -110px) scale(0.9); }
}

/* Comet */
#comet {
  position: absolute;
  z-index: 7;
  font-size: 2.6rem;
  cursor: pointer;
  filter: drop-shadow(0 0 18px rgba(255, 230, 150, 0.95));
  animation: cometWobble 0.7s ease-in-out infinite;
  transition: transform 0.1s;
}
#comet:hover { transform: scale(1.2); }
@keyframes cometWobble {
  0%, 100% { rotate: -8deg; }
  50% { rotate: 8deg; }
}

/* ─────────────────────────── Panel ─────────────────────────── */
#panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border-left: 1px solid var(--panel-border);
  backdrop-filter: blur(16px);
}

#tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--panel-border);
}
.tab {
  position: relative;
  padding: 13px 4px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-family: "Inter", sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: color 0.15s, background 0.15s;
}
.tab:hover { color: var(--text); background: rgba(122, 140, 255, 0.06); }
.tab.active { color: var(--gold); border-bottom-color: var(--gold); background: rgba(255, 215, 106, 0.05); }

.badge {
  position: absolute;
  top: 6px;
  right: 14px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--bad);
  color: #fff;
  font-size: 0.66rem;
  font-weight: 700;
  font-style: normal;
  display: grid;
  place-items: center;
  box-shadow: 0 0 8px rgba(255, 94, 122, 0.8);
}

.tab-page {
  display: none;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
  scrollbar-width: thin;
  scrollbar-color: rgba(122, 140, 255, 0.3) transparent;
}
.tab-page.active { display: block; }

/* Quantity selector */
.qty-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 12px;
  position: sticky;
  top: -14px;
  padding: 10px 0;
  background: var(--panel);
  z-index: 2;
}
.qty-label { font-size: 0.8rem; color: var(--text-dim); font-weight: 600; margin-right: 2px; }
.qty {
  padding: 5px 12px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: rgba(122, 140, 255, 0.07);
  color: var(--text-dim);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.12s;
}
.qty:hover { color: var(--text); }
.qty.active { background: rgba(255, 215, 106, 0.15); border-color: rgba(255, 215, 106, 0.5); color: var(--gold); }

/* Generator & upgrade cards */
.card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
  border-radius: var(--radius);
  background: rgba(122, 140, 255, 0.06);
  border: 1px solid var(--panel-border);
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s, background 0.12s, box-shadow 0.12s;
}
.card:hover { transform: translateY(-1px); background: rgba(122, 140, 255, 0.11); }
.card.affordable {
  border-color: rgba(255, 215, 106, 0.45);
  background: rgba(255, 215, 106, 0.06);
  box-shadow: 0 0 18px rgba(255, 215, 106, 0.08), inset 0 0 24px rgba(255, 215, 106, 0.03);
}
.card.affordable:hover { box-shadow: 0 0 26px rgba(255, 215, 106, 0.18); }
.card.locked { cursor: not-allowed; opacity: 0.45; }
.card.locked:hover { transform: none; }
.card.mystery { filter: saturate(0.2); }

.card-icon {
  font-size: 1.9rem;
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgba(5, 7, 20, 0.55);
  border: 1px solid var(--panel-border);
}
.card.affordable .card-icon { animation: iconBob 1.6s ease-in-out infinite; }
@keyframes iconBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

.card-body { flex: 1; min-width: 0; }
.card-name { font-weight: 700; font-size: 0.92rem; display: flex; justify-content: space-between; gap: 8px; }
.card-owned { font-family: "Orbitron", sans-serif; color: var(--cyan); font-size: 0.85rem; }
.card-desc { font-size: 0.74rem; color: var(--text-dim); margin-top: 2px; line-height: 1.35; }
.card-meta { display: flex; justify-content: space-between; align-items: baseline; margin-top: 6px; gap: 8px; }
.card-cost { font-family: "Orbitron", sans-serif; font-size: 0.82rem; font-weight: 700; color: var(--gold); }
.card-cost.cant { color: var(--bad); }
.card-rate { font-size: 0.72rem; color: var(--text-dim); white-space: nowrap; }

.card.owned-upgrade { opacity: 0.5; cursor: default; border-color: rgba(94, 255, 166, 0.3); }
.card.owned-upgrade:hover { transform: none; }
.card.owned-upgrade .card-cost { color: var(--good); }

/* ─────────────────────────── Prestige ─────────────────────────── */
#tab-prestige { text-align: center; padding: 26px 22px; }
.prestige-hero { font-size: 3.4rem; animation: iconBob 3s ease-in-out infinite; filter: drop-shadow(0 0 24px rgba(154, 106, 255, 0.8)); }
#tab-prestige h2 {
  font-family: "Orbitron", sans-serif;
  letter-spacing: 0.2em;
  margin: 10px 0 14px;
  background: linear-gradient(90deg, var(--violet), var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.prestige-desc { font-size: 0.85rem; color: var(--text-dim); line-height: 1.6; margin-bottom: 20px; }
.prestige-desc b { color: var(--violet); }

.prestige-stats { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.pstat {
  display: flex;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(122, 140, 255, 0.07);
  border: 1px solid var(--panel-border);
  font-size: 0.85rem;
}
.pstat b { font-family: "Orbitron", sans-serif; color: var(--violet); }
.pstat b.gold { color: var(--gold); }

#prestige-progress-wrap {
  height: 10px;
  border-radius: 999px;
  background: rgba(122, 140, 255, 0.12);
  border: 1px solid var(--panel-border);
  overflow: hidden;
  margin-bottom: 8px;
}
#prestige-progress {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--violet), var(--cyan));
  box-shadow: 0 0 12px rgba(154, 106, 255, 0.8);
  transition: width 0.3s;
}
#prestige-next { font-size: 0.75rem; color: var(--text-dim); margin-bottom: 20px; }

.big-btn {
  width: 100%;
  padding: 15px;
  border-radius: 12px;
  border: 1px solid rgba(154, 106, 255, 0.6);
  background: linear-gradient(135deg, rgba(154, 106, 255, 0.25), rgba(106, 230, 255, 0.15));
  color: var(--text);
  font-family: "Orbitron", sans-serif;
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  cursor: pointer;
  transition: all 0.15s;
}
.big-btn:hover:not(:disabled) {
  box-shadow: 0 0 30px rgba(154, 106, 255, 0.45);
  transform: translateY(-2px);
}
.big-btn:disabled { opacity: 0.35; cursor: not-allowed; }

#prestige-history { margin-top: 18px; font-size: 0.78rem; color: var(--text-dim); line-height: 1.6; }

/* ─────────────────────────── Stats & achievements ─────────────────────────── */
.stat-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 4px;
  border-bottom: 1px solid rgba(122, 140, 255, 0.09);
  font-size: 0.85rem;
}
.stat-row span { color: var(--text-dim); }
.stat-row b { font-family: "Orbitron", sans-serif; font-weight: 700; text-align: right; }

.ach-title { margin: 22px 0 12px; font-size: 0.95rem; letter-spacing: 0.06em; }
.ach-title span { color: var(--text-dim); font-weight: 500; font-size: 0.8rem; }

#ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }
.ach {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgba(122, 140, 255, 0.05);
  border: 1px solid var(--panel-border);
  font-size: 1.5rem;
  filter: grayscale(1);
  opacity: 0.35;
  transition: all 0.2s;
  cursor: help;
}
.ach.unlocked {
  filter: none;
  opacity: 1;
  background: rgba(255, 215, 106, 0.1);
  border-color: rgba(255, 215, 106, 0.45);
  box-shadow: 0 0 14px rgba(255, 215, 106, 0.12);
}

/* ─────────────────────────── Toasts ─────────────────────────── */
#toast-stack {
  position: fixed;
  top: 70px;
  right: 18px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  min-width: 240px;
  max-width: 320px;
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(14, 18, 42, 0.95);
  border: 1px solid rgba(255, 215, 106, 0.5);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5), 0 0 20px rgba(255, 215, 106, 0.12);
  display: flex;
  gap: 12px;
  align-items: center;
  animation: toastIn 0.3s cubic-bezier(0.2, 1.4, 0.4, 1), toastOut 0.4s ease-in 4.2s forwards;
}
.toast-icon { font-size: 1.6rem; }
.toast-title { font-weight: 700; font-size: 0.85rem; color: var(--gold); }
.toast-msg { font-size: 0.75rem; color: var(--text-dim); margin-top: 2px; }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(60px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateX(60px); }
}

/* ─────────────────────────── Modal ─────────────────────────── */
#modal-root:empty { display: none; }
#modal-root {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  background: rgba(3, 4, 12, 0.75);
  backdrop-filter: blur(6px);
}
.modal {
  width: min(420px, 90vw);
  padding: 28px;
  border-radius: 18px;
  background: linear-gradient(160deg, #161b3f, #0b0e23);
  border: 1px solid rgba(122, 140, 255, 0.3);
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.7);
  text-align: center;
  animation: modalIn 0.25s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}
.modal-icon { font-size: 3rem; margin-bottom: 10px; }
.modal h3 { font-family: "Orbitron", sans-serif; letter-spacing: 0.1em; margin-bottom: 10px; color: var(--gold); }
.modal p { font-size: 0.88rem; color: var(--text-dim); line-height: 1.6; margin-bottom: 20px; }
.modal p b { color: var(--gold); }
.modal-btns { display: flex; gap: 10px; }
.modal-btns button {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: rgba(122, 140, 255, 0.1);
  color: var(--text);
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.12s;
}
.modal-btns button:hover { background: rgba(122, 140, 255, 0.22); }
.modal-btns button.primary { background: rgba(255, 215, 106, 0.18); border-color: rgba(255, 215, 106, 0.55); color: var(--gold); }
.modal-btns button.danger { background: rgba(255, 94, 122, 0.15); border-color: rgba(255, 94, 122, 0.5); color: var(--bad); }

/* Screen flash (supernova / comet) */
#flash {
  position: fixed;
  inset: 0;
  z-index: 150;
  pointer-events: none;
  background: radial-gradient(circle, rgba(255, 255, 240, 0.95) 0%, rgba(255, 200, 100, 0.5) 45%, transparent 75%);
  opacity: 0;
}
#flash.go { animation: flashGo 0.9s ease-out; }
@keyframes flashGo {
  0% { opacity: 0; }
  15% { opacity: 1; }
  100% { opacity: 0; }
}

/* Shake for big events */
body.shake #app { animation: shake 0.5s ease-in-out; }
@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-6px, 3px); }
  40% { transform: translate(5px, -4px); }
  60% { transform: translate(-4px, -2px); }
  80% { transform: translate(3px, 2px); }
}

/* ─────────────────────────── Responsive ─────────────────────────── */
@media (max-width: 900px) {
  body { overflow: auto; }
  #app { height: auto; min-height: 100vh; }
  main { grid-template-columns: 1fr; grid-template-rows: 480px auto; }
  #panel { border-left: none; border-top: 1px solid var(--panel-border); min-height: 60vh; }
  .tab-page { max-height: 60vh; }
  #star-wrap { transform: scale(0.85); }
  .top-stats { justify-content: flex-start; }
}
