/* Stages, forms, the Street View round, the guess map, the video bar. */

#stages {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;      /* individual stages opt back in */
}

.stage { pointer-events: auto; }
.stage[hidden] { display: none !important; }

/* ------------------------------------------------------------ card stages */

.stage--card {
  position: absolute;
  left: 50%;
  bottom: clamp(2rem, 7vh, 5rem);
  transform: translateX(-50%);
  width: min(46rem, 90vw);
  padding: clamp(1.6rem, 3vw, 2.4rem) clamp(1.8rem, 3.4vw, 3rem);
  text-align: center;

  background: linear-gradient(168deg, rgba(24, 29, 41, 0.93), rgba(15, 18, 26, 0.95));
  border: 1px solid var(--line);
  border-radius: 5px;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(14px);
  animation: card-in 0.7s var(--ease) both;
}
@keyframes card-in {
  from { opacity: 0; transform: translateX(-50%) translateY(22px); }
}

.stage--full { position: absolute; inset: 0; }
.stage--bare { position: absolute; inset: 0; display: grid; place-items: center; }

.eyebrow {
  margin: 0 0 0.7rem;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0.85;
}

.prompt {
  margin: 0 0 0.5rem;
  font-size: clamp(1.5rem, 3.1vw, 2.35rem);
  font-weight: 400;
  line-height: 1.22;
  letter-spacing: -0.01em;
}

.body {
  margin: 0.4rem auto 1.4rem;
  max-width: 34rem;
  font-size: 1.02rem;
  line-height: 1.6;
  color: var(--cream-dim);
}

/* ------------------------------------------------------------------ answer */

.answer { position: relative; margin-top: 1.5rem; }

.answer__input {
  width: 100%;
  padding: 0.85rem 3.2rem 0.85rem 1.1rem;
  font-family: var(--serif);
  font-size: 1.2rem;
  color: var(--cream);
  text-align: center;
  background: rgba(255, 255, 255, 0.04);
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 3px 3px 0 0;
  outline: none;
  transition: border-color 0.3s var(--ease), background 0.3s var(--ease);
}
.answer__input::placeholder { color: var(--cream-faint); font-style: italic; }
.answer__input:focus { border-bottom-color: var(--gold); background: rgba(255, 255, 255, 0.07); }

.answer__input--num {
  font-size: 2.4rem;
  letter-spacing: 0.3em;
  padding-right: 1.1rem;
  text-indent: 0.3em;              /* balance the letter-spacing on the right */
}

.answer__go {
  position: absolute;
  right: 0.5rem;
  top: 0.45rem;
  width: 2.4rem;
  height: 2.4rem;
  display: grid;
  place-items: center;
  background: none;
  border: 0;
  cursor: pointer;
  color: var(--cream-faint);
  transition: color 0.25s var(--ease), transform 0.25s var(--ease);
}
.answer__go:hover { color: var(--gold); transform: translateX(3px); }
.answer__go svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.answer__error {
  min-height: 1.3rem;
  margin: 0.6rem 0 0;
  font-size: 0.9rem;
  font-style: italic;
  color: var(--rose);
}

.answer.checking { opacity: 0.6; }
.answer.correct .answer__input { border-bottom-color: var(--gold); }

.shake { animation: shake 0.42s cubic-bezier(0.36, 0.07, 0.19, 0.97) both; }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}

/* --------------------------------------------------------------- number pad */

.pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  max-width: 17rem;
  margin: 1.3rem auto;
}
.pad button {
  padding: 0.75rem 0;
  font-family: var(--serif);
  font-size: 1.25rem;
  color: var(--cream);
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--line);
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.18s var(--ease), transform 0.12s var(--ease), border-color 0.18s var(--ease);
}
.pad button:hover { background: rgba(255, 255, 255, 0.1); border-color: var(--gold-dim); }
.pad button:active { transform: translateY(1px); }
.pad__wide { font-size: 0.85rem !important; font-family: var(--sans) !important; letter-spacing: 0.08em; }

/* ----------------------------------------------------------------- buttons */

