@import url('https://fonts.googleapis.com/css2?family=Overpass:wght@400;500;600;700;800&family=Young+Serif&display=swap');

:root {
  --paper: #ecefe7;
  --card: #f6f8f2;
  --surface: #ffffff;
  --ink: #17231d;
  --muted: #4d5d53;
  --line: #c5cec2;
  --line-soft: #d9e0d6;

  --sign-green: #00693b;
  --sign-green-dark: #004e2b;
  --sign-brown: #6e4426;
  --sign-yellow: #f7cb15;
  --gorse: #e6a817;
  --gorse-soft: #f8efd2;
  --gorse-ink: #382800;
  --urgent: #c43e2b;
  --urgent-soft: #faeae7;

  --hud-bg: rgba(246, 248, 242, 0.84);
  --hud-border: rgba(255, 255, 255, 0.65);
  --top-hud-bg: rgba(20, 38, 30, 0.56);

  --display: "Young Serif", Georgia, "Times New Roman", serif;
  --body: "Overpass", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --radius: 16px;
}

[data-theme="dark"] {
  --paper: #0f1713;
  --card: #16201b;
  --surface: #1e2c25;
  --ink: #e3eae3;
  --muted: #98aa9e;
  --line: #2b3932;
  --line-soft: #223029;
  --sign-green: #168553;
  --sign-green-dark: #0d623b;
  --gorse-soft: #312810;
  --gorse-ink: #f5d376;
  --urgent-soft: #341b18;
  --hud-bg: rgba(20, 31, 26, 0.84);
  --hud-border: rgba(255, 255, 255, 0.14);
  --top-hud-bg: rgba(11, 20, 17, 0.72);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--sign-green);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ==================== FULL-BLEED 3D GAME STAGE ==================== */
.stage-3d {
  position: relative;
  width: 100%;
  height: 100dvh;
  min-height: 640px;
  overflow: hidden;
  background: #cde3ea;
}

#canvas-host {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}
#canvas-host canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* Top Translucent HUD Bar (Matching Mockup v2) */
.hud-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  background: var(--top-hud-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.brand-sign {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--sign-green);
  color: #ffffff;
  padding: 5px 14px 5px 12px;
  border-radius: 6px;
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.85), 0 4px 12px rgba(0, 0, 0, 0.2);
  text-decoration: none;
  flex-shrink: 0;
}
.brand-sign:hover {
  text-decoration: none;
}
.brand-sign-main {
  font-family: var(--display);
  font-size: 1.15rem;
  line-height: 1;
}
.brand-sign-sub {
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.92;
  border-left: 1px solid rgba(255, 255, 255, 0.45);
  padding-left: 8px;
}

/* 7-Dot Stop Progress Bar in Top HUD */
.hud-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 340px;
  justify-content: center;
}

.hud-dot {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1.5px solid rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.82);
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}
.hud-dot.current {
  border-color: var(--sign-yellow);
  background: var(--sign-yellow);
  color: var(--gorse-ink);
  transform: scale(1.14);
}
.hud-dot.done {
  background: rgba(255, 255, 255, 0.92);
  border-color: #ffffff;
}
.hud-dot.eagle {
  background: var(--gorse-soft);
  border-color: var(--gorse);
  box-shadow: 0 0 12px rgba(247, 203, 21, 0.55);
}
.hud-dot svg {
  width: 22px;
  height: 22px;
  display: block;
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.odometer-pill {
  background: rgba(255, 255, 255, 0.92);
  color: #17231d;
  font-size: 0.82rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  padding: 5px 12px;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16);
}

.hud-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  min-width: 30px;
  padding: 0 8px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  border-radius: 999px;
  font-family: var(--body);
  font-size: 0.74rem;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.15s ease;
}
.hud-icon-btn:hover {
  background: rgba(255, 255, 255, 0.28);
}

/* Floating Compact Mode & Region Pills below Top Bar */
.hud-subbar {
  position: absolute;
  top: 64px;
  left: 16px;
  right: 16px;
  z-index: 9;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.hud-pill-group {
  pointer-events: auto;
  display: inline-flex;
  background: rgba(20, 38, 30, 0.48);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}

.hud-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
  padding: 4px 11px;
  border-radius: 999px;
  font-family: var(--body);
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.14s ease;
}
.hud-pill.active {
  background: #ffffff;
  color: #17231d;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.16);
}
.hud-pill:hover:not(.active) {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.14);
}

/* Floating 3D Score Burst above Hiker */
.world-score-float {
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%);
  z-index: 12;
  padding: 6px 18px;
  border-radius: 10px;
  background: rgba(16, 42, 32, 0.82);
  border: 2px solid var(--sign-yellow);
  color: #ffffff;
  font-family: var(--display);
  font-size: 1.75rem;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  animation: worldFloat 1.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.world-score-float.eagle {
  background: linear-gradient(135deg, #c9910e, #e6a817);
  color: #261b00;
  border-color: #ffffff;
  font-size: 2.05rem;
}
@keyframes worldFloat {
  0% { opacity: 0; transform: translate(-50%, 10px) scale(0.7); }
  20% { opacity: 1; transform: translate(-50%, -10px) scale(1.08); }
  100% { opacity: 0; transform: translate(-50%, -62px) scale(0.98); }
}

/* ==================== BOTTOM FROSTED-GLASS GAME CARD ==================== */
.hud-bottom-wrap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 22px;
  z-index: 11;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 14px;
  pointer-events: none;
}

