:root {
  --cream: #F6F3EA;
  --paper: #FFFDF7;
  --ink: #110301;
  --rust: #8F381C;
  --brown: #74460E;
  --caramel: #C39259;
  --butter: #FDD697;
  --peach: #ECBA89;
  --hero-bg: var(--butter);
  --hero-ink: var(--ink);
  --display: 'Bricolage Grotesque', 'Arial Narrow', sans-serif;
  --body: 'Instrument Sans', system-ui, sans-serif;
  --mono: 'DM Mono', ui-monospace, monospace;
  --rule: 1.5px solid var(--ink);
  --ease-out: cubic-bezier(0.2, 0.9, 0.2, 1);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: #E9E1CF;
  color: var(--ink);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2.5px solid var(--rust); outline-offset: 2px; }
.mono { font-family: var(--mono); letter-spacing: 0.08em; text-transform: uppercase; }

/* ---------- App frame (phone first; a centered column on bigger screens) ---------- */
.app {
  position: relative;
  max-width: 440px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  background: var(--cream);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
@media (min-width: 520px) {
  .app { border-inline: var(--rule); }
}

/* ---------- Header + pills ---------- */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(var(--safe-top) + 12px) 20px 0;
}
.brand { display: flex; align-items: center; gap: 10px; }
.wordmark {
  font-family: var(--display);
  font-stretch: 75%;
  font-weight: 800;
  font-size: 32px;
  line-height: 1;
  letter-spacing: -0.01em;
}
.icon-btn {
  width: 44px; height: 44px; flex-shrink: 0;
  border-radius: 999px;
  border: var(--rule);
  background: transparent;
  display: grid; place-items: center;
  padding: 0;
  transition: transform 160ms var(--ease-out);
}
.icon-btn.solid { background: var(--ink); color: var(--cream); border-color: var(--ink); }
.icon-btn:active, .btn:active, .pill:active { transform: scale(0.96); }

.pills {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 16px 20px 14px;
  border-bottom: var(--rule);
  scrollbar-width: none;
  flex-shrink: 0;
}
.pills::-webkit-scrollbar { display: none; }
.pill {
  flex-shrink: 0;
  height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  border: var(--rule);
  background: transparent;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 220ms ease, color 220ms ease, transform 160ms var(--ease-out);
}
.pill[aria-pressed="true"] { background: var(--ink); color: var(--cream); }
.pill.new { border-style: dashed; border-color: var(--brown); color: var(--brown); }

/* ---------- Scroll area ---------- */
.scroller {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.scroller::-webkit-scrollbar { display: none; }

.hero {
  padding: 20px 20px 24px;
  background: var(--hero-bg);
  color: var(--hero-ink);
  transition: background 420ms ease, color 420ms ease;
}
.hero-meta { display: flex; justify-content: space-between; font-size: 12px; }
.hero-title {
  margin: 14px 0 20px;
  font-family: var(--display);
  font-stretch: 75%;
  font-weight: 800;
  font-size: 112px;
  line-height: 0.86;
  letter-spacing: -0.02em;
  overflow: hidden;
  padding-bottom: 0.04em;
}
.hero-title.mid { font-size: 88px; }
.hero-title.long { font-size: 68px; }
.hero-title.xlong { font-size: 54px; }
.hero-title span { display: block; }
.hero-title.reveal span { animation: rise 520ms var(--ease-out) both; }

.seg {
  display: flex;
  border: 1.5px solid var(--hero-ink);
  border-radius: 999px;
  padding: 3px;
}
.seg button {
  flex: 1;
  height: 44px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--hero-ink);
  font-size: 15px;
  font-weight: 650;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: background 240ms ease, color 240ms ease;
}
.seg button .mono { font-size: 12px; letter-spacing: 0.04em; }
.seg button[aria-pressed="true"] { background: var(--hero-ink); color: var(--hero-bg); }

.ticker {
  background: var(--ink);
  color: var(--cream);
  height: 34px;
  display: flex;
  align-items: center;
  overflow: hidden;
  white-space: nowrap;
  font-size: 12px;
  letter-spacing: 0.12em;
}
.ticker-track { display: inline-block; padding-left: 20px; animation: marquee 28s linear infinite; }

