:root {
  --bg: #efeff4;
  --card: #ffffff;
  --text: #111;
  --muted: #8a8a8e;
  --line: #e5e5ea;
  --blue: #1d8cf8;
  --blue-soft: #e3f1ff;
  --green: #2fbf4a;
  --red: #f04b4b;
  --star-bg: #fff4d6;
  --star: #e8a400;
  --chip: #f2f2f7;
  --shadow: 0 6px 24px rgba(0, 0, 0, .08);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
html.dark {
  --bg: #0f0f12;
  --card: #1c1c1f;
  --text: #f2f2f2;
  --muted: #8d8d93;
  --line: #2c2c30;
  --blue-soft: #15304a;
  --star-bg: #3a3017;
  --chip: #2a2a2e;
  --shadow: 0 6px 24px rgba(0, 0, 0, .4);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif; }
body { padding: 64px 14px calc(110px + var(--safe-b)); min-height: 100vh; overscroll-behavior: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
input, select, textarea { font: inherit; color: var(--text); }
img { display: block; }

/* loader */
.loader { position: fixed; inset: 0; z-index: 100; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; transition: opacity .3s; }
.loader.hide { opacity: 0; pointer-events: none; }
.loader-emoji { font-size: 72px; animation: bob 1.4s ease-in-out infinite; }
.loader-title { font-weight: 600; font-size: 18px; margin-top: 8px; }
.loader-sub { color: var(--muted); font-size: 13px; }
.loader-bar { width: 280px; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 14px; }
.loader-bar i { display: block; height: 100%; width: 40%; background: var(--blue); border-radius: 3px; animation: load 1.2s ease-in-out infinite; }
@keyframes load { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }
@keyframes bob { 50% { transform: translateY(-8px); } }

/* top bar */
.topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 20; display: flex; justify-content: space-between; padding: 12px 14px; background: linear-gradient(var(--bg) 70%, transparent); }
.pill { display: inline-flex; align-items: center; gap: 6px; background: var(--card); border-radius: 18px; padding: 7px 12px; font-size: 13px; font-weight: 500; box-shadow: var(--shadow); }
.pill .arrow, .pill .plus { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--chip); font-size: 14px; }
.pill b { font-weight: 600; }

/* bottom bar */
.bottombar { position: fixed; left: 14px; right: 14px; bottom: calc(12px + var(--safe-b)); z-index: 30; display: flex; gap: 10px; align-items: center; }
.tabs { flex: 1; display: flex; background: var(--card); border-radius: 30px; padding: 6px; box-shadow: var(--shadow); }
.tabs button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11.5px; padding: 6px 0; border-radius: 24px; color: var(--text); }
.tabs button .ico { font-size: 20px; line-height: 1; filter: grayscale(1) brightness(.4); }
html.dark .tabs button .ico { filter: grayscale(1) brightness(1.6); }
.tabs button.active { background: var(--blue-soft); color: var(--blue); }
.tabs button.active .ico { filter: none; }
.avatar-btn { width: 62px; height: 62px; border-radius: 50%; background: var(--card); box-shadow: var(--shadow); padding: 6px; flex: none; }
.avatar-btn.active { outline: 2px solid var(--blue); }

