@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;600;700;800&family=Space+Grotesk:wght@500;600;700&display=swap');

:root {
  color-scheme: dark;
  --ink: #fff8ea;
  --muted: #aaa0bd;
  --panel: rgba(29, 20, 52, 0.76);
  --line: rgba(255, 255, 255, 0.1);
  --gold: #ffbd59;
  --orange: #f4763a;
  --purple: #9c73ff;
  font-family: "DM Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 25%, rgba(120, 70, 184, .28), transparent 32%),
    radial-gradient(circle at 80% 80%, rgba(236, 89, 74, .12), transparent 28%),
    #100a20;
}

.stars, .stars::before, .stars::after {
  position: fixed; inset: 0; pointer-events: none; content: "";
  background-image: radial-gradient(#fff 1px, transparent 1px);
  background-size: 53px 53px; opacity: .18;
}
.stars::before { transform: translate(17px, 21px); background-size: 91px 91px; opacity: .25; }
.stars::after { transform: translate(38px, 8px); background-size: 137px 137px; opacity: .3; }

header {
  height: 90px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 clamp(24px, 5vw, 72px); border-bottom: 1px solid var(--line);
  background: rgba(13, 8, 28, .48); backdrop-filter: blur(14px);
}

.eyebrow { margin: 0 0 3px; color: var(--gold); font-size: .68rem; font-weight: 800; letter-spacing: .2em; }
h1, h2 { margin: 0; font-family: "Space Grotesk", sans-serif; }
h1 { font-size: 1.7rem; letter-spacing: -.05em; }
h1 span { color: var(--gold); }
h2 { font-size: 2rem; }
.header-actions { display: flex; gap: 10px; }
.prestige-chip { display:flex; align-items:center; gap:5px; padding:0 13px; color:var(--muted); font-size:.75rem; border:1px solid var(--line); border-radius:12px; background:rgba(156,115,255,.08); }
.prestige-chip span, .prestige-chip strong { color:var(--purple); }
button { font: inherit; touch-action:manipulation; -webkit-tap-highlight-color:transparent; }
.icon-button, .text-button {
  border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: rgba(255,255,255,.05);
  cursor: pointer; transition: .2s ease;
}
.icon-button { width: 42px; height: 42px; font-size: 1.25rem; }
.text-button { padding: 0 17px; }
.icon-button:hover, .text-button:hover { background: rgba(255,255,255,.11); transform: translateY(-1px); }

main { height: calc(100vh - 90px); height: calc(100dvh - 90px); min-height:0; display: grid; grid-template-columns: minmax(0, 1.18fr) minmax(390px, .82fr); overflow:hidden; }
.bakery-panel { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height:0; padding:clamp(18px,4vh,40px); overflow:hidden; }
.score-card { text-align: center; z-index: 3; }
.score-card .label { margin: 0; color: var(--muted); font-size: .72rem; font-weight: 800; letter-spacing: .17em; }
.score-card { width:min(100%,760px); }
.body-identity { margin-bottom:14px; }
.body-identity span { color:var(--purple); font-size:.62rem; font-weight:800; letter-spacing:.18em; }
.body-identity h2 { margin:2px 0; font-size:clamp(1.2rem,2vw,1.8rem); }
.body-identity p { margin:0; color:var(--muted); font-size:.72rem; }
.score-card strong { display:block; max-width:100%; margin:4px auto -4px; font-family:"Space Grotesk"; font-size:clamp(3rem,6vw,5.4rem); line-height:1.08; letter-spacing:-.06em; overflow-wrap:anywhere; }
.score-card .compact-score { margin:8px 0 -8px; color:var(--muted); font-size:.75rem; font-weight:600; }
.score-card > p:last-child { color: var(--gold); font-weight: 700; }

.planet-wrap { position: relative; display: grid; place-items: center; flex:0 1 360px; width:430px; min-height:260px; }
.matter-particle { position:absolute; z-index:3; left:50%; top:50%; border-radius:50%; pointer-events:none; box-shadow:0 0 10px currentColor; will-change:transform,opacity; }
.main-bun {
  --body-color:#777b86;
  position: relative; width: 230px; aspect-ratio: 1; border: 0; border-radius: 50%; cursor: pointer;
  background:radial-gradient(circle at 34% 28%,rgba(255,255,255,.7) 0 2%,transparent 17%),radial-gradient(circle at 45% 42%,var(--body-color),#211b2f 85%);
  box-shadow:0 0 0 9px rgba(156,115,255,.06),0 0 55px color-mix(in srgb,var(--body-color) 55%,transparent),inset -24px -28px 42px rgba(10,4,30,.5),inset 14px 16px 28px rgba(255,255,255,.16);
  transition: transform .08s ease, filter .2s ease; z-index: 2;
}
.main-bun:hover { filter: brightness(1.09); transform: scale(1.03); }
.main-bun:active, .main-bun.pressed { transform: scale(.93); }
.main-bun.impact { animation:gravityImpact .22s ease-out; }
@keyframes gravityImpact { 0%{filter:brightness(1);box-shadow:0 0 40px var(--body-color)} 45%{filter:brightness(1.65);box-shadow:0 0 95px var(--body-color)} 100%{filter:brightness(1)} }
.main-bun::after { content:""; position:absolute; pointer-events:none; }
.main-bun.body-rock { border-radius:46% 54% 42% 58%/53% 43% 57% 47%; }
.main-bun.body-comet::after { z-index:-1; width:190px; height:70px; right:75%; top:42%; border-radius:50%; background:linear-gradient(90deg,transparent,rgba(120,224,255,.55)); filter:blur(8px); transform:rotate(-12deg); }
.main-bun.body-ice { background:radial-gradient(circle at 32% 25%,#fff,transparent 12%),repeating-linear-gradient(18deg,transparent 0 18px,rgba(100,190,220,.18) 20px 23px),radial-gradient(circle,var(--body-color),#354d70); }
.main-bun.body-volcanic { background:radial-gradient(circle at 65% 60%,#ffec69 0 3%,transparent 5%),radial-gradient(circle at 28% 35%,#ff7b35 0 5%,transparent 7%),radial-gradient(circle,var(--body-color),#5d261f); }
.main-bun.body-atmosphere { box-shadow:0 0 0 8px color-mix(in srgb,var(--body-color) 30%,transparent),0 0 60px color-mix(in srgb,var(--body-color) 50%,transparent),inset -25px -30px 44px rgba(35,15,35,.45); }
.main-bun.body-earth { background:radial-gradient(ellipse at 28% 56%,#66ad58 0 11%,transparent 12%),radial-gradient(ellipse at 68% 35%,#82bd62 0 16%,transparent 17%),radial-gradient(circle at 35% 20%,#fff 0 4%,transparent 12%),radial-gradient(circle,#3d9be8,#163f91); }
.main-bun.body-gas { background:repeating-linear-gradient(0deg,rgba(255,255,255,.14) 0 10px,transparent 12px 27px),radial-gradient(circle,var(--body-color),#26326f); }
.main-bun.body-ringed::after { z-index:-1; width:155%; height:42%; left:-27%; top:28%; border:14px double rgba(225,205,152,.72); border-radius:50%; transform:rotate(-15deg); }
.main-bun.body-star { background:radial-gradient(circle at 35% 30%,#fff 0 3%,#ffe7a2 10%,var(--body-color) 52%,#8f251c); box-shadow:0 0 25px #fff,0 0 80px var(--body-color),0 0 130px color-mix(in srgb,var(--body-color) 65%,transparent); }
.main-bun.body-neutron { background:radial-gradient(circle,#fff 0 8%,#a5e6ff 30%,#416bd9 65%,#160b46); box-shadow:0 0 30px #fff,0 0 100px #79cfff; }
.main-bun.body-blackhole { background:radial-gradient(circle,#000 0 55%,#180d2b 62%,#ff9e45 67%,#fff1a0 70%,transparent 74%); box-shadow:0 0 70px rgba(177,102,255,.6); }
.main-bun.body-galaxy { background:repeating-radial-gradient(ellipse at center,#fff 0 2px,transparent 4px 16px),conic-gradient(from 20deg,#28115c,#d6bdff,#34206e,#fff,#28115c); box-shadow:0 0 90px #8d6cff; transform:rotate(-12deg); }
.main-bun.body-universe { background:radial-gradient(circle at 30% 30%,#fff 0 2px,transparent 3%),radial-gradient(circle at 65% 42%,#fff 0 1px,transparent 3%),radial-gradient(circle at 44% 75%,#fff 0 2px,transparent 3%),radial-gradient(circle,#f7ddff,#714ed1 38%,#100523 80%); box-shadow:0 0 120px #fff,0 0 180px #8c67ff; }
.bun-shine { position:absolute; inset:22px; border:2px solid rgba(255,255,255,.25); border-radius:50%; transform:rotate(-25deg); box-shadow:inset 0 0 22px rgba(126,238,255,.25); }
.seed { position:absolute; width:9px; height:9px; border-radius:50%; background:#d8fbff; box-shadow:0 0 12px 4px #72eaff; }
.s1{left:63px;top:82px}.s2{left:142px;top:70px;transform:rotate(-35deg)}.s3{left:99px;top:121px}.s4{left:153px;top:143px;transform:rotate(50deg)}.s5{left:64px;top:163px;transform:rotate(-12deg)}.s6{left:122px;top:188px}
.orbit { position: absolute; width: 350px; height: 140px; border: 1px solid rgba(255,255,255,.15); border-radius: 50%; transform: rotate(-16deg); }
.orbit i { position: absolute; width: 17px; height: 17px; left: 15px; top: 64px; border-radius: 50%; background: var(--purple); box-shadow: 0 0 18px var(--purple); }
.orbit-two { width: 410px; height: 220px; transform: rotate(30deg); border-color: rgba(255,189,89,.1); }
.orbit-two i { left: auto; right: 23px; top: 34px; width: 10px; height: 10px; background: var(--gold); box-shadow: 0 0 13px var(--gold); }
.click-info { display: flex; align-items: baseline; gap: 8px; color: var(--muted); }
.click-info strong { color: var(--ink); font: 700 1.6rem "Space Grotesk"; }
.run-stats { display:flex; gap:22px; margin-top:22px; color:var(--muted); font-size:.72rem; }
.run-stats b { color:var(--ink); }
.body-progress { width:min(430px,90%); margin-top:15px; }
.body-progress>div:first-child { display:flex; justify-content:space-between; gap:14px; color:var(--muted); font-size:.64rem; }
.body-progress b { flex:none; color:var(--ink); }
.progress-track { height:5px; margin-top:7px; overflow:hidden; border-radius:5px; background:rgba(255,255,255,.08); }
.progress-track i { display:block; width:0; height:100%; border-radius:inherit; background:linear-gradient(90deg,var(--purple),var(--gold)); box-shadow:0 0 10px var(--purple); transition:width .3s ease; }

.shop-panel { display:flex; min-height:0; flex-direction:column; padding:clamp(24px,5vh,54px) clamp(24px,4vw,56px) 24px; border-left: 1px solid var(--line); background: rgba(11, 7, 24, .5); backdrop-filter: blur(12px); overflow:hidden; }
.shop-heading { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 28px; }
.save-status { color: #7bdaa0; font-size: .76rem; opacity: 0; transition: opacity .3s; }
.save-status.show { opacity: 1; }
.shop-list { display:grid; min-height:0; gap:12px; padding-right:10px; padding-bottom:20px; overflow-y:auto; overscroll-behavior:contain; scrollbar-width:thin; scrollbar-color:var(--purple) rgba(255,255,255,.05); }
.shop-list::-webkit-scrollbar { width:7px; }
.shop-list::-webkit-scrollbar-track { border-radius:10px; background:rgba(255,255,255,.04); }
.shop-list::-webkit-scrollbar-thumb { border-radius:10px; background:linear-gradient(var(--purple),var(--gold)); }
.shop-tabs { display:grid; grid-template-columns:repeat(3,1fr); gap:5px; margin:-10px 0 20px; padding:5px; border-radius:13px; background:rgba(255,255,255,.04); }
.buy-controls { display:grid; grid-template-columns:auto repeat(4,1fr); align-items:center; gap:5px; margin:-10px 0 14px; }
.buy-controls>span { margin-right:5px; color:var(--muted); font-size:.58rem; font-weight:800; letter-spacing:.12em; }
.buy-mode { padding:7px 5px; color:var(--muted); border:1px solid var(--line); border-radius:8px; background:rgba(255,255,255,.025); cursor:pointer; font-size:.68rem; font-weight:800; }
.buy-mode:hover { border-color:rgba(156,115,255,.45); color:var(--ink); }
.buy-mode.active { color:#1b102e; border-color:transparent; background:linear-gradient(100deg,var(--purple),var(--gold)); }
.tab { position:relative; padding:9px 4px; border:0; border-radius:9px; color:var(--muted); background:transparent; cursor:pointer; font-size:.72rem; font-weight:700; }
.tab.active { color:var(--ink); background:rgba(255,255,255,.09); box-shadow:0 2px 8px rgba(0,0,0,.16); }
#boostBadge { display:inline-grid; place-items:center; min-width:17px; height:17px; margin-left:3px; border-radius:10px; color:#211532; background:var(--gold); font-size:.62rem; }
.upgrade {
  width: 100%; display: grid; grid-template-columns: 58px 1fr auto; gap: 15px; align-items: center;
  padding: 15px; text-align: left; color: var(--ink); border: 1px solid var(--line); border-radius: 16px;
  background: linear-gradient(110deg, rgba(255,255,255,.065), rgba(255,255,255,.025)); cursor: pointer; transition: .18s ease;
}
.upgrade:hover:not(:disabled) { border-color: rgba(255,189,89,.4); transform: translateX(-3px); background: rgba(255,189,89,.08); }
.upgrade:disabled { cursor: not-allowed; opacity: .46; }
.upgrade-icon { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 14px; font-size: 1.7rem; background: rgba(156,115,255,.13); border: 1px solid rgba(156,115,255,.22); }
.upgrade strong, .upgrade small { display: block; }
.upgrade strong { margin-bottom: 3px; font: 700 1rem "Space Grotesk"; }
.upgrade small { color: var(--muted); font-size: .72rem; }
.upgrade em { display:block; margin-top:5px; color:#cfbfff; font-size:.65rem; font-style:normal; }
.upgrade.locked { cursor:default; opacity:.35; }
.upgrade.boost { border-color:rgba(156,115,255,.3); background:rgba(156,115,255,.08); }
.upgrade-price { text-align: right; }
.upgrade-price b { display: block; color: var(--gold); font-size: .88rem; white-space: nowrap; }
.upgrade-price span { color: var(--muted); font-size: .7rem; }
.empty-state { padding:55px 25px; text-align:center; color:var(--muted); border:1px dashed var(--line); border-radius:18px; }
.empty-state>span { font-size:2.3rem; }.empty-state h3 { margin:12px 0 5px; color:var(--ink); }.empty-state p { margin:0 auto 15px; max-width:330px; font-size:.82rem; line-height:1.6; }.empty-state b { color:var(--purple); font-size:.72rem; }
.legacy-card { padding:38px 30px; text-align:center; border:1px solid rgba(156,115,255,.3); border-radius:22px; background:radial-gradient(circle at 50% 0,rgba(156,115,255,.22),transparent 42%),rgba(255,255,255,.035); }
.legacy-orb { display:grid; place-items:center; width:82px; height:82px; margin:0 auto 22px; border:1px solid rgba(255,255,255,.25); border-radius:50%; color:#fff; background:radial-gradient(circle at 35% 30%,#d9cdff,#7550d8 55%,#301c68); box-shadow:0 0 40px rgba(156,115,255,.45); font-size:2.2rem; }
.legacy-card h3 { margin:4px 0 12px; font:700 1.7rem "Space Grotesk"; }.legacy-card>p:not(.eyebrow) { color:var(--muted); font-size:.84rem; line-height:1.65; }.legacy-card>small { display:block; margin-top:14px; color:var(--muted); font-size:.67rem; }
.legacy-gain { display:flex; justify-content:center; align-items:center; gap:12px; margin:25px 0 12px; }.legacy-gain span { color:var(--muted); }.legacy-gain strong { color:var(--gold); font:700 2rem "Space Grotesk"; }
.legacy-heading { position:relative; margin:30px 2px 2px; padding-top:20px; border-top:1px solid var(--line); }
.legacy-heading h3 { margin:2px 0 0; font:700 1.25rem "Space Grotesk"; }
.legacy-heading>span { position:absolute; right:0; bottom:2px; color:var(--gold); font-size:.72rem; font-weight:700; }
.legacy-upgrade { border-color:rgba(156,115,255,.22); }
.prestige-button { width:100%; padding:14px; border:0; border-radius:12px; color:#1e1235; background:linear-gradient(100deg,#b99cff,#ffbd59); font-weight:800; cursor:pointer; box-shadow:0 10px 28px rgba(156,115,255,.2); }.prestige-button:disabled { filter:grayscale(1); opacity:.3; cursor:not-allowed; }
.save-dialog { width:min(560px,calc(100vw - 30px)); padding:32px; color:var(--ink); border:1px solid rgba(156,115,255,.35); border-radius:22px; background:#18102d; box-shadow:0 30px 100px rgba(0,0,0,.65); }
.save-dialog::backdrop { background:rgba(6,3,15,.8); backdrop-filter:blur(6px); }
.save-dialog h2 { margin-bottom:8px; }.save-dialog>p:not(.eyebrow) { margin:0 0 18px; color:var(--muted); font-size:.82rem; line-height:1.5; }.save-dialog>small { display:block; margin-top:13px; color:var(--muted); font-size:.65rem; }
.dialog-close { position:absolute; top:14px; right:16px; width:34px; height:34px; color:var(--muted); border:0; border-radius:50%; background:rgba(255,255,255,.06); cursor:pointer; font-size:1.4rem; }
.save-dialog textarea { width:100%; min-height:150px; resize:vertical; padding:13px; color:#d8cafc; border:1px solid var(--line); border-radius:12px; outline:none; background:#0e091c; font:500 .7rem/1.5 monospace; word-break:break-all; }
.save-dialog textarea:focus { border-color:var(--purple); }
.dialog-actions { display:grid; grid-template-columns:1fr 1fr; gap:9px; margin-top:10px; }.dialog-actions .text-button { min-height:46px; }

.float-text { position: fixed; z-index: 10; color: #fff4b9; font: 800 1.3rem "Space Grotesk"; pointer-events: none; text-shadow: 0 2px 8px #562a1d; animation: floatUp .8s ease-out forwards; }
.float-text.critical { color:#fff; font-size:1.55rem; text-shadow:0 0 14px var(--purple),0 2px 8px #562a1d; }
@keyframes floatUp { to { opacity: 0; transform: translateY(-80px) scale(1.2); } }
.toast { position: fixed; bottom: 22px; left: 50%; z-index: 20; transform: translate(-50%, 20px); padding: 11px 18px; border-radius: 12px; background: #fff5d8; color: #211532; font-weight: 700; opacity: 0; transition: .25s; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 850px) {
  body { height:auto; min-height:100dvh; overflow-x:hidden; overflow-y:auto; }
  header { position:sticky; top:0; z-index:30; height:64px; padding:0 16px; }
  header .eyebrow { display:none; }
  header h1 { font-size:1.35rem; }
  .header-actions { align-items:center; gap:7px; }
  .prestige-chip { display:none; }
  .header-actions .text-button { height:38px; padding:0 11px; font-size:.7rem; }
  .icon-button { width:38px; height:38px; }
  main { display:block; height:auto; min-height:calc(100svh - 64px); overflow:visible; }
  .bakery-panel { min-height:calc(100svh - 64px); padding:18px 14px 20px; overflow:hidden; }
  .body-identity { margin-bottom:9px; }
  .body-identity h2 { font-size:1.35rem; }
  .score-card .label { font-size:.6rem; }
  .score-card strong { line-height:1; }
  .score-card>p:last-child { margin:12px 0 0; font-size:.8rem; }
  .planet-wrap { flex:0 0 255px; width:min(390px,100vw); min-height:220px; }
  .main-bun { width:180px; }
  .bun-shine { inset:18px; }
  .orbit { width:290px; height:115px; }
  .orbit-two { width:340px; height:175px; }
  .click-info strong { font-size:1.35rem; }
  .run-stats { margin-top:12px; }
  .body-progress { margin-top:11px; }
  .shop-panel { height:calc(100svh - 12px); min-height:580px; border-left:0; border-top:1px solid var(--line); padding:25px 16px 14px; }
  .shop-heading { margin-bottom:22px; }
  .shop-heading h2 { font-size:1.65rem; }
  .shop-list { padding-right:6px; }
  .upgrade { grid-template-columns:50px minmax(0,1fr) auto; gap:11px; padding:12px; }
  .upgrade-icon { width:48px; height:48px; font-size:1.45rem; }
  .upgrade strong { font-size:.9rem; }
  .upgrade small { font-size:.66rem; }
  .upgrade em { font-size:.6rem; }
  .upgrade-price { max-width:105px; }
  .upgrade-price b { font-size:.76rem; }
  .upgrade-price span { font-size:.61rem; }
  .save-dialog { max-height:90svh; padding:27px 20px 20px; overflow-y:auto; }
  .save-dialog textarea { min-height:120px; }
  .toast { bottom:14px; width:max-content; max-width:calc(100vw - 28px); text-align:center; font-size:.78rem; }
}
@media (max-width: 560px) {
  #saveCodeButton, #resetButton { width:38px; padding:0; font-size:0; }
  #saveCodeButton::after { content:"⌁"; font-size:1.2rem; }
  #resetButton::after { content:"↺"; font-size:1.2rem; }
  .run-stats { width:100%; justify-content:center; flex-wrap:wrap; gap:4px 16px; }
  .body-progress { width:min(94%,390px); }
  .body-progress>div:first-child { align-items:flex-start; }
  #nextBodyLabel { max-width:82%; }
}
@media (max-width: 390px) {
  header { padding:0 10px; }
  header h1 { font-size:1.12rem; }
  .header-actions { gap:5px; }
  .bakery-panel { padding-inline:9px; }
  .body-identity p { max-width:310px; margin-inline:auto; }
  .planet-wrap { flex-basis:225px; transform:scale(.9); margin:-8px 0; }
  .main-bun { width:165px; }
  .shop-panel { padding-inline:10px; }
  .shop-tabs { gap:3px; }
  .tab { font-size:.64rem; }
  .buy-controls { grid-template-columns:repeat(4,1fr); }
  .buy-controls>span { display:none; }
  .upgrade { grid-template-columns:43px minmax(0,1fr) auto; gap:8px; padding:10px 8px; }
  .upgrade-icon { width:42px; height:42px; font-size:1.25rem; }
  .upgrade-price { max-width:88px; }
  .dialog-actions { grid-template-columns:1fr; }
}
@media (max-height: 700px) and (max-width: 850px) {
  .body-identity p { display:none; }
  .planet-wrap { flex-basis:210px; transform:scale(.86); margin:-12px 0; }
  .run-stats { margin-top:7px; }
  .body-progress { margin-top:7px; }
}
