/* ─── Reset & Base ─── */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0a0a0f;
  --surface: #141420;
  --border: #1e1e2e;
  --border-hover: #3b3b4f;
  --light-bg: #d6d6e3;
  --text: #ffffff;
  --text-muted: #888888;
  --text-dim: #5c5e63;
  --text-ghost: #444444;
  --green: #00ff87;
  --red: #ff3366;
  --orange: #ff9f43;
  --font-body: 'DM Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'DM Mono', 'SF Mono', monospace;
  --font-serif: 'Instrument Serif', Georgia, serif;
  --radius: 12px;
  --radius-lg: 16px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* ─── Scrollbar ─── */

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 2px; }

/* ─── Animations ─── */

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.anim-fade-up { animation: fadeUp 0.35s ease; }
.anim-slide-down { animation: slideDown 0.25s ease; }

/* ─── Layout ─── */

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 10, 15, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  background: none;
  border: none;
  color: var(--text);
  text-decoration: none;
}

.header-logo span:first-child {
  font-size: 20px;
  filter: drop-shadow(0 0 8px rgba(0, 255, 135, 0.3));
}

.header-logo span:last-child {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 400;
  letter-spacing: -0.5px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-points {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--green);
  font-weight: 600;
}

.content {
  flex: 1;
  max-width: 540px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 16px 100px;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  background: rgba(10, 10, 15, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding: 6px 0 env(safe-area-inset-bottom, 8px);
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 0 16px;
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.15s;
  font-family: var(--font-body);
}

.nav-btn span:first-child { font-size: 18px; }
.nav-btn span:last-child { font-size: 10px; font-weight: 600; }
.nav-btn--active { color: var(--green); }
.nav-btn--inactive { color: var(--text-ghost); }

/* ─── Registration ─── */

.reg-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.reg-card {
  max-width: 420px;
  width: 100%;
  text-align: center;
}

.reg-icon {
  font-size: 72px;
  margin-bottom: 8px;
  filter: drop-shadow(0 0 40px rgba(0, 255, 135, 0.3));
}

.reg-title {
  font-family: var(--font-serif);
  font-size: 48px;
  font-weight: 400;
  letter-spacing: -1px;
  margin-bottom: 8px;
}

.reg-subtitle {
  color: var(--text-dim);
  font-size: 15px;
  margin-bottom: 48px;
}

/* ─── Form Elements ─── */

.input {
  width: 100%;
  padding: 16px 20px;
  font-size: 16px;
  background: var(--surface);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius);
  color: var(--text);
  outline: none;
  font-family: var(--font-mono);
  transition: border-color 0.2s;
}

.input:focus {
  border-color: var(--text-dim);
}

.input::placeholder {
  color: var(--text-dim);
}

.btn {
  width: 100%;
  padding: 16px;
  font-size: 16px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 600;
  transition: all 0.2s;
}

.btn--primary {
  background: var(--text);
  color: var(--bg);
}

.btn--green {
  background: var(--green);
  color: var(--bg);
  font-weight: 700;
}

.btn--red {
  background: var(--red);
  color: var(--bg);
  font-weight: 700;
}

.btn--disabled {
  background: var(--border-hover);
  color: var(--text-dim);
  cursor: default;
}

.btn--ghost {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  padding: 0;
  font-family: var(--font-body);
}

/* ─── Country Grid ─── */

.country-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
  padding: 4px;
}

.country-btn {
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border-hover);
  border-radius: 10px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-family: var(--font-body);
  font-size: 14px;
  transition: all 0.15s;
}

.country-btn--selected {
  background: #1a1a2e;
  border-color: var(--green);
}

/* ─── Search ─── */

.search-wrap {
  position: relative;
  margin-bottom: 24px;
}

.search-bar {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0 16px;
  transition: border-color 0.2s;
}

.search-bar--focused {
  border-color: var(--border-hover);
}

.search-icon {
  color: var(--text-dim);
  font-size: 18px;
  margin-right: 12px;
}

.search-input {
  flex: 1;
  padding: 12px 0;
  font-size: 15px;
  background: transparent;
  border: none;
  color: var(--text);
  outline: none;
  font-family: var(--font-body);
}

.search-input::placeholder {
  color: var(--text);
  opacity: 0.4;
}

.search-clear {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
}

.search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 8px;
  background: var(--surface);
  border: 1px solid var(--border-hover);
  border-radius: 14px;
  overflow: hidden;
  z-index: 100;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.search-result {
  width: 100%;
  padding: 14px 18px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--font-body);
  transition: background 0.1s;
}

.search-result:hover {
  background: rgba(255, 255, 255, 0.03);
}

.search-result:last-child {
  border-bottom: none;
}

.search-result-img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--border);
}

.search-result-name {
  font-size: 15px;
  font-weight: 600;
}

