:root {
  --bg: #0c0f0a;
  --surface: #141a10;
  --surface2: #1e2819;
  --border: #2d3d25;
  --text: #e8eddf;
  --text-muted: #8a9b79;
  --accent: #c8b400;
  --green: #4a7c35;
  --red: #c0445a;
  --orange: #d07030;
}

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

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── HEADER ── */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 1000;
  flex-shrink: 0;
}
.logo {
  font-family: 'Playfair Display', serif;
  font-size: 20px;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: -0.5px;
}
.logo span { color: var(--text); }
#progress-dots { display: flex; gap: 7px; align-items: center; }
.dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--border); transition: background 0.4s, transform 0.2s;
}
.dot.active { background: var(--accent); transform: scale(1.3); }
.dot.done { background: var(--green); }
#header-stats { display: flex; align-items: center; gap: 16px; }
.stat-block { text-align: right; }
.stat-label { font-size: 9px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-muted); }
.stat-val { font-family: 'Playfair Display', serif; font-size: 19px; color: var(--accent); line-height: 1.1; }

/* ── MAP ── */
#map-wrap { flex: 1; position: relative; }
#leaflet-map { width: 100%; height: 100%; }
#leaflet-map.guessing { cursor: crosshair !important; }

/* ── ANIMAL CARD ── */
#animal-card {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  z-index: 900; background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px;
  padding: 18px 26px; text-align: center; min-width: 270px; max-width: 340px;
  box-shadow: 0 18px 56px rgba(0,0,0,0.55);
  transition: opacity 0.3s, transform 0.3s;
}
#animal-card.hidden { opacity: 0; pointer-events: none; transform: translateX(-50%) translateY(-10px); }
.animal-name {
  font-family: 'Playfair Display', serif; font-size: 24px; font-weight: 700;
  color: var(--text); margin-bottom: 3px;
}
.animal-sci { font-style: italic; color: var(--text-muted); font-size: 12px; margin-bottom: 10px; }
.animal-tag {
  display: inline-block; font-size: 11px; color: var(--green);
  background: rgba(74,124,53,0.18); border: 1px solid rgba(74,124,53,0.35);
  border-radius: 20px; padding: 3px 12px; margin-bottom: 14px;
}
.card-instruction { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }

/* ── CARD THUMBNAIL ── */
.card-thumb-wrap {
  width: 82px; height: 82px; border-radius: 50%; overflow: hidden;
  margin: 0 auto 10px; border: 2px solid var(--border);
  background: var(--surface2); position: relative; flex-shrink: 0;
}
.card-thumb-wrap img {
  width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity 0.4s ease;
}
.card-thumb-wrap img.loaded { opacity: 1; }
.card-thumb-emoji {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 36px; transition: opacity 0.3s;
}

/* ── RESULT PHOTO ── */
#result-panel { min-width: 340px; }
.result-photo-wrap {
  width: 100%; height: 155px; border-radius: 9px; overflow: hidden;
  margin-bottom: 14px; background: var(--surface2); position: relative;
}
.result-photo-wrap img {
  width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity 0.45s ease;
}
.result-photo-wrap img.loaded { opacity: 1; }
.result-photo-credit {
  position: absolute; bottom: 6px; right: 8px;
  font-size: 9px; color: rgba(255,255,255,0.45);
  background: rgba(0,0,0,0.45); border-radius: 4px; padding: 2px 6px;
  letter-spacing: 0.3px;
}

/* ── BUTTONS ── */
.btn {
  padding: 9px 22px; border-radius: 8px; border: none;
  cursor: pointer; font-family: 'DM Sans', sans-serif;
  font-size: 13px; font-weight: 600; transition: all 0.18s ease;
  letter-spacing: 0.2px;
}
.btn-primary { background: var(--accent); color: #000; }
.btn-primary:hover:not(:disabled) { background: #dac700; transform: translateY(-1px); box-shadow: 0 4px 20px rgba(200,180,0,0.3); }
.btn-primary:disabled { opacity: 0.4; cursor: default; }
.btn-ghost {
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--border); font-size: 12px;
}
.btn-ghost:hover { background: var(--surface2); color: var(--text); }

/* ── TROPHY BUTTON ── */
.btn-trophy {
  background: transparent; border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 14px; color: var(--text-muted);
  font-size: 13px; cursor: pointer; font-family: 'DM Sans', sans-serif;
  transition: all 0.18s ease;
}
.btn-trophy:hover { border-color: var(--accent); color: var(--accent); }

/* ── CROSSHAIR HINT ── */
#crosshair-hint {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  z-index: 900; pointer-events: none;
  background: rgba(200,180,0,0.12); border: 1px solid rgba(200,180,0,0.3);
  border-radius: 8px; padding: 7px 18px;
  font-size: 12px; color: var(--accent); white-space: nowrap;
  transition: opacity 0.3s;
}
#crosshair-hint.hidden { opacity: 0; }

/* ── LOADING ── */
#loading {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%,-50%); z-index: 2000;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 28px 36px; text-align: center;
  display: none;
}
#loading.visible { display: block; }
.spinner {
  width: 36px; height: 36px; margin: 0 auto 14px;
  border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 13px; color: var(--text-muted); }

