:root {
  --bg: #0e1116;
  --bg-2: #151a21;
  --card: #1a2029;
  --card-2: #212935;
  --line: #2a3340;
  --text: #e8edf3;
  --muted: #8a96a6;
  --accent: #3fa9f5;
  --accent-2: #2b8fd6;
  --gold: #f5c04f;
  --violet: #b99bff;
  --ok: #4cc38a;
  --radius: 16px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
a { color: var(--accent); text-decoration: none; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; width: 100%; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.ok { color: var(--ok); }
h1, h2, h3 { margin: 0; letter-spacing: -0.02em; }
h2 { font-size: 24px; }

/* buttons */
.btn {
  border: 0; cursor: pointer; font: inherit; font-weight: 600; color: inherit;
  border-radius: 12px; padding: 10px 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: background .15s, transform .1s, opacity .15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: default; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); }
.btn-ghost { background: var(--card-2); color: var(--text); }
.btn-ghost:hover { background: var(--line); }
.btn-gold { background: rgba(245,192,79,.14); color: var(--gold); border: 1px solid rgba(245,192,79,.35); width: 100%; }
.btn-gold:hover { background: rgba(245,192,79,.22); }
.btn.sm { padding: 6px 12px; font-size: 14px; }

/* topbar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: rgba(14,17,22,.88); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-in { display: flex; align-items: center; gap: 24px; height: 64px; }
.logo { font-weight: 800; font-size: 20px; display: flex; align-items: center; gap: 8px; color: var(--text); }
.logo-mark { color: var(--accent); }
.nav { display: flex; gap: 20px; flex: 1; }
.nav a { color: var(--muted); font-weight: 500; }
.nav a:hover, .nav a.on { color: var(--text); }
.gated .nav, .gated .auth { visibility: hidden; }
.user { display: flex; align-items: center; gap: 10px; color: var(--text); }
.user-text { text-align: right; }
.user-name { font-weight: 600; max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, #3fa9f5, #8a5cf6);
  display: grid; place-items: center; font-weight: 700; text-transform: uppercase;
}
.balance { font-size: 13px; color: var(--gold); font-weight: 600; }

/* login gate */
.gate { display: grid; place-items: center; padding: 72px 16px; }
.gate-card {
  width: min(440px, 100%); text-align: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 36px 28px;
}
.gate-logo { font-size: 40px; color: var(--accent); line-height: 1; }
.gate h1 { font-size: 30px; margin: 8px 0 12px; }
.gate p { margin: 8px 0; }
.widget { min-height: 48px; margin: 22px 0 10px; display: flex; justify-content: center; }

/* hero and search */
.hero {
  padding: 64px 0 32px;
  background:
    radial-gradient(600px 300px at 20% 0%, rgba(63,169,245,.18), transparent 70%),
    radial-gradient(500px 260px at 85% 20%, rgba(138,92,246,.14), transparent 70%);
}
.eyebrow { color: var(--accent); font-weight: 600; margin: 0 0 8px; }
.hero h1 { font-size: clamp(30px, 5vw, 52px); line-height: 1.05; max-width: 720px; }
.lead { color: var(--muted); font-size: 17px; max-width: 640px; margin: 16px 0 24px; }
.search { display: flex; gap: 10px; max-width: 680px; }
.search input {
  flex: 1; min-width: 0; font: inherit; font-size: 16px; color: var(--text);
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 16px; outline: none;
}
.search input:focus { border-color: var(--accent); }
#searchOut { margin-top: 20px; }
.result-head { font-size: 16px; margin: 24px 0 12px; }
.notfound { color: var(--muted); }
.notfound h2 { color: var(--text); margin-bottom: 6px; }
.empty { color: var(--muted); padding: 32px 0; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 8px auto 48px; }
.stat { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat b { display: block; font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.stat span { color: var(--muted); font-size: 13px; }

/* sections, tabs */
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.section-head p { margin: 4px 0 0; }
.controls { display: flex; gap: 10px; flex-wrap: wrap; }
.tabs { display: flex; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; overflow-x: auto; }
.tabs button {
  border: 0; background: none; color: var(--muted); font: inherit; font-size: 14px; font-weight: 600;
  padding: 6px 12px; border-radius: 9px; cursor: pointer; white-space: nowrap;
}
.tabs button.on { background: var(--card-2); color: var(--text); }
select {
  font: inherit; font-size: 14px; color: var(--text); background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 12px; padding: 6px 10px;
}

/* set cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
#browse .grid { margin-bottom: 64px; }
.card {
  display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; cursor: pointer; transition: border-color .15s, transform .15s;
  text-align: left; font: inherit; color: inherit; width: 100%;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.prev { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 12px; min-height: 40px; }
.prev-empty { grid-column: 1 / -1; color: var(--muted); font-size: 13px; padding: 18px 0; text-align: center; }
.cell {
  /* A hard square: iOS Safari squashes aspect-ratio items inside some grids. */
  position: relative; width: 100%; height: 0; padding-bottom: 100%;
  align-self: start; border-radius: 10px; background: var(--bg-2);
  overflow: hidden; font-size: 22px; contain: paint;
}
.cell > * {
  position: absolute; inset: 0; width: 100% !important; height: 100% !important;
  object-fit: contain; display: grid; place-items: center;
}
.skeleton { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.card-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-sub { color: var(--muted); font-size: 13px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 2px; }
.tag {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: 2px 7px; border-radius: 6px; background: var(--card-2); color: var(--muted);
}
.tag.emoji { color: var(--violet); }
.tag.num { color: var(--text); }
.owner-card { display: flex; gap: 14px; align-items: center; color: var(--text); }
.owner-rank { font-size: 20px; font-weight: 800; color: var(--muted); min-width: 44px; }
.more { display: flex; justify-content: center; margin: 24px 0 48px; }

/* owner box (modal and owner page) */
.owner-box { background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0 0 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; word-break: break-word; }
.copy { cursor: pointer; border-bottom: 1px dashed var(--muted); }
.owner-box .small { margin-top: 8px; text-align: center; }

/* modal */
dialog {
  background: var(--card); color: var(--text); border: 1px solid var(--line);
  border-radius: 20px; padding: 0; width: min(780px, calc(100vw - 24px));
  max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain;
}
dialog::backdrop { background: rgba(0,0,0,.6); backdrop-filter: blur(3px); }
.modal-in { padding: 22px; }
.modal-head { display: flex; justify-content: space-between; gap: 16px; align-items: start; }
.modal-title { font-size: 22px; }
.modal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; margin: 18px 0; }
.x { background: var(--card-2); border: 0; color: var(--text); width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 18px; flex: none; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

/* owner page */
.page { padding-top: 24px; padding-bottom: 48px; }
.back { color: var(--muted); font-weight: 500; font-size: 14px; }
.back:hover { color: var(--text); }
.owner-head { display: flex; gap: 22px; align-items: center; margin: 18px 0 22px; }
.owner-avatar {
  flex: none; width: 88px; height: 88px; border-radius: 50%;
  background: linear-gradient(135deg, #3fa9f5, #8a5cf6);
  display: grid; place-items: center; font-size: 30px; font-weight: 800;
}
.owner-main h1 { font-size: clamp(26px, 4vw, 38px); }
.owner-main .actions { margin-top: 12px; }
.owner-cols { display: grid; grid-template-columns: minmax(260px, 360px) 1fr; gap: 14px; margin-bottom: 20px; align-items: start; }
.owner-stats { margin: 0; grid-template-columns: repeat(2, 1fr); }
.strip-box { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 36px; }
.strip-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.strip-head h3 { font-size: 16px; }
.strip { display: flex; flex-wrap: wrap; gap: 4px; }
.slot { width: 14px; height: 14px; border-radius: 4px; background: var(--card-2); border: 0; padding: 0; display: inline-block; }
.slot.on { background: var(--accent); cursor: pointer; }
.slot.on.emoji { background: var(--violet); }
.slot.on:hover { outline: 2px solid var(--text); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 12px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .slot { width: 12px; height: 12px; cursor: default; }

/* cabinet */
.cab-head { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; align-items: end; margin-bottom: 22px; }
.cab-head h1 { font-size: clamp(26px, 4vw, 36px); }
.cab-head p { margin: 4px 0 0; }
.cab-side { display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }
.cab-side .actions { margin: 0; }
.cab-tabs { margin-bottom: 18px; width: fit-content; max-width: 100%; }
.rows { display: grid; gap: 8px; }
.row {
  display: flex; justify-content: space-between; gap: 16px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px;
  font: inherit; color: var(--text); text-align: left; width: 100%;
}
button.row, a.row { cursor: pointer; }
button.row:hover, a.row:hover { border-color: var(--accent); }
.row-main { min-width: 0; display: flex; flex-direction: column; }
.row-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-extra { color: var(--text); font-size: 13px; text-align: right; flex: none; line-height: 1.4; }

/* footer, toast */
.footer { border-top: 1px solid var(--line); padding: 20px 0; }
.footer-in { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px);
  background: var(--card-2); border: 1px solid var(--line); padding: 10px 18px; border-radius: 12px;
  opacity: 0; pointer-events: none; transition: .2s; font-size: 14px; z-index: 100; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 420px) {
  .gate { padding: 32px 8px; }
  .gate-card { padding: 28px 12px; }
}

@media (max-width: 760px) {
  .topbar-in { gap: 12px; }
  .nav { gap: 12px; }
  .user-text { display: none; }
  .search { flex-direction: column; }
  .owner-cols { grid-template-columns: 1fr; }
  .owner-head { gap: 14px; }
  .owner-avatar { width: 64px; height: 64px; font-size: 22px; }
  .cab-side { align-items: stretch; width: 100%; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .row { flex-direction: column; align-items: stretch; }
  .row-extra { text-align: left; }
}
