/* ==================================================================== *
 * GuessClip — "The Expedition" design system.
 *
 * One visual language everywhere: midnight-navy surfaces, gold as the
 * reward/action colour, parchment for text, teal for "your guess",
 * coral for "X marks the spot". Cinzel is reserved for display moments
 * (titles, ranks, scores); Inter carries all functional UI.
 * ==================================================================== */

:root {
  /* surfaces */
  --ink-0: #05070f;
  --ink-1: #0a0e1e;
  --ink-2: #0c1226;
  --ink-3: #131b3d;
  --surface: rgba(12, 18, 38, 0.72);

  /* palette */
  --gold: #f0cf87;
  --gold-deep: #c8972f;
  --gold-soft: #e8c26a;
  --gold-pale: #fff5da;
  --parchment: #ece0c8;
  --teal: #57c7be;
  --coral: #ff7a59;
  --danger: #ff6b6b;

  /* text */
  --text: #e8eaf2;
  --muted: #9aa0b5;

  /* strokes */
  --line-gold: rgba(240, 207, 135, 0.28);
  --line-gold-soft: rgba(240, 207, 135, 0.16);
  --line-parchment: rgba(236, 224, 200, 0.18);

  /* type */
  --font-display: "Cinzel", serif;
  --font-ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* layout */
  --topbar-h: 56px;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  color: var(--text);
  font-family: var(--font-ui);
  background:
    radial-gradient(1200px 900px at 50% -12%, var(--ink-3) 0%, var(--ink-1) 55%, var(--ink-0) 100%)
    fixed;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }

.ico { width: 16px; height: 16px; display: inline-block; vertical-align: middle; flex: none; }

/* Screen + overlay entrances (display flips get a soft fade/rise) */
.screen { padding: 14px; }
.screen:not(.hidden) { animation: screen-in 0.4s ease both; }
@keyframes screen-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* ==================================================================== *
 * Buttons
 * ==================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 10px;
  padding: 12px 22px;
  font-size: 15px;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.2s ease, filter 0.2s ease, background 0.2s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { cursor: not-allowed; }
.btn kbd {
  font: 600 10px var(--font-ui);
  padding: 2px 6px;
  border: 1px solid currentColor;
  border-radius: 5px;
  opacity: 0.55;
}

.btn-primary {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #2a1c00;
  background: linear-gradient(180deg, #fbe6ad 0%, var(--gold) 45%, var(--gold-deep) 100%);
  border: 1px solid rgba(255, 245, 218, 0.5);
  box-shadow: 0 6px 20px rgba(200, 151, 47, 0.3);
}
.btn-primary:hover:not(:disabled) {
  filter: brightness(1.06);
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(200, 151, 47, 0.45);
}
.btn-primary:disabled {
  color: #6b6450;
  background: rgba(236, 224, 200, 0.12);
  border-color: var(--line-parchment);
  box-shadow: none;
}

.btn-ghost {
  font: 600 14px var(--font-ui);
  color: var(--gold-soft);
  background: rgba(236, 224, 200, 0.06);
  border: 1px solid rgba(240, 207, 135, 0.35);
}
.btn-ghost:hover { background: rgba(240, 207, 135, 0.12); }

/* ==================================================================== *
 * Topbar — in-game HUD
 * ==================================================================== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: var(--topbar-h);
  padding: 0 16px;
  background: rgba(10, 14, 30, 0.82);
  border-bottom: 1px solid var(--line-gold);
  backdrop-filter: blur(8px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 6px 12px 6px 8px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.1s ease;
}
.brand:hover {
  border-color: rgba(240, 207, 135, 0.4);
  background: rgba(240, 207, 135, 0.07);
}
.brand:active { transform: translateY(1px); }
.brand-compass {
  width: 20px;
  height: 20px;
  color: var(--gold);
  filter: drop-shadow(0 0 6px rgba(240, 207, 135, 0.5));
}
.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.5px;
  background: linear-gradient(180deg, var(--gold-pale), var(--gold) 60%, var(--gold-deep));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hud { display: flex; align-items: center; gap: 8px; }
.hud-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: 600 13px var(--font-ui);
  color: var(--parchment);
  background: rgba(236, 224, 200, 0.06);
  border: 1px solid var(--line-parchment);
  border-radius: 999px;
  padding: 6px 13px;
  font-variant-numeric: tabular-nums;
}
.hud-mode {
  color: var(--gold-soft);
  letter-spacing: 0.4px;
  text-transform: uppercase;
  font-size: 11.5px;
}

/* round progress pips */
.pips { display: inline-flex; gap: 5px; }
.pip {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid rgba(240, 207, 135, 0.45);
  background: transparent;
  transition: background 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}
.pip.done { background: var(--gold); border-color: var(--gold); }
.pip.current {
  border-color: var(--gold);
  background: rgba(240, 207, 135, 0.35);
  box-shadow: 0 0 6px rgba(240, 207, 135, 0.8);
}
.pips-label { font-size: 11.5px; color: var(--muted); }

.hud-score {
  color: #06210f;
  background: linear-gradient(180deg, var(--gold-soft), var(--gold-deep));
  border-color: transparent;
  font-weight: 700;
}
.hud-score .ico { width: 15px; height: 15px; }
.hud-score.bump { animation: score-bump 0.45s cubic-bezier(0.3, 1.6, 0.4, 1); }
@keyframes score-bump {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.14); }
  100% { transform: scale(1); }
}

