:root {
  --bg: #f6f3ea;
  --surface: rgba(255, 255, 255, 0.76);
  --surface-solid: #fffefa;
  --ink: #172033;
  --muted: #6f7785;
  --line: rgba(23, 32, 51, 0.11);
  --red: #e63946;
  --red-dark: #c52d39;
  --gold: #f2b94b;
  --blue: #4f88d8;
  --shadow: 0 18px 50px rgba(36, 42, 61, 0.09);
}

[data-theme="night"] {
  --bg: #121722;
  --surface: rgba(28, 35, 49, 0.8);
  --surface-solid: #1b2230;
  --ink: #f6f3ea;
  --muted: #a9b1bf;
  --line: rgba(255, 255, 255, 0.1);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}
[data-theme="night"] .collection-picker { background: #1b2230; border-color: rgba(255,255,255,.18); }
[data-theme="night"] .collection-tab { background: #252e3f; border-color: rgba(255,255,255,.2); color: #f6f3ea; }
[data-theme="night"] .collection-tab span { color: #c4cad5; }
[data-theme="night"] .collection-tab.active { background: #34252d; border-color: #ff6873; box-shadow: 0 0 0 3px rgba(255,104,115,.18); }
[data-theme="night"] .collection-tab.active strong { color: #ff7b84; }
[data-theme="night"] .collection-select-wrap select { background: #252e3f; border-color: rgba(255,255,255,.22); color: #f6f3ea; }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  transition: background .25s, color .25s;
}
body.access-locked { overflow: hidden; }
.welcome-gate { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; padding: 20px; overflow-y: auto; background: radial-gradient(circle at 15% 10%, rgba(242,185,75,.24), transparent 36%), radial-gradient(circle at 90% 70%, rgba(230,57,70,.2), transparent 38%), var(--bg); }
.welcome-gate[hidden] { display: none; }
.welcome-card { width: min(680px, 100%); padding: clamp(28px, 6vw, 58px); text-align: center; border: 1px solid var(--line); border-radius: 34px; background: var(--surface-solid); box-shadow: 0 30px 100px rgba(20,25,35,.22); }
.welcome-ball { width: 56px; height: 56px; margin-bottom: 25px; }
.welcome-ball i { width: 16px; height: 16px; }
.welcome-mascots { display: flex; justify-content: center; gap: 8px; margin: -10px 0 4px; }
.welcome-mascots button { width: 74px; height: 74px; padding: 4px; border: 1px solid var(--line); border-radius: 22px; background: var(--surface); cursor: pointer; transition: transform .2s, border-color .2s; }
.welcome-mascots button:hover, .welcome-mascots button.active { transform: translateY(-7px) rotate(-3deg); border-color: var(--red); }
.welcome-mascots img { width: 100%; height: 100%; object-fit: contain; }
.mascot-greeting { min-height: 20px; margin: 7px 0 18px; color: var(--red); font: 700 13px Georgia, serif; }
.welcome-card h1 { font-size: clamp(46px, 8vw, 76px); }
.welcome-story { max-width: 560px; margin: 25px auto 30px; color: var(--muted); font-size: 17px; line-height: 1.7; }
.access-form { text-align: left; }
.access-form > label { display: block; margin: 0 0 8px 4px; font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.welcome-contact { margin: 25px 0 0; color: var(--muted); font-size: 11px; }
.welcome-contact a { color: var(--red); font-weight: 800; text-underline-offset: 3px; }
[data-theme="night"] .welcome-card { border-color: rgba(255,255,255,.18); background: #1b2230; }
button, input, select { font: inherit; }
button { color: inherit; }
.ambient { position: fixed; width: 42vw; height: 42vw; border-radius: 50%; filter: blur(100px); opacity: .16; z-index: -1; pointer-events: none; }
.ambient-one { background: #f2b94b; top: -18vw; left: -15vw; }
.ambient-two { background: #e63946; right: -22vw; top: 25vh; }

.topbar, main, footer { width: min(1180px, calc(100% - 40px)); margin-inline: auto; }
.topbar { height: 92px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 14px; letter-spacing: .04em; }
.brand small { color: var(--muted); font-weight: 650; font-size: 12px; text-transform: uppercase; letter-spacing: .16em; }
.pokeball { width: 39px; height: 39px; border: 3px solid var(--ink); border-radius: 50%; background: linear-gradient(var(--red) 0 46%, var(--ink) 46% 54%, #fff 54%); position: relative; display: inline-block; box-shadow: 0 5px 14px rgba(230,57,70,.2); }
.pokeball i { position: absolute; width: 12px; height: 12px; border-radius: 50%; border: 3px solid var(--ink); background: white; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.pokeball.mini { width: 24px; height: 24px; border-width: 2px; }
.pokeball.mini i { width: 8px; height: 8px; border-width: 2px; }
.icon-button { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); cursor: pointer; font-size: 18px; }
.top-actions { display: flex; align-items: center; gap: 7px; }
.text-button { border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--muted); padding: 9px 13px; font-size: 11px; font-weight: 800; cursor: pointer; }
.text-button:hover { color: var(--ink); background: var(--surface-solid); }
.account-button { border: 0; border-radius: 999px; background: var(--ink); color: var(--bg); padding: 10px 14px; font-size: 10px; font-weight: 850; cursor: pointer; white-space: nowrap; }
.account-button.synced { color: #22783c; background: rgba(52,168,83,.13); }

.collection-picker { padding: 28px; border: 1px solid var(--line); border-radius: 24px; background: var(--surface); box-shadow: var(--shadow); display: flex; align-items: center; justify-content: space-between; gap: 28px; }
.collection-picker h2 { margin: 0; font: 700 30px/1 Georgia, serif; }
.collection-picker .eyebrow { margin-bottom: 9px; }
.collection-tabs { flex: 1; display: grid; grid-template-columns: repeat(4, minmax(155px, 1fr)); gap: 10px; }
.collection-tab { min-width: 0; padding: 14px 18px; text-align: left; border: 1px solid var(--line); border-radius: 17px; background: var(--surface-solid); cursor: pointer; }
.collection-tab strong, .collection-tab span { display: block; }
.collection-tab strong { font-size: 13px; }
.collection-tab span { margin-top: 4px; color: var(--muted); font-size: 10px; }
.collection-tab.active { border-color: var(--red); box-shadow: 0 0 0 3px rgba(230,57,70,.1); }
.collection-tab.active strong { color: var(--red); }
.collection-tab.coming-soon { opacity: .72; cursor: not-allowed; border-style: dashed; }
.collection-select-wrap { flex: 1; max-width: 560px; color: var(--muted); font-size: 10px; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
.collection-select-wrap span { display: block; margin: 0 0 8px 3px; }
.collection-select-wrap select { width: 100%; min-height: 54px; padding: 0 46px 0 17px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-solid); color: var(--ink); font-size: 14px; font-weight: 750; letter-spacing: 0; text-transform: none; cursor: pointer; }
.collection-identity { width: 78px; height: 78px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 20px; background: var(--surface-solid); border: 1px solid var(--line); }
.collection-identity img { max-width: 68px; max-height: 68px; object-fit: contain; }

.hero { padding: 60px 0 76px; display: grid; grid-template-columns: 1.35fr .65fr; align-items: end; gap: 80px; }
.eyebrow { margin: 0 0 14px; color: var(--red); font-size: 11px; font-weight: 850; letter-spacing: .2em; }
h1 { font-family: Georgia, "Times New Roman", serif; font-size: clamp(48px, 7vw, 88px); line-height: .98; letter-spacing: -.055em; margin: 0; font-weight: 700; }
h1 em { color: var(--red); font-weight: 500; }
.hero-intro { max-width: 590px; color: var(--muted); line-height: 1.7; font-size: 16px; margin: 28px 0 30px; }
.hero-actions, .dialog-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.primary-button, .secondary-button { border-radius: 999px; padding: 13px 20px; font-weight: 750; border: 1px solid transparent; cursor: pointer; transition: transform .18s, box-shadow .18s, background .18s; }
.primary-button { background: var(--red); color: white; box-shadow: 0 10px 22px rgba(230,57,70,.2); }
.primary-button:hover { transform: translateY(-2px); box-shadow: 0 14px 28px rgba(230,57,70,.28); }
.primary-button span { margin-left: 9px; }
.secondary-button { background: transparent; border-color: var(--line); }
.secondary-button:hover { background: var(--surface); }

.progress-card { background: var(--surface); border: 1px solid rgba(255,255,255,.65); border-radius: 26px; padding: 27px; box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.progress-topline { display: flex; justify-content: space-between; text-transform: uppercase; font-size: 10px; font-weight: 800; letter-spacing: .12em; color: var(--muted); }
.progress-number { display: flex; align-items: baseline; gap: 8px; margin: 16px 0 13px; }
.progress-number strong { font-family: Georgia, serif; font-size: 47px; line-height: 1; }
.progress-number span { color: var(--muted); font-size: 13px; }
.progress-track { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress-track span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--red), #ff796f); border-radius: inherit; transition: width .4s ease; }
.mini-stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-top: 24px; }
.mini-stats div { display: grid; grid-template-columns: 27px 1fr; align-items: center; }
.mini-stats strong { font-size: 15px; }
.mini-stats small { grid-column: 2; color: var(--muted); font-size: 10px; }
.stat-icon { grid-row: 1/3; width: 23px; height: 23px; border-radius: 50%; display: grid; place-items: center; color: white; font-size: 11px; }
.gold { background: var(--gold); }.coral { background: var(--red); }.blue { background: var(--blue); }

.controls { padding: 26px; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); }
.search-box { height: 52px; display: flex; align-items: center; gap: 12px; background: var(--surface-solid); border: 1px solid var(--line); border-radius: 15px; padding: 0 15px; }
.search-box > span { font-size: 25px; color: var(--muted); transform: rotate(-15deg); }
.search-box input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); }
kbd { border: 1px solid var(--line); border-radius: 6px; color: var(--muted); padding: 3px 7px; font-size: 10px; }
.filter-row { display: flex; justify-content: space-between; gap: 20px; align-items: center; margin-top: 17px; }
.segmented { display: flex; gap: 6px; flex-wrap: wrap; }
.segmented button { border: 0; background: transparent; border-radius: 999px; color: var(--muted); padding: 9px 13px; font-size: 12px; font-weight: 700; cursor: pointer; }
.segmented button.active { background: var(--ink); color: var(--bg); }
.select-wrap { color: var(--muted); text-transform: uppercase; letter-spacing: .1em; font-weight: 800; font-size: 9px; display: flex; align-items: center; gap: 9px; }
select { border: 1px solid var(--line); background: var(--surface-solid); color: var(--ink); padding: 9px 30px 9px 11px; border-radius: 10px; }

.collection-heading { padding: 60px 4px 22px; display: flex; justify-content: space-between; align-items: end; }
.collection-heading h2 { margin: 0; font: 700 36px/1 Georgia, serif; letter-spacing: -.03em; }
.collection-heading > p { color: var(--muted); font-size: 12px; }
.pokemon-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; padding-bottom: 70px; }
.pokemon-card { position: relative; min-width: 0; border: 1px solid var(--line); border-radius: 22px; background: var(--surface); box-shadow: 0 10px 32px rgba(36,42,61,.055); overflow: hidden; transition: transform .2s, box-shadow .2s, border-color .2s; }
.pokemon-card:hover { transform: translateY(-5px); box-shadow: var(--shadow); }
.pokemon-card.is-caught { border-color: rgba(52,168,83,.45); }
.pokemon-card.is-shiny { box-shadow: 0 0 0 1px rgba(242,185,75,.5), 0 15px 40px rgba(242,185,75,.13); }
.pokemon-card.is-tcg .pokemon-art { height: 145px; padding: 8px; }
.pokemon-card.is-tcg .art-button { background: radial-gradient(circle, rgba(255,255,255,.8), transparent 68%); }
.card-topline { padding: 17px 17px 0; display: flex; justify-content: space-between; align-items: center; }
.dex-number { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .1em; }
.favorite-button { border: 0; background: transparent; cursor: pointer; color: var(--muted); font-size: 23px; line-height: 1; padding: 2px; }
.favorite-button.active { color: var(--red); }
.art-button { display: block; width: 100%; border: 0; background: radial-gradient(circle, rgba(255,255,255,.8), transparent 68%); cursor: default; }
.pokemon-art { width: 100%; height: 145px; object-fit: contain; image-rendering: auto; filter: drop-shadow(0 13px 12px rgba(38,45,65,.14)); transition: transform .25s; }
.pokemon-card:hover .pokemon-art { transform: scale(1.07); }
.card-info { text-align: center; padding: 0 16px 16px; }
.card-info h3 { margin: 0 0 10px; text-transform: capitalize; font: 700 21px/1.1 Georgia, serif; }
.type-list { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; }
.type-pill { border-radius: 99px; padding: 4px 9px; font-size: 9px; text-transform: uppercase; letter-spacing: .08em; font-weight: 850; color: #fff; background: #88909d; }
.card-actions { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); }
.state-button { border: 0; background: rgba(255,255,255,.25); padding: 11px 4px; color: var(--muted); font-weight: 750; font-size: 10px; cursor: pointer; }
.state-button + .state-button { border-left: 1px solid var(--line); }
.caught-button.active { background: rgba(52,168,83,.1); color: #278642; }
.shiny-button.active { background: rgba(242,185,75,.14); color: #bd7d0d; }

.loading { min-height: 350px; display: grid; place-items: center; align-content: center; gap: 18px; color: var(--muted); }
.loader-ball { width: 45px; height: 45px; border: 3px solid var(--ink); border-radius: 50%; background: linear-gradient(var(--red) 0 46%, var(--ink) 46% 54%, white 54%); position: relative; animation: bounce 1s infinite alternate ease-in-out; }
.loader-ball i { position: absolute; width: 13px; height: 13px; border-radius: 50%; border: 3px solid var(--ink); background: white; inset: 50% auto auto 50%; transform: translate(-50%,-50%); }
@keyframes bounce { to { transform: translateY(-14px) rotate(15deg); } }
.empty-state { text-align: center; padding: 70px 20px 100px; }
.empty-state > span { display: grid; place-items: center; margin: auto; width: 60px; height: 60px; border-radius: 50%; background: var(--line); font: 700 24px Georgia; }
.empty-state h3 { font: 700 27px Georgia; margin: 18px 0 5px; }
.empty-state p { color: var(--muted); }

dialog { width: min(470px, calc(100% - 30px)); border: 1px solid var(--line); border-radius: 28px; background: var(--surface-solid); color: var(--ink); padding: 34px; text-align: center; box-shadow: 0 30px 100px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(13,18,28,.65); backdrop-filter: blur(8px); }
.dialog-close { position: absolute; right: 16px; top: 14px; border: 0; background: transparent; font-size: 27px; cursor: pointer; color: var(--muted); }
dialog img { display: block; width: 210px; height: 210px; object-fit: contain; margin: 0 auto -3px; filter: drop-shadow(0 20px 15px rgba(40,45,60,.17)); }
.hunt-number { color: var(--muted); font-size: 11px; letter-spacing: .14em; font-weight: 800; }
dialog h2 { text-transform: capitalize; font: 700 38px Georgia; margin: 5px 0 12px; }
dialog > p:not(.eyebrow):not(.hunt-number) { color: var(--muted); line-height: 1.6; }
.dialog-actions { justify-content: center; margin-top: 22px; }

.trainer-list { width: min(1180px, calc(100% - 40px)); margin: 0 auto 56px; padding: 34px; display: grid; grid-template-columns: .9fr 1.1fr; gap: 50px; align-items: center; border: 1px solid var(--line); border-radius: 28px; background: var(--surface); box-shadow: var(--shadow); }
.trainer-list h2 { margin: 0 0 10px; font: 700 36px/1 Georgia, serif; letter-spacing: -.03em; }
.trainer-list > div > p:last-child { margin: 0; color: var(--muted); line-height: 1.6; }
.signup-form label { display: block; margin-bottom: 8px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; }
.signup-row { display: flex; gap: 9px; }
.signup-row input { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 999px; padding: 13px 17px; background: var(--surface-solid); color: var(--ink); outline: 0; }
.signup-row input:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(230,57,70,.12); }
.signup-row button:disabled { cursor: wait; opacity: .7; }
.signup-note, .signup-status { margin: 9px 4px 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.signup-status { min-height: 15px; font-weight: 750; }
.signup-status.success { color: #278642; }
.signup-status.error { color: var(--red); }
.signup-trap { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
footer { border-top: 1px solid var(--line); padding: 30px 0 48px; display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 11px; }
footer p:last-child { margin-left: auto; }
footer a { color: var(--red); }
.toast { position: fixed; z-index: 20; left: 50%; bottom: 25px; transform: translate(-50%, 25px); opacity: 0; pointer-events: none; padding: 11px 17px; border-radius: 999px; background: var(--ink); color: var(--bg); box-shadow: var(--shadow); font-size: 12px; font-weight: 750; transition: .25s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 38px; padding-top: 30px; }
  .progress-card { max-width: 560px; }
  .pokemon-grid { grid-template-columns: repeat(3,1fr); }
  .collection-picker { align-items: stretch; flex-direction: column; }
  .collection-tabs { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 650px) {
  .topbar, main, footer { width: min(100% - 24px, 1180px); }
  .topbar { height: 72px; }
  .text-button { padding: 8px 10px; font-size: 10px; }
  .account-button { padding: 8px 10px; }
  .top-actions { gap: 4px; }
  .brand small { display: none; }
  .hero { padding: 35px 3px 50px; }
  .collection-picker { align-items: stretch; flex-direction: column; padding: 20px; }
  .collection-tabs { grid-template-columns: 1fr; }
  h1 { font-size: 50px; }
  .controls { padding: 14px; }
  .filter-row { align-items: stretch; flex-direction: column; }
  .segmented { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .select-wrap { justify-content: space-between; }
  .collection-heading { padding-top: 45px; }
  .pokemon-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 11px; }
  .pokemon-art { height: 120px; }
  .card-info h3 { font-size: 18px; }
  .card-actions { grid-template-columns: 1fr; }
  .state-button + .state-button { border-left: 0; border-top: 1px solid var(--line); }
  kbd { display: none; }
  footer { flex-wrap: wrap; }
  footer p:last-child { width: 100%; margin: 0; }
  .trainer-list { width: min(100% - 24px, 1180px); grid-template-columns: 1fr; gap: 24px; padding: 24px; }
  .signup-row { align-items: stretch; flex-direction: column; }
  .welcome-card { padding: 30px 22px; }
  .welcome-story { font-size: 15px; }
}