.search-result-desc {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

.search-result-aura {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
}

.search-result-new {
  color: var(--text-ghost);
  font-size: 11px;
  font-style: italic;
}

/* ─── Tabs (Leaderboard) ─── */

.tabs {
  display: flex;
  background: var(--light-bg);
  border-radius: var(--radius);
  padding: 3px;
  margin-bottom: 16px;
}

.tab-btn {
  flex: 1;
  padding: 10px 0;
  font-size: 13px;
  border: none;
  cursor: pointer;
  border-radius: 10px;
  font-family: var(--font-body);
  font-weight: 600;
  transition: all 0.15s;
}

.tab-btn--active {
  background: var(--border-hover);
  color: var(--text);
}

.tab-btn--inactive {
  background: transparent;
  color: var(--text-dim);
}

/* ─── Leaderboard List ─── */

.lb-list {
  background: var(--surface);
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.lb-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-family: var(--font-body);
  text-align: left;
  transition: background 0.1s;
}

.lb-item:last-child { border-bottom: none; }
.lb-item:hover { background: rgba(255, 255, 255, 0.02); }

.lb-rank {
  width: 28px;
  text-align: right;
  font-family: var(--font-mono);
}

.lb-rank--top {
  color: var(--green);
  font-size: 15px;
  font-weight: 700;
}

.lb-rank--normal {
  color: var(--text-ghost);
  font-size: 13px;
}

.lb-img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--border);
}

.lb-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.lb-votes {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 1px;
}

.lb-aura {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
}

.lb-empty {
  text-align: center;
  padding: 40px;
  color: var(--text-ghost);
  font-size: 14px;
}

/* ─── Figure Page ─── */

.figure-header {
  text-align: center;
  margin-bottom: 32px;
}

.figure-img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  margin: 0 auto 16px;
  display: block;
  background: var(--border);
}

.figure-emoji {
  font-size: 64px;
  margin-bottom: 12px;
}

.figure-name {
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 400;
  margin-bottom: 4px;
}

.figure-desc {
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 20px;
}

.figure-aura {
  font-family: var(--font-mono);
  font-size: 56px;
  font-weight: 700;
  line-height: 1;
}

.figure-meta {
  color: var(--text-dim);
  font-size: 12px;
  margin-top: 4px;
}

.figure-added-by {
  color: var(--text-ghost);
  font-size: 11px;
  margin-top: 8px;
}

/* ─── Country Breakdown ─── */

.breakdown-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid var(--border);
  margin-bottom: 16px;
}

.breakdown-title {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 16px;
}

.breakdown-row {
  margin-bottom: 10px;
}

.breakdown-row-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.breakdown-country {
  font-size: 13px;
  color: #aaa;
}

.breakdown-value {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
}

.breakdown-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.breakdown-bar-fill {
  height: 100%;
  border-radius: 2px;
  opacity: 0.6;
  transition: width 0.3s ease;
}

/* ─── Vote Slider ─── */

.vote-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  border: 1px solid var(--border);
  margin-top: 16px;
}

.vote-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.vote-label {
  color: var(--text-muted);
  font-size: 13px;
}

.vote-value {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 700;
  transition: color 0.15s;
}

.vote-slider {
  width: 100%;
  height: 6px;
  appearance: none;
  -webkit-appearance: none;
  background: var(--border-hover);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.vote-slider::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  border: 2px solid var(--bg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.vote-slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  border: 2px solid var(--bg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.vote-range {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-ghost);
  font-family: var(--font-mono);
}

/* ─── Profile ─── */

.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #1a1a2e;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin: 0 auto 12px;
  border: 2px solid var(--border-hover);
}

.profile-username {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 4px;
}

.profile-country {
  color: var(--text-dim);
  font-size: 13px;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin: 24px 0;
}

.stat-card {
  background: var(--surface);
  border-radius: 14px;
  padding: 16px 12px;
  text-align: center;
  border: 1px solid var(--border);
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 700;
}

.stat-label {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
}

.history-card {
  background: var(--surface);
  border-radius: 14px;
  padding: 16px 18px;
  border: 1px solid var(--border);
}

.history-title {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 14px;
}

.history-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
}

.history-row + .history-row {
  border-top: 1px solid #1a1a2a;
}

.history-name {
  color: #aaa;
  font-size: 13px;
}

.history-points {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
}

/* ─── Toast ─── */

.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  z-index: 1000;
  animation: fadeUp 0.3s ease;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
  white-space: nowrap;
}

.toast--success { background: var(--green); color: var(--bg); }
.toast--error { background: var(--red); color: var(--bg); }
.toast--info { background: #333; color: var(--text); }

/* ─── Color utilities ─── */

.c-green { color: var(--green); }
.c-red { color: var(--red); }
.c-orange { color: var(--orange); }
.c-muted { color: var(--text-muted); }
.c-dim { color: var(--text-dim); }

/* ─── Loading ─── */

.loading-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.loading-icon {
  font-size: 48px;
  animation: pulse 1.5s infinite;
}

/* ─── Live indicator ─── */

.live-feed {
  position: fixed;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 16px;
  background: rgba(20, 20, 32, 0.95);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-muted);
  z-index: 40;
  animation: slideDown 0.3s ease;
  backdrop-filter: blur(8px);
  max-width: 90vw;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