/* topbar user chip */
.user-area { display: flex; align-items: center; gap: 8px; }
.user-area.signed-in {
  padding-left: 10px;
  margin-left: 4px;
  border-left: 1px solid rgba(240, 207, 135, 0.25);
}
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 4px 10px 4px 5px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.user-chip:hover {
  border-color: rgba(240, 207, 135, 0.4);
  background: rgba(240, 207, 135, 0.07);
}
.user-chip img {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid rgba(240, 207, 135, 0.5);
}
.user-chip .user-name {
  font: 500 13px var(--font-ui);
  color: var(--parchment);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==================================================================== *
 * Cards (result / final / confirm)
 * ==================================================================== */
.card {
  max-width: 560px;
  margin: 6vh auto;
  background: linear-gradient(180deg, rgba(22, 28, 54, 0.96), rgba(12, 16, 34, 0.96));
  border: 1px solid rgba(240, 207, 135, 0.35);
  border-radius: 18px;
  padding: 30px 32px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 245, 218, 0.12);
}
.card h1, .card h2 {
  font-family: var(--font-display);
  letter-spacing: 1px;
  margin-top: 0;
  background: linear-gradient(180deg, var(--gold-pale), var(--gold) 55%, var(--gold-deep));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.card p { color: var(--muted); line-height: 1.6; }

/* ==================================================================== *
 * EXPEDITION HOME SCREEN
 * Original SVG/CSS art + animation. No external imagery.
 * ==================================================================== */
#start-screen.hunt {
  position: fixed;
  inset: 0;
  z-index: 2000;
  padding: 0;
  overflow-y: auto;
  background:
    radial-gradient(1200px 800px at 50% 38%, #16204a 0%, var(--ink-2) 45%, #060812 100%);
  font-family: var(--font-ui);
}

/* ---- Background layers (fixed so they don't scroll with the hero) ---- */
.hunt-bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; }

