:root {
  --bg: #0f0e0d;
  --bg-elevated: #1a1816;
  --text: #f5f0eb;
  --text-muted: rgba(245, 240, 235, 0.55);
  --accent: #c9a87c;
  --accent-soft: rgba(201, 168, 124, 0.25);
  --heart: #c4777b;
  --font-serif: "Cormorant Garamond", "Georgia", serif;
  --font-sans: "DM Sans", system-ui, sans-serif;
  --radius: 12px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.location-test-badge {
  position: fixed;
  bottom: 0.65rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  margin: 0;
  padding: 0.35rem 0.65rem;
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--accent-soft);
  border-radius: 6px;
  pointer-events: none;
}

#app {
  min-height: 100vh;
  position: relative;
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(1.25rem, 5vw, 2.5rem);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.65s var(--ease), visibility 0.65s;
}

.screen.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.screen-inner {
  width: 100%;
  max-width: 28rem;
  text-align: center;
}

/* Top bar: progress + word */
.app-top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  padding: 0.75rem 1rem 0.5rem;
  background: linear-gradient(to bottom, var(--bg) 60%, transparent);
  pointer-events: none;
}

.app-top.is-hidden {
  opacity: 0;
  visibility: hidden;
}

.app-top-inner {
  max-width: 36rem;
  margin: 0 auto;
  pointer-events: auto;
}

.progress-line {
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.word-builder {
  font-family: var(--font-serif);
  font-size: clamp(1.15rem, 4vw, 1.45rem);
  color: var(--accent);
  text-align: center;
  padding: 0.35rem 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem 0.45rem;
}

.word-builder .slot {
  display: inline-block;
  min-width: 0.75em;
  text-align: center;
}

.word-builder .empty {
  color: var(--text-muted);
  font-weight: 400;
  opacity: 0.45;
}

.word-builder .filled {
  color: var(--text);
  font-weight: 600;
}

/* Splash */
.screen-splash {
  padding: 0;
  justify-content: flex-end;
}

.splash-visual {
  position: absolute;
  inset: 0;
  background: var(--bg);
}

.splash-photo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: top center;
  opacity: 0;
  transition: opacity 1.1s var(--ease);
}

.splash-photo.is-visible {
  opacity: 1;
}

.splash-scrim {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(15, 14, 13, 0.25) 0%,
    rgba(15, 14, 13, 0.5) 45%,
    rgba(15, 14, 13, 0.88) 100%
  );
  z-index: 1;
}

.splash-copy {
  position: relative;
  z-index: 2;
  padding-bottom: clamp(2rem, 8vh, 3.5rem);
}

.splash-title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(2.75rem, 12vw, 4.5rem);
  letter-spacing: 0.02em;
  line-height: 1.05;
  margin: 0 0 1rem;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.45);
}

.splash-sub {
  font-size: 1.05rem;
  color: rgba(245, 240, 235, 0.82);
  font-weight: 400;
  margin: 0 0 2.5rem;
  max-width: 22rem;
  margin-left: auto;
  margin-right: auto;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.4);
}

.splash-start-over-row {
  width: 100%;
  margin-top: clamp(2.25rem, 11vh, 5rem);
  padding-top: clamp(1.25rem, 4vh, 2rem);
  border-top: 1px solid rgba(245, 240, 235, 0.12);
  display: flex;
  justify-content: center;
}

.splash-start-over {
  margin-top: 0;
  color: rgba(245, 240, 235, 0.45);
}

.splash-start-over:hover {
  color: rgba(245, 240, 235, 0.75);
}

.clue-back-welcome {
  margin-top: 1.75rem;
  width: 100%;
  color: var(--text-muted);
}

/* Clue */
.clue-text {
  font-family: var(--font-serif);
  font-size: clamp(1.35rem, 4.5vw, 1.75rem);
  line-height: 1.55;
  font-weight: 500;
  white-space: pre-line;
  margin: 0 0 1.75rem;
  text-align: left;
}

.distance-hint {
  font-size: 0.9rem;
  color: var(--accent);
  margin: -0.5rem 0 1.25rem;
  min-height: 1.5em;
}

.distance-hint:empty {
  margin: 0;
  min-height: 0;
}

