:root {
  --bg: #0b0b10;
  --panel: #15151d;
  --panel-2: #1d1d28;
  --line: #2a2a38;
  --text: #f4f1e8;
  --muted: #9a97a8;
  --gold: #f5c542;
  --gold-2: #ffdf7e;
  --green: #3ddc84;
  --red: #ff5d5d;
  --radius: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 600px at 50% -10%, #23233a 0%, var(--bg) 55%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
button { font: inherit; cursor: pointer; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%;
}
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
a { color: var(--gold); }

.gamebar {
  position: sticky; top: calc(59px + env(safe-area-inset-top)); z-index: 19;
  display: flex; gap: 8px; padding: 10px 16px;
  background: rgba(11, 11, 16, .88); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line); overflow-x: auto;
}
.gamebtn {
  flex: 1; white-space: nowrap; background: var(--panel-2); color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 8px 10px; font-weight: 700; font-size: 13px;
}
.gamebtn.active { background: var(--gold); color: #17130a; border-color: var(--gold); }
.game-badge {
  display: inline-block; font-size: 10px; font-weight: 800; letter-spacing: .05em;
  padding: 2px 7px; border-radius: 999px; background: rgba(245, 197, 66, .16); color: var(--gold);
  text-transform: uppercase; margin-bottom: 4px;
}

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(11, 11, 16, .88); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { width: 38px; height: 38px; border-radius: 10px; }
.brand-name { font-weight: 800; font-size: 20px; letter-spacing: .06em; color: var(--gold); line-height: 1; }
.brand-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.chip {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 999px; padding: 8px 14px; font-size: 13px; font-weight: 600;
}
.chip.master { border-color: var(--gold); color: var(--gold); }

main { max-width: 880px; margin: 0 auto; padding: 16px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: rgba(13, 13, 19, .96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; background: none; border: 0; color: var(--muted);
  padding: 8px 2px 10px; font-size: 11px; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tab-ico { font-size: 20px; }
.tab.active { color: var(--gold); }

.hero {
  background: linear-gradient(135deg, #26263e, #15151d 60%);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-bottom: 16px;
}
.hero .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .12em; }
.hero .total { font-size: 40px; font-weight: 800; color: var(--gold); line-height: 1.1; }
.trend { display: inline-block; font-size: 13px; font-weight: 700; padding: 3px 9px; border-radius: 999px; margin-left: 8px; vertical-align: middle; }
.trend.up { background: rgba(61, 220, 132, .15); color: var(--green); }
.trend.down { background: rgba(255, 93, 93, .15); color: var(--red); }
.trend.flat { background: rgba(154, 151, 168, .15); color: var(--muted); }
.spark { width: 100%; height: 56px; margin-top: 10px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.cardcell { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; text-align: left; color: var(--text); }
.cardcell img { width: 100%; border-radius: 10px; display: block; background: #222; aspect-ratio: 63/88; object-fit: cover; }
.cardcell .nm { font-weight: 700; font-size: 14px; margin-top: 8px; }
.cardcell .st { color: var(--muted); font-size: 12px; }
.cardcell .pr { color: var(--gold); font-weight: 800; margin-top: 4px; }
.cardcell .tag { display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); margin-top: 5px; }
.fav-star { color: var(--gold); }

.tilt { transform-style: preserve-3d; transition: transform .18s ease; position: relative; }
.tilt::after {
  content: ""; position: absolute; inset: 0; border-radius: 10px; pointer-events: none;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, .28) 48%, transparent 60%);
  background-size: 250% 250%; background-position: var(--sheen, 120%) 0; mix-blend-mode: screen;
}

.btn {
  background: var(--gold); color: #17130a; border: 0; border-radius: 12px;
  padding: 12px 18px; font-weight: 800; width: 100%;
}
.btn.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--red); border: 1px solid var(--red); }
.btn.small { width: auto; padding: 8px 14px; font-size: 14px; }
.btn:disabled { opacity: .5; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.section-title { font-size: 18px; font-weight: 800; margin: 22px 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: 36px 16px; border: 1px dashed var(--line); border-radius: var(--radius); }

.pack {
  border: 1px solid var(--gold); border-radius: var(--radius); padding: 16px;
  background: linear-gradient(150deg, rgba(245, 197, 66, .14), var(--panel) 55%);
  margin-bottom: 14px;
}
.pack .price { font-size: 26px; font-weight: 800; color: var(--gold); }
.listing { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: flex; gap: 12px; margin-bottom: 12px; }
.listing img { width: 74px; border-radius: 8px; aspect-ratio: 63/88; object-fit: cover; background: #222; }
.listing .grow { flex: 1; min-width: 0; }
.vs { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.vs.under { background: rgba(61, 220, 132, .15); color: var(--green); }
.vs.over { background: rgba(255, 93, 93, .15); color: var(--red); }
.vs.at { background: rgba(154, 151, 168, .18); color: var(--muted); }

.sheet-wrap { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .6); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--panel); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  border-radius: 20px 20px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
}
.sheet h2 { margin: 0 0 6px; font-size: 20px; }
.sheet .close-x { float: right; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); border-radius: 999px; width: 34px; height: 34px; }
.detail-img { width: 62%; max-width: 300px; display: block; margin: 8px auto; border-radius: 12px; }
.kv { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv b { color: var(--gold); }

.toast {
  position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #23232f; color: var(--text); border: 1px solid var(--gold);
  padding: 11px 18px; border-radius: 999px; z-index: 60; font-weight: 600; font-size: 14px;
  max-width: 92vw; text-align: center;
}
.confetti { position: fixed; inset: 0; z-index: 55; pointer-events: none; }
video.scan-video { width: 100%; border-radius: var(--radius); background: #000; }
.captured { width: 100%; border-radius: var(--radius); }
.searchbar { display: flex; gap: 8px; }
.searchbar input { flex: 1; }
.searchbar button { width: auto; }
.ledger-row { display: flex; justify-content: space-between; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.err { color: var(--red); font-size: 14px; margin-top: 8px; }
.toggle-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.toggle-row .btn { width: auto; }