/* faint cartographic lat/long grid + globe curvature */
.hunt-lat {
  position: absolute;
  inset: -10%;
  background-image:
    linear-gradient(rgba(240, 207, 135, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(240, 207, 135, 0.05) 1px, transparent 1px),
    radial-gradient(circle at 50% 40%, rgba(87, 199, 190, 0.08), transparent 60%);
  background-size: 46px 46px, 46px 46px, 100% 100%;
  animation: grid-drift 40s linear infinite;
}
@keyframes grid-drift {
  from { transform: translate3d(0, 0, 0); }
  to   { transform: translate3d(-46px, -46px, 0); }
}

/* compass rose */
.hunt-compass {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(70vh, 620px);
  height: min(70vh, 620px);
  transform: translate(-50%, -52%);
  opacity: 0.16;
  animation: spin 90s linear infinite;
  will-change: transform;
}
.hunt-compass .cmp-ring { fill: none; stroke: var(--gold); stroke-width: 1.2; }
.hunt-compass .cmp-ring-2 { stroke-dasharray: 4 10; opacity: 0.7; }
.hunt-compass .cmp-ticks line { stroke: var(--gold); stroke-width: 2.5; }
.hunt-compass .cmp-needle-n { fill: var(--gold-deep); }
.hunt-compass .cmp-needle-s { fill: rgba(236, 224, 200, 0.5); }
.hunt-compass .cmp-label {
  fill: var(--gold); font-family: var(--font-display); font-size: 15px;
  text-anchor: middle; font-weight: 700;
}
@keyframes spin { to { transform: translate(-50%, -52%) rotate(360deg); } }

/* animated travel routes */
.hunt-routes { position: absolute; inset: 0; width: 100%; height: 100%; }
.hunt-routes .route {
  fill: none;
  stroke: var(--teal);
  stroke-width: 2.5;
  stroke-dasharray: 10 12;
  opacity: 0.5;
  filter: drop-shadow(0 0 6px rgba(87, 199, 190, 0.5));
  animation: route-flow 6s linear infinite;
}
.hunt-routes .route-2 { animation-duration: 8s; opacity: 0.32; }
@keyframes route-flow { to { stroke-dashoffset: -220; } }

.hunt-routes .pin circle {
  fill: var(--gold);
  filter: drop-shadow(0 0 8px rgba(240, 207, 135, 0.9));
  transform-box: fill-box;
  transform-origin: center;
  animation: pin-pulse 2.4s ease-in-out infinite;
  animation-delay: var(--d, 0s);
}
@keyframes pin-pulse {
  0%, 100% { transform: scale(0.7); opacity: 0.6; }
  50%      { transform: scale(1.25); opacity: 1; }
}
.hunt-routes .xmark line {
  stroke: var(--coral); stroke-width: 4; stroke-linecap: round;
  filter: drop-shadow(0 0 8px rgba(255, 122, 89, 0.9));
  animation: x-throb 2s ease-in-out infinite;
}
@keyframes x-throb {
  0%, 100% { opacity: 0.75; }
  50%      { opacity: 1; }
}

/* drifting dust particles (populated by JS) */
.hunt-dust { position: absolute; inset: 0; overflow: hidden; }
.hunt-dust .dust {
  position: absolute;
  bottom: -12px;
  width: 3px; height: 3px;
  border-radius: 50%;
  background: rgba(240, 207, 135, 0.7);
  box-shadow: 0 0 6px rgba(240, 207, 135, 0.6);
  animation: dust-rise linear infinite;
}
@keyframes dust-rise {
  0%   { transform: translateY(0) translateX(0); opacity: 0; }
  10%  { opacity: 0.8; }
  90%  { opacity: 0.6; }
  100% { transform: translateY(-104vh) translateX(var(--dx, 24px)); opacity: 0; }
}

.hunt-vignette {
  position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 42%, transparent 42%, rgba(3, 5, 12, 0.72) 100%);
  pointer-events: none;
}

/* ---- Foreground hero ---- */
.hunt-hero {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 7vh 24px 56px;
  max-width: 860px;
  margin: 0 auto;
  will-change: transform;
}
.hunt-kicker {
  font-family: var(--font-display);
  letter-spacing: 4px;
  font-size: 13px;
  color: var(--gold-soft);
  margin: 0 0 14px;
  opacity: 0;
  animation: rise-in 0.7s ease-out 0.1s forwards;
}
.hunt-title {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(44px, 8vw, 90px);
  line-height: 1.14;
  margin: 0;
  letter-spacing: 2px;
  display: inline-block;
  padding: 0.06em 0.16em;      /* room so background-clip doesn't trim glyphs */
  overflow: visible;
  white-space: nowrap;
  background: linear-gradient(180deg, var(--gold-pale) 0%, var(--gold) 42%, var(--gold-deep) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 6px 30px rgba(200, 151, 47, 0.35);
  position: relative;
  opacity: 0;
  animation: rise-in 0.9s cubic-bezier(.2,.7,.2,1) 0.25s forwards;
}
/* shimmer sweep across the title */
.hunt-title::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.65) 50%, transparent 60%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  mix-blend-mode: screen;
  animation: shimmer 4.5s ease-in-out 1.4s infinite;
}
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  60%, 100% { background-position: 200% 0; }
}
.hunt-sub {
  color: #b9c0d6;
  font-size: clamp(15px, 1.8vw, 17px);
  line-height: 1.65;
  max-width: 540px;
  margin: 14px auto 0;
  opacity: 0;
  animation: rise-in 0.8s ease-out 0.5s forwards;
}

/* how-to-play strip */
.hunt-steps {
  display: flex;
  gap: 10px 26px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 22px 0 0;
  opacity: 0;
  animation: rise-in 0.8s ease-out 0.65s forwards;
}
.step {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: 500 13px var(--font-ui);
  color: #b9c0d6;
}
.step .ico { width: 17px; height: 17px; color: var(--gold-soft); }
.step-n {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(240, 207, 135, 0.5);
  color: var(--gold-soft);
  font: 700 10px/17px var(--font-ui);
  text-align: center;
}