.challenge-banner {
  pointer-events: auto;
  margin-bottom: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--gorse);
  color: var(--gorse-ink);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

.frosted-card {
  pointer-events: auto;
  width: 100%;
  max-width: 560px;
  background: var(--hud-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1.5px solid var(--hud-border);
  border-radius: 20px;
  padding: 18px 20px;
  box-shadow: 0 18px 46px rgba(10, 24, 18, 0.24);
  max-height: calc(100dvh - 132px);
  overflow-y: auto;
}

.prompt-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.category-sign {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--sign-green);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 4px 10px;
  border-radius: 5px;
  box-shadow: inset 0 0 0 1.2px rgba(255, 255, 255, 0.8);
}
.category-sign .stop-num {
  color: var(--sign-yellow);
}

.streak-badge {
  display: inline-flex;
  align-items: center;
  background: var(--gorse);
  color: var(--gorse-ink);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 5px;
}

/* Circular SVG Countdown Timer Ring */
.timer-ring-wrap {
  position: relative;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.timer-ring-svg {
  width: 40px;
  height: 40px;
  transform: rotate(-90deg);
}
.timer-ring-bg {
  fill: none;
  stroke: rgba(0, 0, 0, 0.12);
  stroke-width: 3.5;
}
.timer-ring-fg {
  fill: none;
  stroke: var(--sign-green);
  stroke-width: 3.5;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.35s linear, stroke 0.2s ease;
}
.timer-ring-wrap.warn .timer-ring-fg {
  stroke: var(--gorse);
}
.timer-ring-wrap.urgent .timer-ring-fg {
  stroke: var(--urgent);
}
.timer-ring-wrap.urgent {
  animation: heartbeat 0.85s ease-in-out infinite;
}
.timer-ring-text {
  position: absolute;
  font-size: 0.8rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.timer-ring-wrap.urgent .timer-ring-text {
  color: var(--urgent);
}
@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  35% { transform: scale(1.1); }
}

.prompt-text {
  font-family: var(--display);
  font-size: clamp(1.22rem, 2.8vw, 1.58rem);
  font-weight: 400;
  line-height: 1.25;
  text-align: center;
  margin: 4px 0 14px;
  color: var(--ink);
}

.answer-form {
  display: flex;
  gap: 9px;
}

.answer-input {
  flex: 1;
  min-width: 0;
  font-family: var(--body);
  font-size: 1.02rem;
  font-weight: 500;
  padding: 12px 15px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.answer-input:focus {
  border-color: var(--sign-green);
  box-shadow: 0 0 0 3px rgba(0, 105, 59, 0.16);
}
.answer-input.shake {
  animation: shakeX 0.32s ease;
  border-color: var(--urgent);
}
@keyframes shakeX {
  0%, 100% { transform: translateX(0); }
  25%, 75% { transform: translateX(-5px); }
  50% { transform: translateX(5px); }
}

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 11px 20px;
  font-family: var(--body);
  font-size: 0.92rem;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.14s ease, transform 0.08s ease, box-shadow 0.08s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-primary {
  background: var(--sign-green);
  color: #ffffff;
  box-shadow: 0 3px 0 var(--sign-green-dark);
}
.btn-primary:hover {
  background: #007d46;
}
.btn-primary:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--sign-green-dark);
}
.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
  box-shadow: 0 2px 0 var(--line);
}
.btn-secondary:hover {
  border-color: var(--sign-green);
}
.btn-secondary:active {
  transform: translateY(2px);
  box-shadow: none;
}

.retry-toast {
  margin-top: 8px;
  padding: 6px 11px;
  border-radius: 6px;
  background: var(--urgent-soft);
  border-left: 3px solid var(--urgent);
  color: var(--urgent);
  font-size: 0.8rem;
  font-weight: 700;
}

.helper-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 9px;
  font-size: 0.8rem;
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--sign-green);
  font-family: var(--body);
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
}
.link-btn:hover {
  text-decoration: underline;
}

.hint-box {
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--gorse-soft);
  border-left: 3px solid var(--gorse);
  color: var(--gorse-ink);
  font-size: 0.84rem;
  font-weight: 600;
}

/* Result Panel inside Frosted Card */
.result-panel {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  animation: fadeSlideUp 0.22s ease;
}
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.rarity-ladder {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 5px;
  margin-bottom: 12px;
}
.ladder-step {
  background: var(--surface);
  border: 1.5px solid var(--line-soft);
  border-radius: 8px;
  padding: 4px 2px;
  text-align: center;
  opacity: 0.3;
  transform: scale(0.94);
  transition: opacity 0.16s ease, transform 0.22s cubic-bezier(0.2, 1.4, 0.4, 1), border-color 0.16s ease;
}
.ladder-step svg {
  width: 24px;
  height: 24px;
  display: block;
  margin: 0 auto 1px;
}
.ladder-step span {
  display: block;
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--muted);
}
.ladder-step.lit {
  opacity: 0.85;
  transform: scale(1);
  border-color: var(--sign-green);
}
.ladder-step.winner {
  opacity: 1;
  transform: scale(1.07);
  border-color: var(--sign-green);
  box-shadow: 0 3px 10px rgba(0, 105, 59, 0.2);
}
.ladder-step.winner.eagle {
  border-color: var(--gorse);
  background: var(--gorse-soft);
}

