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

fieldset {
  border: none;
  min-inline-size: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:root {
  --green: #00d46a;
  --green-dark: #00b85c;
  --green-text: #007a3d;
  --coral: #ff6b4a;
  --coral-text: #c0392b;
  --blue: #4a90ff;
  --blue-text: #1a5cbf;
  --yellow: #f5c400;
  --yellow-text: #8a6d00;
  --bg: #fafaf8;
  --white: #fff;
  --ink: #1a1a1a;
  --grey: #6b6b6b;
  --faint: #e8e8e4;
  --border: #888;
  --radius: 14px;
}

body {
  font-family: 'Space Grotesk', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 460px;
  margin: 0 auto;
  padding: 0 20px 40px;
}

/* -- Header ------------------------------------------------------- */

header {
  padding: 32px 0 4px;
}

header h1 {
  font-size: 2.6rem;
  font-weight: 700;
  letter-spacing: -0.05em;
  line-height: 1;
  color: var(--ink);
}

header h1 a {
  color: inherit;
  text-decoration: none;
}


.tagline {
  font-size: 1.05rem;
  color: var(--grey);
  margin-top: 6px;
  font-weight: 400;
}

/* -- Form area ---------------------------------------------------- */

.form-area {
  margin-top: 24px;
}

.address-block {
  background: var(--white);
  border: 2px solid var(--faint);
  border-radius: var(--radius);
  padding: 14px 14px;
  min-height: 130px;
}

.address-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pip {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border-radius: 50%;
}

.pip-0 { background: var(--green); }
.pip-1 { background: var(--coral); }
.pip-2 { background: var(--blue); }
.pip-3 { background: var(--yellow); }

.route-line {
  width: 3px;
  height: 16px;
  background: var(--faint);
  margin: 4px 0 4px 6.5px;
  border-radius: 2px;
}

.autocomplete-wrapper {
  flex: 1;
  min-width: 0;
}

.autocomplete-wrapper gmp-place-autocomplete {
  display: block;
  width: 100%;
}

.autocomplete-wrapper gmp-place-autocomplete::part(input) {
  width: 100%;
  padding: 10px 0;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--ink);
  color-scheme: light;
  font-size: 1.05rem;
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-weight: 500;
  outline: none;
  transition: border-color 0.15s;
  touch-action: manipulation;
}

gmp-place-autocomplete {
  touch-action: manipulation;
}

#autocomplete-0 gmp-place-autocomplete::part(input):focus {
  border-bottom-color: var(--green);
}

#autocomplete-1 gmp-place-autocomplete::part(input):focus {
  border-bottom-color: var(--coral);
}

#autocomplete-2 gmp-place-autocomplete::part(input):focus {
  border-bottom-color: var(--blue);
}

#autocomplete-3 gmp-place-autocomplete::part(input):focus {
  border-bottom-color: var(--yellow);
}

.autocomplete-wrapper gmp-place-autocomplete::part(input)::placeholder {
  color: var(--grey);
  font-weight: 400;
}


/* -- Add friend / remove buttons --------------------------------- */

.add-friend-btn {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-top: 8px;
  padding: 0;
  background: none;
  border: none;
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--grey);
  cursor: pointer;
  transition: color 0.1s;
}


.add-friend-btn[hidden] {
  display: none;
}

.remove-person-btn {
  flex-shrink: 0;
  position: relative;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: var(--faint);
  color: var(--grey);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
  transition: all 0.15s;
  padding: 0;
}

.remove-person-btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  min-width: 44px;
  min-height: 44px;
}


/* -- Locate button ----------------------------------------------- */

.locate-btn {
  flex-shrink: 0;
  position: relative;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--white);
  color: var(--grey);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  padding: 0;
}

.locate-btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  min-width: 44px;
  min-height: 44px;
}


.locate-btn.loading {
  pointer-events: none;
  opacity: 0.5;
}

/* -- Geolocated label -------------------------------------------- */

