:root {
  --bg: #ffffff;
  --ink: #0b0f1a;
  --muted: #6b7280;
  --line: #e5e7eb;

  --card-radius: 18px;
  --paper-shadow: 0 2px 4px rgba(0,0,0,.04), 0 12px 28px rgba(0,0,0,.12);
  --paper-shadow-soft: 0 1px 2px rgba(0,0,0,.04), 0 8px 18px rgba(0,0,0,.10);

  --brand: #111827;
  --accent: #ff6b5a;

  --content-max: 560px;
  --input-max: 520px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: 'DM Sans', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  padding-bottom: 86px;
}

/* ================= PAGE ================= */
.wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 32px 16px 100px;
  overflow: visible;
}

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 140px;
  padding-bottom: 220px;
  position: relative;
  overflow: visible;
}

/* ================= STACK ================= */
.stack{
  position: relative;
  width: min(800px, 92vw);
  height: min(460px, calc(100vh - 260px)); /* NORMAL DEFAULT */
  overflow: visible;
}

/* nav sits under the card always */
.floating-nav{
  position: absolute;
  left: 50%;
  bottom: -22px;              /* outside under the card */
  transform: translateX(-50%);
  z-index: 3000;

  display: flex;
  gap: 14px;

  pointer-events: none;
}

.floating-nav .btn{
  pointer-events: auto;
  box-shadow: 0 12px 28px rgba(0,0,0,.18);
}


/* ================= FLASHCARDS ================= */
.card {
  position: absolute;
  inset: 0;
  background: #fff;
  border-radius: var(--card-radius);
  border: 1px solid rgba(0,0,0,.04);
  box-shadow: var(--paper-shadow);

  display: flex;
  flex-direction: column;
  justify-content: flex-start;

  padding: 44px 28px 18px;

  z-index: var(--z, 0);
  transform: none;
  transition: transform .28s ease, opacity .28s ease, box-shadow .28s ease;

  max-height: calc(100vh - 170px); /* was -240px */
  opacity: 0; /* Start hidden, JS will show the active one */
}

/* Force first card visible immediately */
.card[data-step="dish"][aria-hidden="false"] {
  opacity: 1 !important;
  z-index: 100 !important;
}

/* Center sections, but do NOT clip dropdowns */
.card > div {
  width: 100%;
  max-width: var(--content-max);
  margin-left: auto;
  margin-right: auto;
  overflow: visible !important; /* Allow dropdown to escape */
}

/* ===== Location card: let map fill the whole card ===== */
.card[data-step="location"]{
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.card[data-step="location"] > div{
  max-width: none;
  margin: 0;
}

.card[data-step="location"] #mapWrap{
  flex: 1;
  min-height: 0;
  position: relative;
}

.card[data-step="location"] #map{
  width: 100%;
  height: 100%;
  border-radius: 0;
}

.card[data-step="location"] .actions{
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  padding: 14px 28px;
  margin: 0;
}


/* The field div specifically needs visible overflow */
.card .field {
  overflow: visible !important;
}

/* Only the active card can scroll if needed */
.card[aria-hidden="false"] {
  overflow: visible;
  opacity: 1 !important;
  pointer-events: auto !important;
}


.card[aria-hidden="false"] { opacity: 1; pointer-events: auto; }
.card[aria-hidden="true"] { pointer-events: none; box-shadow: var(--paper-shadow-soft); }

.card[aria-hidden="true"]::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.88);
  border-radius: inherit;
  pointer-events: none;
}

/* Hide ALL content on inactive cards so nothing bleeds through */
.card[aria-hidden="true"] > * { visibility: hidden; }

/* Header alignment */
.card > div:first-child { text-align: center; }

/* Step label */
.kicker {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
  margin-bottom: 6px;
}

/* Title */
.title {
  font-size: 34px;
  font-weight: 700;
  margin: 0 0 6px;
  letter-spacing: -0.5px;
}

/* Subtitle */
.sub {
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 12px;
}

.label { display: none; }

/* ================= INPUTS ================= */
.input,
.area,
select {
  width: 100%;
  max-width: var(--input-max);
  margin: 0 auto;
  display: block;

  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 18px;
  font-size: 18px;
}