/* ---------- Ranked list ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.row {
  width: 100%;
  min-height: 88px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  border: 0;
  border-bottom: var(--rule);
  background: transparent;
  text-align: left;
  transition: background 200ms ease;
}
.row:active { background: rgba(195, 146, 89, 0.16); }
.list.enter li { animation: rise 460ms var(--ease-out) both; animation-delay: calc(var(--i, 0) * 38ms); }
.row.flash { animation: flash 1400ms ease-out; }

.rank {
  width: 64px;
  flex-shrink: 0;
  font-family: var(--display);
  font-stretch: 75%;
  font-weight: 800;
  font-size: 54px;
  line-height: 0.9;
  letter-spacing: -0.02em;
  color: var(--rust);
}
.rank.hollow { color: transparent; -webkit-text-stroke: 1.5px var(--rust); }
.rank.slot { color: transparent; -webkit-text-stroke: 1.5px var(--caramel); }

.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.row-name { font-size: 19px; font-weight: 650; line-height: 1.15; }
.row-dish { font-size: 14px; line-height: 1.3; }
.row-dish.empty { color: var(--brown); }
.row-dish .tag { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--rust); margin-right: 6px; }
.row-area { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--brown); }
.chev { flex-shrink: 0; }

.slot-row {
  min-height: 72px;
  padding: 10px 20px;
  border-bottom: 1.5px dashed var(--caramel);
  color: var(--brown);
}
.slot-label { flex: 1; font-size: 15px; font-weight: 600; }
.slot-add { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
.empty-note { padding: 18px 20px; border-bottom: var(--rule); color: var(--brown); font-size: 15px; line-height: 1.45; }

.list-tools { display: flex; justify-content: center; padding: 20px 20px 0; }

.bigfoot {
  margin-top: 28px;
  background: var(--rust);
  color: var(--cream);
  padding: 36px 20px calc(var(--safe-bottom) + 96px);
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.bigfoot-meta { display: flex; justify-content: space-between; font-size: 12px; letter-spacing: 0.1em; }
.bigfoot-word {
  font-family: var(--display);
  font-stretch: 75%;
  font-weight: 800;
  font-size: clamp(84px, 30vw, 124px);
  line-height: 0.82;
  letter-spacing: -0.03em;
}

/* ---------- Buttons + fields ---------- */
.btn {
  height: 52px;
  border-radius: 999px;
  border: var(--rule);
  background: transparent;
  font-size: 16px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  text-decoration: none;
  color: var(--ink);
  transition: transform 160ms var(--ease-out), opacity 200ms ease;
}
.btn.outline { height: 48px; font-size: 15px; font-weight: 650; }
.btn.solid { background: var(--ink); color: var(--cream); }
.btn.butter { background: var(--butter); }
.btn:disabled { opacity: 0.35; }
.row-2 { display: flex; gap: 10px; }
.row-2 .btn { flex: 1; }

.text-btn {
  align-self: center;
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  background: transparent;
  color: var(--rust);
  font-size: 14px;
  font-weight: 650;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.text-btn.ink { color: var(--ink); text-decoration: none; align-self: flex-start; padding: 0; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 11px; letter-spacing: 0.1em; color: var(--brown); }
.input, .search {
  height: 52px;
  border: var(--rule);
  border-radius: 16px;
  background: var(--paper);
  font-size: 17px;
}
.input { padding: 0 16px; width: 100%; outline: none; }
.input:focus, .search:focus-within { box-shadow: 0 0 0 3px rgba(143, 56, 28, 0.25); }
.search { display: flex; align-items: center; gap: 10px; padding: 0 16px; }
.search input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; font-size: 17px; }
.search input::-webkit-search-cancel-button { display: none; }

