:root {
  --bg: #0B1220;
  --bg-2: #10182A;
  --elev: #141C30;
  --card: #1A2338;
  --line: rgba(255,255,255,.08);
  --text: #F5F7FB;
  --muted: #9AA3B8;
  --accent: #FF5A2A;
  --accent-2: #F79622;
  --accent-soft: rgba(255,90,42,.16);
  --gold: #F6C445;
  --success: #22C55E;
  --danger: #EF4444;
  --dark-btn: #1C2436;
  --tab-h: 64px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: "Cairo", system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); }
html { height: 100%; height: 100dvh; }
body {
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}
img { max-width: 100%; display: block; -webkit-user-drag: none; }
button { font-family: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
h1, h2 { margin: 0; }

.app {
  height: 100dvh;
  height: 100svh;
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-t);
  padding-bottom: calc(var(--tab-h) + var(--safe-b));
}

.status-bleed {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: var(--safe-t);
  background: var(--bg);
  z-index: 40;
}

/* Screens */
.screen {
  position: absolute;
  inset: 0 0 calc(var(--tab-h) + var(--safe-b)) 0;
  padding-top: var(--safe-t);
  display: flex;
  flex-direction: column;
  background: var(--bg);
  opacity: 0;
  visibility: hidden;
  transform: translateX(12%);
  transition: transform .38s cubic-bezier(.22,.8,.24,1), opacity .28s ease, visibility .38s;
  z-index: 1;
}
.screen.is-active {
  opacity: 1;
  visibility: visible;
  transform: none;
  z-index: 2;
}
/* cart always enters from the physical right */
.screen-cart { transform: translateX(100%); }
.screen-cart.is-active { transform: none; }
html[dir="ltr"] .screen:not(.screen-cart) { transform: translateX(-12%); }
html[dir="ltr"] .screen.is-active { transform: none; }

.scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 0 18px 24px;
}
.build-scroll { padding-bottom: 28px; }

/* Top bar */
.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 52px;
  padding: 6px 10px 4px;
  flex-shrink: 0;
  position: relative;
  z-index: 5;
}
.topbar .brand,
.topbar .icon-btn:first-child,
.topbar > :first-child { justify-self: start; }
.topbar-title {
  justify-self: center;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0;
}
.topbar-actions, .lang-btn, .topbar-spacer { justify-self: end; }
.topbar-actions { display: flex; gap: 2px; }
.topbar-spacer { width: 42px; }

.brand { display: flex; align-items: center; gap: 8px; grid-column: 1 / 3; justify-self: start; }
.topbar:has(.brand) { grid-template-columns: 1fr auto; }
.brand-logo { width: 36px; height: 36px; object-fit: contain; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-size: 16px; font-weight: 800; }
.brand-text span { font-size: 11px; color: var(--muted); }

.icon-btn {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  color: var(--text);
  position: relative;
  border-radius: 50%;
}
.icon-btn:active { background: rgba(255,255,255,.06); }
.red-dot {
  position: absolute;
  top: 9px; left: 11px;
  width: 8px; height: 8px;
  background: var(--danger);
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--bg);
}
.lang-btn {
  width: 42px; height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-weight: 700;
  font-size: 12px;
  color: var(--gold);
}

/* Hero builder entry */
.hero-cta {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: start;
  background: linear-gradient(135deg, #1d263c, #151c2e 60%);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 12px 14px;
  margin: 8px 0 16px;
}
.hero-cta img { width: 54px; height: 54px; object-fit: contain; }
.hero-cta b { display: block; font-size: 18px; font-weight: 800; }
.hero-cta span { color: var(--muted); font-size: 12px; }
.hero-cta .chev { margin-inline-start: auto; font-size: 22px; color: var(--muted); }
.hero-cta:active { transform: scale(.985); }

/* Categories */
.cats {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 0 14px;
  margin: 0 -18px;
  padding-inline: 18px;
  scrollbar-width: none;
}
.cats::-webkit-scrollbar { display: none; }
.cat {
  flex: 0 0 auto;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--elev);
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.cat.is-on {
  background: var(--accent-soft);
  color: #fff;
  border-color: rgba(255,90,42,.35);
}

/* Item cards */
.items { display: flex; flex-direction: column; gap: 10px; padding-bottom: 8px; }
.item-card {
  display: grid;
  grid-template-columns: 86px 1fr auto;
  gap: 12px;
  align-items: center;
  background: var(--card);
  border-radius: 18px;
  padding: 10px;
  border: 1px solid var(--line);
}
.item-card .pic {
  width: 86px; height: 86px;
  border-radius: 14px;
  background: #0e1422;
  display: grid; place-items: center;
  overflow: hidden;
}
.item-card .pic img { width: 100%; height: 100%; object-fit: contain; }
.item-card .meta { min-width: 0; }
.item-card h3 {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 2px;
}
.item-card p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.item-card .price {
  color: var(--gold);
  font-weight: 800;
  font-size: 14px;
  margin-top: 4px;
}
.item-card .price small { font-weight: 600; font-size: 10px; margin-inline-start: 3px; }
.add-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  display: grid; place-items: center;
  box-shadow: 0 6px 16px rgba(255,90,42,.35);
}
.add-btn:active { transform: scale(.94); }