/* Buttons */
.btn {
  appearance: none;
  border: none;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 0.9rem 1.75rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 0.2s var(--ease), background 0.2s, opacity 0.2s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: var(--bg);
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 0.5rem 0.75rem;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.btn-ghost:hover {
  color: var(--text);
}

.btn-row {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
  width: 100%;
}

/* Letter challenge */
.instruction-block {
  font-family: var(--font-serif);
  font-size: clamp(1.2rem, 3.8vw, 1.5rem);
  margin-bottom: 1.5rem;
  line-height: 1.45;
}

.letter-input-wrap {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

#letter-input {
  width: 3.5rem;
  height: 3.5rem;
  text-align: center;
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 600;
  text-transform: uppercase;
  border: 1px solid var(--accent-soft);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}

#letter-input:focus {
  border-color: var(--accent);
}

.feedback {
  min-height: 1.5rem;
  font-size: 0.95rem;
  color: var(--heart);
  margin-bottom: 0.5rem;
}

.feedback.ok {
  color: var(--accent);
}

/* GPS panel */
.gps-panel {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--bg-elevated);
  border-radius: var(--radius);
  font-size: 0.88rem;
  color: var(--text-muted);
  display: none;
}

.gps-panel.is-visible {
  display: block;
}

.gps-msg {
  margin-bottom: 0.75rem;
  color: var(--text);
}

/* Memory */
.screen-memory {
  padding: 0;
  justify-content: stretch;
}

.memory-frame {
  position: absolute;
  inset: 0;
  background: var(--bg-elevated);
}

.memory-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: top center;
  opacity: 0;
  transition: opacity 1.2s var(--ease);
}

.memory-frame img.is-visible {
  opacity: 1;
}

.memory-placeholder {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 30% 20%, rgba(201, 168, 124, 0.15), transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(196, 119, 123, 0.12), transparent 45%),
    var(--bg);
}

.memory-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: clamp(1.5rem, 6vw, 3rem);
  background: linear-gradient(transparent 20%, rgba(15, 14, 13, 0.92) 100%);
}

.memory-caption {
  font-family: var(--font-serif);
  font-size: clamp(1.1rem, 3.5vw, 1.35rem);
  line-height: 1.55;
  max-width: 32rem;
  margin: 0 auto 1.5rem;
  text-align: center;
}

.memory-actions {
  display: flex;
  justify-content: center;
}

/* Memory delay (breathing moment) */
.screen-memory-delay .breath {
  width: 4rem;
  height: 4rem;
  border-radius: 50%;
  border: 1px solid var(--accent-soft);
  animation: breath 2s ease-in-out infinite;
}

@keyframes breath {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.4;
  }
  50% {
    transform: scale(1.15);
    opacity: 0.9;
  }
}

.screen-memory-delay p {
  margin-top: 1.5rem;
  font-family: var(--font-serif);
  font-size: 1.15rem;
  color: var(--text-muted);
}

/* Final */
.final-word-display {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 10vw, 3.5rem);
  letter-spacing: 0.15em;
  min-height: 1.2em;
  margin-bottom: 2rem;
}

.final-extra {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.screen-final-image {
  padding: 0;
}

.final-img-wrap {
  position: absolute;
  inset: 0;
  background: var(--bg);
}

.final-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: top center;
}

.final-img-fallback {
  position: absolute;
  inset: 0;
  background: linear-gradient(145deg, var(--bg-elevated), var(--bg));
}

.final-closing {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 2rem;
  text-align: center;
  background: linear-gradient(transparent, rgba(15, 14, 13, 0.95));
}

.final-closing h2 {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(2rem, 8vw, 3rem);
  margin: 0;
}

.hint-floating {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 60;
}

.hint-floating.is-hidden {
  display: none;
}

.hint-popover {
  position: fixed;
  bottom: 3.5rem;
  right: 1rem;
  left: 1rem;
  max-width: 20rem;
  margin-left: auto;
  padding: 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--accent-soft);
  border-radius: var(--radius);
  font-size: 0.88rem;
  color: var(--text-muted);
  z-index: 60;
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition: opacity 0.3s, visibility 0.3s, transform 0.3s;
}

.hint-popover.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.reset-row {
  margin-top: 2rem;
}

@media (min-width: 480px) {
  .clue-text {
    text-align: center;
  }
}