.avatar { border-radius: 50%; object-fit: cover; background: linear-gradient(135deg, #7ab8ff, #3d7cf5); color: #fff; display: grid; place-items: center; font-weight: 600; overflow: hidden; width: 100%; height: 100%; }

/* cards & grids */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.gcard { position: relative; background: var(--card); border-radius: 18px; padding: 10px 8px 10px; display: flex; flex-direction: column; align-items: center; overflow: hidden; min-width: 0; }
.gcard .art { width: 100%; aspect-ratio: 1; }
.gcard .gname { font-size: 12px; font-weight: 600; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.gcard .gsub { font-size: 11px; color: var(--muted); }
.gcard.up { padding: 0; }
.gcard.up .art { border-radius: 18px; }
.gcard.up .price { position: absolute; bottom: 8px; background: rgba(0, 0, 0, .35); color: #fff; }
.gcard.dim { opacity: .55; }
.price { display: inline-flex; align-items: center; gap: 4px; background: var(--star-bg); border-radius: 14px; padding: 4px 12px; font-weight: 600; font-size: 14px; margin-top: 6px; white-space: nowrap; }
.price.small { font-size: 12px; padding: 3px 8px; }
.ribbon { position: absolute; top: 14px; right: -30px; width: 110px; transform: rotate(45deg); text-align: center; font-size: 10.5px; font-weight: 600; color: #fff; padding: 3px 0; background: #2ea6ff; z-index: 2; }
.ribbon.red { background: var(--red); }
.ribbon.green { background: #16b84a; }

/* gift art */
.art { position: relative; display: grid; place-items: center; overflow: hidden; }
.art > img.model { width: 78%; height: 78%; object-fit: contain; position: relative; z-index: 1; }
.art.plain > img.model { width: 86%; height: 86%; }
.art .pat { position: absolute; width: 11%; height: 11%; -webkit-mask-size: contain; mask-size: contain; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; -webkit-mask-position: center; mask-position: center; transform: translate(-50%, -50%); }

.section-title { font-size: 20px; font-weight: 600; margin: 18px 4px 10px; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.skeleton { background: linear-gradient(90deg, var(--chip), var(--card), var(--chip)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 14px; aspect-ratio: 1; }
@keyframes sk { to { background-position: -200% 0; } }

/* lists */
.box { background: var(--card); border-radius: 22px; padding: 6px 16px; margin-bottom: 14px; }
.box h3 { margin: 12px 0 6px; font-size: 19px; font-weight: 600; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item .li-ico { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; color: #fff; font-size: 17px; flex: none; }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { font-size: 15.5px; }
.list-item .li-sub { font-size: 12.5px; color: var(--star); font-weight: 600; }
.list-item .li-sub.muted { color: var(--muted); font-weight: 400; }
.list-item .chev { color: var(--muted); font-size: 20px; }
.list-item.disabled { opacity: .45; pointer-events: none; }
.task-group { background: var(--card); border-radius: 22px; padding: 4px 14px; }
.task-group .inner { background: var(--chip); border-radius: 16px; padding: 0 12px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--blue); color: #fff; border-radius: 20px; padding: 7px 16px; font-weight: 600; font-size: 14px; white-space: nowrap; }
.btn.green { background: var(--green); }
.btn.gray { background: var(--chip); color: var(--muted); }
.btn.red { background: var(--red); }
.btn.block { display: flex; width: 100%; padding: 15px; border-radius: 26px; font-size: 17px; }
.btn:disabled { opacity: .6; pointer-events: none; }
.btn.light { background: var(--blue-soft); color: var(--blue); }

/* profile */
.profile-card { background: var(--card); border-radius: 26px; padding: 28px 16px 22px; text-align: center; margin-bottom: 14px; }
.profile-card .pa { width: 92px; height: 92px; margin: 0 auto 10px; }
.profile-card .pname { font-size: 26px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.profile-card .psub { color: var(--muted); margin-top: 4px; }
.seg-row { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.seg { flex: 1; display: flex; background: var(--card); border-radius: 22px; padding: 4px; }
.seg button { flex: 1; padding: 9px 0; border-radius: 18px; font-size: 14px; font-weight: 500; }
.seg button.active { background: var(--blue-soft); color: var(--blue); }
.round-btn { width: 40px; height: 40px; border-radius: 50%; background: var(--card); display: grid; place-items: center; font-size: 18px; flex: none; }
.badge-tick { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; color: #fff; font-size: 11px; vertical-align: middle; }

/* market filters */
.filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 10px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filters select { appearance: none; -webkit-appearance: none; background: var(--card); border: 0; border-radius: 16px; padding: 8px 14px; font-size: 13px; font-weight: 500; flex: none; max-width: 170px; }
.filters select.on { background: var(--blue-soft); color: var(--blue); }

/* sheets */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .35); display: flex; align-items: flex-end; animation: fade .2s; }
.sheet { width: 100%; max-height: 92vh; overflow-y: auto; background: var(--bg); border-radius: 28px 28px 0 0; padding: 0 0 calc(18px + var(--safe-b)); animation: up .25s cubic-bezier(.2, .8, .2, 1); position: relative; }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: rgba(128, 128, 128, .45); margin: 8px auto 0; position: sticky; top: 8px; z-index: 5; }
.sheet .pad { padding: 14px 18px 0; }
.sheet h2 { margin: 8px 0 2px; font-size: 24px; font-weight: 600; }
.sheet .sub { color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.sheet-wrap.closing { animation: fade .2s reverse forwards; }
.sheet-wrap.closing .sheet { animation: up .2s reverse forwards; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(100%); } }

.hero { position: relative; padding: 24px 18px 18px; color: #fff; text-align: center; overflow: hidden; border-radius: 28px 28px 0 0; }
.hero .art.bg { position: absolute; inset: 0; z-index: 0; }
.hero .art.bg .pat { width: 34px; height: 34px; }
.hero .hero-in { position: relative; z-index: 1; }
.hero .hero-model { width: 140px; height: 140px; margin: 6px auto 0; object-fit: contain; }
.hero .hname { font-size: 22px; font-weight: 700; margin-top: 8px; }
.hero .hname span { opacity: .7; font-weight: 500; }
.hero .hsub { opacity: .75; font-size: 14px; }
.hero .hpill { display: inline-block; background: rgba(255, 255, 255, .2); border-radius: 12px; padding: 2px 10px; font-size: 13px; margin-top: 4px; }
.hero-close, .hero-more { position: absolute; top: 14px; width: 40px; height: 40px; border-radius: 50%; background: rgba(255, 255, 255, .22); color: #fff; font-size: 22px; z-index: 3; display: grid; place-items: center; }
.hero-close { left: 16px; }
.hero-more { right: 16px; }
.hero-actions { display: flex; gap: 10px; margin-top: 16px; }
.hero-actions button { flex: 1; background: rgba(255, 255, 255, .2); border-radius: 16px; padding: 10px 4px; color: #fff; font-size: 13px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.hero-actions button .i { font-size: 20px; }
.hero-actions button:disabled { opacity: .45; }
.hero.green { background: linear-gradient(160deg, #c4e17f, #4fb36a); }
.hero.plainbg { background: linear-gradient(160deg, #6fb6ff, #3f7cf0); }

.table { background: var(--card); border-radius: 16px; border: 1px solid var(--line); overflow: hidden; margin: 14px 0 6px; }
.table .tr { display: flex; border-bottom: 1px solid var(--line); min-height: 44px; }
.table .tr:last-child { border-bottom: 0; }
.table .th { width: 36%; background: var(--chip); padding: 11px 12px; color: var(--text); opacity: .85; }
.table .td { flex: 1; padding: 11px 12px; display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; }
.table .td .val { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.table .td .val.spin { animation: spin-val .09s linear; }
@keyframes spin-val { from { transform: translateY(-60%); opacity: .2; } }
.rar { background: var(--blue-soft); color: var(--blue); border-radius: 10px; padding: 1px 7px; font-size: 12px; font-weight: 600; }
.link { color: var(--blue); }
.note { text-align: center; color: var(--muted); font-size: 13px; margin: 10px 0 14px; }

.field { background: var(--card); border-radius: 18px; padding: 14px 16px; display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.field input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 16px; min-width: 0; }
.input-glass { width: 100%; border: 0; outline: 0; border-radius: 20px; padding: 13px 18px; background: rgba(255, 255, 255, .45); color: #fff; font-size: 16px; }
.input-glass::placeholder { color: rgba(255, 255, 255, .8); }
.switch { position: relative; width: 52px; height: 30px; flex: none; }
.switch input { display: none; }
.switch i { position: absolute; inset: 0; border-radius: 15px; background: var(--line); transition: .2s; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: .2s; }
.switch input:checked + i { background: var(--green); }
.switch input:checked + i::after { left: 25px; }

.progress { position: relative; height: 34px; border-radius: 17px; background: var(--line); overflow: hidden; display: flex; align-items: center; justify-content: space-between; padding: 0 14px; font-weight: 500; font-size: 14px; margin: 14px 0 6px; }
.progress i { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg, #0aa6ff, #19b5ff); border-radius: 17px; }
.progress span { position: relative; z-index: 1; }
.progress span:first-of-type { color: #fff; }

.preview-card { width: 210px; margin: 10px auto 0; background: rgba(0, 0, 0, .15); border-radius: 22px; padding: 18px 12px 16px; position: relative; overflow: hidden; }
.preview-card img { width: 96px; height: 96px; margin: 0 auto; object-fit: contain; }
.preview-card .t { font-weight: 700; margin-top: 8px; }
.preview-card .s { font-size: 13px; opacity: .9; }

.feature { display: flex; gap: 14px; margin: 16px 0; }
.feature .fi { font-size: 22px; color: var(--blue); width: 28px; flex: none; text-align: center; }
.feature b { display: block; margin-bottom: 2px; }
.feature span { color: var(--muted); font-size: 14px; }

.pack { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.pack:last-child { border-bottom: 0; }
.pack b { flex: 1; font-weight: 500; }
.pack .cost { color: var(--muted); }

.exch { background: var(--card); border-radius: 22px; padding: 14px 16px; position: relative; }
.exch .row { display: flex; align-items: center; justify-content: space-between; }
.exch label { color: var(--muted); font-size: 14px; }
.exch input { border: 0; outline: 0; background: transparent; font-size: 28px; font-weight: 600; width: 60%; }
.exch .big { font-size: 28px; font-weight: 600; }
.exch .tag { border: 1px solid var(--line); border-radius: 16px; padding: 5px 10px; font-size: 14px; }
.exch .arrow { display: grid; place-items: center; width: 40px; height: 40px; margin: 6px auto; border: 1px solid var(--line); border-radius: 12px; color: var(--muted); }

.lb-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.lb-row:last-child { border-bottom: 0; }
.lb-row .rank { width: 30px; text-align: center; font-weight: 600; color: var(--muted); }
.lb-row .av { width: 40px; height: 40px; flex: none; }
.lb-row .nm { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-row.me { background: var(--blue-soft); border-radius: 14px; padding: 10px; border: 0; margin-bottom: 8px; }

.reflink { display: flex; gap: 8px; align-items: center; background: var(--chip); border-radius: 14px; padding: 10px 12px; font-size: 13px; word-break: break-all; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stats div { background: var(--card); border-radius: 16px; padding: 14px; }
.stats b { display: block; font-size: 22px; }
.stats span { color: var(--muted); font-size: 13px; }

.toast { position: fixed; left: 50%; top: 70px; transform: translate(-50%, -20px); background: rgba(30, 30, 30, .92); color: #fff; padding: 10px 16px; border-radius: 14px; font-size: 14px; z-index: 200; opacity: 0; pointer-events: none; transition: .25s; max-width: 88vw; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: rgba(200, 40, 40, .95); }

.menu { background: var(--card); border-radius: 18px; overflow: hidden; }
.menu button { display: flex; width: 100%; padding: 15px 18px; border-bottom: 1px solid var(--line); gap: 12px; font-size: 16px; }
.menu button:last-child { border-bottom: 0; }
.menu button.danger { color: var(--red); }

.upgrading .hero .art.bg, .upgrading .hero img { transition: none; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 120; }