/* Build */
.build-title {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.03em;
  text-align: center;
  margin: 6px 0 14px;
  line-height: 1.15;
}
.build-title span.accent { color: var(--accent-2); }

.toggle {
  position: relative;
  z-index: 4;
  display: flex;
  width: min(260px, 70%);
  margin: 0 auto 4px;
  background: #0a101c;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
}
.toggle button {
  flex: 1;
  padding: 8px 0;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
  color: var(--muted);
}
.toggle button.is-on {
  background: #eef1f6;
  color: #111827;
}

/* Stage / burger */
.stage {
  position: relative;
  height: 360px;
  margin: 0 -6px 4px;
  overflow: hidden;
}
.plate-img {
  position: absolute;
  left: 18%;
  right: 18%;
  bottom: 8px;
  width: 64%;
  height: auto;
  z-index: 1;
  filter: drop-shadow(0 10px 14px rgba(0,0,0,.42));
  pointer-events: none;
}
.stack {
  position: absolute;
  left: 3%;
  right: 3%;
  bottom: 46px;
  height: 312px;
  z-index: 2;
  pointer-events: none;
  transform: scale(var(--fit, 1));
  transform-origin: 50% 100%;
}
.layer {
  position: absolute;
  left: 0; right: 0;
  width: 100%;
  bottom: var(--y, 0px);
  z-index: var(--z, 1);
  transform-origin: 50% 90%;
  transform: rotate(var(--rot, 0deg)) scale(var(--sc, 1));
}
.layer img {
  width: 96%;
  max-width: none;
  height: auto;
  max-height: none;
  margin: 0 auto;
  display: block;
  filter: drop-shadow(0 5px 6px rgba(40, 16, 6, 0.48)) sepia(0.16) saturate(1.14) contrast(1.05) brightness(1.03);
}
.layer[data-id="bun-top"] img,
.layer[data-id="bun-bottom"] img { width: 100%; }
.layer[data-id="protein"] img { width: 100%; }
.layer[data-id="cheddar"] img { width: 106%; }
.layer[data-id="lettuce"] img { width: 108%; }
.layer[data-id="bacon"] img { width: 98%; }
.layer[data-id="egg"] img { width: 94%; }
.layer[data-id="tomato"] img { width: 98%; }
.layer[data-id="pickles"] img,
.layer[data-id="onion"] img { width: 96%; }
.layer[data-id="sauce"] img { width: 36%; margin: 0 8% 0 auto; position: relative; top: 10px; }
.layer.is-in { animation: dropBounce .55s cubic-bezier(.2,1.35,.3,1) both; }
.layer.is-out { animation: liftOut .32s ease forwards; }
@keyframes dropBounce {
  0% { transform: translateY(-170px) rotate(var(--rot, 0deg)) scale(calc(var(--sc, 1) * 1.06)); opacity: 0; }
  62% { transform: translateY(8px) rotate(var(--rot, 0deg)) scale(calc(var(--sc, 1) * 1.015)); opacity: 1; }
  80% { transform: translateY(-5px) rotate(var(--rot, 0deg)) scale(var(--sc, 1)); }
  100% { transform: translateY(0) rotate(var(--rot, 0deg)) scale(var(--sc, 1)); }
}
@keyframes liftOut {
  to { transform: translateY(-80px) rotate(var(--rot, 0deg)) scale(calc(var(--sc, 1) * 0.9)); opacity: 0; }
}

