:root {
  --bg:             #0e0e14;
  --surface:        #15151d;
  --surface-raised: #1c1c26;
  --border:         #26263a;
  --text-primary:   #e2e2f0;
  --text-secondary: #8080a0;
  --text-muted:     #50507a;
  --green:          #7ecba0;
  --red:            #e08888;
  --amethyst:       #a78bfa;
  --amethyst-light: #c4b0ff;
  --amethyst-dim:   #6d5bbf;
  --gold:           #c8b87e;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 14px;
}

/* ── Sky background layers (crossfade via JS) ── */
.sky-layer {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-size: cover; background-position: center;
  opacity: 0; transition: opacity 1.2s ease;
}
.sky-layer.sky-active { opacity: 0.13; }

/* ── Sky switcher button ── */
.sky-btn {
  position: fixed; top: 14px; right: 14px; z-index: 200;
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.14);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .2s, transform .35s ease;
  color: rgba(255,255,255,.5); font-size: 14px;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.sky-btn:hover { background: rgba(255,255,255,.14); color: rgba(255,255,255,.85); }
.sky-btn.spinning { transform: rotate(180deg); }

/* ── Landing ── */
.landing { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 40px; padding: 40px 16px; }
.landing-inner { text-align: center; max-width: 400px; padding: 24px; }
.site-logo { font-size: 32px; font-weight: 800; margin-bottom: 8px; letter-spacing: .02em; display: flex; align-items: center; justify-content: center; gap: 12px; }
.tagline { color: var(--text-secondary); font-size: 14px; margin-bottom: 4px; }
.tagline-sub { font-size: 13px; margin-bottom: 32px; }
.lookup-input {
  width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text-primary); font-size: 14px;
  padding: 12px 16px; margin-bottom: 10px; outline: none;
}
.lookup-input:focus { border-color: var(--amethyst-dim); }
.lookup-btn {
  width: 100%; background: var(--amethyst); border: none; border-radius: 10px;
  color: #fff; font-size: 14px; font-weight: 600; padding: 12px; cursor: pointer;
}
.lookup-btn:hover { background: var(--amethyst-dim); }
.form-error { color: var(--red); font-size: 12px; margin-bottom: 10px; }

/* ── Profile page wrapper ── */
.page { max-width: 680px; margin: 0 auto; padding: 0 0 8px; }

/* ── Top banner ── */
.top-banner {
  position: relative;
  background-size: cover; background-position: center 30%;
  border-radius: 0 0 20px 20px;
  margin-bottom: 20px; overflow: hidden;
}
.top-banner::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(10,10,18,.40) 0%, rgba(10,10,18,.62) 100%);
}
.top-inner { position: relative; z-index: 1; padding: 36px 24px 40px; }
.nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }
.nav-logo {
  font-weight: 800; font-size: 16px; letter-spacing: .04em; color: #fff; text-decoration: none;
  display: flex; align-items: center; gap: 8px;
}
.nav-sub { color: rgba(255,255,255,.35); font-size: 12px; }
.share-btn {
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.18);
  border-radius: 6px; color: rgba(255,255,255,.6); font-size: 11px;
  padding: 4px 10px; cursor: pointer; transition: background .15s, color .15s;
}
.share-btn:hover { background: rgba(255,255,255,.16); color: rgba(255,255,255,.9); }
.share-btn.copied { color: var(--green); border-color: var(--green); }
.header { display: flex; align-items: center; gap: 16px; }
.avatar-pin {
  width: 56px; height: 56px; border-radius: 50%;
  border: 2px solid rgba(167,139,250,.5); object-fit: cover; flex-shrink: 0;
  box-shadow: 0 0 0 4px rgba(167,139,250,.12);
}
.avatar-placeholder {
  background: linear-gradient(135deg, #2a2a4a, #1a1a32);
  display: flex; align-items: center; justify-content: center;
  font-size: 44px; line-height: 1; overflow: hidden;
}
.header-info h1 { font-size: 20px; font-weight: 700; margin-bottom: 5px; color: #fff; }
.header-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.badge {
  background: rgba(200,184,126,.15); border: 1px solid rgba(200,184,126,.3);
  border-radius: 20px; padding: 2px 9px; font-size: 11px; color: var(--gold);
}
.meta-txt { color: rgba(255,255,255,.5); font-size: 12px; }
.avatar-placeholder .flag-img,
.pop-avatar-ph .flag-img,
.doppel-pin-ph .flag-img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ── Content area ── */
.content { padding: 0 20px; }

/* ── Collecting state ── */
.collecting-msg { text-align: center; padding: 48px 24px; color: var(--text-secondary); }
.collecting-msg h2 { font-size: 18px; margin-bottom: 8px; color: var(--text-primary); }

/* ── Hero card ── */
.hero {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 20px 22px; margin-bottom: 14px;
}
.hero-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-muted); margin-bottom: 6px;
}
.hero-rating { font-size: 44px; font-weight: 800; line-height: 1; margin-bottom: 8px; }
.hero-deltas { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 8px; }
.dp { color: var(--green); font-size: 12px; }
.dn { color: var(--red); font-size: 12px; }
.dm { color: var(--text-muted); font-size: 12px; }
.hero-rank { font-size: 12px; color: var(--text-secondary); }
.hero-rank b { color: var(--text-primary); }

