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

:root {
  --bg: #faf5ee;
  --bg-warm: #f5ead9;
  --card: #ffffff;
  --ink: #2b211b;
  --muted: #8a7c6f;
  --line: #ece2d4;
  --accent: #e85d3d;
  --accent-dark: #d14a2b;
  --accent-soft: #fdeee8;
  --green: #3d9960;
}

body {
  background: linear-gradient(180deg, var(--bg-warm), var(--bg) 400px);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  min-height: 100vh;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* Top bar */
.topbar {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-inner {
  width: min(860px, 92vw);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.brand {
  font-size: 1.2rem;
  font-weight: 800;
}

.back {
  color: var(--muted);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  transition: color 0.2s, border-color 0.2s;
  white-space: nowrap;
}

.back:hover { color: var(--ink); border-color: var(--accent); }

/* Layout */
.app {
  width: min(860px, 92vw);
  margin: 0 auto;
  padding: 40px 0 80px;
}

.hero { text-align: center; margin-bottom: 32px; }

.hero h2 {
  font-size: clamp(2.2rem, 6vw, 3.4rem);
  font-weight: 900;
  letter-spacing: -0.03em;
}

.hero p { margin-top: 10px; color: var(--muted); font-size: 1.05rem; }

/* Form card */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 28px;
  box-shadow: 0 20px 50px rgba(96, 70, 40, 0.1);
  display: grid;
  gap: 22px;
}

.field { display: grid; gap: 10px; }

.field-row {
  display: grid;
  gap: 22px;
}

@media (min-width: 640px) {
  .field-row { grid-template-columns: 1fr 1fr; }
}

.field-label {
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.field-hint, .auto-note {
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
  opacity: 0.8;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  padding: 9px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s, transform 0.1s;
}

.chip:hover { border-color: var(--accent); }

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.chip:active { transform: scale(0.96); }

/* CTA */
.cta {
  margin-top: 4px;
  padding: 16px;
  border: none;
  border-radius: 16px;
  background: var(--accent);
  color: white;
  font-family: inherit;
  font-weight: 900;
  font-size: 1.1rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 10px 24px rgba(232, 93, 61, 0.35);
}

.cta:hover {
  background: var(--accent-dark);
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(232, 93, 61, 0.45);
}

/* Results */
.result { margin-top: 30px; }
.hidden { display: none; }

.result-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

.result-head h2 { font-size: 1.7rem; font-weight: 900; letter-spacing: -0.02em; }

.reroll {
  padding: 10px 16px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  font-weight: 800;
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.reroll:hover { border-color: var(--accent); background: var(--accent-soft); }

.results-list { display: grid; gap: 18px; }

.food-result {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 24px;
  box-shadow: 0 14px 36px rgba(96, 70, 40, 0.08);
}

.food-result--top { border: 2px solid var(--accent); }

.fr-head { display: flex; gap: 16px; align-items: flex-start; }

.fr-emoji { font-size: 2.6rem; line-height: 1; }

.fr-title { flex: 1; min-width: 0; }

.fr-rank-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.rank {
  color: var(--accent);
  font-weight: 900;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.match {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--muted);
}

.match-bar {
  width: 70px;
  height: 6px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
  display: inline-block;
}

.match-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #f0955c);
}

.food-result h3 { font-size: 1.5rem; font-weight: 900; margin-top: 2px; }

.fr-budget { color: var(--green); font-size: 1rem; font-weight: 800; margin-left: 4px; }

.reasons {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.reasons li {
  background: var(--accent-soft);
  color: #a4432c;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 700;
}

.order-box {
  margin-top: 16px;
  background: #fbf7f0;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
}

.order-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.order-box ul { list-style: none; display: grid; gap: 6px; }

.order-box li {
  font-size: 0.95rem;
  padding-left: 18px;
  position: relative;
}

.order-box li::before {
  content: "→";
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 800;
}

.pro-tip {
  margin-top: 14px;
  font-size: 0.92rem;
  color: #6b5d4f;
  line-height: 1.55;
}

.fr-actions {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.nearby-btn {
  padding: 11px 16px;
  border-radius: 12px;
  border: none;
  background: var(--ink);
  color: #fff;
  font-family: inherit;
  font-weight: 800;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}

.nearby-btn:hover:not(:disabled) { background: #46372c; transform: translateY(-1px); }
.nearby-btn:disabled { opacity: 0.6; cursor: wait; }

.maps-link {
  color: var(--accent-dark);
  font-weight: 800;
  font-size: 0.9rem;
  text-decoration: none;
  padding: 11px 6px;
}

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

/* Nearby results */
.nearby { margin-top: 6px; }

.nearby-status {
  margin-top: 10px;
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 600;
}

.nearby .order-label { margin-top: 14px; }

.nearby-list { list-style: none; display: grid; gap: 8px; }

.nearby-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: #fbf7f0;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.nearby-list a {
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

.nearby-list a:hover { color: var(--accent-dark); text-decoration: underline; }

.nearby-meta { font-size: 0.82rem; color: var(--muted); font-weight: 600; }

.nearby-credit {
  margin-top: 8px;
  font-size: 0.72rem;
  color: var(--muted);
  opacity: 0.7;
}

.no-match { color: var(--muted); font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
