:root{
  --navy-1:#050810; --navy-2:#0A1230; --navy-3:#111B3E;
  --panel: rgba(18,26,58,0.62);
  --panel-solid:#0E1530;
  --line: rgba(212,175,55,0.28);
  --line-soft: rgba(212,175,55,0.16);
  --hair: rgba(255,255,255,0.09);
  --text:#F4EFDD; --muted:#9AA3C4;
  --field: rgba(255,255,255,0.045);
  --gold-1:#F6E7B4; --gold-2:#D4AF37; --gold-3:#9C7A1E;
  --emerald:#3FCF9E; --ruby:#E5637A; --sapphire:#4F8DFF;
  --grad-gold: linear-gradient(120deg, var(--gold-1), var(--gold-2) 55%, var(--gold-3));
  --grad-gold-text: linear-gradient(100deg, #FBEFC7, var(--gold-2) 45%, #FBEFC7 90%);
  --display:"Playfair Display", "Georgia", serif;
  --body:"Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 18px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { background: var(--navy-1); }

body {
  margin: 0;
  font-family: var(--body);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 40px;
  position: relative;
  overflow-x: hidden;
  background:
    radial-gradient(1000px 500px at 50% -12%, rgba(212,175,55,0.14), transparent 60%),
    radial-gradient(800px 800px at 110% 15%, rgba(79,141,255,0.10), transparent 55%),
    radial-gradient(700px 700px at -10% 85%, rgba(212,175,55,0.08), transparent 55%),
    linear-gradient(175deg, var(--navy-1), var(--navy-2) 45%, var(--navy-3));
  background-attachment: fixed, fixed, fixed, fixed;
}

/* fine gold hairline grid, very subtle — texture, not a toy */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    linear-gradient(rgba(212,175,55,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(212,175,55,0.05) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(1100px 700px at 50% 0%, #000 0%, transparent 70%);
  -webkit-mask-image: radial-gradient(1100px 700px at 50% 0%, #000 0%, transparent 70%);
}

button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--gold-2); outline-offset: 2px; border-radius: 6px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(5,8,16,0.72);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid var(--line-soft);
}

.brand { font-family: var(--display); font-weight: 700; font-size: 1.05rem; letter-spacing: 0.01em; color: var(--gold-1); display: flex; gap: 9px; align-items: center; }
.logo-flame { flex-shrink: 0; filter: drop-shadow(0 0 8px rgba(212,175,55,0.55)); }

.tabs { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--line-soft); padding: 4px; border-radius: 999px; }
.tab {
  background: transparent; border: none; color: var(--muted);
  padding: 7px 13px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; cursor: pointer;
  transition: transform .15s, background .2s, color .2s;
}
.tab:active { transform: scale(.94); }
.tab.active { background: var(--grad-gold); color: #1A1305; font-weight: 700; }

.ghost-btn {
  background: transparent; border: 1px solid var(--line); color: var(--gold-1);
  padding: 6px 13px; border-radius: 999px; font-size: 0.78rem; cursor: pointer; font-weight: 600;
  transition: background .2s;
}
.ghost-btn:hover { background: var(--panel); }

main { max-width: 640px; margin: 0 auto; padding: 20px 16px; }

.card {
  background: var(--panel);
  border: 1px solid var(--hair);
  box-shadow: 0 14px 40px -16px rgba(0,0,0,0.65);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 18px;
}

h1 { font-family: var(--display); font-weight: 700; font-size: 1.5rem; margin: 4px 0 8px; line-height: 1.2; }
h2 { font-family: var(--display); font-weight: 700; font-size: 1.15rem; margin: 0 0 10px; letter-spacing: 0.01em; }
h3 { font-family: var(--body); font-weight: 700; font-size: 0.78rem; margin: 16px 0 8px; color: var(--gold-2); text-transform: uppercase; letter-spacing: 0.08em; }
.muted { color: var(--muted); }
.small { font-size: 0.8rem; }
.row-between { display: flex; align-items: center; justify-content: space-between; }

.gold-text {
  background: var(--grad-gold-text); background-size: 200% auto;
  -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent;
}

/* ---------- Auth: a real landing moment, not just a form ---------- */
.auth-screen { display: flex; flex-direction: column; align-items: center; gap: 26px; padding: 18px 0 10px; }

.hero { text-align: center; max-width: 480px; padding: 6px 6px 2px; }
.auth-mark {
  width: 52px; height: 52px; border-radius: 50%; margin: 0 auto 16px; display: grid; place-items: center;
  background: var(--grad-gold); box-shadow: 0 0 0 1px var(--line-soft), 0 0 28px rgba(212,175,55,0.45);
}
.eyebrow { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.22em; color: var(--gold-2); margin: 0 0 6px; }
.hero-title {
  font-family: var(--display); font-weight: 700; font-size: 2.1rem; line-height: 1.15; margin: 0 0 12px;
  background: var(--grad-gold-text); background-size: 200% auto;
  -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent;
  animation: sheen 5s linear infinite;
}
@keyframes sheen { to { background-position: 200% center; } }
@media (prefers-reduced-motion: reduce) { .hero-title { animation: none; } }
.hero-sub { color: var(--muted); font-size: 0.92rem; line-height: 1.55; margin: 0 auto 20px; max-width: 40ch; }

.hero-facts { display: flex; gap: 10px; justify-content: center; margin-bottom: 24px; flex-wrap: wrap; }
.fact {
  background: var(--field); border: 1px solid var(--line-soft); border-radius: 14px; padding: 10px 16px; min-width: 108px;
}
.fact b { display: block; font-family: var(--display); font-weight: 700; font-size: 1rem; color: var(--gold-1); }
.fact span { font-size: 0.66rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }

.how-it-works { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.step { display: flex; gap: 14px; align-items: flex-start; }
.step-n {
  flex-shrink: 0; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  font-family: var(--display); font-weight: 700; font-size: 0.9rem;
  background: var(--field); border: 1px solid var(--line); color: var(--gold-1);
}
.step b { font-family: var(--body); font-size: 0.9rem; font-weight: 700; color: var(--text); }
.step p { margin: 2px 0 0; font-size: 0.82rem; color: var(--muted); line-height: 1.5; }

.auth-card { text-align: left; max-width: 420px; width: 100%; padding: 26px 24px; }
.auth-toggle {
  display: flex; gap: 2px; margin: 0 0 18px; padding: 4px; background: var(--field);
  border: 1px solid var(--line-soft); border-radius: 999px;
}
.pill { flex: 1; border: none; padding: 9px 0; border-radius: 999px; background: transparent; color: var(--muted); font-weight: 700; font-size: 0.88rem; cursor: pointer; transition: background .2s, color .2s; }
.pill.active { background: var(--grad-gold); color: #1A1305; }

.stack { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.stack label { font-size: 0.8rem; font-weight: 600; color: var(--muted); display: flex; flex-direction: column; gap: 5px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 420px) { .row { grid-template-columns: 1fr; } }

input, select {
  background: var(--field);
  border: 1px solid var(--hair);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 0.96rem;
  width: 100%;
  transition: border-color .2s, background .2s;
}
input::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
input:focus, select:focus { border-color: var(--gold-2); background: rgba(212,175,55,0.05); }

.primary-btn {
  background: var(--grad-gold);
  color: #1A1305;
  border: none;
  box-shadow: 0 10px 28px -10px rgba(212,175,55,0.55);
  padding: 13px 18px;
  border-radius: 14px;
  font-family: var(--body);
  font-weight: 700;
  font-size: 0.96rem;
  cursor: pointer;
  margin-top: 4px;
  width: 100%;
  transition: transform .12s, box-shadow .12s, filter .12s;
}
.primary-btn:hover { filter: brightness(1.07); }
.primary-btn:active { transform: translateY(1px) scale(.99); }

.link-btn {
  background: none; border: none; color: var(--gold-2); font-weight: 700; font-size: 0.8rem; cursor: pointer;
  padding: 0;
}

.error { color: var(--ruby); min-height: 1.2em; font-size: 0.85rem; font-weight: 600; }

.avatar-pick { display: flex; gap: 6px; flex-wrap: wrap; }
.avatar-pick button {
  font-size: 1.3rem; background: var(--field); border: 1px solid var(--hair);
  border-radius: 12px; padding: 6px 10px; cursor: pointer; transition: background .15s, transform .1s;
}
.avatar-pick button.selected { background: var(--grad-gold); transform: scale(1.05); }

/* Status badge */
.status-badge {
  background: var(--panel); border: 1px solid var(--line-soft); box-shadow: 0 8px 24px -10px rgba(0,0,0,.6);
  backdrop-filter: blur(14px);
  padding: 12px 18px; border-radius: 16px; font-weight: 600; margin-bottom: 18px;
}
.status-badge b {
  font-family: var(--display); font-weight: 700; font-size: 1.25rem; display: block; line-height: 1.2;
  background: var(--grad-gold-text); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent;
}

/* Podium */
.podium-card { padding-bottom: 4px; overflow: hidden; }
.podium {
  display: grid; grid-template-columns: 1fr 1.15fr 1fr; align-items: end; gap: 10px;
  margin-top: 14px;
}
.podium-spot { display: flex; flex-direction: column; align-items: center; text-align: center; min-width: 0; }
.podium-avatar {
  width: 52px; height: 52px; border-radius: 50%; margin: 0 auto 6px; display: grid; place-items: center;
  font-size: 1.5rem; border: 1px solid var(--hair); background: var(--field);
}
.podium-spot.gold .podium-avatar { width: 72px; height: 72px; font-size: 1.9rem; background: var(--grad-gold); box-shadow: 0 0 0 4px rgba(212,175,55,0.22), 0 0 26px rgba(212,175,55,0.55); }
.podium-name { font-weight: 700; font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.podium-score { font-size: 0.72rem; color: var(--muted); font-weight: 600; }
.podium-bar {
  width: 100%; border: 1px solid var(--hair); border-bottom: none; border-radius: 14px 14px 0 0;
  margin-top: 8px; display: flex; align-items: flex-start; justify-content: center;
  font-family: var(--display); font-weight: 700; padding-top: 6px; font-size: 1.4rem;
}
.podium-spot.gold .podium-bar { background: var(--grad-gold); height: 118px; color: #1A1305; box-shadow: 0 -8px 30px -6px rgba(212,175,55,0.55); }
.podium-spot.silver .podium-bar { background: linear-gradient(180deg, #E4E8F2, #9AA3C4); height: 88px; color: #1A1305; }
.podium-spot.bronze .podium-bar { background: linear-gradient(180deg, #E3A472, #A9663A); height: 64px; color: #1A1305; }
@media (prefers-reduced-motion: no-preference) {
  .podium.ready .podium-bar { animation: rise .6s cubic-bezier(.2,1.4,.4,1) both; }
  .podium.ready .podium-spot.silver .podium-bar { animation-delay: .08s; }
  .podium.ready .podium-spot.gold .podium-bar { animation-delay: .2s; }
  @keyframes rise { from { transform: translateY(100%); } to { transform: none; } }
}

/* Leaderboard list */
.lb-list { display: flex; flex-direction: column; gap: 8px; }
.lb-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--field); border: 1px solid var(--hair); border-radius: 14px; padding: 11px 14px;
  transition: border-color .2s;
}
.lb-rank { width: 26px; text-align: center; font-family: var(--display); font-weight: 700; color: var(--muted); }
.lb-row.prize .lb-rank { background: var(--grad-gold-text); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent; }
.lb-avatar { font-size: 1.3rem; }
.lb-name { flex: 1; font-weight: 700; }
.lb-meta { font-size: 0.72rem; color: var(--muted); font-weight: 500; }
.lb-total { font-family: var(--display); font-weight: 700; color: var(--gold-1); font-size: 1.1rem; }
.lb-row.me { border-color: var(--gold-2); box-shadow: 0 0 0 1px rgba(212,175,55,0.35); }
.youtag { font-size: 0.63rem; background: var(--grad-gold); color: #1A1305; border-radius: 6px; padding: 1px 6px; margin-left: 6px; font-weight: 800; }

.teambar { margin: 10px 0; }
.teambar .lbl { display: flex; justify-content: space-between; font-weight: 700; font-size: 0.85rem; }
.teambar .track { height: 14px; border: 1px solid var(--hair); border-radius: 999px; background: var(--field); overflow: hidden; margin-top: 4px; }
.teambar .fill { height: 100%; background: linear-gradient(90deg, var(--sapphire), var(--gold-2)); }
.teambar:nth-child(2) .fill { background: var(--grad-gold); }

/* Skeleton loading */
.skel { background: linear-gradient(90deg, var(--field) 25%, rgba(212,175,55,0.12) 50%, var(--field) 75%);
  background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 10px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } }

/* Upload */
.upload-box {
  background: var(--field); border: 1.5px dashed var(--line); border-radius: 18px;
  min-height: 140px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; text-align: center; padding: 14px; position: relative; overflow: hidden;
  margin: 14px 0; transition: border-color .2s, background .2s;
}
.upload-box:hover { border-color: var(--gold-2); }
.upload-box.filled { border-style: solid; border-color: var(--emerald); box-shadow: 0 0 0 1px rgba(63,207,158,0.35); }
.upload-box img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0.22; }
.upload-placeholder { position: relative; z-index: 1; font-size: 1.3rem; line-height: 1.6; font-weight: 600; }

.reading-row {
  display: flex; align-items: center; gap: 10px; justify-content: center; font-weight: 600; color: var(--muted);
  padding: 10px; margin-bottom: 10px;
}
.spinner { width: 20px; height: 20px; border: 3px solid var(--field); border-top-color: var(--gold-2); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Summary confirm card */
.summary-card { background: var(--field); border: 1px solid var(--hair); border-radius: 18px; padding: 18px; margin-top: 6px; }
.summary-title { font-weight: 700; }
.summary-grid { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; }
.summary-chip { background: var(--panel-solid); border: 1px solid var(--hair); border-radius: 12px; padding: 10px 12px; text-align: center; flex: 1; min-width: 90px; }
.summary-chip b { display: block; font-family: var(--display); font-weight: 700; font-size: 1.2rem; color: var(--gold-1); }
.summary-chip span { font-size: 0.66rem; color: var(--muted); font-weight: 600; }
.preview-points { text-align: center; font-weight: 700; margin-bottom: 14px; }
.preview-points .n {
  font-family: var(--display); font-weight: 700; font-size: 1.7rem;
  background: var(--grad-gold-text); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent;
}

.score-result {
  background: rgba(63,207,158,0.10); border: 1px solid rgba(63,207,158,0.35);
  border-radius: 18px; padding: 20px; margin-top: 16px; text-align: center;
}
.score-result .big { font-family: var(--display); font-weight: 700; font-size: 2.2rem; color: var(--emerald); }

/* my stats */
.stats { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; margin-bottom: 16px; }
.stat { background: var(--field); border: 1px solid var(--hair); border-radius: 14px; padding: 10px 8px; text-align: center; }
.stat b { display: block; font-family: var(--display); font-weight: 700; font-size: 1.25rem; line-height: 1.2; color: var(--gold-1); }
.stat span { font-size: 0.66rem; color: var(--muted); font-weight: 600; }
.stat.flame b { animation: pulse 1.6s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .stat.flame b { animation: none; } }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.12); } }

.days { display: grid; grid-template-columns: repeat(10,1fr); gap: 5px; margin-bottom: 14px; }
.day { aspect-ratio: 1; border: 1px solid var(--hair); border-radius: 8px; background: var(--field); font-size: 9px; display: grid; place-items: center; font-weight: 700; color: var(--muted); }
.day.hit { background: var(--grad-gold); color: #1A1305; }
.day.flagged { background: var(--ruby); color: #1A1305; }
.day.today { outline: 2px solid var(--gold-2); outline-offset: 1px; }
.day.future { opacity: 0.35; }

.badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.badge { border: 1px solid var(--hair); border-radius: 12px; padding: 5px 11px; font-weight: 700; font-size: 0.76rem; background: var(--field); opacity: 0.4; }
.badge.on { opacity: 1; background: var(--grad-gold); color: #1A1305; }

.confetti { position: fixed; top: -12px; width: 9px; height: 13px; z-index: 50; pointer-events: none; border-radius: 2px; }
@media (prefers-reduced-motion: reduce) { .confetti { display: none; } }

/* Toasts */
.toast-host { position: fixed; left: 0; right: 0; bottom: 16px; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 100; pointer-events: none; }
.toast {
  background: var(--panel-solid); border: 1px solid var(--hair); box-shadow: 0 10px 30px -8px rgba(0,0,0,.7);
  backdrop-filter: blur(12px);
  border-radius: 14px; padding: 10px 18px; font-weight: 600; max-width: 90vw; text-align: center;
  animation: toast-in .25s ease-out;
}
.toast.error { background: rgba(229,99,122,0.18); border-color: rgba(229,99,122,0.4); }
.toast.success { background: rgba(63,207,158,0.16); border-color: rgba(63,207,158,0.4); }
@keyframes toast-in { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (max-width: 420px) {
  .brand span { display: none; }
  .tab { padding: 7px 10px; font-size: 0.74rem; }
  .hero-title { font-size: 1.7rem; }
}