.area { min-height: 96px; }

/* Helper */
.help {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin-top: 16px;
  margin-bottom: 8px;
}

/* ================= RATING SLIDER ================= */
.rating-slider-wrap {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
}

.rating-display {
  font-size: 3rem;
  font-weight: 700;
  line-height: 1;
  color: #111;
}

.rating-max {
  font-size: 1.4rem;
  font-weight: 400;
  color: #888;
}

.rating-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: #e5e7eb;
  outline: none;
  cursor: pointer;
}

.rating-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: #fff;
  border: 2px solid var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.rating-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 4px 14px rgba(255,107,90,0.35);
}

.rating-slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: #fff;
  border: 2px solid var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  cursor: pointer;
}

.rating-ticks {
  width: 100%;
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: #999;
  padding: 0 2px;
}

/* ================= ACTIONS / BUTTONS ================= */
.actions{
  margin-top: auto;
  padding-top: 14px;
  display: flex;
  justify-content: center;
  gap: 14px;

  position: sticky;
  bottom: 0;
  z-index: 5;

  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);

  padding: 14px 0 6px;
}

.btn {
  color: #111;
  padding: 12px 22px;
  font-size: 16px;
  border-radius: 999px;
  min-width: 110px;
  height: 44px;
}

.btn.primary {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
}

.btn.ghost {
  color: #111;
  background: #fff;
  border-color: var(--line);
}

/* ================= CHIPS ================= */
.chips {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 8px 0 14px;
}

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: #111;
  max-width: 240px;
  overflow: hidden;
}

.chip .chip-value {
  display: inline-block;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
  color: #111;
}

.chip .chip-edit {
  margin-left: 8px;
  color: var(--muted);
  font-weight: 700;
  flex-shrink: 0;
}

/* ================= COMBOBOX ================= */
/* === SINGLE dropdown system === */

/* Make sure the dropdown can escape and is clearly visible */
.field { 
  position: relative; 
  overflow: visible !important; 
  z-index: 1000 !important;
  isolation: isolate; /* Create stacking context */
}

.combo-wrap {
  overflow: visible !important;
  z-index: 1001 !important;
  max-width: var(--input-max);
  margin: 0 auto;
}

/* Inner wrapper: the dropdown is positioned relative to the input, not the label */
.input-drop-wrap {
  position: relative;
  overflow: visible !important;
}

/* COMBO DROPDOWN - Must override theme.css */
#dishDropdown.combo,
#restaurantDropdown.combo,
#newDishRestDropdown.combo {
  position: absolute !important;
  top: calc(100% + 4px) !important;
  margin-top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  z-index: 9999 !important;
  background: #fff !important;
  border: 1px solid rgba(0,0,0,.10) !important;
  border-radius: 12px !important;
  box-shadow: 0 12px 28px rgba(0,0,0,.12) !important;

  max-height: 260px !important;
  overflow: auto !important;
  
  display: none !important; /* Hidden by default */
}

/* Show when not hidden */
#dishDropdown.combo:not([hidden]),
#restaurantDropdown.combo:not([hidden]),
#newDishRestDropdown.combo:not([hidden]) {
  display: block !important;
}

/* Explicit hidden state */
#dishDropdown.combo[hidden],
#restaurantDropdown.combo[hidden],
#newDishRestDropdown.combo[hidden] {
  display: none !important;
}

#dishDropdown .combo-item,
#restaurantDropdown .combo-item,
#newDishRestDropdown .combo-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 14px;
}

.combo-item:hover{
  background: #fafafa;
}

.combo-item + .combo-item{
  border-top: 1px solid rgba(0,0,0,.06);
}

.combo-item .muted{
  color: var(--muted);
  font-weight: 600;
  margin-left: 12px;
  white-space: nowrap;
}


/* Prevent clipping on dropdown steps */
.card[data-step="dish"][aria-hidden="false"],
.card[data-step="restaurant"][aria-hidden="false"],
.card[data-step="newdish"][aria-hidden="false"],
.card[data-step="dish"][aria-hidden="false"] > div,
.card[data-step="restaurant"][aria-hidden="false"] > div,
.card[data-step="newdish"][aria-hidden="false"] > div {
  overflow: visible !important;
  max-height: none !important;
}