/* ---------- Sheets ---------- */
.scrim {
  position: absolute; inset: 0;
  border: 0; padding: 0;
  background: rgba(17, 3, 1, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity 320ms ease, visibility 0s linear 320ms;
  z-index: 10;
}
.scrim.show { opacity: 1; visibility: visible; transition: opacity 320ms ease, visibility 0s; }

.sheet {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  max-height: calc(100% - var(--safe-top) - 24px);
  background: var(--cream);
  border-top: var(--rule);
  border-radius: 28px 28px 0 0;
  transform: translateY(105%);
  visibility: hidden;
  /* Hide only after sliding out; become visible instantly on open so inputs can take focus. */
  transition: transform 440ms var(--ease-out), visibility 0s linear 440ms;
  z-index: 11;
  display: flex;
  flex-direction: column;
  padding-bottom: var(--safe-bottom);
}
.sheet.open { transform: translateY(0); visibility: visible; transition: transform 440ms var(--ease-out), visibility 0s; }
.sheet.dragging { transition: none; }
.sheet-tall { top: calc(var(--safe-top) + 24px); }
.sheet-inner { display: flex; flex-direction: column; overflow-y: auto; }
.sheet-head { padding: 10px 20px 0; display: flex; flex-direction: column; gap: 14px; touch-action: none; }
.grabber { width: 44px; height: 5px; border-radius: 999px; background: var(--caramel); align-self: center; }
.sheet-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.sheet-title {
  margin: 0;
  font-family: var(--display);
  font-stretch: 75%;
  font-weight: 800;
  font-size: 44px;
  line-height: 0.9;
  letter-spacing: -0.02em;
}
.crumb { font-size: 12px; color: var(--rust); margin-top: 6px; }
.sheet-head .crumb:first-child { margin-top: 0; }
.sheet-scroll { flex: 1; overflow-y: auto; margin-top: 8px; border-top: var(--rule); }

.results { list-style: none; margin: 0; padding: 0; }
.result {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px;
  min-height: 64px;
  border-bottom: var(--rule);
}
.result-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.result-name { font-size: 17px; font-weight: 650; line-height: 1.2; }
.result-sub { font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--brown); line-height: 1.4; }
.result .btn { height: 44px; min-width: 76px; padding: 0 16px; font-size: 14px; flex-shrink: 0; }
.result .btn:disabled { opacity: 1; background: transparent; color: var(--brown); border-color: var(--caramel); }
.results-note { padding: 18px 20px; color: var(--brown); font-size: 15px; line-height: 1.45; }
.powered { padding: 16px 20px 28px; font-size: 11px; color: var(--brown); text-transform: none; }

.detail-rank {
  font-family: var(--display);
  font-stretch: 75%;
  font-weight: 800;
  font-size: 104px;
  line-height: 0.82;
  letter-spacing: -0.03em;
  color: var(--rust);
  margin-top: 4px;
}
.detail-rank.hollow { color: transparent; -webkit-text-stroke: 2px var(--rust); }
.detail-body { padding: 16px 20px 24px; display: flex; flex-direction: column; gap: 16px; }
.detail-name { margin: 0; font-family: var(--display); font-weight: 700; font-size: 30px; line-height: 1.05; letter-spacing: -0.01em; }
.detail-area { display: flex; align-items: flex-start; gap: 6px; margin-top: 8px; font-size: 12px; color: var(--brown); line-height: 1.4; }
.detail-area svg { flex-shrink: 0; margin-top: 1px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chips:empty { display: none; }
.chips .label { font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--brown); }
.chip {
  height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  border: var(--rule);
  background: var(--chip-bg, transparent);
  color: var(--chip-ink, var(--ink));
  font-size: 13px;
  font-weight: 650;
}
.other { display: flex; flex-direction: column; gap: 10px; }

/* ---------- Toast ---------- */
.toast {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 28px);
  transform: translate(-50%, 14px);
  opacity: 0;
  pointer-events: none;
  background: var(--ink);
  color: var(--cream);
  border-radius: 999px;
  padding: 12px 20px;
  font-size: 12px;
  letter-spacing: 0.06em;
  white-space: nowrap;
  max-width: calc(100% - 40px);
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 240ms ease, transform 240ms var(--ease-out);
  z-index: 30;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Sign in ---------- */
.login {
  position: absolute; inset: 0;
  z-index: 40;
  background: var(--butter);
  display: flex;
  align-items: flex-end;
  padding: calc(var(--safe-top) + 24px) 20px calc(var(--safe-bottom) + 28px);
}
.login[hidden] { display: none; }
.login-inner { width: 100%; display: flex; flex-direction: column; gap: 16px; }
.login-word {
  margin: 8px 0 0;
  font-family: var(--display);
  font-stretch: 75%;
  font-weight: 800;
  font-size: clamp(88px, 29vw, 128px);
  line-height: 0.8;
  letter-spacing: -0.03em;
  color: var(--ink);
}
.login-sub { margin: 0 0 12px; font-size: 12px; color: var(--rust); }
.login-err { margin: 0; min-height: 20px; color: var(--rust); font-weight: 600; }
.login.shake .login-inner { animation: shake 420ms ease; }

/* ---------- Motion ---------- */
@keyframes rise { from { transform: translateY(18px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes flash { 0% { background: var(--butter); } 100% { background: transparent; } }
@keyframes marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@keyframes shake { 0%, 100% { transform: none; } 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
  .ticker-track { animation: none; }
}
