:root {
  --bg: #0b1020;
  --bg2: #131a33;
  --card: rgba(255, 255, 255, .06);
  --card-b: rgba(255, 255, 255, .12);
  --text: #eef1ff;
  --muted: #9aa4cc;
  --gold: #ffd166;
  --gold2: #ff9f1c;
  --ok: #4ade80;
  --bad: #f87171;
  --radius: 18px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(255, 209, 102, .16), transparent 60%),
    radial-gradient(800px 500px at -10% 10%, rgba(99, 102, 241, .22), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  padding-bottom: env(safe-area-inset-bottom);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 100; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 16px; }

/* Header */
header.top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 0 8px; }
.logo { font-weight: 800; font-size: 1.35rem; letter-spacing: .3px; display: flex; align-items: center; gap: 8px; }
.logo b { background: linear-gradient(90deg, var(--gold), var(--gold2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.spacer { flex: 1; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--card-b); font-size: .85rem; color: var(--muted);
}
.chip.btn:hover { border-color: var(--gold); color: var(--text); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }
.dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }

.banner {
  margin: 8px 0; padding: 10px 14px; border-radius: 12px; font-size: .88rem;
  background: rgba(255, 159, 28, .12); border: 1px solid rgba(255, 159, 28, .4); color: #ffd9a3;
}

/* Tabs */
nav.tabs { display: flex; gap: 6px; margin: 12px 0 18px; background: var(--card); border: 1px solid var(--card-b); padding: 5px; border-radius: 14px; width: fit-content; max-width: 100%; overflow-x: auto; }
nav.tabs button { border: 0; background: transparent; padding: 9px 16px; border-radius: 10px; color: var(--muted); font-weight: 600; white-space: nowrap; }
nav.tabs button.on { background: linear-gradient(135deg, var(--gold), var(--gold2)); color: #2b1a00; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.btn-primary {
  border: 0; padding: 11px 18px; border-radius: 12px; font-weight: 700; color: #2b1a00;
  background: linear-gradient(135deg, var(--gold), var(--gold2)); box-shadow: 0 6px 20px rgba(255, 159, 28, .25);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { border: 1px solid var(--card-b); background: var(--card); padding: 10px 14px; border-radius: 12px; }
.btn-ghost:hover { border-color: var(--gold); }
.btn-danger { border: 1px solid rgba(248, 113, 113, .5); background: rgba(248, 113, 113, .1); color: #fecaca; padding: 10px 14px; border-radius: 12px; }

/* Hunt cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.hunt {
  position: relative; background: var(--card); border: 1px solid var(--card-b); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 12px; overflow: hidden;
  backdrop-filter: blur(6px);
}
.hunt::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(260px 160px at 50% 0%, rgba(255, 209, 102, .14), transparent 70%); }
.hunt .head { display: flex; align-items: center; gap: 12px; position: relative; }
.sprite-box { width: 96px; height: 96px; flex: none; display: grid; place-items: center; border-radius: 16px; background: rgba(0, 0, 0, .25); position: relative; }
.sprite-box img { width: 84px; height: 84px; object-fit: contain; image-rendering: pixelated; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, .5)); }
.sprite-box .spark { position: absolute; top: 4px; right: 6px; font-size: 1rem; animation: twinkle 2s infinite; }
@keyframes twinkle { 0%, 100% { opacity: .3; transform: scale(.8) } 50% { opacity: 1; transform: scale(1.2) } }
.hunt h3 { margin: 0; font-size: 1.15rem; }
.dexno { color: var(--muted); font-size: .8rem; font-weight: 600; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tag { font-size: .72rem; padding: 3px 8px; border-radius: 999px; background: rgba(255, 255, 255, .08); color: var(--muted); }
.tag.hunter { color: #fff; font-weight: 700; }
.counter { text-align: center; position: relative; }
.counter .n { font-size: 3.2rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.counter .lbl { color: var(--muted); font-size: .78rem; margin-top: 2px; }
.bar { height: 8px; border-radius: 999px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), var(--gold2)); border-radius: 999px; transition: width .3s; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: .78rem; color: var(--muted); }
.stats b { color: var(--text); display: block; font-size: .95rem; }
.tap { display: grid; grid-template-columns: 56px 1fr; gap: 10px; }
.tap button { border-radius: 14px; border: 1px solid var(--card-b); background: var(--card); font-size: 1.4rem; font-weight: 800; padding: 14px 0; }
.tap button.plus { background: linear-gradient(135deg, #6366f1, #8b5cf6); border: 0; font-size: 1.3rem; box-shadow: 0 6px 18px rgba(99, 102, 241, .35); }
.tap button:active { transform: scale(.97); }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
.small { font-size: .82rem; padding: 8px 10px; }
.empty { text-align: center; color: var(--muted); padding: 50px 10px; border: 1px dashed var(--card-b); border-radius: var(--radius); }
.empty .big { font-size: 2.4rem; }

/* Shiny Dex */
.progress-top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.progress-top .bar { flex: 1; min-width: 160px; height: 12px; }
.dex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.dex-cell { position: relative; text-align: center; background: var(--card); border: 1px solid var(--card-b); border-radius: 14px; padding: 8px 4px 6px; }
.dex-cell img { width: 72px; height: 72px; image-rendering: pixelated; object-fit: contain; }
.dex-cell .nm { font-size: .72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dex-cell .no { font-size: .65rem; color: var(--muted); opacity: .7; }
.dex-cell.todo img { filter: brightness(0) invert(.3); opacity: .8; }
.dex-cell.hunting { border-color: rgba(129, 140, 248, .7); }
.dex-cell.hunting img { filter: brightness(0) invert(.35); }
.dex-cell.found { border-color: var(--gold); background: linear-gradient(180deg, rgba(255, 209, 102, .18), rgba(255, 255, 255, .05)); box-shadow: 0 0 18px rgba(255, 209, 102, .15); }
.dex-cell.found .nm { color: var(--text); font-weight: 700; }
.dex-cell .badge { position: absolute; top: 4px; right: 4px; font-size: .8rem; }
.dex-cell.found .by { font-size: .62rem; font-weight: 700; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: .8rem; margin-bottom: 12px; }

/* History */
.hist { display: flex; flex-direction: column; gap: 10px; }
.hist-item { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--card-b); border-radius: 14px; padding: 10px 14px; }
.hist-item img { width: 64px; height: 64px; image-rendering: pixelated; object-fit: contain; }
.hist-item .t { flex: 1; min-width: 0; }
.hist-item .t b { font-size: 1rem; }
.hist-item .t div { color: var(--muted); font-size: .8rem; }
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.summary .box { background: var(--card); border: 1px solid var(--card-b); border-radius: 14px; padding: 12px 14px; }
.summary .box b { font-size: 1.6rem; display: block; }
.summary .box span { color: var(--muted); font-size: .8rem; }

/* Dialogs */
dialog { border: 1px solid var(--card-b); border-radius: 20px; background: #121936; color: var(--text); padding: 0; width: min(620px, 94vw); max-height: 92vh; }
dialog::backdrop { background: rgba(3, 6, 18, .7); backdrop-filter: blur(3px); }
.dlg { padding: 20px; display: flex; flex-direction: column; gap: 14px; max-height: 90vh; overflow: auto; }
.dlg h2 { margin: 0; font-size: 1.2rem; }
label.f { display: flex; flex-direction: column; gap: 6px; font-size: .82rem; color: var(--muted); }
input[type=text], input[type=number], select, textarea {
  background: rgba(255, 255, 255, .06); border: 1px solid var(--card-b); border-radius: 10px; padding: 10px 12px; width: 100%; color: var(--text);
}
select option { color: #111; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.check { display: flex; align-items: center; gap: 10px; font-size: .9rem; }
.check input { width: 18px; height: 18px; accent-color: var(--gold2); }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: 8px; max-height: 260px; overflow: auto; padding: 4px; border: 1px solid var(--card-b); border-radius: 12px; }
.pick { background: rgba(255, 255, 255, .05); border: 1px solid transparent; border-radius: 10px; padding: 4px 2px; text-align: center; }
.pick img { width: 56px; height: 56px; image-rendering: pixelated; object-fit: contain; }
.pick span { display: block; font-size: .62rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick.sel { border-color: var(--gold); background: rgba(255, 209, 102, .15); }
.pick.dim { opacity: .45; }
.odds-note { font-size: .82rem; color: var(--muted); padding: 10px 12px; border-radius: 10px; background: rgba(255, 255, 255, .05); }
.odds-note b { color: var(--gold); }

/* Welcome */
.welcome { max-width: 460px; margin: 8vh auto; text-align: center; display: flex; flex-direction: column; gap: 14px; }
.welcome .logo { justify-content: center; font-size: 2rem; }
.welcome .card { background: var(--card); border: 1px solid var(--card-b); border-radius: 20px; padding: 22px; display: flex; flex-direction: column; gap: 12px; text-align: left; }
.or { text-align: center; color: var(--muted); font-size: .8rem; }
.code-input { text-transform: uppercase; letter-spacing: 3px; text-align: center; font-weight: 700; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); background: #1d2650; border: 1px solid var(--gold); padding: 10px 18px; border-radius: 12px; opacity: 0; pointer-events: none; transition: .25s; z-index: 200; font-size: .9rem; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.celebrate { text-align: center; }
.celebrate img { width: 160px; height: 160px; image-rendering: pixelated; object-fit: contain; filter: drop-shadow(0 0 20px rgba(255, 209, 102, .6)); }
.celebrate h2 { font-size: 1.6rem; background: linear-gradient(90deg, var(--gold), var(--gold2)); -webkit-background-clip: text; background-clip: text; color: transparent; }

@media (max-width: 480px) {
  .grid { grid-template-columns: 1fr; }
  .counter .n { font-size: 2.8rem; }
}