/* ── RESULT PANEL ── */
#result-panel {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  z-index: 900; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 18px 28px; text-align: center;
  box-shadow: 0 18px 56px rgba(0,0,0,0.55);
  display: none; animation: slideUp 0.35s ease;
}
@keyframes slideUp {
  from { opacity:0; transform:translateX(-50%) translateY(16px); }
  to   { opacity:1; transform:translateX(-50%) translateY(0); }
}
#result-panel.visible { display: block; }
.result-pts {
  font-family: 'Playfair Display', serif;
  font-size: 52px; font-weight: 900; line-height: 1;
  margin-bottom: 3px;
}
.pts-excellent { color: #6abf4b; }
.pts-good      { color: var(--accent); }
.pts-ok        { color: var(--orange); }
.pts-miss      { color: var(--red); }
.result-dist { font-size: 13px; color: var(--text-muted); margin-bottom: 14px; }
.result-actions { display: flex; gap: 10px; justify-content: center; }

/* ── END SCREEN ── */
#end-screen {
  position: absolute; inset: 0; z-index: 3000;
  background: rgba(12,15,10,0.96);
  display: none; align-items: center; justify-content: center;
  flex-direction: column; text-align: center;
}
#end-screen.visible { display: flex; animation: fadeIn 0.5s ease; }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
.end-logo { font-family: 'Playfair Display', serif; font-size: 32px; font-weight: 900; color: var(--accent); margin-bottom: 6px; }
.end-sub { color: var(--text-muted); font-size: 14px; margin-bottom: 36px; }
.end-score-big {
  font-family: 'Playfair Display', serif; font-size: 90px; font-weight: 900;
  color: var(--text); line-height: 1; margin-bottom: 4px;
}
.end-denom { font-size: 13px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 2px; margin-bottom: 16px; }
.end-grade { font-size: 17px; color: var(--accent); margin-bottom: 36px; }
.end-breakdown { display: flex; gap: 12px; margin-bottom: 32px; flex-wrap: wrap; justify-content: center; }
.end-round-pill {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 16px; font-size: 13px;
}
.end-round-pill .rp-label { color: var(--text-muted); font-size: 10px; text-transform: uppercase; letter-spacing: 1px; }
.end-round-pill .rp-val { font-family: 'Playfair Display', serif; font-size: 18px; color: var(--accent); }

/* ── LEADERBOARD ── */
#lb-screen {
  position: absolute; inset: 0; z-index: 4000;
  background: rgba(12,15,10,0.97);
  display: none; align-items: center; justify-content: center;
  flex-direction: column; text-align: center;
}
#lb-screen.visible { display: flex; animation: fadeIn 0.4s ease; }
.lb-title { font-family: 'Playfair Display', serif; font-size: 28px; font-weight: 900; color: var(--accent); margin-bottom: 4px; }
.lb-sub { font-size: 13px; color: var(--text-muted); margin-bottom: 28px; }
.lb-table { width: 420px; max-width: 90vw; }
.lb-row {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 16px; border-radius: 10px; margin-bottom: 6px;
  background: var(--surface); border: 1px solid var(--border);
}
.lb-row.you      { border-color: var(--accent); background: rgba(200,180,0,0.08); }
.lb-row.gold-row { border-color: #f5c518; background: rgba(245,197,24,0.06); }
.lb-rank  { font-family: 'Playfair Display', serif; font-size: 18px; color: var(--text-muted); width: 28px; text-align: center; flex-shrink: 0; }
.lb-name  { flex: 1; text-align: left; font-size: 14px; font-weight: 500; }
.lb-score { font-family: 'Playfair Display', serif; font-size: 18px; color: var(--accent); }
.lb-empty { color: var(--text-muted); font-size: 14px; padding: 40px; }

/* ── NAME INPUT ── */
.name-input-wrap { display: flex; gap: 8px; margin-bottom: 20px; }
.name-input {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 16px; color: var(--text);
  font-family: 'DM Sans', sans-serif; font-size: 14px;
  width: 220px; outline: none; transition: border-color 0.2s;
}
.name-input:focus { border-color: var(--accent); }
.name-input::placeholder { color: var(--text-muted); }

/* ── INTRO SCREEN ── */
#intro-screen {
  position: absolute; inset: 0; z-index: 3000;
  background: rgba(12,15,10,0.97);
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; text-align: center;
}
.intro-logo {
  font-family: 'Playfair Display', serif; font-size: 56px; font-weight: 900;
  color: var(--accent); margin-bottom: 8px; letter-spacing: -2px;
}
.intro-logo span { color: var(--text); }
.intro-tagline { font-size: 16px; color: var(--text-muted); margin-bottom: 40px; max-width: 340px; line-height: 1.6; }
.intro-how { max-width: 380px; text-align: left; margin-bottom: 36px; }
.how-item { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 16px; }
.how-num {
  width: 26px; height: 26px; border-radius: 50%; background: var(--accent);
  color: #000; font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.how-text { font-size: 14px; color: var(--text-muted); line-height: 1.5; }
.how-text strong { color: var(--text); }