/* ===== CATPPUCCIN MOCHA PALETTE ===== */
:root {
  --rosewater: #f5e0dc;
  --flamingo:  #f2cdcd;
  --pink:      #f5c2e7;
  --mauve:     #cba6f7;
  --red:       #f38ba8;
  --maroon:    #eba0ac;
  --peach:     #fab387;
  --yellow:    #f9e2af;
  --green:     #a6e3a1;
  --teal:      #94e2d5;
  --sky:       #89dceb;
  --sapphire:  #74c7ec;
  --blue:      #89b4fa;
  --lavender:  #b4befe;
  --text:      #cdd6f4;
  --subtext1:  #bac2de;
  --subtext0:  #a6adc8;
  --overlay2:  #9399b2;
  --overlay1:  #7f849c;
  --overlay0:  #6c7086;
  --surface2:  #585b70;
  --surface1:  #45475a;
  --surface0:  #313244;
  --base:      #1e1e2e;
  --mantle:    #181825;
  --crust:     #11111b;

  --font-display: 'Bebas Neue', sans-serif;
  --font-body:    'DM Sans', sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--base);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* ===== NOISE OVERLAY ===== */
.noise-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1000;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 128px;
}

/* ===== HERO ===== */
.hero {
  position: relative;
  overflow: hidden;
  padding: 80px 24px 60px;
  text-align: center;
  background: linear-gradient(180deg, var(--mantle) 0%, var(--base) 100%);
  border-bottom: 1px solid var(--surface0);
}

.hero::before {
  content: '';
  position: absolute;
  top: -120px; left: 50%; transform: translateX(-50%);
  width: 700px; height: 700px;
  background: radial-gradient(circle, rgba(166, 227, 161, 0.08) 0%, transparent 65%);
  pointer-events: none;
}

.hero-bg-text {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-size: clamp(120px, 22vw, 260px);
  color: var(--surface0);
  opacity: 0.45;
  letter-spacing: 0.05em;
  user-select: none;
  white-space: nowrap;
  pointer-events: none;
}

.hero-content {
  position: relative;
  z-index: 2;
}

.badge {
  display: inline-block;
  background: var(--surface0);
  border: 1px solid var(--surface2);
  color: var(--green);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 4px 14px;
  border-radius: 100px;
  margin-bottom: 20px;
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(36px, 10vw, 120px);
  line-height: 0.95;
  letter-spacing: 0.02em;
  color: var(--text);
  margin-bottom: 20px;
  word-break: break-word;
  overflow-wrap: break-word;
}

.hero-title .accent {
  color: var(--green);
  text-shadow: 0 0 60px rgba(166, 227, 161, 0.4);
}

.hero-sub {
  color: var(--subtext1);
  font-size: 18px;
  font-weight: 300;
  max-width: 420px;
  margin: 0 auto;
}

/* ===== SEARCH SECTION ===== */
.search-section {
  max-width: 680px;
  margin: 0 auto;
  padding: 48px 24px 24px;
}

/* ── Total users diagnosed counter ─────────────────────── */
.diagnosed-counter {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--overlay1);
  letter-spacing: 0.02em;
}

.diagnosed-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  flex-shrink: 0;
  animation: pulse-dot 2.4s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.75); }
}

#diagnosedCount {
  color: var(--green);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}


  background: var(--mantle);
  border: 1px solid var(--surface1);
  border-radius: 20px;
  padding: 32px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.4);
}

.search-label {
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 0.15em;
  color: var(--overlay1);
  margin-bottom: 12px;
}

.search-row {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--surface0);
  border: 1px solid var(--surface2);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.2s;
}

.search-row:focus-within {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(166, 227, 161, 0.12);
}

.search-prefix {
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--green);
  padding: 0 4px 0 18px;
  user-select: none;
}

.search-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 18px;
  font-weight: 500;
  padding: 16px 12px;
  caret-color: var(--green);
}

.search-input::placeholder { color: var(--overlay0); font-weight: 300; }

.analyze-btn {
  background: var(--green);
  color: var(--crust);
  border: none;
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: 0.08em;
  padding: 0 24px;
  height: 100%;
  min-height: 54px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.2s, transform 0.1s;
  flex-shrink: 0;
}