/* Ingredient grid */
.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px 8px;
  padding: 4px 0 8px;
}
.ing {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
  background: none;
}
.ing .well {
  width: 68px; height: 68px;
  border-radius: 50%;
  border: 2px solid transparent;
  overflow: hidden;
  background: radial-gradient(circle at 40% 35%, #2a3348, #121826 70%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.05);
  position: relative;
}
.ing img { width: 68px; height: 68px; object-fit: cover; }
.ing span {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
  line-height: 1.2;
  min-height: 26px;
}
.ing.is-on .well {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(255,90,42,.18);
}
.ing .check, .ing .minus {
  position: absolute;
  width: 18px; height: 18px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 800;
  display: none;
  place-items: center;
  z-index: 2;
  line-height: 1;
}
.ing .check {
  top: -2px; left: 8px;
  background: var(--danger);
  color: #fff;
}
.ing .minus {
  top: -2px; right: 8px;
  background: #2a3348;
  color: #fff;
  border: 1px solid rgba(255,255,255,.2);
}
.ing.is-on .check, .ing.is-on .minus { display: grid; }
.ing.is-locked .minus { display: none !important; }
.ing .tag {
  font-size: 9px;
  color: var(--gold);
  font-weight: 700;
  margin-top: -4px;
}

/* Sticky CTAs */
.sticky-cta {
  flex-shrink: 0;
  padding: 8px 18px 10px;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.sticky-cta.frost {
  background: rgba(11,18,32,.72);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.cta {
  width: 100%;
  min-height: 56px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 17px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  box-shadow: 0 10px 24px rgba(255,90,42,.32);
  transition: background .25s, color .25s, box-shadow .25s, transform .15s;
}
.cta:active { transform: scale(.98); }
.cta-price { font-weight: 800; letter-spacing: 0; }
.cta-price small { font-weight: 600; font-size: 11px; margin-inline-start: 4px; }

.cta.is-added {
  background: var(--dark-btn);
  color: #fff;
  box-shadow: none;
  justify-content: center;
  gap: 8px;
}
.cta.is-added .cta-price { display: none; }
.cta.is-added .cta-label::before {
  content: "✓";
  display: inline-block;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--success);
  color: #fff;
  font-size: 13px;
  text-align: center;
  line-height: 22px;
  margin-inline-end: 8px;
}
.cta.is-view {
  background: transparent;
  color: #fff;
  border: 1.5px solid var(--accent);
  box-shadow: none;
  justify-content: center;
}
.cta.is-view .cta-price { display: none; }

/* Cart */
.cart-list { display: flex; flex-direction: column; gap: 10px; padding-top: 8px; padding-bottom: 12px; }
.cart-card {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 10px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 10px;
}
.cart-card .pic {
  width: 72px; height: 72px;
  border-radius: 14px;
  background: #0e1422;
  overflow: hidden;
  display: grid; place-items: center;
}
.cart-card .pic img { width: 100%; height: 100%; object-fit: contain; }
.cart-card h3 { font-size: 15px; font-weight: 800; margin: 0 0 2px; }
.cart-card .bits { color: var(--muted); font-size: 12px; line-height: 1.35; }
.cart-card .price { color: var(--gold); font-weight: 800; margin-top: 4px; font-size: 14px; }
.stepper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #0e1422;
  border-radius: 999px;
  padding: 4px;
  border: 1px solid var(--line);
}
.stepper button {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: #222b40;
  font-weight: 800;
  font-size: 16px;
}
.stepper em { font-style: normal; font-weight: 800; min-width: 14px; text-align: center; }

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 50%;
  gap: 18px;
  text-align: center;
  padding-top: 48px;
}
.empty p { font-size: 20px; font-weight: 800; margin: 0; }
.pill {
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 16px;
  padding: 12px 28px;
  border-radius: 999px;
  box-shadow: 0 8px 18px rgba(255,90,42,.3);
}
.hidden { display: none !important; }

/* Summary sheet */
.sheet[hidden] { display: none !important; }
.sheet {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 30;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px 16px calc(16px + var(--safe-b));
}
.sheet-card {
  width: 100%;
  max-width: 480px;
  background: var(--elev);
  border-radius: 24px;
  padding: 22px 18px 18px;
  border: 1px solid var(--line);
  animation: sheetUp .32s cubic-bezier(.22,.8,.24,1);
}
@keyframes sheetUp {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.ok-badge {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--success);
  color: #fff;
  display: grid; place-items: center;
  font-size: 24px;
  margin: 0 auto 10px;
}
.sheet-card h2 { text-align: center; font-size: 20px; margin-bottom: 14px; }
.summary-lines { display: flex; flex-direction: column; gap: 8px; }
.summary-lines div {
  display: flex; justify-content: space-between; gap: 8px;
  color: var(--muted); font-size: 14px;
}
.summary-total {
  display: flex; justify-content: space-between;
  margin: 14px 0 8px;
  font-size: 18px; font-weight: 800;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.fine { color: var(--muted); font-size: 12px; text-align: center; margin: 0 0 14px; }
.sheet-card .cta { justify-content: center; }

/* Tab bar */
.tabbar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--tab-h) + var(--safe-b));
  padding: 6px 10px var(--safe-b);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: rgba(11,18,32,.92);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
  z-index: 20;
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  position: relative;
  padding-top: 4px;
}
.tab.is-on { color: var(--accent); }
.tab .badge {
  position: absolute;
  top: 0;
  left: calc(50% + 8px);
  min-width: 16px; height: 16px;
  padding: 0 4px;
  border-radius: 99px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-style: normal;
  display: grid; place-items: center;
}

/* Toast */
.toast {
  position: absolute;
  left: 50%;
  bottom: calc(var(--tab-h) + var(--safe-b) + 72px);
  transform: translateX(-50%) translateY(12px);
  background: #1f2a44;
  border: 1px solid var(--line);
  color: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  opacity: 0;
  z-index: 25;
  transition: .25s ease;
  white-space: nowrap;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* LTR */
html[dir="ltr"] .build-title { letter-spacing: -0.02em; }
html[dir="ltr"] .icon-btn svg { transform: scaleX(-1); }
html[dir="ltr"] .red-dot { left: auto; right: 11px; }
html[dir="ltr"] .hero-cta { text-align: left; }
html[dir="ltr"] .tab .badge { left: auto; right: calc(50% - 22px); }