.btn {
  display: inline-block;
  padding: 0.7rem 1.6rem;
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  border-radius: 3px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.22s var(--ease), color 0.22s var(--ease),
              border-color 0.22s var(--ease), transform 0.12s var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn--primary {
  color: #14171f;
  background: var(--gold);
  border-color: var(--gold);
}
.btn--primary:hover { background: #eec37e; }
.btn--primary:disabled { background: transparent; color: var(--cream-faint); border-color: var(--line); cursor: default; }
.btn--ghost {
  color: var(--cream-dim);
  background: none;
  border-color: var(--line);
}
.btn--ghost:hover { color: var(--cream); border-color: var(--cream-faint); }

/* ------------------------------------------------------------- street view */

/* Its own layer, below the envelope canvas (z-index 2) and below #stages (10),
   so the envelope stays visible docked in the corner during a round. */
.pano {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: none;
  background: #10131a;
}
body[data-stage="geo"] .pano { display: block; }

/* The geo stage is only overlays; it must not blanket the panorama. */
.stage--overlay { pointer-events: none; }
.stage--overlay > * { pointer-events: auto; }
/* Google slips a few links into the pano; keep the chrome quiet without
   removing the attribution Google requires. */
.pano .gm-style-cc { opacity: 0.35; }

.round-chip {
  position: absolute;
  z-index: 12;
  top: 1.4rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.45rem 1.1rem;
  font-family: var(--sans);
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--cream-dim);
  background: rgba(12, 14, 20, 0.72);
  border: 1px solid var(--line);
  border-radius: 999px;
  backdrop-filter: blur(8px);
}
.round-chip b { color: var(--gold); font-weight: 500; margin-left: 0.3rem; }

/* --------------------------------------------------------------- guess map */

.guess-panel {
  position: absolute;
  z-index: 14;
  right: 1.2rem;
  bottom: 1.2rem;
  width: 19rem;
  height: 13rem;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: rgba(12, 14, 20, 0.82);
  border: 1px solid var(--line);
  border-radius: 5px;
  box-shadow: 0 20px 50px -12px rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
  opacity: 0.82;
  transition: width 0.32s var(--ease), height 0.32s var(--ease), opacity 0.32s var(--ease);
}
.guess-panel.expanded { width: min(38rem, 46vw); height: min(30rem, 58vh); opacity: 1; }
.guess-panel.pinned   { opacity: 1; }
.guess-panel.pinned .guess-panel__pin { color: var(--gold); }

.guess-panel__pin {
  position: absolute;
  top: -0.85rem;
  left: -0.85rem;
  z-index: 5;
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  color: var(--cream-faint);
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
  transition: color 0.2s var(--ease);
}
.guess-panel__pin svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.6; }

.guess-map { flex: 1; border-radius: 3px; overflow: hidden; background: #222; }
.guess-panel__go { width: 100%; padding: 0.55rem; font-size: 0.72rem; }

/* leaflet is light by default; take the edge off so it sits in the dark UI */
.leaflet-container { background: #1b1f28; font-family: var(--sans); }
.leaflet-control-attribution {
  background: rgba(12, 14, 20, 0.7) !important;
  color: var(--cream-faint) !important;
  font-size: 9px !important;
}
.leaflet-control-attribution a { color: var(--cream-dim) !important; }
.leaflet-bar a { background: var(--ink-2) !important; color: var(--cream) !important; border-color: var(--line) !important; }

.pin__dot {
  position: absolute;
  left: 50%;
  top: 0;
  width: 15px;
  height: 15px;
  margin-left: -7.5px;
  border-radius: 50%;
  border: 2px solid #10131a;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}
.pin__stick {
  position: absolute;
  left: 50%;
  top: 13px;
  width: 2px;
  height: 17px;
  margin-left: -1px;
  background: #10131a;
}
.pin--guess .pin__dot { background: var(--cream); }
.pin--truth .pin__dot { background: var(--gold); }

/* ------------------------------------------------------------ round result */

.round-result {
  position: absolute;
  z-index: 20;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(30rem, 88vw);
  padding: 1.8rem 2rem;
  text-align: center;
  background: linear-gradient(168deg, rgba(24, 29, 41, 0.96), rgba(15, 18, 26, 0.97));
  border: 1px solid var(--line);
  border-radius: 5px;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(14px);
  animation: card-in 0.5s var(--ease) both;
}
.round-result[hidden] { display: none; }
.round-result h2 {
  margin: 0 0 0.3rem;
  font-size: 1.5rem;
  font-weight: 400;
  font-style: italic;
  color: var(--gold);
}
.result__praise { margin: 0 0 1.1rem; color: var(--cream-dim); font-size: 1.02rem; }

.result__stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin: 0 0 1.4rem;
}
.result__stats div { display: grid; gap: 0.2rem; }
.result__stats dt {
  font-family: var(--sans);
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--cream-faint);
}
.result__stats dd { margin: 0; font-size: 1.4rem; color: var(--cream); }

/* ------------------------------------------------------------------ reveal */

#reveal-video {
  /* The VideoTexture reads from this element; it must stay in the document and
     must not be display:none (Chrome will not decode a display:none video),
     so it is parked off-screen at 1px instead. */
  position: fixed;
  width: 1px;
  height: 1px;
  opacity: 0.001;
  left: -10px;
  bottom: -10px;
  pointer-events: none;
  z-index: -1;
}
body.no-webgl #reveal-video,
body:not(.reveal-3d) #reveal-video[controls] {
  position: static;
  width: min(94vw, 1400px);
  height: auto;
  opacity: 1;
  pointer-events: auto;
  z-index: auto;
}