.analyze-btn:hover { background: #b6eeaf; }
.analyze-btn:active { transform: scale(0.97); }
.analyze-btn.loading { opacity: 0.6; pointer-events: none; }

.btn-arrow {
  width: 18px; height: 18px;
  transition: transform 0.2s;
}
.analyze-btn:hover .btn-arrow { transform: translateX(3px); }

/* Mobile-only full-width analyze button */
.analyze-btn-mobile {
  display: none;
  width: 100%;
  margin-top: 12px;
  background: var(--green);
  color: var(--crust);
  border: none;
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 0.1em;
  padding: 16px;
  border-radius: 12px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: background 0.2s, transform 0.1s;
}
.analyze-btn-mobile:hover  { background: #b6eeaf; }
.analyze-btn-mobile:active { transform: scale(0.98); }
.analyze-btn-mobile.loading { opacity: 0.6; pointer-events: none; }

.error-msg {
  color: var(--red);
  font-size: 14px;
  margin-top: 12px;
  padding: 10px 14px;
  background: rgba(243, 139, 168, 0.1);
  border: 1px solid rgba(243, 139, 168, 0.25);
  border-radius: 8px;
}
.hidden { display: none !important; }

/* ===== LOADING ===== */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 60px 24px;
}

.grass-loader {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 48px;
}

.blade {
  width: 10px;
  background: var(--green);
  border-radius: 4px 4px 2px 2px;
  animation: grow 1s ease-in-out infinite;
  transform-origin: bottom;
}
.blade.b1 { height: 24px; animation-delay: 0s; }
.blade.b2 { height: 36px; animation-delay: 0.1s; }
.blade.b3 { height: 48px; animation-delay: 0.2s; }
.blade.b4 { height: 32px; animation-delay: 0.3s; }
.blade.b5 { height: 20px; animation-delay: 0.4s; }

@keyframes grow {
  0%, 100% { transform: scaleY(0.6); opacity: 0.5; }
  50%       { transform: scaleY(1);   opacity: 1;   }
}

.loading-text {
  color: var(--subtext0);
  font-size: 15px;
  letter-spacing: 0.04em;
}

/* ===== RESULT SECTION ===== */
.result-section {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 24px 48px;
  animation: slideUp 0.5s cubic-bezier(0.22,1,0.36,1) both;
}

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

.result-card {
  background: var(--mantle);
  border: 1px solid var(--surface1);
  border-radius: 20px;
  padding: 32px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.4);
  position: relative;
  overflow: hidden;
}

.result-card::before {
  content: '';
  position: absolute;
  top: -60px; right: -60px;
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(166,227,161,0.06) 0%, transparent 70%);
  pointer-events: none;
}

.result-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.result-avatar {
  width: 56px; height: 56px;
  background: var(--surface0);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  border: 1px solid var(--surface2);
}

.result-meta { flex: 1; }
.result-username {
  font-family: var(--font-display);
  font-size: 28px;
  letter-spacing: 0.04em;
  color: var(--text);
  line-height: 1;
}
.result-sub {
  color: var(--subtext0);
  font-size: 13px;
  margin-top: 3px;
}

.result-rank-badge {
  background: var(--surface0);
  border: 1px solid var(--surface2);
  border-radius: 12px;
  padding: 10px 18px;
  text-align: center;
  min-width: 80px;
}
.rank-num {
  display: block;
  font-family: var(--font-display);
  font-size: 28px;
  color: var(--peach);
  line-height: 1;
}
.rank-label {
  display: block;
  font-size: 10px;
  letter-spacing: 0.15em;
  color: var(--overlay1);
  margin-top: 2px;
}

/* Score Bar */
.score-display { margin-bottom: 12px; }

.score-track {
  position: relative;
  height: 12px;
  background: var(--surface0);
  border-radius: 100px;
  overflow: visible;
  margin-bottom: 8px;
}

.score-fill {
  height: 100%;
  border-radius: 100px;
  background: linear-gradient(90deg, var(--green), var(--yellow), var(--peach), var(--red));
  transition: width 1.2s cubic-bezier(0.22,1,0.36,1);
  position: relative;
}

.score-thumb {
  position: absolute;
  top: 50%; transform: translate(-50%, -50%);
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--text);
  border: 3px solid var(--mantle);
  box-shadow: 0 0 0 2px var(--green);
  transition: left 1.2s cubic-bezier(0.22,1,0.36,1);
  z-index: 2;
}

.score-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--overlay0);
  letter-spacing: 0.04em;
}

/* Big Score */
.score-big {
  text-align: center;
  margin: 24px 0;
}

#scoreBig {
  font-family: var(--font-display);
  font-size: 88px;
  line-height: 1;
  color: var(--green);
  text-shadow: 0 0 40px rgba(166,227,161,0.3);
  transition: color 0.5s;
}

.score-unit {
  font-family: var(--font-display);
  font-size: 32px;
  color: var(--overlay1);
  margin-left: 6px;
}

/* Verdict */
.verdict-box {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface0);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 28px;
  border: 1px solid var(--surface1);
}

.verdict-emoji { font-size: 32px; }
.verdict-text {
  font-size: 17px;
  font-weight: 500;
  color: var(--subtext1);
  line-height: 1.4;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}

.stat-item {
  background: var(--surface0);
  border: 1px solid var(--surface1);
  border-radius: 12px;
  padding: 14px 16px;
  transition: border-color 0.2s;
}
.stat-item:hover { border-color: var(--surface2); }

