/* Jude's Skylanders — bright, chunky, touch-first. */
:root {
  --bg: #1d1440;
  --bg2: #2b1a5e;
  --panel: #33246e;
  --panel2: #3f2f82;
  --ink: #fff7e6;
  --ink-dim: #c9bfe8;
  --accent: #ffb020;
  --accent2: #ff5c8a;
  --good: #3ddc84;
  --line: rgba(255,255,255,.12);
  --radius: 18px;
  --shadow: 0 8px 24px rgba(0,0,0,.35);
  /* element colors */
  --el-magic: #a259ff; --el-water: #2f9df4; --el-tech: #ff8c1a; --el-fire: #ff4b3e;
  --el-earth: #b8783c; --el-life: #3dcc5c; --el-undead: #7d5bd6; --el-air: #56d3ff;
  --el-light: #ffd83d; --el-dark: #47506b; --el-kaos: #9aa3b5; --el-none: #6d6a8a;
  font-size: 17px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  background: radial-gradient(1200px 600px at 20% -10%, #4a2a9a 0%, var(--bg2) 45%, var(--bg) 100%) fixed;
  color: var(--ink);
  font-family: 'Fredoka', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
.hidden { display: none !important; }
h1, h2, h3 { margin: 0; font-weight: 600; }
.display { font-family: 'Luckiest Guy', 'Fredoka', sans-serif; letter-spacing: .5px; font-weight: 400; }

/* ---------- gate ---------- */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.gate-card { width: min(420px, 100%); background: var(--panel); border-radius: 28px; box-shadow: var(--shadow); padding: 32px 28px; text-align: center; }
.gate-card .logo { font-size: 72px; line-height: 1; margin-bottom: 8px; }
.gate-card h1 { font-size: 34px; color: var(--accent); }
.gate-card p { color: var(--ink-dim); margin: 6px 0 22px; }
.gate-card input { width: 100%; padding: 16px; border-radius: 14px; border: 2px solid var(--line); background: var(--bg); text-align: center; font-size: 24px; letter-spacing: 4px; }
.gate-card input:focus { outline: none; border-color: var(--accent); }
.gate-card .err { color: var(--accent2); min-height: 1.4em; margin-top: 10px; font-weight: 600; }
.btn-big { display: block; width: 100%; margin-top: 14px; padding: 16px; border-radius: 16px; background: var(--accent); color: #2a1600; font-weight: 700; font-size: 20px; box-shadow: 0 6px 0 #c47f00; transition: transform .08s; }
.btn-big:active { transform: translateY(4px); box-shadow: 0 2px 0 #c47f00; }

/* ---------- header / stats ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(29,20,64,.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); padding: env(safe-area-inset-top) 0 0; }
.brand { display: flex; align-items: center; gap: 10px; padding: 10px 16px 0; }
.brand h1 { font-size: 28px; color: var(--accent); flex: 1; }
.brand .icon { font-size: 30px; }
.brand button { color: var(--ink-dim); font-size: 14px; padding: 8px 10px; border-radius: 10px; }
.brand button:active { background: var(--panel); }
.brand .helpbtn { background: var(--panel); color: var(--ink); font-weight: 600; }
.gate-help { display: block; width: 100%; margin-top: 14px; padding: 10px; color: var(--ink-dim); font-size: 15px; text-decoration: underline; }
/* field guide */
.sheet.help { grid-template-columns: minmax(0, 1fr); max-width: 640px; position: relative; }
.sheet.help h3 { color: var(--accent); font-size: 19px; margin-top: 6px; }
.sheet.help p, .sheet.help li { line-height: 1.45; font-size: 15px; margin: 0; }
.sheet.help ul { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.sheet.help .muted { color: var(--ink-dim); font-size: 13px; }
.bases { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.base { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center; background: var(--panel); border-radius: 12px; padding: 8px 10px; }
.base i { grid-row: 1 / 3; width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(255,255,255,.25); box-shadow: inset 0 -6px 0 rgba(0,0,0,.25); }
.base b { font-size: 15px; line-height: 1.1; }
.base span { color: var(--ink-dim); font-size: 12px; }

.stats { display: grid; grid-template-columns: 1.5fr 1fr; gap: 10px; padding: 10px 16px; }
.stat { background: var(--panel); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.stat .label { color: var(--ink-dim); font-size: 13px; text-transform: uppercase; letter-spacing: .8px; }
.stat .big { font-size: 34px; line-height: 1.1; color: #fff; }
.stat .big small { font-size: 18px; color: var(--ink-dim); }
.stat .sub { color: var(--ink-dim); font-size: 14px; margin-top: 2px; }
.stat.value .big { color: var(--good); }
.bar { height: 12px; border-radius: 8px; background: rgba(0,0,0,.35); overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 8px; transition: width .5s ease; }

.games { display: flex; gap: 8px; padding: 0 16px 10px; overflow-x: auto; scrollbar-width: none; }
.games::-webkit-scrollbar { display: none; }
.game-chip { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 132px; padding: 8px 12px; border-radius: 14px; background: var(--panel); border: 2px solid transparent; color: var(--ink); text-align: left; }
.game-chip b { font-size: 15px; }
.game-chip span { font-size: 12px; color: var(--ink-dim); }
.game-chip .mini { height: 5px; }
.game-chip.on { border-color: var(--accent); background: var(--panel2); }

/* ---------- toolbar ---------- */
.toolbar { padding: 10px 16px 6px; display: grid; gap: 8px; }
.search { position: relative; }
.search input { width: 100%; padding: 14px 44px 14px 46px; border-radius: 16px; border: 2px solid var(--line); background: var(--panel); font-size: 19px; }
.search input:focus { outline: none; border-color: var(--accent); }
.search .mag { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); font-size: 20px; opacity: .7; }
.search .clear { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,.12); font-size: 18px; }
.row { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.row::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; padding: 9px 14px; border-radius: 999px; background: var(--panel); color: var(--ink-dim); font-weight: 600; font-size: 15px; border: 2px solid transparent; white-space: nowrap; }
.chip.on { background: var(--accent); color: #2a1600; }
.chip.el { padding: 7px 10px; font-size: 18px; }
.chip.el.on { background: var(--el); color: #fff; border-color: #fff; }
.chip.have.on { background: var(--good); color: #05391a; }
.chip.need.on { background: var(--accent2); color: #fff; }
.bank { display: flex; align-items: center; gap: 8px; margin-left: auto; flex: 0 0 auto; }
.bank label { color: var(--ink-dim); font-size: 14px; }
.bank input { width: 92px; padding: 7px 10px; border-radius: 10px; border: 2px solid var(--line); background: var(--panel); font-size: 16px; }
select.sort { padding: 8px 10px; border-radius: 10px; border: 2px solid var(--line); background: var(--panel); flex: 0 0 auto; }

/* ---------- grid ---------- */
.content { padding: 4px 16px 80px; }
.section-head { display: flex; align-items: baseline; gap: 10px; margin: 18px 0 8px; }
.section-head h2 { font-size: 24px; color: var(--accent); }
.section-head .meta { color: var(--ink-dim); font-size: 14px; }
.section-head .bar { flex: 1; max-width: 220px; height: 8px; margin: 0 0 4px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.card { position: relative; background: var(--panel); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); text-align: left; padding: 0; color: var(--ink); display: flex; flex-direction: column; transition: transform .1s; }
.card:active { transform: scale(.97); }
.card .pic { aspect-ratio: 1 / 1; background: var(--el, var(--el-none)); display: grid; place-items: center; position: relative; overflow: hidden; }
.card .pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .pic .emblem { font-size: 56px; filter: drop-shadow(0 4px 6px rgba(0,0,0,.35)); opacity: .9; }
.card .pic .initials { position: absolute; bottom: 6px; right: 8px; font-size: 14px; color: rgba(255,255,255,.7); font-weight: 700; }
.card .body { padding: 8px 10px 10px; display: grid; gap: 3px; }
.card .name { font-weight: 700; font-size: 16px; line-height: 1.15; }
.card .tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { font-size: 11px; padding: 2px 7px; border-radius: 999px; background: rgba(255,255,255,.12); color: var(--ink-dim); font-weight: 600; }
.tag.variant { background: var(--accent2); color: #fff; }
.tag.type { background: rgba(255,255,255,.08); }
.card .price { font-weight: 700; color: var(--good); font-size: 15px; }
.card .price.none { color: var(--ink-dim); font-weight: 500; }
.card.owned .pic::after { content: '✓'; position: absolute; top: 8px; left: 8px; width: 30px; height: 30px; border-radius: 50%; background: var(--good); color: #05391a; font-weight: 900; display: grid; place-items: center; font-size: 18px; box-shadow: 0 2px 6px rgba(0,0,0,.4); }
.card .qty { position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,.6); color: #fff; font-weight: 700; font-size: 13px; padding: 2px 8px; border-radius: 999px; }
.card:not(.owned) { opacity: .82; }
.card:not(.owned) .pic { filter: saturate(.55); }
.card .afford { position: absolute; bottom: 8px; left: 8px; background: var(--accent); color: #2a1600; font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 999px; }
.empty { text-align: center; color: var(--ink-dim); padding: 50px 20px; font-size: 18px; }

/* ---------- detail modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(10,6,25,.7); backdrop-filter: blur(6px); display: grid; place-items: center; padding: 12px; }
.sheet { width: min(760px, 100%); max-height: calc(100vh - 24px); overflow-y: auto; overflow-x: hidden; background: var(--bg2); border-radius: 24px; box-shadow: var(--shadow); display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 640px) { .sheet { grid-template-columns: minmax(0, 1fr); max-height: calc(100vh - 12px); border-radius: 20px; } .modal { padding: 6px; align-items: end; } }
.sheet .photo { position: relative; min-width: 0; background: var(--el, var(--el-none)); aspect-ratio: 1 / 1; display: grid; place-items: center; overflow: hidden; }
.sheet .photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.sheet .photo .emblem { font-size: 120px; filter: drop-shadow(0 6px 10px rgba(0,0,0,.4)); }
.sheet .photo .hint { position: absolute; bottom: 12px; left: 12px; right: 12px; text-align: center; color: #fff; font-weight: 700; background: rgba(0,0,0,.45); border-radius: 12px; padding: 8px; font-size: 15px; }
.sheet .close { position: absolute; top: 10px; right: 10px; width: 40px; height: 40px; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; font-size: 22px; z-index: 2; }
.sheet .info { min-width: 0; padding: 18px 18px 22px; display: grid; gap: 12px; align-content: start; }
.sheet h2 { font-size: 28px; line-height: 1.1; }
.sheet .sub { color: var(--ink-dim); margin-top: 2px; }
.sheet .catch { font-family: 'Luckiest Guy', sans-serif; font-size: 22px; color: var(--accent); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn { padding: 14px 12px; border-radius: 14px; font-weight: 700; font-size: 17px; background: var(--panel2); color: var(--ink); box-shadow: 0 4px 0 rgba(0,0,0,.35); transition: transform .08s; text-align: center; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.35); }
.btn.own { background: var(--panel2); }
.btn.own.on { background: var(--good); color: #05391a; }
.btn.cam { background: var(--accent); color: #2a1600; }
.btn.danger { background: transparent; color: var(--accent2); box-shadow: none; font-size: 14px; padding: 8px; }
.btn.wide { grid-column: 1 / -1; }
.btn[disabled] { opacity: .5; }
.qtyrow { display: flex; align-items: center; gap: 12px; justify-content: center; background: var(--panel); border-radius: 14px; padding: 8px; }
.qtyrow b { font-size: 22px; min-width: 2.5em; text-align: center; }
.qtyrow span { color: var(--ink-dim); font-size: 14px; }
.qtyrow button { width: 44px; height: 44px; border-radius: 50%; background: var(--panel2); font-size: 24px; font-weight: 700; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 15px; background: var(--panel); border-radius: 14px; padding: 12px 14px; }
.facts dt { color: var(--ink-dim); }
.facts dd { margin: 0; font-weight: 600; }
.facts .elpill { display: inline-block; padding: 1px 10px; border-radius: 999px; background: var(--el); color: #fff; }
.desc { color: var(--ink); line-height: 1.45; font-size: 15px; }
.pricebox { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.pricebox .amt { font-size: 30px; color: var(--good); font-weight: 700; }
.pricebox small { color: var(--ink-dim); }
.pricebox a { color: var(--ink-dim); font-size: 13px; }
textarea.notes { width: 100%; min-height: 64px; border-radius: 12px; border: 2px solid var(--line); background: var(--panel); padding: 10px; resize: vertical; }
.busy { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.5); color: #fff; font-weight: 700; font-size: 18px; z-index: 3; }

/* celebrate */
@keyframes pop { 0% { transform: scale(.6); opacity: 0 } 40% { transform: scale(1.15); opacity: 1 } 100% { transform: scale(1); opacity: 0 } }
.toast { position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%); background: var(--good); color: #05391a; font-weight: 800; font-size: 20px; padding: 12px 22px; border-radius: 999px; z-index: 60; animation: pop 1.6s ease forwards; pointer-events: none; box-shadow: var(--shadow); }
.toast.bad { background: var(--accent2); color: #fff; }
.footer { text-align: center; color: var(--ink-dim); font-size: 12px; padding: 20px; }
