:root { --ink:#eff4ff; --muted:#98a5bb; --navy:#101522; --panel:#192133; --edge:#2b3852; --cyan:#52e1dd; --violet:#9b7bff; --money:#a7f46d; --danger:#ff8c91; }
* { box-sizing:border-box; }
body { margin:0; min-width:320px; color:var(--ink); background:radial-gradient(circle at 12% -10%,#26395d 0,transparent 38%),radial-gradient(circle at 95% 10%,#33265f 0,transparent 36%),var(--navy); font:15px/1.45 Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif; }
button { border:0; font:inherit; font-weight:750; color:var(--ink); cursor:pointer; transition:.18s transform,.18s filter,.18s opacity; }
button:hover { filter:brightness(1.12); transform:translateY(-1px); }
button:disabled { cursor:not-allowed; opacity:.45; transform:none; filter:none; }
header { max-width:1240px; margin:auto; padding:26px 28px 18px; display:flex; align-items:center; justify-content:space-between; gap:18px; }
.brand { display:flex; align-items:center; gap:12px; font-weight:900; letter-spacing:-.04em; font-size:22px; }
.logo { width:38px; height:38px; border-radius:11px; background:linear-gradient(135deg,var(--cyan),var(--violet)); display:grid; place-items:center; color:#111627; box-shadow:0 8px 25px #5ae9e044; }
.logo svg { width:23px; fill:currentColor; }
.tag { color:var(--muted); font-size:12px; letter-spacing:.12em; text-transform:uppercase; font-weight:800; }
.account { padding:10px 14px; border:1px solid var(--edge); border-radius:10px; background:#1a2334; font-size:13px; }
.account span { color:var(--cyan); }
main { max-width:1240px; margin:auto; padding:0 28px 40px; display:grid; gap:18px; }
.hero { display:flex; justify-content:space-between; align-items:flex-end; gap:20px; padding:23px 26px; border:1px solid var(--edge); border-radius:18px; background:linear-gradient(115deg,#18233aee,#172035aa); overflow:hidden; position:relative; }
.hero::after { content:""; position:absolute; right:-50px; bottom:-110px; width:300px; height:210px; background:repeating-linear-gradient(90deg,transparent 0 13px,#52e1dd11 14px 16px); transform:perspective(260px) rotateX(53deg) rotateZ(-12deg); }
h1 { margin:3px 0 7px; font-size:clamp(26px,4vw,42px); letter-spacing:-.055em; }
.hero p { margin:0; color:var(--muted); max-width:630px; }
.hero-copy, .statbar { position:relative; z-index:1; }
.statbar { display:flex; gap:10px; }
.money { min-width:155px; padding:12px 16px; border-radius:12px; background:#162a25; border:1px solid #315c4b; }
.money strong { color:var(--money); font-size:22px; display:block; }
.money small { color:#89ae9b; font-weight:700; text-transform:uppercase; letter-spacing:.09em; font-size:10px; }
.grid { display:grid; grid-template-columns:1.25fr .75fr; gap:18px; }
.view-tabs { display:flex; gap:8px; }
.view-tabs button { padding:8px 12px; border:1px solid var(--edge); border-radius:9px; background:#192133; color:var(--muted); font-size:12px; }
.view-tabs button.active { background:#176e70; border-color:#52e1dd66; color:var(--ink); }
.hidden { display:none; }
.panel { border:1px solid var(--edge); border-radius:18px; background:#172033db; box-shadow:0 14px 40px #02040b25; }
.panel-head { display:flex; justify-content:space-between; align-items:center; padding:17px 19px; border-bottom:1px solid var(--edge); }
.panel h2 { font-size:14px; text-transform:uppercase; letter-spacing:.1em; margin:0; }
.pill { color:var(--cyan); background:#17343b; padding:5px 9px; border-radius:999px; font-size:11px; font-weight:800; }
.selected-printer-badge { flex:0 0 auto; align-self:center; white-space:nowrap; line-height:1; }
.shop, .upgrades { padding:12px; display:grid; gap:10px; }
.product { display:grid; grid-template-columns:50px 1fr auto; gap:13px; align-items:center; padding:12px; border-radius:13px; background:#202b41; border:1px solid transparent; }
.product.active { border-color:#52e1dd66; background:linear-gradient(100deg,#203946,#202b41); }
.product-icon { display:grid; place-items:center; }
.product-sprite { position:relative; display:inline-block; width:31px; height:28px; image-rendering:pixelated; }
.product-sprite.small { width:16px; height:15px; margin-right:4px; vertical-align:-3px; transform:scale(.55); transform-origin:left center; }
.product-sprite.slug { background:linear-gradient(90deg,transparent 0 18%,#9b7bff 18% 35%,#c7b7ff 35% 57%,#9b7bff 57% 75%,transparent 75%) 0 14px/100% 8px no-repeat; }
.product-sprite.slug::before { content:""; position:absolute; left:3px; top:8px; width:9px; height:9px; background:#c7b7ff; box-shadow:8px 4px #9b7bff,16px 4px #9b7bff,24px 8px #7655ca; }
.product-sprite.slug i { position:absolute; left:7px; top:10px; width:3px; height:3px; background:#101522; }
.product-sprite.keycaps { background:linear-gradient(90deg,#52e1dd 0 27%,transparent 27% 36%,#ff8c91 36% 63%,transparent 63% 72%,#a7f46d 72%) 3px 7px/25px 10px no-repeat,linear-gradient(90deg,#a7f46d 0 38%,transparent 38% 46%,#52e1dd 46% 100%) 3px 19px/25px 7px no-repeat; box-shadow:inset 0 -3px #34415d; }
.product-sprite.planter { background:linear-gradient(90deg,transparent 0 23%,#d9915e 23% 77%,transparent 77%) 6px 17px/19px 9px no-repeat; }
.product-sprite.planter::before { content:""; position:absolute; left:13px; top:2px; width:7px; height:18px; background:#a7f46d; box-shadow:-7px 6px #52e1dd,7px 4px #73c955; }
.product-sprite.planter i { position:absolute; left:8px; top:17px; width:17px; height:3px; background:#f4c76f; }
.product h3, .upgrade h3 { margin:0; font-size:15px; }
.product p, .upgrade p { margin:2px 0 0; color:var(--muted); font-size:12px; }
.product button, .upgrade button { padding:9px 11px; border-radius:9px; background:#2e3c59; font-size:12px; }
.product.active button { background:#176e70; }
.machines { padding:16px; display:grid; gap:12px; }
.machine { padding:15px; border-radius:13px; background:#202b41; border:1px solid #30405d; }
.machine.selected { border-color:var(--cyan); box-shadow:0 0 0 1px #52e1dd55, 0 0 20px #52e1dd18; }
.machine-top, .machine-foot { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.printer-state { width:14px; height:14px; flex:0 0 14px; image-rendering:pixelated; }
.printer-state.printing { background:#52e1dd; box-shadow:4px 0 #1b5d68,-4px 0 #1b5d68,0 4px #f4c76f,0 -4px #f4c76f; }
.printer-state.idle { background:#66738e; box-shadow:4px 4px #66738e,8px 4px #66738e,8px 0 #66738e; }
.machine-identity { display:flex; align-items:center; gap:10px; min-width:0; }
.pixel-printer { position:relative; width:58px; height:46px; flex:0 0 58px; overflow:hidden; background:linear-gradient(#293752 0 22%,#182238 22%); image-rendering:pixelated; }
.pixel-printer::before { content:""; position:absolute; left:8px; top:7px; width:40px; height:30px; border:5px solid #aab7d3; border-bottom:0; box-shadow:inset 0 0 0 3px #465574; }
.pixel-printer::after { content:""; position:absolute; left:4px; bottom:4px; width:50px; height:8px; background:#4d5a76; border-top:3px solid #c9d5e8; }
.pixel-printer i { position:absolute; z-index:1; left:25px; top:18px; width:8px; height:13px; background:#f4c76f; box-shadow:inset 3px 0 #ff8c91; }
.pixel-printer i::after { content:""; position:absolute; left:2px; top:12px; width:4px; height:7px; background:#202a42; }
.pixel-printer b { position:absolute; z-index:1; left:9px; top:17px; width:39px; height:4px; background:#52e1dd; box-shadow:0 2px #1b5d68; }
.pixel-printer.sidewinder-mk1 { background:linear-gradient(#322856 0 22%,#201b35 22%); }
.pixel-printer.sidewinder-mk1::before { border-color:#b792ff; box-shadow:inset 0 0 0 3px #594687; }
.pixel-printer.sidewinder-mk1::after { background:#51426f; border-top-color:#d8c7ff; }
.pixel-printer.sidewinder-mk1 b { background:#ff8c91; box-shadow:0 2px #874956; }
.machine-name { font-weight:850; }
.machine-model, .machine-foot { color:var(--muted); font-size:12px; }
.machine-capabilities { margin-top:7px; color:#9aa9c8; font-size:10px; text-transform:uppercase; letter-spacing:.06em; }
.filament-assignment { display:flex; align-items:center; justify-content:space-between; gap:10px; margin-top:10px; color:var(--muted); font-size:11px; }
.filament-assignment select { min-width:145px; padding:6px 8px; border:1px solid #3d4d6d; border-radius:7px; color:var(--ink); background:#182238; font:inherit; }
.print-area { height:13px; margin-top:12px; border-radius:99px; background:#101724; overflow:hidden; }
.print-area i { display:block; height:100%; width:0; background:linear-gradient(90deg,var(--cyan),#89f1e8); box-shadow:0 0 12px var(--cyan); transition:width .45s linear; }
.machine-foot { margin-top:7px; }
.machine-foot b { color:var(--money); }
.machine-alert { margin-top:10px; padding:7px 9px; border-radius:7px; color:#ffd0d2; background:#552c39; border:1px solid #914451; font-size:11px; line-height:1.35; }
.machine-queue { width:100%; margin-top:12px; padding:8px; border-radius:8px; background:#176e70; font-size:11px; }
.machine-auto { width:100%; margin-top:8px; padding:8px; border-radius:8px; background:#2c3955; font-size:11px; }
.machine-auto.active { background:#275d53; color:var(--cyan); }
.machine-auto.purchase, .upgrade button { background:#423576; }
.market-up { color:var(--money); }
.market-down { color:var(--danger); }
.right { display:grid; gap:18px; align-content:start; }
.actions { padding:16px; display:grid; gap:10px; }
.primary { padding:13px; border-radius:11px; background:linear-gradient(100deg,#167f80,#3569a3); font-size:14px; }
.secondary { padding:11px; border-radius:11px; background:#273552; }
.sell-note { color:var(--muted); font-size:12px; text-align:center; margin:0; }
.upgrade { display:grid; grid-template-columns:1fr auto; gap:10px; align-items:center; padding:12px; background:#202b41; border-radius:12px; }
.upgrade h3 { font-size:13px; }
.upgrade p { font-size:11px; }
.upgrade button.owned { background:#234e47; color:var(--cyan); }
.ledger { padding:14px 18px; color:var(--muted); font-size:12px; }
.ledger div { display:flex; justify-content:space-between; padding:7px 0; border-bottom:1px solid #283650; }
.ledger div:last-child { border:0; }
.ledger b { color:var(--ink); }
.market-list { padding:8px 18px; }
.market-list div { display:grid; grid-template-columns:1fr auto; column-gap:10px; padding:7px 0; border-bottom:1px solid #283650; font-size:12px; }
.market-list div:last-child { border:0; }
.market-list small { grid-column:1; color:var(--muted); }
.filament-list { padding:10px 12px; display:grid; gap:8px; }
.filament-stock { padding:10px 14px; display:grid; gap:10px; }
.filament-stock-row { display:grid; grid-template-columns:1fr auto; gap:4px 10px; align-items:end; font-size:12px; }
.filament-stock-row span { color:var(--ink); font-weight:700; }
.filament-stock-row b { color:var(--muted); font-size:11px; }
.filament-meter { grid-column:1 / -1; height:7px; overflow:hidden; border-radius:99px; background:#101724; }
.filament-meter i { display:block; height:100%; border-radius:inherit; background:linear-gradient(90deg,#f4c76f,#a7f46d); transition:width .3s ease; }
.filament { padding:10px; border:1px solid transparent; border-radius:10px; background:#202b41; }
.filament.active { border-color:#52e1dd66; }
.filament h3 { margin:0; font-size:13px; }
.filament p { margin:2px 0 8px; color:var(--muted); font-size:11px; }
.filament div:last-child { display:flex; gap:7px; }
.filament button { flex:1; padding:7px; border-radius:7px; background:#2e3c59; font-size:11px; }
.filament button[data-filament] { background:#176e70; }
.inventory-view { min-height:430px; }
.spool-grid { padding:16px; display:grid; grid-template-columns:repeat(auto-fit,minmax(180px,1fr)); gap:12px; }
.spool-card { padding:15px; border:1px solid #30405d; border-radius:12px; background:#202b41; }
.spool-card h3 { margin:0; font-size:14px; }
.spool-card strong { display:block; margin:10px 0 2px; color:var(--cyan); font-size:24px; }
.spool-card p { margin:0; color:var(--muted); font-size:12px; }
.printer-market { padding:16px; display:grid; grid-template-columns:repeat(auto-fit,minmax(230px,1fr)); gap:14px; }
.market-printer { padding:15px; border:1px solid #30405d; border-radius:13px; background:#202b41; }
.market-printer-head { display:flex; align-items:center; gap:12px; }
.market-printer h3 { margin:0; font-size:15px; }
.market-printer p { margin:4px 0 12px; color:var(--muted); font-size:12px; }
.market-printer button { width:100%; padding:9px; border-radius:8px; background:#423576; font-size:12px; }
.market-printer button.owned { background:#234e47; color:var(--cyan); }
.filament-store { padding:16px; display:grid; grid-template-columns:repeat(auto-fit,minmax(220px,1fr)); gap:14px; }
.filament-store .filament { padding:15px; }
.filament-store .filament button { width:100%; }
footer { text-align:center; color:#63718a; font-size:12px; padding:0 0 20px; }
@media (max-width:820px) { header { padding:18px; } .hero { align-items:flex-start; flex-direction:column; } .grid { grid-template-columns:1fr; } main { padding:0 16px 25px; } .statbar { width:100%; } .money { flex:1; } header .tag { display:none; } }
@media (max-width:450px) { .product { grid-template-columns:39px 1fr; } .product button { grid-column:2; } .account { padding:8px; } .brand { font-size:18px; } }

.machine-select { padding:4px; border-radius:5px; background:transparent; text-align:left; }
button:focus-visible, select:focus-visible { outline:3px solid var(--cyan); outline-offset:3px; }
#saveStatus:empty { display:none; }
#saveStatus { color:var(--danger); margin:0; }

footer a { color:var(--cyan); }

/* Sign-in gate + account popover */
body.signed-out header, body.signed-out main, body.signed-out footer { display:none; }
#authGate { max-width:520px; margin:8vh auto 0; padding:0 16px; }
.gate-card { padding:26px; border:1px solid var(--edge); border-radius:18px; background:#172033e8; box-shadow:0 14px 40px #02040b40; }
.gate-brand { display:flex; gap:14px; align-items:center; margin-bottom:18px; }
.gate-brand h1 { margin:0; font-size:22px; }
.gate-brand p { margin:2px 0 0; color:var(--muted); font-size:13px; }
.gate-logo { width:38px; height:38px; flex:0 0 38px; border-radius:11px; background:linear-gradient(135deg,var(--cyan),var(--violet)); display:grid; place-items:center; color:#111627; }
.gate-logo svg { width:22px; fill:currentColor; }
.gate-tabs { display:flex; gap:8px; margin-bottom:14px; }
.gate-tabs button { padding:8px 12px; border:1px solid var(--edge); border-radius:9px; background:#192133; color:var(--muted); font-size:12px; }
.gate-tabs button.active { background:#176e70; border-color:#52e1dd66; color:var(--ink); }
#gateForm { display:grid; gap:12px; }
#gateForm label { display:grid; gap:5px; font-size:12px; color:var(--muted); font-weight:700; }
#gateForm input:not([type="checkbox"]) { padding:10px 12px; border:1px solid #3d4d6d; border-radius:9px; color:var(--ink); background:#182238; font:inherit; }
#gateForm small { color:#63718a; font-weight:500; }
.gate-import { display:flex; align-items:center; gap:8px; }
.gate-error { color:var(--danger); font-size:12px; margin:0; min-height:1em; }
#accountMenu { position:fixed; top:64px; right:24px; z-index:30; }
.account-card { display:grid; gap:4px; padding:14px 16px; border:1px solid var(--edge); border-radius:12px; background:#1a2334f2; box-shadow:0 14px 40px #02040b60; font-size:13px; }
.account-card small { color:#63718a; }
.account-card button { margin-top:8px; padding:8px; border-radius:8px; background:#2c3955; }
@media (max-width:820px) { #accountMenu { right:12px; top:58px; } }

/* Leaderboard */
.board { padding:10px 18px 16px; }
.board-head { display:flex; gap:8px; align-items:center; padding:8px 0 12px; }
.board-head button { padding:6px 12px; border:1px solid var(--edge); border-radius:9px; background:#192133; color:var(--muted); font-size:12px; }
.board-head button.active { background:#176e70; border-color:#52e1dd66; color:var(--ink); }
.board-refresh { margin-left:auto; font-size:15px; }
.board-row { display:grid; grid-template-columns:44px 1fr auto; gap:10px; align-items:center; padding:9px 4px; border-bottom:1px solid #283650; font-size:13px; }
.board-row:last-of-type { border-bottom:0; }
.board-row.me { background:#17343b66; border-radius:8px; }
.board-row.me .board-name { color:var(--cyan); }
.board-rank { color:var(--muted); font-weight:800; }
.board-name { font-weight:700; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.board-row b { color:var(--money); }
.board-empty { color:var(--muted); font-size:13px; padding:8px 0; }
