/* Sweet Spot: mobile-first styles, light and dark. */
:root {
  --bg: #f5f2ec;
  --card: #ffffff;
  --text: #1d2629;
  --muted: #5b676b;
  --line: #e2ddd3;
  --accent: #2f6f5e;
  --accent-ink: #ffffff;
  --accent-soft: #e2efe9;
  --like: #2e6fab;
  --like-soft: #e3eef8;
  --love: #c63d55;
  --love-soft: #fbe6ea;
  --star: #b7791f;
  --star-soft: #fdf1d8;
  --warn: #7a5200;
  --warn-soft: #fff3d6;
  --danger: #b3261e;
  --danger-ink: #ffffff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 6px 18px rgba(0, 0, 0, .05);
  --pop: #ffffff;
  --pop-line: rgba(60, 60, 67, .14);
  --pop-shadow: rgba(0, 0, 0, .16);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121719;
    --card: #1b2225;
    --text: #e6ebec;
    --muted: #9aa8ac;
    --line: #2d383c;
    --accent: #5cb497;
    --accent-ink: #0c1a15;
    --accent-soft: #1f3530;
    --like: #86b9e8;
    --like-soft: #1d2c3a;
    --love: #ef8296;
    --love-soft: #3a2027;
    --star: #f2c66d;
    --star-soft: #382d17;
    --warn: #f2c66d;
    --warn-soft: #352c19;
    --danger: #ff8a80;
    --danger-ink: #2a0c0a;
    --shadow: none;
    --pop: #2a3438;
    --pop-line: rgba(255, 255, 255, .09);
    --pop-shadow: rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 1.7rem; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1.05rem; }
p { margin: 0; }

/* Wrapping rules, used everywhere:
   - headings that take two or three lines get lines of similar length
   - paragraphs avoid leaving a single word on the last line
   - "A · B · C" detail lines break only between parts (.meta-part), never inside one
   - short phrases (drive ranges, links, badges) are never split */
h1, h2 { text-wrap: balance; }
h3, p, li { text-wrap: pretty; }
.meta-part { display: inline-block; max-width: 100%; }
.drive-range, .links, .badge, .match, .chip { white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- layout ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--card);
  position: sticky; top: 0; z-index: 1000;
}
.brand { font-weight: 700; text-decoration: none; color: var(--text); }
.me-chip { display: inline-flex; align-items: center; gap: 4px; font-size: .9rem; color: var(--muted); }
/* --bottom-bar is the height of the host bar pinned to the bottom of the screen (set by
   outing.js, 0 when there isn't one), so the end of the page, footer included, clears it. */
body { padding-bottom: var(--bottom-bar, 0px); }
.wrap { max-width: 760px; margin: 0 auto; padding: 16px 16px 24px; }
.footer { max-width: 760px; margin: 0 auto; padding: 0 16px 32px; font-size: .8rem; color: var(--muted); }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px;
}
.card.highlight { border-color: var(--accent); background: var(--accent-soft); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row > input { flex: 1 1 180px; min-width: 0; }
.row.end { justify-content: flex-end; }
.center { text-align: center; align-items: center; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.two-up { display: grid; gap: 0 14px; }
@media (min-width: 700px) { .two-up { grid-template-columns: 1fr 1fr; } }

.hero { padding: 12px 0 20px; }
.hero h1 { font-size: 2.1rem; margin-bottom: 8px; }
.lead { font-size: 1.05rem; color: var(--muted); max-width: 36em; }
.steps { margin: 8px 0 0; padding-left: 1.3em; display: grid; gap: 6px; }
.recent-list { list-style: none; margin: 0; padding: 0; }
.recent-list li { display: flex; align-items: center; gap: 10px; padding: 2px 0; border-top: 1px solid var(--line); }
.recent-list li:first-child { border-top: 0; }
.recent-list a { flex: 1; min-width: 0; overflow-wrap: anywhere; padding: 6px 0; }
.recent-list .small { white-space: nowrap; letter-spacing: .08em; }
.forget { flex: none; width: 36px; height: 36px; margin-right: -8px; border: 0; border-radius: 50%; background: transparent;
  color: var(--muted); font: inherit; cursor: pointer; }
.forget:hover, .forget:focus-visible { background: var(--line); color: var(--text); }

.outing-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; margin: 4px 0 16px; }
.code-chip { font-size: .85rem; color: var(--muted); background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; }
.code-chip strong { letter-spacing: .12em; color: var(--text); }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .95rem; }
input[type=text], select {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%;
}
select { width: auto; }
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px;
}
.code-input { text-transform: uppercase; letter-spacing: .3em; font-weight: 700; font-size: 1.2rem; }
.form-error { color: var(--danger); font-weight: 600; }
.form-error:empty { display: none; }
.note { background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: 8px 12px; font-size: .875rem; }
.banner { background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; font-weight: 600; }