.geo-label {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--ink);
}

.geo-label span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 4px;
}

.geo-clear {
  flex-shrink: 0;
  position: relative;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: var(--faint);
  color: var(--grey);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
  transition: all 0.15s;
  padding: 0;
}

.geo-clear::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  min-width: 44px;
  min-height: 44px;
}


/* -- Options ------------------------------------------------------ */

.options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill-row input[type="radio"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.pill-row label {
  padding: 7px 16px;
  border-radius: 100px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid var(--border);
  background: var(--white);
  color: var(--grey);
  transition: all 0.1s;
  user-select: none;
}


.pill-row input:checked + label {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--white);
}

/* -- Arrival time ------------------------------------------------- */

.arrive-wrap {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.arrive-wrap[hidden] {
  display: none;
}

.arrive-chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 100px;
  border: 2px solid var(--border);
  background: var(--white);
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--grey);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}


.arrive-chip[data-set],
.arrive-chip[data-open] {
  border-color: var(--ink);
  color: var(--ink);
}

.arrive-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.arrive-row[hidden] {
  display: none;
}

.arrive-row input[type="datetime-local"] {
  flex: 1;
  min-width: 0;
  padding: 6px 12px;
  border-radius: 100px;
  border: 2px solid var(--border);
  background: var(--white);
  color: var(--ink);
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-size: 1rem;
  font-weight: 500;
  outline: none;
  transition: border-color 0.1s;
}

.arrive-row input[type="datetime-local"]:focus {
  border-color: var(--ink);
}

.arrive-clear {
  flex-shrink: 0;
  position: relative;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: var(--faint);
  color: var(--grey);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
  transition: all 0.15s;
  padding: 0;
}

.arrive-clear::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  min-width: 44px;
  min-height: 44px;
}

.arrive-clear[hidden] {
  display: none;
}


/* -- Surprise button --------------------------------------------- */

.options > #v-surprise {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.surprise-btn {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-top: 2px;
  padding: 0;
  background: none;
  border: none;
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  font-style: italic;
  color: var(--grey);
  cursor: pointer;
  transition: color 0.1s;
  user-select: none;
}


#v-surprise:checked + .surprise-btn {
  color: var(--coral-text);
}

/* -- Button ------------------------------------------------------- */

#search-btn {
  width: 100%;
  margin-top: 16px;
  padding: 14px;
  border: none;
  border-radius: var(--radius);
  font-size: 1.1rem;
  font-weight: 700;
  font-family: 'Space Grotesk', system-ui, sans-serif;
  cursor: pointer;
  background: var(--green);
  color: var(--ink);
  letter-spacing: -0.02em;
  transition: all 0.1s;
}


#search-btn:active:not(:disabled) {
  transform: scale(0.98);
}

#search-btn:disabled {
  background: var(--faint);
  color: #b5b5b0;
  cursor: not-allowed;
}

/* -- Error -------------------------------------------------------- */

.error-banner {
  background: #fff0ed;
  color: var(--coral-text);
  border: 2px solid #ffd6cc;
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-top: 16px;
  font-size: 0.9rem;
  font-weight: 600;
}

.error-hint {
  margin-top: 0.75em;
  font-weight: 400;
}

.error-retry-btn {
  display: block;
  margin-top: 4px;
  background: none;
  border: none;
  padding: 4px 0;
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--coral-text);
  cursor: pointer;
  text-decoration: underline;
}

/* -- Loading ------------------------------------------------------ */

.loading {
  text-align: center;
  padding: 32px 0 16px;
}

.bounce {
  display: inline-flex;
  gap: 6px;
}

.bounce span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  animation: bob 1s ease-in-out infinite;
}

.bounce span:nth-child(2) { animation-delay: 0.15s; }
.bounce span:nth-child(3) { animation-delay: 0.3s; }

@keyframes bob {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-12px); }
}

.loading p {
  color: var(--grey);
  font-size: 0.9rem;
  margin-top: 12px;
  font-weight: 500;
}