.stat-value {
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--text);
  line-height: 1;
  margin-bottom: 4px;
}
.stat-label {
  font-size: 11px;
  color: var(--overlay1);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Breakdown */
.breakdown-section {}
.breakdown-title {
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 0.18em;
  color: var(--overlay1);
  margin-bottom: 10px;
}
.breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.breakdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--surface0);
  border-radius: 8px;
  font-size: 13px;
  color: var(--subtext1);
}
.breakdown-item .b-label { display: flex; align-items: center; gap: 8px; }
.breakdown-item .b-pts {
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: 0.05em;
}
.b-pts.positive { color: var(--red); }
.b-pts.negative { color: var(--green); }

/* ===== LEADERBOARD ===== */
.leaderboard-section {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

.leaderboard-header {
  margin-bottom: 20px;
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
}
.leaderboard-title {
  font-family: var(--font-display);
  font-size: 42px;
  letter-spacing: 0.05em;
  color: var(--text);
}
.leaderboard-sub {
  color: var(--overlay0);
  font-size: 13px;
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lb-empty {
  text-align: center;
  color: var(--overlay0);
  padding: 48px;
  background: var(--mantle);
  border-radius: 16px;
  border: 1px dashed var(--surface1);
  font-size: 15px;
}

.lb-item {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--mantle);
  border: 1px solid var(--surface1);
  border-radius: 14px;
  padding: 14px 20px;
  transition: border-color 0.2s, transform 0.15s;
  cursor: pointer;
}
.lb-item:hover {
  border-color: var(--green);
  transform: translateX(4px);
}
.lb-item.is-you {
  border-color: var(--green);
  background: rgba(166,227,161,0.05);
}

.lb-rank {
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--overlay1);
  min-width: 40px;
  text-align: center;
}
.lb-item:nth-child(1) .lb-rank { color: var(--yellow); }
.lb-item:nth-child(2) .lb-rank { color: var(--subtext1); }
.lb-item:nth-child(3) .lb-rank { color: var(--peach); }

.lb-user { flex: 1; min-width: 0; } /* min-width:0 lets flex child shrink below content size */
.lb-name {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lb-meta {
  font-size: 12px;
  color: var(--overlay0);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-score {
  font-family: var(--font-display);
  font-size: 26px;
  color: var(--red);
  letter-spacing: 0.04em;
}

.lb-emoji { font-size: 22px; }

/* ===== MODAL ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(17, 17, 27, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease both;
}

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

.modal-card {
  background: var(--mantle);
  border: 1px solid var(--surface1);
  border-radius: 24px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 32px;
  position: relative;
  box-shadow: 0 40px 120px rgba(0,0,0,0.6);
  animation: modalUp 0.3s cubic-bezier(0.22,1,0.36,1) both;
}

@keyframes modalUp {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-close {
  position: absolute;
  top: 20px; right: 20px;
  background: var(--surface0);
  border: 1px solid var(--surface2);
  border-radius: 8px;
  color: var(--subtext0);
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  z-index: 10;
}
.modal-close:hover { background: var(--surface1); color: var(--text); }

.modal-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 48px 0;
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.modal-content { }

/* Reddit link button */
.reddit-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
  padding: 12px 20px;
  background: var(--surface0);
  border: 1px solid var(--surface2);
  border-radius: 10px;
  color: var(--peach);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.reddit-link:hover {
  background: var(--surface1);
  border-color: var(--peach);
  transform: translateY(-1px);
}

/* Scrollbar styling for modal */
.modal-card::-webkit-scrollbar { width: 6px; }
.modal-card::-webkit-scrollbar-track { background: transparent; }
.modal-card::-webkit-scrollbar-thumb { background: var(--surface2); border-radius: 3px; }

/* ===== FOOTER ===== */
.footer {
  border-top: 1px solid var(--surface0);
  padding: 24px;
  text-align: center;
  color: var(--overlay0);
  font-size: 13px;
}
.footer-accent { color: var(--green); }

/* ===== RESPONSIVE ===== */
@media (max-width: 560px) {
  .analyze-btn { display: none; }
  .analyze-btn-mobile { display: flex; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .result-header { flex-direction: column; align-items: flex-start; }
  #scoreBig { font-size: 64px; }
  .modal-card { padding: 24px 20px; }
  .search-card { padding: 24px 20px; }

  /* Hero: tighter padding on small screens */
  .hero { padding: 48px 16px 40px; }
  .hero-sub { font-size: 15px; }

  /* Leaderboard: tighter on small screens */
  .lb-item { gap: 10px; padding: 12px 14px; }
  .lb-rank { font-size: 18px; min-width: 28px; }
  .lb-name { font-size: 13px; }
  .lb-meta { font-size: 11px; }
  .lb-score { font-size: 20px; }
  .lb-emoji { font-size: 18px; }
}

@media (max-width: 360px) {
  .hero-title { font-size: clamp(28px, 9vw, 48px); letter-spacing: 0; }
  .hero-sub { font-size: 13px; }
}

/* ── Turnstile ───────────────────────────────────────────── */
.turnstile-wrap {
  margin-top: 14px;
  display: flex;
  justify-content: center;
}

.cf-turnstile {
  width: 100%;
}