/* ── Chart card ── */
.chart-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 16px 20px; margin-bottom: 14px;
}
.chart-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.chart-mode-label { font-size: 12px; color: var(--text-secondary); }
.chart-mode-label span { color: var(--text-primary); font-weight: 600; }
.range-btns { display: flex; gap: 4px; }
.rbtn {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  color: var(--text-secondary); padding: 3px 9px; font-size: 11px; cursor: pointer;
}
.rbtn.active { background: var(--surface-raised); color: var(--text-primary); border-color: #3a3a58; }

/* ── Mode cards ── */
.mode-hint { font-size: 11px; color: var(--text-muted); text-align: center; margin-bottom: 14px; }
.mode-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-bottom: 6px; }
.mode-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 16px; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.mode-card:hover { border-color: #3a3a58; }
.mode-card.active { border-color: var(--amethyst-dim); background: #17172a; }
.mode-card.active .mode-label { color: var(--amethyst); }
.mode-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-muted); margin-bottom: 6px; transition: color .15s;
}
.mode-rating { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.mode-delta { font-size: 11px; }
.mode-rank { font-size: 10px; color: var(--text-muted); margin-top: 4px; }
.rank-pos { color: var(--amethyst-light); }
.mode-spark { width: 100%; height: 20px; display: block; margin-top: 8px; }

/* ── Stats grid ── */
.section-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-muted); margin-bottom: 8px; padding-left: 2px; margin-top: 14px;
}
.stats-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 10px; margin-bottom: 14px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 16px;
}
.stat-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-muted); margin-bottom: 4px;
}
.stat-value { font-size: 20px; font-weight: 700; }
.stat-sub { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }

/* ── Highlights ── */
.highlights {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 18px 20px;
}
.hl-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.hl-row:last-child { border-bottom: none; }
.hl-name { color: var(--text-secondary); font-size: 12px; min-width: 5.5rem; }
.hl-rank { color: var(--amethyst-light); font-size: 10px; margin-left: 4px; }
.hl-val { font-weight: 600; font-size: 13px; }
.hl-date { color: var(--text-muted); font-size: 11px; }

/* ── Landing popular section ── */
.popular { width: 100%; max-width: 680px; }
.popular-label {
  color: var(--text-secondary); font-size: 11px; text-transform: uppercase;
  letter-spacing: .08em; margin-bottom: 12px;
}
.popular-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 480px) { .popular-grid { grid-template-columns: 1fr; } }
.pop-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px 12px; text-decoration: none; color: var(--text-primary);
  transition: border-color .15s;
}
.pop-card:hover { border-color: var(--amethyst-dim); }
.pop-avatar {
  width: 40px; height: 40px; border-radius: 50%; object-fit: cover;
  border: 2px solid rgba(167,139,250,.35);
  box-shadow: 0 0 0 3px rgba(167,139,250,.1);
}
.pop-avatar-ph {
  width: 40px; height: 40px; border-radius: 50%; display: flex;
  align-items: center; justify-content: center;
  background: var(--surface-raised); font-size: 32px; line-height: 1; overflow: hidden;
  border: 2px solid rgba(167,139,250,.35);
  box-shadow: 0 0 0 3px rgba(167,139,250,.1);
}
.pop-nick { font-weight: 600; font-size: 13px; text-align: center; }
.pop-country { color: var(--text-secondary); font-size: 11px; }
.pop-rating { color: var(--amethyst); font-size: 13px; font-weight: 700; }

/* ── Forecast ── */
.forecast-grid { display: flex; gap: .75rem; flex-wrap: wrap; margin-bottom: 14px; }
.fc-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 16px; min-width: 7rem; flex: 1;
}
.fc-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-muted); margin-bottom: 4px;
}
.fc-delta { font-size: 22px; font-weight: 700; margin-bottom: 2px; }
.fc-rating { font-size: 12px; color: var(--text-secondary); }
.fc-conf { font-size: 11px; color: var(--text-muted); }
.fc-empty { font-size: 12px; color: var(--text-muted); padding: 8px 0; }

