* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body.results-mode {
  overflow-y: auto;
}

body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: linear-gradient(135deg, #ffe9d6 0%, #ffd6e8 50%, #d6e9ff 100%);
}

.stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stage.results-mode {
  align-items: flex-start;
}

.card {
  text-align: center;
  padding: 32px 24px;
  max-width: 90vw;
}

.music-toggle {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 20;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 16px;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.75);
  color: #3a2e40;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.music-toggle:hover {
  transform: scale(1.05);
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.14);
}

.tracker {
  position: fixed;
  top: 108px; /* clears the stacked Рекорди + Ново бягане buttons in the top-right corner */
  left: 50%;
  transform: translateX(-50%);
  color: #3a2e40;
  max-width: 92vw;
  text-align: center;
  z-index: 10;
}

/* on the results page the message should scroll away with the rest of the
   page like normal content, not stay pinned over the map/list as an overlay */
body.results-mode .tracker {
  position: static;
  transform: none;
  /* .card's own 32px padding isn't quite enough clearance below the fixed
     Ново бягане / Рекорди buttons — add a bit more so the first line doesn't
     start underneath them */
  margin: 28px 0 24px;
}

.tracker-line {
  font-weight: 700;
  font-size: clamp(1.3rem, 6vw, 2.6rem);
}

.tracker-line-secondary {
  font-size: clamp(1rem, 3.6vw, 1.5rem);
  margin-top: 4px;
}

.pace-line {
  position: fixed;
  left: 50%;
  /* top is set from JS to the midpoint between the tracker stats and the
     greeting (which varies with viewport height) — centering on both axes
     here means that midpoint is this element's true visual center, not just
     where its top edge starts */
  transform: translate(-50%, -50%);
  margin: 0;
  color: #3a2e40;
  font-weight: 600;
  font-size: clamp(1rem, 3.6vw, 1.5rem);
  max-width: 92vw;
  text-align: center;
  z-index: 10;
}

.tracker-final {
  font-weight: 700;
  font-size: clamp(1.1rem, 3.2vw, 1.7rem);
  line-height: 1.4;
  white-space: normal;
  max-width: 90vw;
  margin: 0 auto;
}

h1 {
  font-size: clamp(1.4rem, 5vw, 2.2rem);
  color: #3a2e40;
  margin-bottom: 40px;
}

.greeting {
  font-size: clamp(1rem, 3.5vw, 1.3rem);
  font-weight: 600;
  color: #3a2e40;
  margin: 0 0 8px;
}

.answers {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.btn {
  font-size: 1.2rem;
  font-weight: 600;
  padding: 14px 36px;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn:active {
  transform: scale(0.95);
}

.btn-yes {
  background: #4CAF50;
  color: white;
}

.btn-yes:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.yes-wrapper,
.no-wrapper {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
}

.no-wrapper.fleeing {
  position: fixed;
  margin: 0;
  z-index: 15; /* above the tracker/pace text (10) so it never hides behind them while roaming */
  transition: left 0.35s ease, top 0.35s ease;
}

.runner {
  width: 64px;
  height: 64px;
  object-fit: contain;
  margin-bottom: 4px;
  transform-origin: center bottom;
  user-select: none;
  pointer-events: none;
}

.runner.flip {
  transform: scaleX(-1);
}

.btn-no {
  background: #e0e0e0;
  color: #333;
}

.celebration {
  font-size: clamp(1.4rem, 5vw, 2.2rem);
  color: #3a2e40;
}

.race-loading,
.race-empty {
  font-size: 1.1rem;
  color: #3a2e40;
  max-width: 100%;
  margin: 0 auto;
}

.race-list {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  max-width: min(480px, 100%);
  max-height: 60vh;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.race-item {
  text-align: left;
}

.race-link {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.6);
  text-decoration: none;
  color: #3a2e40;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.race-link:hover {
  transform: scale(1.02);
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.14);
}

.race-date {
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0.7;
}

.race-name {
  font-size: 1.05rem;
  font-weight: 700;
  overflow-wrap: break-word;
}

.race-meta {
  font-size: 0.85rem;
  opacity: 0.8;
  overflow-wrap: break-word;
}

.new-run-btn {
  margin-top: 20px;
  background: #ffffff;
  color: #3a2e40;
}

.goggins-img {
  display: block;
  width: auto;
  height: auto;
  max-width: min(480px, 100%);
  max-height: min(55vh, 480px);
  margin: 0 auto;
  border-radius: 14px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
}

.race-map {
  width: min(480px, 100%);
  height: 320px;
  margin: 0 auto 16px;
  /* no border-radius/overflow:hidden here — Google Maps' logo and
     attribution links must stay fully visible and un-clipped per its ToS */
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
}

.map-tooltip {
  text-align: left;
  font-family: inherit;
  line-height: 1.3;
}

.map-tooltip-date {
  font-size: 0.75rem;
  font-weight: 600;
  opacity: 0.7;
}

.map-tooltip-name {
  font-size: 0.95rem;
  font-weight: 700;
}

.leaflet-popup-content a.map-popup-link {
  color: #1a73e8;
  text-decoration: underline;
}

.map-tooltip-meta {
  font-size: 0.75rem;
  opacity: 0.8;
}

/* records page — unlike the game page, this one scrolls normally */
body.records-body {
  overflow-y: auto;
  min-height: 100%;
}

.records-page {
  max-width: 700px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

.back-link {
  display: inline-block;
  margin-bottom: 16px;
  color: #3a2e40;
  text-decoration: none;
  font-weight: 600;
}

.back-link:hover {
  text-decoration: underline;
}

.records-title {
  font-size: clamp(1.6rem, 6vw, 2.4rem);
  text-align: center;
  margin: 0 0 32px;
  color: #3a2e40;
}

.records-section {
  margin-bottom: 32px;
}

.records-section h2 {
  font-size: 1.15rem;
  color: #3a2e40;
  margin: 0 0 12px;
}

.records-categories-heading {
  font-size: clamp(1.2rem, 4vw, 1.6rem);
  font-weight: 700;
  color: #3a2e40;
  text-align: center;
  margin: 8px 0 24px;
}

.records-list {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  max-width: min(480px, 100%);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.records-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.6);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
}

.records-rank {
  font-weight: 700;
  min-width: 30px;
  color: #3a2e40;
}

.records-main {
  flex: 1;
  font-weight: 600;
  color: #3a2e40;
}

.records-sub {
  font-size: 0.8rem;
  opacity: 0.7;
  color: #3a2e40;
  white-space: nowrap;
}

.records-empty {
  text-align: center;
  color: #3a2e40;
  font-size: 1.1rem;
}

.records-link {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 20;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  color: #3a2e40;
  text-decoration: none;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.records-link:hover {
  transform: scale(1.05);
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.14);
}

.new-run-btn-top {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 20;
  font-size: 0.85rem;
  padding: 8px 16px;
  background: #ffffff;
  color: #3a2e40;
}