/* Daily Challenge featured card */
.daily-wrap {
  margin-top: 34px;
  opacity: 0;
  animation: rise-in 0.7s ease-out 0.75s forwards;
  min-height: 10px;
}
.daily-card {
  max-width: 460px;
  margin: 0 auto;
  padding: 20px 24px 18px;
  border-radius: var(--radius);
  border: 1px solid rgba(240, 207, 135, 0.55);
  background: linear-gradient(180deg, rgba(240, 207, 135, 0.12), rgba(236, 224, 200, 0.03));
  box-shadow: 0 10px 34px rgba(200, 151, 47, 0.18);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
}
.daily-title {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 2.5px;
  font-size: 15px;
  color: var(--gold-pale);
  margin: 0;
}
.daily-sub { font-size: 12.5px; color: var(--muted); margin: 0; line-height: 1.5; }
.daily-btn { padding: 11px 30px; font-size: 15px; }
.daily-resets { font-variant-numeric: tabular-nums; }
.daily-score { font: 500 14px var(--font-ui); color: var(--parchment); margin: 0; }
.daily-score strong { color: var(--gold); font-variant-numeric: tabular-nums; }
.daily-card.is-done { border-color: rgba(240, 207, 135, 0.3); box-shadow: none; }

/* mode picker */
.hunt-choose {
  font-family: var(--font-display);
  letter-spacing: 3px;
  font-size: 12px;
  color: var(--gold-soft);
  margin: 30px 0 16px;
  opacity: 0;
  animation: rise-in 0.7s ease-out 0.85s forwards;
}
.hunt-modes {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
  opacity: 0;
  animation: rise-in 0.7s ease-out 0.9s forwards;
}
.mode-card {
  width: 176px;
  padding: 22px 16px 20px;
  border-radius: var(--radius);
  border: 1px solid rgba(240, 207, 135, 0.25);
  background: linear-gradient(180deg, rgba(236, 224, 200, 0.07), rgba(236, 224, 200, 0.02));
  color: var(--parchment);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  text-align: center;
  font-family: var(--font-ui);
  transition: transform 0.15s ease, border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.mode-card:hover, .mode-card:focus-visible {
  transform: translateY(-4px);
  border-color: rgba(240, 207, 135, 0.65);
  background: linear-gradient(180deg, rgba(240, 207, 135, 0.12), rgba(236, 224, 200, 0.03));
  box-shadow: 0 14px 34px rgba(200, 151, 47, 0.25);
  outline: none;
}
.mode-card:active { transform: translateY(-1px); }
.mode-ico { width: 36px; height: 36px; color: var(--gold-soft); }
.mode-ico svg { width: 100%; height: 100%; }
.mode-label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  color: var(--gold-pale);
  letter-spacing: 0.5px;
}
.modes-loading { color: var(--muted); font-size: 13.5px; font-style: italic; }