/* ---------- buttons ---------- */
.btn {
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; text-align: center;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 10px; padding: 9px 14px; min-height: 42px;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--danger); color: var(--danger-ink); border-color: var(--danger); }
.btn.danger:hover { filter: brightness(1.07); }
.btn.big { padding: 12px 18px; font-size: 1.05rem; width: 100%; }
.linkish { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: left; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
.linkish:hover { text-decoration-color: var(--accent); }

/* ---------- interest chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font: inherit; font-size: .95rem; cursor: pointer; border-radius: 999px; padding: 7px 12px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
}
.chip.small { font-size: .85rem; padding: 5px 10px; }
.chip.like { background: var(--like-soft); border-color: var(--like); }
.chip.love { background: var(--love-soft); border-color: var(--love); font-weight: 600; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* ---------- location picking ---------- */
.results { display: grid; gap: 6px; font-size: .925rem; }
.result {
  font: inherit; text-align: left; cursor: pointer; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
}
.result:hover { border-color: var(--accent); }
.chosen { font-weight: 600; }
.check { color: var(--accent); }

/* ---------- maps ---------- */
.map { height: 340px; border-radius: var(--radius); border: 1px solid var(--line); margin-bottom: 14px; z-index: 0; }
.map.small { height: 230px; margin-bottom: 0; }
.friend-pin span {
  display: flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%;
  color: #fff; font-weight: 700; font-size: .9rem; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
}
.place-pin span {
  display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%;
  background: #fff; border: 2px solid #8a9599; font-size: 1.05rem; box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
}
.place-pin.voted span { border-color: #2f6f5e; border-width: 3px; }
.place-pin.winner span { width: 44px; height: 44px; font-size: 1.4rem; border-color: #b7791f; border-width: 3px; }

/* ---------- lobby ---------- */
.code-big { font-size: 2.2rem; font-weight: 800; letter-spacing: .25em; color: var(--accent); }
.link-input { font-size: .9rem; }
.people { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.people li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.people li:last-child { border-bottom: 0; }
.person-name { font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.person-meta { color: var(--muted); font-size: .875rem; margin-left: auto; }
.people .remove { font-size: .8rem; color: var(--danger); text-decoration-color: currentColor; }
.person-interests { width: 100%; padding-left: 22px; font-size: .95rem; }
.person-interests:empty { display: none; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; flex: none; }
.badge { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; border-radius: 6px; padding: 1px 6px; background: var(--accent-soft); color: var(--accent); }
.badge.you { background: var(--like-soft); color: var(--like); }
.badge.absentee { background: var(--line); color: var(--muted); }
/* "Ann is already in this outing. Is that you? [That's me]" */
.name-match { display: grid; gap: 8px; padding: 12px; border-radius: 10px; background: var(--accent-soft); border: 1px solid var(--accent); }
.name-match p { margin: 0; }
.name-match .form-error:empty { display: none; }

.spinner {
  width: 44px; height: 44px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--accent);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* ---------- voting ---------- */
.areas { margin: 0; padding-left: 1.3em; display: grid; gap: 4px; }
/* "2 of 4 have voted" with a bar that fills as people vote */
.progress { display: grid; gap: 8px; }
.progress-text { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 2px 12px; }
.progress-bar { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress-bar span { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .3s ease; }
.leader { margin: 0; font-size: .9rem; }
.leader .linkish { font-weight: 600; text-decoration-color: var(--accent); }

/* Place count + sort on one line, filter chips below */
.toolbar { display: grid; gap: 10px; margin-bottom: 14px; }
.toolbar-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.toolbar-top select { padding: 7px 10px; }
.toolbar .chip { flex: none; }
@media (max-width: 699px) {
  /* One row you swipe sideways, running to the screen edges */
  .toolbar .chips {
    flex-wrap: nowrap; overflow-x: auto; margin: -4px -16px; padding: 4px 16px;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .toolbar .chips::-webkit-scrollbar { display: none; }
}

.places { display: grid; gap: 12px; }
.place {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; display: grid; gap: 12px; scroll-margin: 80px;
}
.place.flash { animation: flash 1.4s ease-out; }
@keyframes flash { from { box-shadow: 0 0 0 4px var(--accent); } to { box-shadow: var(--shadow); } }
/* Icon tile | name + "#1 · Golf · Near Auburn" | match % */
.place-head { display: flex; align-items: flex-start; gap: 12px; }
.place-icon {
  flex: none; display: grid; place-items: center; width: 46px; height: 46px;
  border-radius: 12px; background: var(--bg); font-size: 1.6rem; line-height: 1;
}
.place-title { flex: 1; min-width: 0; padding-top: 1px; }
.place-title h3 { font-size: 1rem; overflow-wrap: break-word; margin-bottom: 2px; }
/* The name is a button that shows the place on the map: underline only on hover, so a
   two-line name doesn't get two heavy underlines. */
.place-name { color: inherit; text-decoration: none; }
.place-name:hover, .place-name:focus-visible { text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 3px; }
.match { font-weight: 800; color: var(--accent); background: var(--accent-soft); border-radius: 8px; padding: 2px 8px; font-size: .9rem; }
.place-title .match { float: right; margin: 0 0 4px 10px; }
.reason { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; min-height: 26px; }
/* "❤️ 3" pill: tap to see who likes this kind of place */
.hearts {
  position: relative; display: inline-flex; align-items: center; gap: 5px;
  min-height: 28px; padding: 4px 11px 4px 9px; border: 0; border-radius: 999px;
  font: inherit; font-size: .875rem; font-weight: 700; line-height: 1;
  color: var(--love); background: var(--love-soft); cursor: pointer;
  -webkit-tap-highlight-color: transparent; transition: transform .12s ease, box-shadow .12s ease;
}
.hearts::before { content: ""; position: absolute; inset: -8px -4px; } /* bigger tap target */
.hearts:active { transform: scale(.93); }
.hearts[aria-expanded="true"] { box-shadow: 0 0 0 2px var(--love); }
.hearts:focus-visible { outline: 3px solid color-mix(in srgb, var(--love) 45%, transparent); outline-offset: 2px; }
.hearts-icon { font-size: .95rem; }
/* "✨ Worth a look": a well-known spot of a kind nobody picked */
.worth-a-look {
  display: inline-flex; align-items: center; min-height: 28px; padding: 4px 11px 4px 9px; border-radius: 999px;
  font-size: .875rem; font-weight: 700; line-height: 1; color: var(--warn); background: var(--star-soft);
}

/* iOS-style popover listing who likes it */
.fans-pop {
  position: absolute; z-index: 1500; width: max-content; min-width: 210px; max-width: min(300px, calc(100vw - 32px));
  background: var(--pop); color: var(--text); border-radius: 14px;
  filter: drop-shadow(0 10px 28px var(--pop-shadow)) drop-shadow(0 1px 2px var(--pop-shadow));
  transform-origin: var(--arrow-x, 50%) top; animation: pop-in .18s cubic-bezier(.2, .9, .3, 1.15);
}
.fans-pop.above { transform-origin: var(--arrow-x, 50%) bottom; }
.fans-pop:focus { outline: none; }
.fans-pop::before { /* arrow */
  content: ""; position: absolute; left: var(--arrow-x, 50%); top: -9px; width: 20px; height: 10px;
  transform: translateX(-50%); background: var(--pop); clip-path: polygon(50% 0, 100% 100%, 0 100%);
}
.fans-pop.above::before { top: auto; bottom: -9px; clip-path: polygon(0 0, 100% 0, 50% 100%); }
.fans-pop-title {
  margin: 0; padding: 11px 16px 8px; text-align: center;
  font-size: .8rem; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--pop-line);
}
.fans-pop-list { list-style: none; margin: 0; padding: 4px 0; max-height: min(55vh, 340px); overflow-y: auto; }
.fans-pop-list li { position: relative; display: flex; align-items: center; gap: 10px; padding: 8px 16px; }
.fans-pop-list li + li::before { content: ""; position: absolute; top: 0; right: 0; left: 54px; border-top: 1px solid var(--pop-line); }
.avatar {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%; color: #fff; font-size: .8rem; font-weight: 700; line-height: 1;
}
.fans-pop-name { flex: 1; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.fans-pop-level { font-size: .8rem; color: var(--muted); white-space: nowrap; }
@keyframes pop-in { from { opacity: 0; transform: scale(.9); } }
@media (prefers-reduced-motion: reduce) {
  .fans-pop { animation: none; }
  .hearts { transition: none; }
}
/* Drive times as a small table in even columns. The page picks the column count from the group
   size (--cols-sm on phones, at most 2; --cols-lg wider, at most 4) so rows come out as even as
   possible: 2 people split the panel, 5 people are 3 + 2 rather than 4 + 1. An odd person out
   sits in the first column like everyone else.
   Each person gets a line on their left and top; the panel clips the ones on its outer edge,
   so lines only show *between* people. */
.drives {
  display: grid; grid-template-columns: repeat(var(--cols-sm, 2), minmax(0, 1fr));
  border-radius: 10px; background: var(--bg); font-size: .8125rem; overflow: hidden;
}
@media (min-width: 640px) {
  .drives { grid-template-columns: repeat(var(--cols-lg, 4), minmax(0, 1fr)); font-size: .875rem; }
}
.drive {
  display: flex; justify-content: center; min-width: 0; padding: 8px;
  border-left: 1px solid var(--line); border-top: 1px solid var(--line); margin: -1px 0 0 -1px;
}
/* Name and time stay together: in a wide cell they're kept within 220px and centered. */
.drive-in { flex: 0 1 220px; min-width: 0; display: flex; align-items: center; gap: 5px; }
.drive-in .dot { width: 10px; height: 10px; }
.drive-name { flex: 1; min-width: 0; overflow-wrap: break-word; line-height: 1.3; }
.drive-time { flex: none; color: var(--muted); font-variant-numeric: tabular-nums; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}
.place-info { display: flex; flex-wrap: wrap; gap: 2px 16px; }
/* Phones: two equal vote buttons, then tally (left) and links (right).
   Wider screens: buttons on the left, tally and links filling the rest of the row. */
.place-foot { display: grid; gap: 10px; align-items: center; }
.vote-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.foot-meta { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 16px; }
@media (min-width: 640px) {
  .place-foot { grid-template-columns: auto 1fr; gap: 16px; }
  .vote-buttons { grid-template-columns: repeat(2, minmax(130px, auto)); }
}
.btn.vote.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.star.on { background: var(--star-soft); color: var(--star); border-color: var(--star); }
.tally { font-size: .875rem; color: var(--muted); }
.links { display: inline-flex; gap: 16px; font-size: .875rem; margin-left: auto; }
.links .linkish { color: var(--accent); text-decoration-color: currentColor; }

.host-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000;
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--card); border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(0, 0, 0, .06);
}
.host-label { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
/* On the smallest phones, drop the label so both buttons fit on one row */
@media (max-width: 359px) { .host-label { display: none; } }

.dialog {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--text);
  width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 64px); padding: 18px;
}
.dialog::backdrop { background: rgba(0, 0, 0, .45); }
.pick-list { display: grid; gap: 6px; max-height: 50vh; overflow-y: auto; }
.pick-option { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.pick-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.pick-name { flex: 1; font-weight: 600; }

.compute-step { margin: 0; font-weight: 600; min-height: 1.5em; }
/* "3 fair areas found: Auburn, MA · Dudley, MA · Boylston, MA" under the step */
#compute-areas { margin: 0; }
.compute-area-names { display: inline; }

/* ---------- winner ---------- */
.winner { border-color: var(--star); }
.eyebrow { font-weight: 700; color: var(--star); text-transform: uppercase; letter-spacing: .05em; font-size: .85rem; }
.winner-name { font-size: 1.6rem; }
/* Phones: Directions across the top, the other buttons share the row below. Wider: one row. */
.winner-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.winner-actions .primary, .winner-actions > :last-child:nth-child(2) { grid-column: 1 / -1; }
@media (min-width: 640px) {
  .winner-actions { display: flex; flex-wrap: wrap; }
}

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--bottom-bar, 0px) + 20px); transform: translate(-50%, 20px); opacity: 0; z-index: 2000;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600;
  transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }
