:root {
  --bg: #0f1923;
  --bg-elevated: #16232e;
  --gold: #c9a84c;
  --gold-glow: rgba(201, 168, 76, 0.45);
  --gold-soft: rgba(201, 168, 76, 0.12);
  --white: #ffffff;
  --text-secondary: #8a97a3;
  --border: rgba(255, 255, 255, 0.06);
  --font-serif: Georgia, "Iowan Old Style", "Palatino Linotype", "Times New Roman", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
}

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

html, body {
  height: 100%;
}

body {
  font-family: var(--font-sans);
  background: radial-gradient(circle at 50% 0%, #142230 0%, var(--bg) 55%);
  color: var(--white);
  -webkit-font-smoothing: antialiased;
}

.app {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 18px) 24px calc(env(safe-area-inset-bottom) + 18px);
  gap: 16px;
}

.hidden {
  display: none !important;
}

/* Header */

.app-header {
  position: relative;
  text-align: center;
}

.settings-btn {
  position: absolute;
  top: 0;
  right: 0;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
}

/* Location + pulse */

.location-section {
  text-align: center;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.location-name {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 26px;
  line-height: 1.25;
  color: var(--white);
  max-width: 300px;
}

.pulse {
  position: relative;
  width: 64px;
  height: 64px;
  margin: 14px auto 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pulse-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid var(--gold);
  opacity: 0;
  animation: pulse-ring 2.8s cubic-bezier(0.16, 0.8, 0.3, 1) infinite;
}

.pulse-ring--delay {
  animation-delay: 1.4s;
}

.pulse-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 22px var(--gold-glow);
  opacity: 0.55;
  transition: opacity 0.4s ease;
}

/* Before GPS lock the dot is dim and the rings pulse slowly ("searching").
   Once locked (3 stable readings), it brightens and picks up pace. */
.pulse-ring {
  animation-duration: 3.6s;
}

.pulse.is-locked .pulse-dot {
  opacity: 1;
}

.pulse.is-locked .pulse-ring {
  animation-duration: 2.8s;
}

@keyframes pulse-ring {
  0% {
    transform: scale(0.5);
    opacity: 0.5;
  }
  70% {
    opacity: 0.12;
  }
  100% {
    transform: scale(1.7);
    opacity: 0;
  }
}

.status-text {
  font-size: 14px;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}

/* Player card — a fixed bottom drawer. Collapsed by default (only the peek
   handle shows) so the screen stays clean while walking; tap or swipe up
   to reveal the full narration, tap the X or swipe down to hide it again. */

.player-card {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.45);
  transform: translateY(calc(100% - 56px - env(safe-area-inset-bottom)));
  transition: transform 0.32s cubic-bezier(0.16, 0.8, 0.3, 1);
}

.player-card.is-open {
  transform: translateY(0);
}

.drawer-handle {
  width: 100%;
  height: 56px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.drawer-handle-bar {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--gold-soft);
}

.drawer-handle-hint {
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--gold);
}

.drawer-content {
  position: relative;
  padding: 40px 24px calc(env(safe-area-inset-bottom) + 24px);
  max-height: 70vh;
  overflow-y: auto;
}

.drawer-close {
  position: absolute;
  top: 8px;
  right: 16px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  font-size: 14px;
}

.place-photo {
  width: calc(100% + 48px);
  margin: 0 -24px 16px;
  height: 160px;
  background: linear-gradient(135deg, var(--gold-soft) 0%, var(--bg) 70%);
  background-size: cover;
  background-position: center;
}

.now-playing {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
}

.story-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--white);
  margin-top: 8px;
}

.story-description {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-secondary);
  margin-top: 4px;
}

.story-description--fallback {
  font-size: 16px;
  font-weight: 500;
  color: var(--white);
  line-height: 1.6;
}

.speed-controls {
  display: flex;
  gap: 8px;
  margin-top: 18px;
}

.speed-btn {
  flex: 1;
  padding: 8px 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.speed-btn.is-active {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--bg);
}

.progress-track {
  margin-top: 18px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--gold);
  transition: width 0.3s ease;
}

.controls {
  margin-top: 20px;
  display: flex;
  justify-content: center;
}

.control-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: var(--gold);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px var(--gold-glow);
}

.control-btn:active {
  transform: scale(0.96);
}

/* Footer */

.app-footer {
  text-align: center;
}

.tap-hint {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}

.start-btn {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 18px;
  background: var(--gold);
  color: var(--bg);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: 0 10px 30px var(--gold-glow);
}

.start-btn:active {
  transform: scale(0.98);
  opacity: 0.95;
}

/* iOS/Android PWA install banner — slides up from the bottom, above
   everything else in the app. */

.install-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  max-width: 480px;
  margin: 0 auto;
  padding: 18px 20px calc(env(safe-area-inset-bottom) + 18px);
  background: #1a2535;
  border: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.5);
  transform: translateY(110%);
  transition: transform 0.4s cubic-bezier(0.16, 0.8, 0.3, 1);
}

.install-banner.is-visible {
  transform: translateY(0);
}

.install-banner-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  font-size: 12px;
}

.install-banner-main {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding-right: 24px;
}

.install-banner-logo {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--bg);
  border: 1px solid var(--gold-soft);
  color: var(--gold);
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.install-banner-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--white);
  line-height: 1.4;
}

.install-banner-steps {
  margin-top: 10px;
  padding-left: 18px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.install-banner-steps li {
  margin-bottom: 4px;
}

.install-banner-share-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-right: 4px;
  color: var(--gold);
  vertical-align: middle;
  animation: share-icon-glow 2.2s ease-in-out infinite;
}

@keyframes share-icon-glow {
  0%,
  100% {
    filter: drop-shadow(0 0 0 rgba(201, 168, 76, 0));
  }
  50% {
    filter: drop-shadow(0 0 6px rgba(201, 168, 76, 0.85));
  }
}

.install-banner-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}

.install-banner-cta {
  padding: 10px 22px;
  border: none;
  border-radius: 999px;
  background: var(--gold);
  color: var(--bg);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.03em;
  box-shadow: 0 6px 18px var(--gold-glow);
}

.install-banner-cta:active {
  transform: scale(0.97);
}

.install-banner-arrow {
  position: absolute;
  left: 50%;
  bottom: -6px;
  transform: translateX(-50%);
  color: var(--gold);
  animation: install-arrow-bounce 1.6s ease-in-out infinite;
}

@keyframes install-arrow-bounce {
  0%,
  100% {
    transform: translate(-50%, 0);
    opacity: 0.5;
  }
  50% {
    transform: translate(-50%, 6px);
    opacity: 1;
  }
}

/* Tap-to-talk mic button — floats bottom-right above the drawer/footer. */

.mic-btn {
  position: fixed;
  right: 24px;
  bottom: calc(env(safe-area-inset-bottom) + 84px);
  z-index: 25;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.mic-btn.is-available {
  background: var(--gold);
  color: var(--bg);
  box-shadow: 0 8px 24px var(--gold-glow);
}

.mic-btn.is-listening {
  background: #d64545;
  color: #ffffff;
  box-shadow: 0 0 0 0 rgba(214, 69, 69, 0.6);
  animation: mic-pulse 1.2s ease-out infinite;
}

@keyframes mic-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(214, 69, 69, 0.55);
  }
  100% {
    box-shadow: 0 0 0 18px rgba(214, 69, 69, 0);
  }
}

.ask-subtitle {
  position: fixed;
  left: 24px;
  right: 24px;
  bottom: calc(env(safe-area-inset-bottom) + 150px);
  z-index: 25;
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(15, 25, 35, 0.9);
  border: 1px solid var(--border);
  color: var(--white);
  font-size: 14px;
  line-height: 1.4;
  text-align: center;
}

/* Settings drawer — slides in from the right. */

.settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 29;
  background: rgba(0, 0, 0, 0.5);
}

.settings-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  width: min(340px, 86vw);
  background: var(--bg-elevated);
  border-left: 1px solid var(--border);
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.45);
  transform: translateX(100%);
  transition: transform 0.32s cubic-bezier(0.16, 0.8, 0.3, 1);
  display: flex;
  flex-direction: column;
}

.settings-drawer.is-open {
  transform: translateX(0);
}

.settings-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 20px) 20px 16px;
  border-bottom: 1px solid var(--border);
}

.settings-drawer-header h2 {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 500;
  color: var(--white);
}

.settings-drawer-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.settings-section {
  margin-bottom: 28px;
}

.settings-section-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 12px;
}

.voice-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.voice-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: transparent;
  text-align: left;
}

.voice-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--white);
}

.voice-card-desc {
  font-size: 12px;
  color: var(--text-secondary);
}

.voice-card.is-active {
  border-color: var(--gold);
  background: var(--gold-soft);
}

.voice-card.is-active .voice-card-name {
  color: var(--gold);
}

.depth-options {
  display: flex;
  gap: 8px;
}

.depth-pill {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 4px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: transparent;
  text-align: center;
}

.depth-pill-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--white);
}

.depth-pill-desc {
  font-size: 10px;
  color: var(--text-secondary);
}

.depth-pill.is-active {
  border-color: var(--gold);
  background: var(--gold-soft);
}

.depth-pill.is-active .depth-pill-name {
  color: var(--gold);
}

.language-select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg);
  color: var(--white);
  font-size: 14px;
}

.settings-about {
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.settings-about p {
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-secondary);
}