@keyframes rise-in {
  from { opacity: 0; transform: translateY(22px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Home sign-in area */
.hunt-auth {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 34px;
  opacity: 0;
  animation: rise-in 0.8s ease-out 1.05s forwards;
}
#gis-button { min-height: 40px; }
.auth-hint { color: var(--muted); font-size: 12.5px; margin: 0; }

/* Recent hunts list */
.hunt-history {
  margin: 32px auto 0;
  max-width: 460px;
  text-align: left;
}
.history-title {
  font-family: var(--font-display);
  color: var(--gold-soft);
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin: 0 0 8px;
  text-align: center;
}
.history-list { list-style: none; padding: 0; margin: 0; }
.history-list li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 8px 12px;
  border: 1px solid rgba(240, 207, 135, 0.14);
  border-radius: 10px;
  background: rgba(236, 224, 200, 0.04);
  margin-bottom: 6px;
  font-size: 13px;
}
.history-mode { color: var(--parchment); font-weight: 600; }
.history-score { color: var(--gold); font-variant-numeric: tabular-nums; }
.history-when { color: var(--muted); font-size: 12px; }
.history-wip { color: #ff9d9d; }
.history-empty { color: var(--muted); font-style: italic; text-align: center; border: none; background: none; }

/* ==================================================================== *
 * PROFILE SCREEN — identity, lifetime stats, past games
 * ==================================================================== */
.profile-card { max-width: 620px; text-align: left; }
.profile-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}
.profile-pic {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid rgba(240, 207, 135, 0.5);
  flex: none;
}
.profile-id { flex: 1; min-width: 0; }
.profile-card .profile-id h1 {
  font-size: 24px;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.profile-email {
  font-size: 12.5px;
  color: var(--muted);
  margin: 2px 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.profile-head .btn { flex: none; padding: 9px 16px; font-size: 13px; }

.profile-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 22px;
}
.pstat {
  border: 1px solid var(--line-gold-soft);
  border-radius: 12px;
  background: rgba(236, 224, 200, 0.04);
  padding: 12px 10px;
  text-align: center;
}
.pstat b {
  display: block;
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 700;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.pstat span {
  display: block;
  margin-top: 3px;
  font-size: 10.5px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--muted);
}

.profile-sub {
  font-size: 15px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin: 0 0 10px;
}
.profile-list { max-height: 320px; overflow-y: auto; }
#profile-play { display: block; margin: 20px auto 0; }

/* ==================================================================== *
 * GAME STAGE — big video with a map overlay
 * ==================================================================== */
.stage {
  position: relative;
  height: calc(100vh - var(--topbar-h) - 28px);
  height: calc(100dvh - var(--topbar-h) - 28px);
  min-height: 420px;
}

/* Video fills the whole stage */
.video-pane { position: absolute; inset: 0; }
#player-wrap {
  position: relative;
  height: 100%;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line-gold-soft);
}
#player, #player iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
/* The YouTube API REPLACES <div id="player"> with an <iframe id="player">
   (it keeps the id), so we must disable pointer events on #player itself, not a
   descendant iframe. This makes the whole video non-interactive: no clickable
   cursor, no hover chrome, and no click-through to youtube.com. */
#player,
#player iframe,
iframe#player { pointer-events: none !important; }

/* Opaque masks that hide residual YouTube chrome. */
.chrome-mask {
  position: absolute;
  z-index: 5;
  background: #000;
  pointer-events: none;
}
/* Covers the video title + channel name that render along the top edge. */
.chrome-mask-top {
  top: 0;
  left: 0;
  right: 0;
  height: 84px;
}
/* Covers the bottom row where YouTube shows the logo, share, watch-later and
   the "More videos" strip. Sits in the letterbox area so no footage is lost. */
.chrome-mask-bottom {
  left: 0;
  right: 0;
  bottom: 0;
  height: 100px;
}

/* compass spinner while the clip buffers */
.video-loading {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.spin-compass {
  width: 54px;
  height: 54px;
  color: var(--gold-soft);
  filter: drop-shadow(0 0 10px rgba(240, 207, 135, 0.4));
  animation: compass-seek 1.6s ease-in-out infinite;
}
@keyframes compass-seek {
  0%   { transform: rotate(0deg); }
  30%  { transform: rotate(140deg); }
  55%  { transform: rotate(80deg); }
  80%  { transform: rotate(220deg); }
  100% { transform: rotate(360deg); }
}

/* Custom controls (bottom-left), the only interactive layer over the video. */
.vg-controls {
  position: absolute;
  z-index: 6;
  left: 12px;
  bottom: 12px;
  display: flex;
  gap: 8px;
  pointer-events: auto;
}
.vg-ctrl {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid rgba(240, 207, 135, 0.4);
  background: rgba(0, 0, 0, 0.55);
  color: var(--gold-soft);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  transition: background 0.15s ease;
}
.vg-ctrl .ico { width: 18px; height: 18px; }
.vg-ctrl:hover { background: rgba(240, 207, 135, 0.14); }

.vg-bigplay {
  position: absolute;
  z-index: 10;
  inset: 0;
  margin: auto;
  width: 84px;
  height: 84px;
  border-radius: 999px;
  border: 1px solid rgba(240, 207, 135, 0.5);
  background: rgba(0, 0, 0, 0.6);
  color: var(--gold);
  cursor: pointer;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
.vg-bigplay .ico { width: 34px; height: 34px; }
.vg-bigplay:hover { background: rgba(0, 0, 0, 0.8); }

.video-error {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #10131f;
  text-align: center;
  gap: 6px;
}

/* ---- Between-rounds interstitial ---- */
.round-flash {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: rgba(5, 7, 15, 0.82);
  backdrop-filter: blur(5px);
  border-radius: var(--radius);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}
.round-flash.show { opacity: 1; }
.rf-kicker {
  font-family: var(--font-display);
  letter-spacing: 3px;
  font-size: 13px;
  text-transform: uppercase;
  color: var(--gold-soft);
  margin: 0;
}
.rf-title {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(34px, 5vw, 56px);
  letter-spacing: 2px;
  margin: 0;
  background: linear-gradient(180deg, var(--gold-pale), var(--gold) 55%, var(--gold-deep));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---- Map panel: corner overlay on desktop, bottom sheet on touch ---- */
.map-overlay {
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: 360px;
  height: 300px;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(240, 207, 135, 0.5);
  border-radius: var(--radius);
  overflow: hidden;
  z-index: 30;
  background: var(--ink-2);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.6);
  transition: opacity 0.2s ease, width 0.28s ease, height 0.28s ease, transform 0.3s ease;
}
.map-overlay.enlarged {
  width: min(46vw, 760px);
  height: min(64vh, 640px);
}
/* faded "peek" state only where hover exists; pointer devices w/o hover keep it solid */
@media (hover: hover) {
  .map-overlay { opacity: 0.62; }
  .map-overlay:hover,
  .map-overlay.enlarged,
  .map-overlay.has-pin { opacity: 1; }
}

.map-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px 9px 12px;
  background: rgba(10, 14, 30, 0.92);
  border-bottom: 1px solid var(--line-gold-soft);
  cursor: pointer;
  user-select: none;
}
.map-head > .ico { width: 15px; height: 15px; color: var(--gold-soft); }
#guess-hint {
  flex: 1;
  text-align: left;
  font: 600 12px var(--font-ui);
  color: var(--gold-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.map-chevron { display: none; }
.map-size-btn {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid rgba(240, 207, 135, 0.35);
  background: transparent;
  color: var(--gold-soft);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.map-size-btn .ico { width: 14px; height: 14px; }
.map-size-btn:hover { background: rgba(240, 207, 135, 0.12); }

.map-body { position: relative; flex: 1; min-height: 0; }
#map { position: absolute; inset: 0; width: 100%; height: 100%; background: var(--ink-2); }

.map-guess-btn {
  width: 100%;
  border-radius: 0;
  padding: 13px;
  font-size: 15px;
}
/* the moment a pin lands, the lock-in button glows */
.map-guess-btn:not(:disabled) { animation: guess-ready 1.8s ease-in-out infinite; }
@keyframes guess-ready {
  0%, 100% { box-shadow: 0 0 0 0 rgba(240, 207, 135, 0.45); }
  50%      { box-shadow: 0 0 22px 4px rgba(240, 207, 135, 0.35); }
}

/* ==================================================================== *
 * ROUND RESULT — the reveal
 * ==================================================================== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 14, 0.82);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.overlay:not(.hidden) { animation: overlay-in 0.25s ease both; }
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }
.overlay:not(.hidden) .card { animation: card-in 0.35s cubic-bezier(0.2, 0.9, 0.3, 1) both; }
@keyframes card-in {
  from { opacity: 0; transform: translateY(18px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

.result-card { margin: 0; max-width: 640px; width: 100%; padding: 24px 28px; }
.result-kicker {
  font-family: var(--font-display);
  letter-spacing: 2.5px;
  font-size: 11.5px;
  text-transform: uppercase;
  color: var(--gold-soft);
  margin: 0 0 2px;
}
.result-card h2 { font-size: 27px; margin: 0 0 12px; transition: filter 0.3s ease; }
.result-card.grade-great h2 { filter: drop-shadow(0 0 14px rgba(240, 207, 135, 0.55)); }
.result-card.grade-poor h2 { opacity: 0.8; }

#result-map {
  height: 260px;
  border-radius: 12px;
  border: 1px solid rgba(240, 207, 135, 0.3);
  margin: 0 0 16px;
  background: var(--ink-2);
}

.result-stats {
  display: flex;
  justify-content: space-around;
  gap: 14px;
  margin-bottom: 4px;
}
.result-stats > div { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.stat-label {
  font-family: var(--font-display);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--gold-soft);
}
.result-stats strong {
  font: 700 17px var(--font-ui);
  color: var(--parchment);
  font-variant-numeric: tabular-nums;
}
.stat-sub { font-size: 11.5px; color: var(--muted); }

.score-meter {
  height: 10px;
  border-radius: 999px;
  background: rgba(236, 224, 200, 0.1);
  border: 1px solid rgba(240, 207, 135, 0.25);
  overflow: hidden;
  margin: 14px 0 10px;
}
.score-meter-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold));
  box-shadow: 0 0 10px rgba(240, 207, 135, 0.5);
  transition: width 0.8s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.result-total { font-size: 13px; color: var(--muted); margin: 0 0 18px; }
.result-total strong { color: var(--gold-soft); font-variant-numeric: tabular-nums; }

/* Leaflet marker art shared by result + final maps */
.vg-pin { background: transparent; border: none; }
.vg-pin svg { display: block; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.5)); }
.vg-x { background: transparent; border: none; }
.vg-x svg { display: block; overflow: visible; }
.vg-x line {
  stroke: var(--coral);
  stroke-width: 4;
  stroke-linecap: round;
  filter: drop-shadow(0 0 6px rgba(255, 122, 89, 0.9));
}
.vg-x.stamp svg { animation: x-stamp 0.4s cubic-bezier(0.3, 1.5, 0.5, 1) both; }
@keyframes x-stamp {
  from { transform: scale(2.6); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* ==================================================================== *
 * FINAL SCREEN — expedition debrief
 * ==================================================================== */
.final-card { max-width: 780px; }
.final-kicker {
  font-family: var(--font-display);
  letter-spacing: 3px;
  font-size: 12px;
  color: var(--gold-soft);
  margin: 0 0 6px;
}
#final-rank {
  font-size: clamp(28px, 4.5vw, 42px);
  font-weight: 900;
  margin: 0 0 2px;
}
.final-score {
  font-family: var(--font-ui);
  color: var(--parchment);
  margin: 4px 0 16px;
  font-variant-numeric: tabular-nums;
}
.final-score strong {
  font-family: var(--font-display);
  font-size: 30px;
  color: var(--gold);
}
.final-score .final-max { color: var(--muted); font-size: 15px; margin-left: 4px; }

#final-map {
  height: 380px;
  border-radius: 12px;
  border: 1px solid rgba(240, 207, 135, 0.3);
  margin: 0 0 8px;
  background: var(--ink-2);
}
.final-map-legend { font-size: 12.5px; color: var(--muted); margin: 0 0 4px; }
.final-map-legend .lg { font-weight: 700; }
.final-map-legend .lg-guess { color: #9ab0e8; }
.final-map-legend .lg-actual { color: var(--gold); }

.final-miss { font-size: 13px; color: var(--coral); margin: 6px 0 0; }

.breakdown {
  list-style: none;
  padding: 0;
  margin: 18px 0 4px;
  text-align: left;
}
.breakdown li {
  display: grid;
  grid-template-columns: auto 1fr auto minmax(120px, 150px);
  gap: 12px;
  align-items: center;
  padding: 9px 8px;
  border-bottom: 1px solid rgba(240, 207, 135, 0.12);
}
.breakdown li:last-child { border-bottom: none; }
.bd-idx {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(240, 207, 135, 0.4);
  color: var(--gold-soft);
  font: 700 11px/21px var(--font-ui);
  text-align: center;
}
.bd-place { display: flex; flex-direction: column; min-width: 0; }
.bd-place strong {
  color: var(--parchment);
  font: 600 13.5px var(--font-ui);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bd-city { color: var(--muted); font-size: 11.5px; }
.bd-dist { color: var(--muted); font: 500 12px var(--font-ui); white-space: nowrap; }
.bd-score { display: flex; align-items: center; gap: 8px; }
.bd-bar {
  flex: 1;
  height: 6px;
  min-width: 56px;
  border-radius: 999px;
  background: rgba(236, 224, 200, 0.1);
  overflow: hidden;
}
.bd-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold));
}
.bd-score > strong {
  color: var(--gold-soft);
  font: 700 13px var(--font-ui);
  min-width: 46px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.final-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 18px;
}

/* ==================================================================== *
 * Share dialog
 * ==================================================================== */
.share-card {
  position: relative;
  max-width: 420px;
  margin: 0;
  padding: 26px 28px 24px;
}
.share-card h2 { font-size: 22px; margin-bottom: 14px; }
.share-preview {
  font: 500 12.5px/1.6 var(--font-ui);
  color: var(--parchment);
  background: rgba(5, 7, 15, 0.55);
  border: 1px solid var(--line-gold-soft);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 0 0 18px;
  text-align: left;
  white-space: pre-wrap;
  word-break: break-word;
}
.share-grid {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-bottom: 18px;
}
.share-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font: 500 11.5px var(--font-ui);
  color: var(--muted);
}
.share-opt:hover { color: var(--parchment); }
.share-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid rgba(240, 207, 135, 0.35);
  background: rgba(236, 224, 200, 0.06);
  color: var(--gold-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.share-circle svg { width: 22px; height: 22px; }
.share-opt:hover .share-circle {
  background: rgba(240, 207, 135, 0.14);
  border-color: rgba(240, 207, 135, 0.65);
  transform: translateY(-2px);
}
.share-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.share-close:hover { color: var(--parchment); background: rgba(236, 224, 200, 0.08); }
.share-close .ico { width: 15px; height: 15px; }

/* ==================================================================== *
 * Confirm dialog + toasts
 * ==================================================================== */
.confirm-card { max-width: 400px; margin: 0; padding: 26px 28px; }
.confirm-card h2 { font-size: 22px; margin-bottom: 6px; }
.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 18px;
}