.result-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.animal-badge {
  display: flex;
  align-items: center;
  gap: 10px;
}
.animal-medallion {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
}
.animal-medallion svg {
  width: 100%;
  height: 100%;
  display: block;
}
.animal-medallion.pop {
  animation: medallionSlam 0.4s cubic-bezier(0.18, 1.45, 0.38, 1);
}
@keyframes medallionSlam {
  0% { transform: scale(0.45); opacity: 0; }
  65% { transform: scale(1.16); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
.animal-title {
  font-family: var(--display);
  font-size: 1.12rem;
  line-height: 1.15;
}
.animal-sub {
  font-size: 0.82rem;
  color: var(--muted);
}

.score-pill {
  font-size: 0.96rem;
  font-weight: 800;
  padding: 5px 12px;
  border-radius: 7px;
  background: var(--sign-green);
  color: #ffffff;
}
.score-pill.eagle {
  background: var(--gorse);
  color: var(--gorse-ink);
}
.score-pill.zero {
  background: var(--muted);
}

.rare-examples {
  margin-top: 10px;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.rare-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}
.rare-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 2px 8px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink);
}
.rare-chip svg {
  width: 15px;
  height: 15px;
}

.next-row {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
}

/* Summary View inside Frosted Card */
.summary-box {
  text-align: center;
}
.summary-distance {
  font-family: var(--display);
  font-size: clamp(2rem, 5vw, 2.7rem);
  color: var(--ink);
  line-height: 1.05;
}
.summary-medallions {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 10px 0 12px;
}
.summary-medallions svg {
  width: 30px;
  height: 30px;
}
.summary-list {
  text-align: left;
  margin: 10px 0 14px;
  max-height: 180px;
  overflow-y: auto;
  border-top: 1px solid var(--line);
}
.summary-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 0.84rem;
}
.summary-right {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  white-space: nowrap;
}
.summary-right svg {
  width: 20px;
  height: 20px;
}
.summary-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

/* ==================== BELOW-THE-FOLD STATS, LEGEND & SEO ==================== */
.below-stage {
  max-width: 780px;
  margin: 0 auto;
  padding: 28px 16px 56px;
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 10px;
  text-align: center;
}
.stat-val {
  font-family: var(--display);
  font-size: 1.25rem;
  color: var(--ink);
}
.stat-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 700;
}

.tier-strip-wrap {
  margin-top: 16px;
}
.tier-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 10px;
}
.tier-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 8px;
  text-align: center;
}
.tier-card .tier-svg {
  width: 38px;
  height: 38px;
  margin: 0 auto 6px;
}
.tier-card .tier-svg svg {
  width: 100%;
  height: 100%;
}
.tier-card .name {
  font-weight: 800;
  font-size: 0.84rem;
}
.tier-card .pts {
  font-size: 0.76rem;
  color: var(--sign-green);
  font-weight: 700;
}

.ad-slot {
  margin: 22px auto;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.drawer-section {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 16px;
}
.drawer-section summary {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.drawer-section summary::-webkit-details-marker {
  display: none;
}
.drawer-section summary::after {
  content: "+";
  font-size: 1rem;
  font-weight: 700;
}
.drawer-section[open] summary::after {
  content: "−";
}
.drawer-body {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
  font-size: 0.86rem;
  color: var(--muted);
}

/* Subpages support (how-to-play / about / privacy / terms) */
.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  max-width: 840px;
  margin: 0 auto;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--display);
  font-size: 1.25rem;
  color: var(--ink);
}
.road-sign-badge {
  font-family: var(--body);
  background: var(--sign-green);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 7px;
  border-radius: 4px;
}
.nav-links {
  display: flex;
  gap: 16px;
  font-size: 0.86rem;
  font-weight: 600;
}
.container {
  max-width: 780px;
  margin: 0 auto;
  padding: 24px 16px 56px;
}
.guide-section {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px;
}
.guide-section h1, .guide-section h2 {
  font-family: var(--display);
  font-weight: 400;
}

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--card);
  padding: 22px 16px;
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
}
.footer-links {
  display: flex;
  justify-content: center;
  gap: 18px;
  font-weight: 600;
}

.hidden {
  display: none !important;
}

@media (max-width: 680px) {
  .hud-progress {
    display: none;
  }
  .hud-top {
    padding: 8px 12px;
  }
  .hud-subbar {
    top: 56px;
    justify-content: center;
  }
  .frosted-card {
    padding: 14px 14px;
  }
  .stats-strip {
    grid-template-columns: repeat(2, 1fr);
  }
}