.card[data-step="dish"],
.card[data-step="restaurant"] {
  padding-bottom: 72px;
}

.card[data-step="dish"][aria-hidden="false"] .actions,
.card[data-step="restaurant"][aria-hidden="false"] .actions{
  position: absolute !important;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: none !important;
  margin: 0 !important;
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  padding: 14px 28px !important;
  justify-content: center;
}

/* ================= SUBMIT CARD ================= */
.card[data-step="submit"] {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

.card[data-step="submit"][aria-hidden="false"] {
  bottom: auto !important;
  height: auto !important;
  min-height: 0 !important;
  overflow: visible !important;
  padding: 0 !important;
  display: block !important;
}

.card[data-step="submit"] .submit-actions {
  position: static !important;
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  padding: 14px 0 8px !important;
  margin-top: 0 !important;
}

/* ================= RECEIPT SUMMARY ================= */
.summary {
  max-width: 340px;
  margin: 0 auto;
}

.receipt {
  background: #fff;
  width: 100%;
  padding: 20px 18px 16px;
  font-family: 'Courier New', 'Courier', monospace;
  font-size: 12px;
  line-height: 1.6;
  color: #111;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12), 0 8px 24px rgba(0,0,0,0.06);
  position: relative;
}

/* Jagged top edge — perforated tear */
.receipt::before {
  content: "";
  position: absolute;
  top: -8px; left: 0; right: 0;
  height: 8px;
  background:
    radial-gradient(circle at 50% 100%, #fff 6px, transparent 6px) -12px 0 / 24px 8px repeat-x,
    #fff;
}

.rcpt-header {
  text-align: center;
  padding-bottom: 8px;
}

.rcpt-brand {
  font-size: 15px;
  font-weight: bold;
  letter-spacing: 3px;
}

.rcpt-tagline {
  font-size: 10px;
  color: #555;
  margin-top: 2px;
}

.rcpt-url {
  font-size: 10px;
  color: #888;
}

.rcpt-divider {
  color: #888;
  letter-spacing: 1px;
  margin: 8px 0;
  font-size: 11px;
  overflow: hidden;
  white-space: nowrap;
}

.rcpt-meta {
  margin: 6px 0;
}

.rcpt-meta-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
}

.rcpt-meta-row span:first-child {
  color: #666;
  flex-shrink: 0;
}

.rcpt-items {
  margin: 4px 0;
}

.rcpt-item-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 3px 0;
}

.rcpt-item-row span:first-child {
  color: #555;
  flex-shrink: 0;
  min-width: 80px;
}

.rcpt-item-row span:last-child {
  text-align: right;
  font-weight: bold;
  overflow-wrap: anywhere;
}

.rcpt-item-header {
  font-weight: bold;
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #888 !important;
  border-bottom: 1px solid #ddd;
  padding-bottom: 4px;
  margin-bottom: 4px;
}