/* -- Map ---------------------------------------------------------- */

.map-wrap {
  margin-top: 20px;
  border-radius: 18px;
  overflow: hidden;
  border: 2px solid var(--faint);
}

#map {
  width: 100%;
  height: 300px;
}

/* -- Results ------------------------------------------------------ */

.results {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.results-heading-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
}

.results-heading {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.reroll-btn {
  flex-shrink: 0;
  padding: 4px 12px;
  border-radius: 100px;
  border: 2px solid var(--faint);
  background: var(--white);
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--grey);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.result-card {
  padding: 16px 0;
  border-bottom: 2px solid var(--faint);
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.result-card:last-of-type {
  border-bottom: none;
}

.result-rank {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.result-card .result-rank {
  background: var(--faint);
  color: var(--ink);
}

.result-card--top .result-rank {
  background: var(--green);
  color: var(--ink);
}

.result-info {
  flex: 1;
  min-width: 0;
}

.result-name {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.result-name-link {
  color: inherit;
  text-decoration: none;
}

.result-name-link:hover,
.result-name-link:focus-visible {
  text-decoration: underline;
}

.result-rating {
  font-weight: 500;
  font-size: 0.82rem;
  color: var(--grey);
}

.result-address {
  color: var(--grey);
  font-size: 0.82rem;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-hours {
  font-size: 0.82rem;
  margin-top: 2px;
}

.hours-open { color: var(--green-text); }
.hours-closed { color: var(--grey); }

.result-times {
  display: flex;
  flex-wrap: wrap;
  gap: 0 8px;
  margin-top: 8px;
  font-size: 0.85rem;
  font-weight: 600;
}

.time-break {
  flex-basis: 100%;
  height: 0;
}

.time-person { font-weight: 600; }

.time-p0 { color: var(--green-text); }
.time-p1 { color: var(--coral-text); }
.time-p2 { color: var(--blue-text); }
.time-p3 { color: var(--yellow-text); }

.time-sep {
  color: var(--grey);
}

.result-leave {
  display: flex;
  flex-wrap: wrap;
  gap: 0 8px;
  margin-top: 4px;
  font-size: 0.85rem;
  font-weight: 600;
}

.leave-label {
  color: var(--grey);
  font-weight: 500;
}

.result-fairness {
  font-size: 0.8rem;
  color: var(--grey);
  margin-top: 4px;
}

.result-footnote {
  font-size: 0.85rem;
  color: var(--grey);
  margin: 16px 0 0;
}

.result-link {
  display: inline-block;
  min-height: 24px;
  margin-top: 4px;
  padding: 4px 0;
  font-size: 0.8rem;
  color: var(--ink);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--faint);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  transition: text-decoration-color 0.1s;
}


/* -- Map markers -------------------------------------------------- */

.marker {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.7rem;
  font-family: 'Space Grotesk', system-ui, sans-serif;
}

.marker.you     { background: var(--green); color: #fff; }
.marker.them    { background: var(--coral); color: #fff; }
.marker.friend3 { background: var(--blue); color: #fff; }
.marker.friend4 { background: var(--yellow); color: #1a1a1a; }
.marker.venue   { background: #1a1a1a; color: #fff; cursor: pointer; }

/* -- Share button ------------------------------------------------- */

.copy-link-btn {
  display: block;
  width: 100%;
  margin-top: 20px;
  padding: 12px;
  background: var(--white);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--grey);
  cursor: pointer;
  transition: all 0.1s;
}


.bmc-link {
  display: block;
  margin-top: 14px;
  font-size: 0.8rem;
  color: var(--grey);
  text-align: center;
  text-decoration: underline;
  text-decoration-color: var(--faint);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 0.1s, text-decoration-color 0.1s;
}

/* -- Install nudge ----------------------------------------------- */

html:has(.install-nudge:not([hidden])) {
  scroll-padding-bottom: calc(70px + env(safe-area-inset-bottom));
}

.install-nudge {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--white);
  border-top: 2px solid var(--faint);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--grey);
  z-index: 100;
}

.install-nudge[hidden] {
  display: none;
}

#install-nudge-msg {
  flex: 1;
  min-width: 0;
  line-height: 1.4;
}

.install-nudge-btn {
  flex-shrink: 0;
  padding: 5px 12px;
  border-radius: 100px;
  border: 2px solid var(--border);
  background: var(--white);
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.1s;
}


.install-nudge-close {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: var(--faint);
  color: var(--grey);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
  padding: 0;
  transition: all 0.15s;
}


/* -- No-JS message ------------------------------------------------ */

.noscript-msg {
  margin-top: 16px;
  padding: 16px;
  background: var(--white);
  border: 2px solid var(--faint);
  border-radius: var(--radius);
  font-size: 0.9rem;
  color: var(--grey);
  font-weight: 500;
  line-height: 1.5;
}

/* -- About -------------------------------------------------------- */

.about {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 2px solid var(--faint);
}

.about p {
  font-size: 0.82rem;
  color: var(--grey);
  font-weight: 500;
  line-height: 1.6;
}

/* -- Focus -------------------------------------------------------- */

#search-btn:focus-visible,
.locate-btn:focus-visible,
.geo-clear:focus-visible,
.result-link:focus-visible,
.bmc-link:focus-visible,
.copy-link-btn:focus-visible,
.remove-person-btn:focus-visible,
.add-friend-btn:focus-visible,
.reroll-btn:focus-visible,
.arrive-clear:focus-visible,
.arrive-chip:focus-visible,
.install-nudge-btn:focus-visible,
.error-retry-btn:focus-visible,
.install-nudge-close:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.pill-row input[type="radio"]:focus-visible + label,
#v-surprise:focus-visible + .surprise-btn {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* -- Responsive --------------------------------------------------- */

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141412;
    --white: #1e1e1b;
    --ink: #f0f0ee;
    --grey: #8a8a86;
    --faint: #2e2e2a;
    --border: #555552;
    --green-text: #00c862;
    --coral-text: #ff7055;
    --blue-text: #6aadff;
    --yellow-text: #f5c400;
  }

  body {
    color-scheme: dark;
  }

  .autocomplete-wrapper gmp-place-autocomplete::part(input) {
    color: var(--ink);
    color-scheme: dark;
  }

  .error-banner {
    background: #2a1510;
    border-color: #5a2820;
  }

  .install-nudge {
    background: #272724;
    border-top-color: var(--border);
  }
}

@media (prefers-reduced-motion: reduce) {
  .bounce span { animation: none; }
}

@media (max-width: 480px) {
  .app { padding: 0 16px 32px; }
  header h1 { font-size: 2.1rem; }
  #map { height: 250px; }
}

@media (hover: hover) {
  .add-friend-btn:hover { color: var(--ink); }
  .remove-person-btn:hover { background: var(--coral); color: var(--white); }
  .locate-btn:hover { border-color: var(--green); color: var(--green); }
  .geo-clear:hover { background: var(--coral); color: var(--white); }
  .pill-row label:hover { border-color: var(--ink); color: var(--ink); }
  .arrive-chip:hover { border-color: var(--ink); color: var(--ink); }
  .arrive-clear:hover { background: var(--coral); color: var(--white); }
  .reroll-btn:hover { color: var(--ink); border-color: var(--border); }
  .surprise-btn:hover { color: var(--coral-text); }
  #search-btn:hover:not(:disabled) { background: var(--green-dark); }
  .result-link:hover { text-decoration-color: var(--ink); }
  .bmc-link:hover { color: var(--ink); text-decoration-color: var(--ink); }
  .copy-link-btn:hover { color: var(--ink); border-color: var(--ink); }
  .install-nudge-btn:hover { border-color: var(--ink); }
  .install-nudge-close:hover { background: var(--coral); color: var(--white); }
}