.toasts {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: max-content;
  max-width: 92vw;
}
.toast {
  font: 600 13.5px var(--font-ui);
  color: var(--parchment);
  background: rgba(10, 14, 30, 0.94);
  border: 1px solid var(--line-gold);
  border-radius: 999px;
  padding: 10px 18px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  animation: toast-in 0.3s cubic-bezier(0.2, 0.9, 0.3, 1) both;
  transition: opacity 0.3s ease, transform 0.3s ease;
  max-width: 100%;
}
.toast.error { border-color: rgba(255, 107, 107, 0.55); color: #ffb4b4; }
.toast.leaving { opacity: 0; transform: translateY(8px); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}

/* ==================================================================== *
 * Touch & small screens
 * ==================================================================== */
@media (max-width: 760px) {
  .screen { padding: 8px; }
  .topbar { padding: 0 10px; }
  .hud { gap: 6px; }
  .hud-mode, .pips-label, .btn kbd { display: none; }
  .hud-pill { padding: 6px 10px; }
  .brand-name { font-size: 15px; }
  .user-area .user-name { display: none; }

  .stage {
    height: calc(100vh - var(--topbar-h) - 16px);
    height: calc(100dvh - var(--topbar-h) - 16px);
    min-height: 0;
  }

  /* Map becomes a bottom sheet: header always peeking, tap to expand. */
  .map-overlay {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    height: min(62vh, 540px);
    height: min(62dvh, 540px);
    border-radius: 16px 16px 0 0;
    border-bottom: none;
    transform: translateY(calc(100% - 44px));
  }
  .map-overlay.enlarged {
    width: auto;
    height: min(62vh, 540px);
    height: min(62dvh, 540px);
    transform: translateY(0);
  }
  .map-head { padding: 12px 14px; }
  #guess-hint { font-size: 13px; }
  .map-size-btn { display: none; }
  .map-chevron {
    display: block;
    width: 9px;
    height: 9px;
    border-left: 2px solid var(--gold-soft);
    border-top: 2px solid var(--gold-soft);
    transform: rotate(45deg) translateY(2px);
    transition: transform 0.3s ease;
    flex: none;
  }
  .map-overlay.enlarged .map-chevron { transform: rotate(225deg) translateY(-1px); }

  /* keep the video's own controls clear of the collapsed sheet */
  .vg-controls { bottom: 56px; }

  .card { padding: 22px 18px; margin: 3vh auto; }
  .result-card { padding: 18px 16px; }
  #result-map { height: 220px; }
  .result-stats { flex-wrap: wrap; }
  #final-map { height: 260px; }
  .breakdown li { grid-template-columns: auto 1fr auto; }
  .bd-score { grid-column: 2 / 4; }
  .final-actions .btn { flex: 1 1 auto; }
  .profile-stats { grid-template-columns: repeat(2, 1fr); }
  .profile-head { flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .bd-bar { display: none; }
  .hunt-hero { padding-top: 5vh; }
  .mode-card { width: 100%; max-width: 340px; }
}

/* ==================================================================== *
 * Reduced motion
 * ==================================================================== */
@media (prefers-reduced-motion: reduce) {
  .hunt-compass, .hunt-routes .route, .hunt-routes .pin circle,
  .hunt-routes .xmark line, .hunt-lat, .hunt-title::after,
  .hunt-dust .dust {
    animation: none !important;
  }
  .hunt-kicker, .hunt-title, .hunt-sub, .hunt-steps, .hunt-choose,
  .hunt-modes, .hunt-auth { opacity: 1; animation: none; }

  .screen:not(.hidden),
  .overlay:not(.hidden),
  .overlay:not(.hidden) .card,
  .toast,
  .vg-x.stamp svg { animation: none !important; }
  .hud-score.bump { animation: none; }
  .map-guess-btn:not(:disabled) { animation: none; }
  .score-meter-fill { transition: none; }
  .round-flash { transition: none; }
  .spin-compass { animation-duration: 3s; }
}