.rcpt-item-header span { color: #888 !important; font-weight: bold; }

.rcpt-total {
  text-align: center;
  padding: 8px 0;
}

.rcpt-total-label {
  font-size: 10px;
  letter-spacing: 2px;
  color: #666;
  text-transform: uppercase;
}

.rcpt-total-stars {
  font-size: 20px;
  letter-spacing: 4px;
  margin: 6px 0 3px;
}

.rcpt-total-score {
  font-size: 22px;
  font-weight: bold;
  letter-spacing: 2px;
}

.rcpt-footer {
  text-align: center;
  font-size: 11px;
  padding: 6px 0 4px;
  letter-spacing: 1px;
}

.rcpt-footer-sub {
  font-size: 10px;
  color: #888;
  margin-top: 2px;
}

/* Barcode */
.rcpt-barcode {
  text-align: center;
  margin-top: 12px;
}

.rcpt-bars {
  height: 36px;
  background-image: repeating-linear-gradient(
    to right,
    #111 0px, #111 2px,
    transparent 2px, transparent 4px,
    #111 4px, #111 5px,
    transparent 5px, transparent 8px,
    #111 8px, #111 11px,
    transparent 11px, transparent 13px,
    #111 13px, #111 14px,
    transparent 14px, transparent 17px,
    #111 17px, #111 20px,
    transparent 20px, transparent 21px,
    #111 21px, #111 23px,
    transparent 23px, transparent 26px,
    #111 26px, #111 27px,
    transparent 27px, transparent 30px
  );
  background-size: 30px 36px;
  margin-bottom: 4px;
}

.rcpt-barcode-num {
  font-size: 9px;
  letter-spacing: 3px;
  color: #666;
}

.receipt-actions {
  text-align: center;
  margin-top: 14px;
}

/* ---------- FIELD FEEDBACK ---------- */
.field-feedback {
  font-size: 0.8rem;
  font-weight: 600;
  min-height: 16px;
  margin-top: 5px;
  padding-left: 4px;
  transition: opacity 0.2s ease;
}

.field-feedback.ok  { color: #22c55e; }
.field-feedback.err { color: #ef4444; }

/* ================= MESSAGES ================= */
.msg { text-align: center; font-size: 13px; margin-top: 8px; }
.msg.ok { color: #0a7d28; }
.msg.err { color: #b00020; }

/* ================= FOOD PICTOGRAM BACKGROUND ================= */
.food-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

/* ================= PROGRESS TEXT ================= */
.progress-wrap {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 40;
  text-align: center;
}

.progress-text {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.3px;
}

/* ================= QUOTE ================= */
.quote-row{
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 78px;
  width: min(640px, 92vw);
  text-align: center;
  pointer-events: none;
  z-index: 500;
}

.quote-text{
  font-size: 22px;
  line-height: 1.5;
  font-style: italic;
  color: #8b93a6;
  opacity: 0.75;
}

.quote-text::before{ content: "“"; }
.quote-text::after{ content: "”"; }

.quote-author{
  margin-top: 8px;
  font-size: 14px;
  color: #b0b7c6;
}

.quote-row.fade{ animation: quoteFade 180ms ease-out; }
.quote-row.dim{ opacity: 0.6; }

@keyframes quoteFade{
  from{ opacity: 0; transform: translate(-50%, 4px); }
  to{ opacity: 1; transform: translate(-50%, 0); }
}

/* ================= NEW DISH CARD ================= */
.field-label {
  font-size: 14px;
  font-weight: 600;
  color: #111;
  margin-bottom: 4px;
  text-align: center;
}

.field-desc {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 6px;
  text-align: center;
}

.newdish-header {
  text-align: center;
  margin-bottom: 16px;
}

.newdish-row {
  display: flex;
  gap: 18px;
  width: 100%;
  max-width: 720px;
  margin: 0 auto 12px;
}

.newdish-field {
  flex: 1;
  min-width: 0;
}

.newdish-bottom {
  width: 100%;
  max-width: 720px;
  margin: 14px auto 0;
}

.card[data-step="newdish"] {
  padding-top: 42px;
  padding-bottom: 10px;
}

.card[data-step="newdish"] .sub { margin-bottom: 10px; }
.card[data-step="newdish"] .actions { margin-top: 10px; }

/* ================= PRICE CARD ================= */
.card[data-step="price"] {
  padding-bottom: 72px;
}

.card[data-step="price"][aria-hidden="false"] .actions {
  position: absolute !important;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: none !important;
  margin: 0 !important;
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  padding: 14px 28px !important;
  justify-content: center;
}

.price-pile-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0;
  width: 100%;
  min-height: 0;  /* allow flex children to shrink */
  overflow: visible;
}

.coin-pile {
  position: relative;
  height: 132px;   /* MAX_PER_COL(4) × COIN_TH(28) + COIN_FH(20) */
  width: 280px;
  max-width: 100%;
  flex-shrink: 0;
  overflow: visible;  /* coins fall in from above */
}

.coin {
  /* Per-coin entry drift (JS sets --dx on each element) */
  --dx: 0px;

  position: absolute;
  width: 48px;
  height: 20px;
  border-radius: 50%;

  /* Gold coin face — flat ellipse, like coins in the photo */
  background: radial-gradient(
    ellipse at 38% 30%,
    #fffde4 3%,
    #fef9a0 14%,
    #fde047 30%,
    #fbbf24 55%,
    #d97706 78%,
    #b45309 96%
  );

  border: 1px solid #92400e;

  /* 4 stacked box-shadow layers = 8 px of visible coin edge (COIN_EDGE) */
  box-shadow:
    0 2px 0 #e59420,
    0 4px 0 #b45309,
    0 6px 0 #92400e,
    0 8px 0 #78350f,
    0 11px 8px rgba(0,0,0,0.38);

  user-select: none;
  -webkit-user-select: none;

  animation: coinDrop 0.52s cubic-bezier(0.215, 0.61, 0.355, 1) forwards;
}

/* Step re-entry: place instantly with no animation */
.coin.no-anim {
  animation: none;
  transform: none;
}

/* Removal: fly off upward */
.coin.removing {
  animation: coinFly 0.26s cubic-bezier(0.55, 0, 1, 0.45) forwards;
}

.coin-pile.pile-bounce {
  animation: pileBounce 0.3s ease;
}

@keyframes coinDrop {
  0% {
    /* scaleY(0.15) = coin edge-on as it spins in, then slaps flat on landing */
    transform: translateY(-220px) translateX(var(--dx)) scaleY(0.15);
    opacity: 0;
  }
  6%  { opacity: 0.8; }
  60% {
    transform: translateY(6px) translateX(0) scaleY(1);
    opacity: 1;
  }
  75% {
    /* impact squish */
    transform: translateY(-3px) scaleX(1.09) scaleY(0.84);
    opacity: 1;
  }
  90% {
    transform: translateY(2px) scaleX(0.97) scaleY(1.04);
    opacity: 1;
  }
  100% {
    transform: none;
    opacity: 1;
  }
}

@keyframes coinFly {
  0%   { transform: none; opacity: 1; }
  100% {
    transform: translateY(-150px) translateX(var(--dx)) rotate(210deg) scaleY(0.15);
    opacity: 0;
  }
}

@keyframes pileBounce {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.06) translateY(-4px); }
  70%  { transform: scale(0.97); }
  100% { transform: scale(1); }
}

.price-num {
  font-size: 44px;
  font-weight: 700;
  letter-spacing: -1.5px;
  text-align: center;
  color: var(--ink);
  line-height: 1;
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.price-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.price-btn {
  width: 48px !important;
  height: 48px !important;
  min-width: unset !important;
  border-radius: 50% !important;
  font-size: 24px !important;
  padding: 0 !important;
  line-height: 1 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  user-select: none;
  -webkit-user-select: none;
}

/* ================= RESPONSIVE ================= */
@media (max-width: 640px) {
  .newdish-row {
    flex-direction: column;
    gap: 14px;
    margin-bottom: 12px;
  }
  .newdish-bottom { margin-top: 12px; }
  .title { font-size: 30px; }
  .quote-text { font-size: 17px; }
}

/* Very small phones (≤380px) */
@media (max-width: 380px) {
  .rating-display { font-size: 2.4rem; }
  .title { font-size: 26px; }
  .card { padding: 32px 18px 14px; }
}

/* ===== Location card: slightly bigger + map fills card ===== */
.card[data-step="location"]{
  max-width: 860px;         /* slightly bigger than other cards */
}

.card[data-step="location"] .body{
  padding: 0;               /* remove white bands */
  height: 520px;            /* controls visible map height */
}

#map{
  width: 100%;
  height: 100%;
  border-radius: 18px;
}

/* ===== Transition: rating -> location ===== */
.card.exit-zoom{
  transform: scale(1.04);
  opacity: 0;
  transition: transform 380ms ease, opacity 380ms ease;
}

.card.enter-fade{
  opacity: 0;
  transform: scale(0.985);
}

/* ===== Transition: location -> submit ===== */
/* Map card fades + sinks slightly on exit */
.card.exit-fade-down{
  opacity: 0;
  transform: scale(0.97) translateY(8px);
  transition: transform 360ms cubic-bezier(0.4, 0, 0.2, 1), opacity 360ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Submit card rises up from slightly below on enter */
.card.enter-rise{
  opacity: 0;
  transform: translateY(18px) scale(0.98);
}

.card{
  transition: transform 380ms ease, opacity 380ms ease; /* ensure cards can animate */
}