.notice { position: static !important; transform: none !important; }

.reveal-continue {
  position: absolute;
  bottom: 6.5rem;
  left: 50%;
  transform: translateX(-50%);
}
.reveal-continue[hidden] { display: none; }

/* --------------------------------------------------------------- video bar */

.video-bar {
  position: fixed;
  z-index: 40;
  left: 50%;
  bottom: 1.6rem;
  transform: translateX(-50%);
  width: min(60rem, 92vw);
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.6rem 1rem;
  background: rgba(12, 14, 20, 0.78);
  border: 1px solid var(--line);
  border-radius: 999px;
  backdrop-filter: blur(12px);
  animation: card-in 0.6s var(--ease) both;
}
.video-bar[hidden] { display: none; }

.vb__btn {
  flex: none;
  width: 2.2rem;
  height: 2.2rem;
  display: grid;
  place-items: center;
  color: var(--cream);
  background: none;
  border: 0;
  cursor: pointer;
  opacity: 0.82;
  transition: opacity 0.2s var(--ease), color 0.2s var(--ease);
}
.vb__btn:hover { opacity: 1; color: var(--gold); }
.vb__btn svg { width: 19px; height: 19px; fill: currentColor; }
.vb__btn--sm svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.vb__btn--sm[aria-label="Mute"] svg path:first-child { fill: currentColor; stroke: none; }

.vb__btn[data-state="paused"] .vb__pause,
.vb__btn[data-state="playing"] .vb__play { display: none; }
.vb__btn[data-state="muted"] .vb__wave { opacity: 0.2; }

.vb__time {
  flex: none;
  font-family: var(--sans);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  color: var(--cream-dim);
  min-width: 8.5ch;
  text-align: center;
}

.vb__seek { flex: 1; }
.vb__vol  { flex: none; width: 5rem; }

.video-bar input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  background: rgba(244, 239, 228, 0.22);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}
.video-bar input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 3px rgba(223, 174, 99, 0.2);
}
.video-bar input[type="range"]::-moz-range-thumb {
  width: 13px; height: 13px; border: 0; border-radius: 50%; background: var(--gold);
}

/* ------------------------------------------------------------------ final */

.scorecard {
  margin: 1.4rem auto 1.6rem;
  padding: 1.2rem 1.4rem;
  max-width: 30rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.03);
}
.scorecard[hidden] { display: none; }
.scorecard h3 {
  margin: 0 0 0.9rem;
  font-family: var(--sans);
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--cream-faint);
}
.scorecard__best { margin: 0; font-size: 0.95rem; color: var(--cream-dim); font-style: italic; }
.scorecard__best strong { color: var(--gold); font-weight: 400; font-style: normal; }

/* --------------------------------------------------------------- narrow-ish */
/* Desktop-first by decision; this only keeps a phone from being broken. */

@media (max-width: 860px) {
  .guess-panel { width: 12rem; height: 9rem; right: 0.7rem; bottom: 0.7rem; }
  .guess-panel.expanded { width: calc(100vw - 1.4rem); height: 58vh; }
  .stage--card { width: 94vw; bottom: 1rem; padding: 1.3rem 1.1rem; }
  .hint-dock { right: 0.8rem; bottom: 0.8rem; max-width: 70vw; }
  .video-bar { gap: 0.5rem; padding: 0.5rem 0.7rem; }
  .vb__vol { display: none; }
}