/* ── Doppelgängers ── */
.doppel-grid { display: flex; gap: .75rem; flex-wrap: wrap; margin-bottom: 14px; }
.doppel-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 14px; min-width: 14rem; flex: 1;
  text-decoration: none; color: inherit; transition: border-color .15s;
}
.doppel-card:hover { border-color: var(--amethyst); }
.doppel-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-muted); margin-bottom: 6px;
}
.doppel-row { display: flex; align-items: center; gap: 10px; }
.doppel-pin {
  width: 36px; height: 36px; border-radius: 50%;
  object-fit: cover; flex-shrink: 0;
}
.doppel-pin-ph {
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; background: var(--bg-secondary); overflow: hidden;
}
.doppel-info { flex: 1; min-width: 0; }
.doppel-nick { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doppel-meta { font-size: 11px; color: var(--text-secondary); }
.doppel-rating { color: #c4b0fd; }
.doppel-sim { color: var(--amethyst); font-weight: 700; font-size: 16px; }

/* ── Site footer ── */
.site-footer {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 24px 18px 20px;
  font-size: 11px; color: var(--text-muted);
}
.footer-by { font-size: 11px; color: var(--text-muted); }
.footer-by a { color: var(--text-muted); text-decoration: none; }
.footer-by a:hover { color: var(--text-secondary); }
.footer-link {
  color: var(--text-muted); text-decoration: none;
  transition: color .15s; display: flex; align-items: center;
}
.footer-link:hover { color: var(--text-secondary); }
.footer-link svg { width: 17px; height: 17px; display: block; }
.nick-link { color: inherit; text-decoration: none; }
.nick-link:hover { text-decoration: underline; }

/* ── Badge tiers ── */
.badge-champion {
  background: rgba(167,139,250,.18); border-color: rgba(167,139,250,.4);
  color: var(--amethyst);
}
.badge-master {
  background: rgba(224,136,136,.15); border-color: rgba(224,136,136,.35);
  color: var(--red);
}
.badge-silver {
  background: rgba(210,210,230,.1); border-color: rgba(210,210,230,.3);
  color: #cccce0;
}
.badge-bronze {
  background: rgba(180,130,90,.12); border-color: rgba(180,130,90,.3);
  color: #c49a6c;
}

/* ── Nick autocomplete ── */
.lookup-wrap { position: relative; margin-bottom: 10px; }
.lookup-wrap .lookup-input { margin-bottom: 0; }
.autocomplete-list {
  display: none; position: absolute; top: calc(100% + 2px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; list-style: none; z-index: 20;
  overflow: hidden; box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.autocomplete-list.open { display: block; }
.autocomplete-list li {
  padding: 10px 16px; cursor: pointer; font-size: 13px;
  color: var(--text-primary); transition: background .1s;
  display: flex; justify-content: space-between; align-items: center;
}
.autocomplete-list li:hover { background: var(--surface-raised); }
.autocomplete-list li:not(:last-child) { border-bottom: 1px solid var(--border); }
.ac-rating { color: var(--amethyst); font-size: 12px; font-weight: 600; }

/* ── Leaderboard ── */
.lb-page { max-width: 720px; margin: 0 auto; padding: 0 0 40px; }
.lb-content { padding: 0 20px; }
.lb-page-title { font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.lb-page-sub { color: var(--text-secondary); font-size: 13px; margin-bottom: 20px; }

.lb-tabs { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.lb-tab {
  padding: 6px 14px; border-radius: 8px; font-size: 13px; font-weight: 500;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-secondary); text-decoration: none; transition: all .15s;
}
.lb-tab:hover { border-color: var(--amethyst-dim); color: var(--text-primary); }
.lb-tab.active { background: var(--amethyst-dim); border-color: var(--amethyst); color: #fff; }

.lb-table { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.lb-head {
  display: grid; grid-template-columns: 52px 1fr 88px;
  padding: 0 16px; height: 34px; align-items: center;
  background: var(--surface-raised); border-bottom: 1px solid var(--border);
}
.lb-head span { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.lbh-r { text-align: right; }

.lb-row {
  display: grid; grid-template-columns: 52px 1fr 88px;
  align-items: center; padding: 0 16px; height: 50px;
  border-bottom: 1px solid var(--border);
  text-decoration: none; color: inherit; transition: background .12s;
}
.lb-row:last-child { border-bottom: none; }
.lb-row:hover { background: var(--surface-raised); }
.lb-row.lb-r1 { background: rgba(200,184,126,.05); }
.lb-row.lb-r2 { background: rgba(160,168,184,.04); }
.lb-row.lb-r3 { background: rgba(192,128,96,.04); }
.lb-row.lb-r1:hover { background: rgba(200,184,126,.09); }
.lb-row.lb-r2:hover { background: rgba(160,168,184,.08); }
.lb-row.lb-r3:hover { background: rgba(192,128,96,.08); }

.lb-pos { font-size: 13px; font-weight: 700; color: var(--text-muted); line-height: 1; }
.lb-pos.pg { color: var(--gold); font-size: 17px; }
.lb-pos.ps { color: #a0a8b8; font-size: 17px; }
.lb-pos.pb { color: #c08060; font-size: 17px; }
.lb-pos.pt { color: var(--amethyst); }

.lb-player { display: flex; align-items: center; gap: 9px; min-width: 0; }
.lb-flag { font-size: 17px; flex-shrink: 0; }
.lb-nick { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-cc { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.lb-nick-wrap { min-width: 0; }
.lb-rating { font-size: 14px; font-weight: 700; color: var(--amethyst-light); text-align: right; }
.lb-empty { padding: 32px; text-align: center; color: var(--text-muted); font-size: 13px; }
.lb-note { margin-top: 12px; color: var(--text-muted); font-size: 12px; text-align: center; }
.lb-controls { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }
.lb-limit-pills { display: flex; gap: 4px; align-items: center; }
.lb-limit-pill {
  padding: 4px 10px; border-radius: 8px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--border); color: var(--text-secondary);
  text-decoration: none; transition: border-color .15s, color .15s, background .15s;
}
.lb-limit-pill:hover { border-color: var(--amethyst-dim); color: var(--text-primary); }
.lb-limit-pill.active { background: var(--amethyst-dim); border-color: var(--amethyst); color: #fff; }
.lb-search-wrap { position: relative; }
.lb-search {
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px;
  color: var(--text-primary); font-size: 13px; padding: 5px 12px; width: 190px;
  outline: none; transition: border-color .15s;
}
.lb-search::placeholder { color: var(--text-muted); }
.lb-search:focus { border-color: var(--amethyst-dim); }

.lb-country-wrap { position: relative; }
.lb-country-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px;
  color: var(--text-primary); font-size: 13px; padding: 5px 10px; cursor: pointer;
  transition: border-color .15s;
}
.lb-country-btn:hover { border-color: var(--amethyst-dim); }
.lb-country-btn[aria-expanded="true"] { border-color: var(--amethyst-dim); }
.lb-country-cur { display: inline-flex; align-items: center; gap: 6px; }
.lb-country-caret { color: var(--text-muted); font-size: 11px; }
.lb-country-pop {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 50;
  width: 240px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.lb-country-input {
  width: 100%; box-sizing: border-box;
  background: transparent; border: 1px solid var(--border); border-radius: 7px;
  color: var(--text-primary); font-size: 13px; padding: 5px 10px; outline: none;
  margin-bottom: 6px;
}
.lb-country-input:focus { border-color: var(--amethyst-dim); }
.lb-country-list {
  list-style: none; margin: 0; padding: 0;
  max-height: 260px; overflow-y: auto;
}
.lb-country-opt {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 13px;
  color: var(--text-primary);
}
.lb-country-opt:hover { background: var(--amethyst-dim); }
.lb-country-opt.active { background: rgba(167,139,250,.18); }
.lb-country-flag { width: 22px; text-align: center; }
.lb-country-lbl { flex: 1; }
.lb-country-cnt { color: var(--text-muted); font-size: 11px; }
.lb-country-empty { padding: 8px; color: var(--text-muted); font-size: 12px; text-align: center; }

/* ── Chart tooltip ── */
#chart-tooltip {
  display: none; position: absolute;
  background: #1e1b4b; color: var(--text-primary);
  padding: 4px 8px; border-radius: 6px; font-size: 12px;
  pointer-events: none; white-space: nowrap; z-index: 10;
  border: 1px solid var(--border);
}

/* ── Anomaly (Profile rarity) ── */
.anomaly-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 16px; margin-bottom: 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.anomaly-pct {
  font-size: 28px; font-weight: 700; color: var(--amethyst);
  letter-spacing: -.01em;
}
.anomaly-drivers { display: flex; flex-wrap: wrap; gap: 6px; }
.anomaly-driver {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(167,139,250,.10);
  border: 1px solid rgba(167,139,250,.25);
  color: var(--text-secondary);
  border-radius: 999px; padding: 3px 10px;
  font-size: 12px;
}
.anomaly-arrow { font-weight: 700; color: var(--amethyst); }
.anomaly-driver-down .anomaly-arrow { color: #c4b0fd; }
