:root {
  --bg: #07080f; --bg2: #0d1020; --panel: rgba(16, 19, 36, .72); --panel-solid: #121528;
  --line: rgba(255, 255, 255, .09); --line2: rgba(255, 255, 255, .16);
  --text: #eef1ff; --muted: #9aa3c7; --accent: #7c5cff; --accent2: #22d3ee;
  --ok: #22c55e; --warn: #facc15; --bad: #f43f5e;
  --r: 18px; --r-sm: 12px; --blur: blur(18px) saturate(160%);
  --shadow: 0 20px 60px -20px rgba(0, 0, 0, .7);
  --grad: linear-gradient(135deg, var(--accent), var(--accent2));
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --display: Unbounded, Inter, system-ui, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); overflow: hidden; }
body { overscroll-behavior: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: var(--accent2); }
.hidden { display: none !important; }
::selection { background: var(--accent); color: #fff; }
::-webkit-scrollbar { width: 8px; height: 8px; } ::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 8px; }

#stage { position: fixed; inset: 0; cursor: grab; }
#stage:active { cursor: grabbing; }
#stage canvas { display: block; }

.glass { background: var(--panel); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); border: 1px solid var(--line); box-shadow: var(--shadow); }

/* ---------- Loader ---------- */
#loader { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: radial-gradient(circle at 50% 40%, #1a1440, var(--bg) 60%); transition: opacity .6s, visibility .6s; }
#loader.done { opacity: 0; visibility: hidden; }
.load-box { text-align: center; }
.load-logo { width: 92px; height: 92px; margin: 0 auto 22px; border-radius: 28px; background: var(--grad); display: grid; place-items: center; font: 900 40px var(--display); color: #fff; animation: float 2.4s ease-in-out infinite; box-shadow: 0 0 60px -6px var(--accent); }
.load-title { font: 800 22px var(--display); letter-spacing: .02em; }
.load-sub { color: var(--muted); margin-top: 8px; font-size: 14px; }
.load-bar { width: 220px; height: 4px; border-radius: 4px; background: var(--line); margin: 20px auto 0; overflow: hidden; }
.load-bar i { display: block; height: 100%; width: 40%; background: var(--grad); border-radius: 4px; animation: slide 1.1s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-10px) rotate(-4deg); } }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }

/* ---------- Topbar ---------- */
.topbar { position: fixed; z-index: 20; top: calc(12px + var(--safe-t)); left: 12px; right: 12px; display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 14px; border-radius: 22px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; text-decoration: none; color: inherit; }
.brand-logo { width: 38px; height: 38px; border-radius: 12px; background: var(--grad); display: grid; place-items: center; font: 900 18px var(--display); color: #fff; flex: none; box-shadow: 0 0 24px -4px var(--accent); }
.brand-name { font: 800 16px var(--display); white-space: nowrap; }
.brand-tag { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.search { position: relative; flex: 1; max-width: 520px; margin: 0 auto; }
.search input { width: 100%; height: 44px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255, 255, 255, .05); padding: 0 14px 0 42px; outline: none; transition: border-color .2s, background .2s; }
.search input:focus { border-color: var(--accent); background: rgba(255, 255, 255, .08); }
.search svg { position: absolute; left: 13px; top: 12px; opacity: .6; }
.search kbd { position: absolute; right: 10px; top: 11px; font-size: 11px; color: var(--muted); border: 1px solid var(--line2); border-radius: 6px; padding: 2px 6px; }
.results { position: absolute; top: 52px; left: 0; right: 0; border-radius: 16px; padding: 6px; max-height: 60vh; overflow: auto; }
.res { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; cursor: pointer; }
.res:hover, .res.sel { background: rgba(255, 255, 255, .07); }
.res .thumb { width: 40px; height: 40px; font-size: 22px; border-radius: 10px; }
.res-name { font-weight: 600; font-size: 14px; } .res-cat { font-size: 12px; color: var(--muted); }
.res .price { margin-left: auto; font-weight: 800; font-size: 14px; }
.res .locate { width: 34px; height: 34px; border-radius: 10px; background: rgba(255, 255, 255, .06); flex: none; }
.res .locate:hover { background: var(--accent); }
.empty { padding: 18px; text-align: center; color: var(--muted); font-size: 14px; }
.actions { display: flex; gap: 6px; }
.btn-icon { position: relative; height: 44px; min-width: 44px; padding: 0 12px; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: rgba(255, 255, 255, .06); border: 1px solid var(--line); transition: background .2s, transform .15s; font-weight: 600; font-size: 14px; white-space: nowrap; }
.btn-icon:hover { background: rgba(255, 255, 255, .12); }
.btn-icon:active { transform: scale(.96); }
.btn-icon.on { background: var(--accent); border-color: transparent; }
.btn-icon.primary { background: var(--grad); border: 0; color: #fff; }
.badge { position: absolute; top: -5px; right: -5px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 800; display: grid; place-items: center; border: 2px solid var(--bg); }
.badge.bump { animation: bump .45s; }
@keyframes bump { 40% { transform: scale(1.5); } }

/* ---------- Promo ---------- */
.promo { position: fixed; z-index: 19; top: calc(80px + var(--safe-t)); left: 50%; transform: translateX(-50%); max-width: min(720px, calc(100% - 24px)); padding: 7px 16px; border-radius: 999px; font-size: 13px; font-weight: 600; background: linear-gradient(90deg, rgba(124, 92, 255, .25), rgba(34, 211, 238, .2)); border: 1px solid var(--line2); backdrop-filter: var(--blur); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Categories ---------- */
.cats { position: fixed; z-index: 20; bottom: calc(14px + var(--safe-b)); left: 50%; transform: translateX(-50%); max-width: calc(100% - 24px); display: flex; gap: 6px; padding: 6px; border-radius: 20px; overflow-x: auto; scrollbar-width: none; }
.cats::-webkit-scrollbar { display: none; }
.chip { flex: none; display: flex; align-items: center; gap: 7px; height: 42px; padding: 0 14px; border-radius: 14px; font-weight: 600; font-size: 13.5px; white-space: nowrap; transition: background .2s, color .2s; color: var(--muted); }
.chip:hover { background: rgba(255, 255, 255, .07); color: var(--text); }
.chip.on { background: rgba(255, 255, 255, .12); color: var(--text); box-shadow: inset 0 -3px 0 var(--c, var(--accent)); }
.chip .em { font-size: 18px; }

/* ---------- HUD ---------- */
.hud { position: fixed; z-index: 18; right: 12px; bottom: calc(80px + var(--safe-b)); display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
#minimap { width: 180px; height: 150px; border-radius: 16px; display: block; }
.hud-row { display: flex; gap: 6px; }
#tooltip { position: fixed; z-index: 30; pointer-events: none; padding: 10px 12px; border-radius: 14px; font-size: 13px; transform: translate(16px, 16px); white-space: nowrap; }
#tooltip b { display: block; font-size: 14px; } #tooltip .p { color: var(--accent2); font-weight: 800; }
#tooltip small { color: var(--muted); }
#joy { position: fixed; z-index: 25; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; border: 2px solid var(--line2); background: rgba(255, 255, 255, .05); pointer-events: none; }
#joy i { position: absolute; left: 50%; top: 50%; width: 50px; height: 50px; margin: -25px; border-radius: 50%; background: var(--grad); opacity: .85; }
.touring { position: fixed; z-index: 21; left: 50%; top: calc(124px + var(--safe-t)); transform: translateX(-50%); padding: 10px 18px; border-radius: 999px; font: 700 15px var(--display); }

/* ---------- Help ---------- */
.help { position: fixed; z-index: 40; inset: 0; display: grid; place-items: center; background: rgba(4, 5, 12, .55); padding: 16px; }
.help-card { max-width: 440px; width: 100%; border-radius: 26px; padding: 26px; }
.help-card h2 { margin: 0 0 6px; font: 800 22px var(--display); }
.help-card p { color: var(--muted); margin: 0 0 18px; line-height: 1.5; }
.keys { display: grid; gap: 10px; margin-bottom: 20px; }
.key { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.key span:first-child { flex: none; min-width: 92px; text-align: center; padding: 6px 8px; border-radius: 10px; background: rgba(255, 255, 255, .07); border: 1px solid var(--line2); font-weight: 700; font-size: 12.5px; }
.btn { height: 48px; padding: 0 20px; border-radius: 14px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: transform .15s, filter .2s, background .2s; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 10px 30px -10px var(--accent); }
.btn-primary:hover { filter: brightness(1.1); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.btn-ghost { background: rgba(255, 255, 255, .07); border: 1px solid var(--line); }
.btn-ghost:hover { background: rgba(255, 255, 255, .12); }
.w100 { width: 100%; }
.keys.only-touch { display: none; } .keys.only-mouse { display: grid; }
@media (pointer: coarse) { .keys.only-touch { display: grid; } .keys.only-mouse { display: none; } }

/* ---------- Thumbs / cards ---------- */
.thumb { display: grid; place-items: center; background: linear-gradient(135deg, var(--c1), var(--c2)); position: relative; overflow: hidden; flex: none; }
.thumb::after { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 25% 15%, rgba(255, 255, 255, .35), transparent 50%); }
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

/* ---------- Catalog ---------- */
.catalog { position: fixed; z-index: 15; inset: 0; padding: calc(124px + var(--safe-t)) 16px calc(90px + var(--safe-b)); overflow: auto; background: radial-gradient(1200px 600px at 80% -10%, rgba(124, 92, 255, .18), transparent 60%), var(--bg); }
.cat-head { max-width: 1240px; margin: 0 auto 16px; display: flex; align-items: end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.cat-head h1 { margin: 0; font: 800 clamp(22px, 4vw, 34px) var(--display); }
.cat-head p { margin: 4px 0 0; color: var(--muted); }
.select { height: 42px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-solid); outline: none; }
.grid { max-width: 1240px; margin: 0 auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.card { border-radius: 20px; overflow: hidden; background: var(--panel-solid); border: 1px solid var(--line); display: flex; flex-direction: column; transition: transform .25s, border-color .25s, box-shadow .25s; cursor: pointer; }
.card:hover { transform: translateY(-4px); border-color: var(--line2); box-shadow: 0 18px 40px -20px var(--accent); }
.card .thumb { aspect-ratio: 1.15; font-size: 64px; }
.card .thumb .em { transition: transform .35s; filter: drop-shadow(0 10px 14px rgba(0, 0, 0, .35)); }
.card:hover .thumb .em { transform: scale(1.12) rotate(-6deg); }
.tag { position: absolute; z-index: 1; top: 10px; left: 10px; padding: 4px 9px; border-radius: 8px; font-size: 11.5px; font-weight: 800; background: rgba(0, 0, 0, .55); color: #fff; backdrop-filter: blur(6px); }
.tag.sale { background: var(--warn); color: #111; }
.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card-name { font-weight: 700; font-size: 15px; }
.card-meta { font-size: 12.5px; color: var(--muted); }
.card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 8px; gap: 8px; }
.price { font-weight: 800; font-size: 17px; }
.old { color: var(--muted); text-decoration: line-through; font-size: 13px; margin-left: 6px; font-weight: 500; }
.add { width: 40px; height: 40px; border-radius: 12px; background: var(--grad); color: #fff; font-size: 22px; font-weight: 700; display: grid; place-items: center; flex: none; }
.add:disabled { background: var(--line2); cursor: not-allowed; }
.section-title { max-width: 1240px; margin: 26px auto 12px; display: flex; align-items: center; gap: 10px; font: 700 18px var(--display); }
.section-title .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); box-shadow: 0 0 12px var(--c); }

/* ---------- Modal ---------- */
.modal { position: fixed; z-index: 50; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(3, 4, 10, .6); animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(20px) scale(.98); } }
.modal-card { width: 100%; max-width: 760px; max-height: calc(100% - 20px); overflow: auto; border-radius: 28px; display: grid; grid-template-columns: 1fr 1fr; animation: rise .3s cubic-bezier(.2, .9, .3, 1.2); }
.modal-card .thumb { min-height: 320px; font-size: 140px; }
.modal-info { padding: 26px; display: flex; flex-direction: column; gap: 12px; }
.modal-info h2 { margin: 0; font: 800 26px var(--display); line-height: 1.15; }
.modal-info .desc { color: var(--muted); line-height: 1.55; margin: 0; }
.modal-price { font: 900 32px var(--display); }
.close { position: absolute; top: 14px; right: 14px; z-index: 2; width: 40px; height: 40px; border-radius: 12px; background: rgba(0, 0, 0, .45); font-size: 20px; color: #fff; backdrop-filter: blur(8px); }
.stock { font-size: 13px; font-weight: 600; } .stock.ok { color: var(--ok); } .stock.low { color: var(--warn); } .stock.no { color: var(--bad); }
.qty { display: inline-flex; align-items: center; border-radius: 14px; border: 1px solid var(--line2); overflow: hidden; height: 48px; }
.qty button { width: 44px; height: 100%; font-size: 20px; } .qty button:hover { background: rgba(255, 255, 255, .08); }
.qty span { min-width: 36px; text-align: center; font-weight: 800; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { padding: 5px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: rgba(255, 255, 255, .07); border: 1px solid var(--line); }

/* ---------- Drawer (cart) ---------- */
.drawer-bg { position: fixed; z-index: 45; inset: 0; background: rgba(3, 4, 10, .5); animation: fade .2s; }
.drawer { position: fixed; z-index: 46; top: 0; right: 0; bottom: 0; width: min(440px, 100%); display: flex; flex-direction: column; background: rgba(13, 16, 32, .92); backdrop-filter: var(--blur); border-left: 1px solid var(--line); transform: translateX(100%); transition: transform .35s cubic-bezier(.2, .8, .2, 1); padding-top: var(--safe-t); }
.drawer.open { transform: none; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.drawer-head h3 { margin: 0; font: 800 20px var(--display); }
.drawer-body { flex: 1; overflow: auto; padding: 14px 20px; }
.drawer-foot { padding: 16px 20px calc(16px + var(--safe-b)); border-top: 1px solid var(--line); display: grid; gap: 10px; }
.citem { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.citem .thumb { width: 56px; height: 56px; border-radius: 14px; font-size: 28px; }
.citem-info { flex: 1; min-width: 0; } .citem-name { font-weight: 700; font-size: 14.5px; }
.citem .qty { height: 36px; } .citem .qty button { width: 32px; font-size: 17px; }
.sum-row { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); }
.sum-row.total { color: var(--text); font: 800 20px var(--display); }
.progress { height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; } .progress i { display: block; height: 100%; background: var(--grad); border-radius: 6px; transition: width .4s; }
.hint { font-size: 12.5px; color: var(--muted); }
.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 13px; color: var(--muted); font-weight: 600; }
.input { width: 100%; height: 46px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line2); background: rgba(255, 255, 255, .04); outline: none; transition: border-color .2s; }
textarea.input { height: 80px; padding: 12px 14px; resize: vertical; }
.input:focus { border-color: var(--accent); }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg label { display: flex; align-items: center; justify-content: center; gap: 8px; height: 46px; border-radius: 12px; border: 1px solid var(--line2); cursor: pointer; font-weight: 600; font-size: 14px; color: var(--text); }
.seg input { display: none; } .seg input:checked + span { color: var(--accent2); }
.seg label:has(input:checked) { border-color: var(--accent2); background: rgba(34, 211, 238, .08); }
.success { text-align: center; padding: 30px 6px; }
.success .big { font-size: 72px; animation: rise .5s; }
.success h3 { font: 800 24px var(--display); margin: 10px 0; }
.empty-cart { text-align: center; padding: 50px 10px; color: var(--muted); } .empty-cart div { font-size: 64px; margin-bottom: 10px; }

/* ---------- Toasts ---------- */
#toasts { position: fixed; z-index: 60; left: 50%; top: calc(130px + var(--safe-t)); transform: translateX(-50%); display: grid; gap: 8px; pointer-events: none; width: max-content; max-width: calc(100% - 24px); }
.toast { padding: 12px 18px; border-radius: 14px; font-weight: 600; font-size: 14px; animation: rise .3s; display: flex; gap: 10px; align-items: center; }
.toast.out { opacity: 0; transform: translateY(-10px); transition: .3s; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .brand-text { display: none; }
  .btn-icon .lbl { display: none; }
  .search kbd { display: none; }
}
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; padding: 8px; gap: 8px; top: calc(8px + var(--safe-t)); left: 8px; right: 8px; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .actions { margin-left: auto; }
  .promo { top: calc(120px + var(--safe-t)); font-size: 12px; }
  .catalog { padding-top: calc(164px + var(--safe-t)); }
  #minimap { width: 120px; height: 100px; }
  .hud { bottom: calc(76px + var(--safe-b)); right: 8px; }
  .modal { padding: 0; align-items: end; }
  .modal-card { grid-template-columns: 1fr; border-radius: 26px 26px 0 0; max-height: 92vh; }
  .modal-card .thumb { min-height: 200px; font-size: 100px; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .card .thumb { font-size: 52px; }
  .touring { top: calc(160px + var(--safe-t)); }
  #toasts { top: calc(164px + var(--safe-t)); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
