:root {
  --red: #b91c1c;
  --red-dark: #7f1d1d;
  --yellow: #facc15;
  --yellow-dark: #ca8a04;
  --cream: #fffbeb;
  --white: #ffffff;
  --ink: #1c1917;
  --muted: #78716c;
  --line: #e7e5e4;
  --shadow: 0 8px 32px rgba(28, 25, 23, 0.12);
  --radius: 16px;
  --radius-lg: 24px;
  --touch-min: 48px;
  --sidebar: 220px;
  --footer-h: 88px;
  --font: "Nunito", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  color: var(--ink);
  background: var(--white);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: manipulation;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  animation: fadeIn 0.25s ease;
}

.screen.active {
  display: flex;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* —— Welcome —— */
.screen-welcome {
  position: relative;
  background: linear-gradient(180deg, var(--cream) 0%, var(--white) 42%);
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem 1.5rem 3rem;
}

.welcome-promo {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background: var(--red);
  color: var(--white);
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  padding: 0.65rem 1rem;
}

.welcome-logo {
  width: min(280px, 72vw);
  height: auto;
  margin-bottom: 1rem;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.08));
}

.welcome-title {
  margin: 0 0 0.25rem;
  font-size: clamp(1.75rem, 5vw, 2.5rem);
  font-weight: 900;
  color: var(--red);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.welcome-sub {
  margin: 0 0 2rem;
  font-size: 1.15rem;
  color: var(--muted);
  font-weight: 600;
}

.btn-start {
  border: none;
  background: var(--red);
  color: var(--white);
  font-family: inherit;
  font-weight: 800;
  font-size: 1.25rem;
  padding: 1.25rem 2.5rem;
  border-radius: 999px;
  box-shadow: var(--shadow);
  cursor: pointer;
  min-height: var(--touch-min);
  transition: transform 0.15s, background 0.15s;
}

.btn-start:active {
  transform: scale(0.98);
  background: var(--red-dark);
}

.welcome-hero {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 38%;
  background: linear-gradient(
      to top,
      rgba(255, 251, 235, 0.95) 0%,
      transparent 55%
    ),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 200'%3E%3Crect fill='%23facc15' width='400' height='200'/%3E%3Cellipse cx='200' cy='120' rx='140' ry='70' fill='%23eab308'/%3E%3Cpath d='M80 100 Q200 40 320 100' fill='none' stroke='%23ca8a04' stroke-width='3'/%3E%3C/svg%3E")
      center bottom / cover no-repeat;
  pointer-events: none;
  opacity: 0.5;
}

/* —— Service type —— */
.screen-service {
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: var(--cream);
}

.service-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.service-header img {
  width: 160px;
  margin-bottom: 1rem;
}

.service-header h2 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 900;
  color: var(--red-dark);
}

.service-options {
  display: grid;
  gap: 1.25rem;
  width: min(420px, 100%);
}

.service-card {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1.5rem 1.75rem;
  background: var(--white);
  border: 3px solid var(--line);
  border-radius: var(--radius-lg);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
  min-height: 88px;
}

.service-card:active,
.service-card:hover {
  border-color: var(--yellow);
  box-shadow: var(--shadow);
}

.service-icon {
  font-size: 2.5rem;
  line-height: 1;
}

.service-card strong {
  display: block;
  font-size: 1.25rem;
  color: var(--ink);
}

.service-card span {
  font-size: 0.95rem;
  color: var(--muted);
  font-weight: 600;
}

.btn-back-ghost {
  position: absolute;
  top: 1rem;
  left: 1rem;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-weight: 700;
  font-size: 1rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  min-height: var(--touch-min);
}

/* —— Menu layout —— */
.screen-menu {
  background: var(--white);
}

.menu-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--white);
  flex-shrink: 0;
}

.menu-topbar img {
  height: 48px;
}

.menu-badge {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--red);
  background: #fef2f2;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
}

.menu-body {
  display: flex;
  flex: 1;
  min-height: 0;
  padding-bottom: var(--footer-h);
}

.menu-sidebar {
  width: var(--sidebar);
  flex-shrink: 0;
  border-right: 1px solid var(--line);
  overflow-y: auto;
  background: #fafaf9;
}

.cat-btn {
  display: block;
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  padding: 1.1rem 1rem;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  border-left: 4px solid transparent;
  min-height: var(--touch-min);
}

.cat-btn.active {
  color: var(--red-dark);
  background: var(--white);
  border-left-color: var(--red);
}

.menu-grid-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem 1.5rem;
}

.menu-section-title {
  margin: 0 0 1rem;
  font-size: 1.35rem;
  font-weight: 900;
  color: var(--ink);
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.product-card {
  position: relative;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--white);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  padding: 0;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.product-card:active {
  border-color: var(--yellow);
  box-shadow: var(--shadow);
}

.product-thumb {
  height: 120px;
  background: linear-gradient(145deg, var(--yellow) 0%, #fde047 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
}

.product-info {
  padding: 0.85rem 1rem 1rem;
}

.product-info h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.25;
}

.product-info p {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-price {
  font-size: 1.1rem;
  font-weight: 900;
  color: var(--red-dark);
}

.qty-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--yellow);
  color: var(--ink);
  font-weight: 900;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.toast {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%) translateY(-120%);
  background: var(--ink);
  color: var(--white);
  padding: 0.75rem 1.25rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.95rem;
  z-index: 100;
  transition: transform 0.3s ease;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.cart-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--footer-h);
  background: var(--yellow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.1);
  z-index: 50;
}

.cart-footer.hidden {
  display: none;
}

.cart-summary {
  font-weight: 800;
  font-size: 1.1rem;
}

.btn-confirm {
  border: none;
  background: var(--white);
  color: var(--ink);
  font-family: inherit;
  font-weight: 900;
  font-size: 1.15rem;
  padding: 1rem 1.75rem;
  border-radius: 999px;
  cursor: pointer;
  min-height: var(--touch-min);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.btn-confirm:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* —— Checkout —— */
.screen-checkout {
  background: var(--cream);
  padding: 1.5rem;
  overflow-y: auto;
}

.checkout-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.checkout-header h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 900;
}

.order-lines {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 0.5rem 0;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}

.order-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}

.order-line:last-child {
  border-bottom: none;
}

.order-total {
  display: flex;
  justify-content: space-between;
  font-size: 1.35rem;
  font-weight: 900;
  padding: 0 0.25rem 1.5rem;
}

.payment-methods {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.pay-btn {
  border: 3px solid var(--line);
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.25rem;
  font-family: inherit;
  font-weight: 800;
  font-size: 1.05rem;
  cursor: pointer;
  min-height: 72px;
}

.pay-btn.selected {
  border-color: var(--red);
  background: #fef2f2;
}

.pay-btn:active {
  transform: scale(0.98);
}

.checkout-note {
  font-size: 0.9rem;
  color: var(--muted);
  text-align: center;
  margin: 1rem 0;
  line-height: 1.5;
}

.btn-pay {
  width: 100%;
  border: none;
  background: var(--red);
  color: var(--white);
  font-family: inherit;
  font-weight: 900;
  font-size: 1.2rem;
  padding: 1.25rem;
  border-radius: var(--radius-lg);
  cursor: pointer;
  min-height: 56px;
}

.btn-pay:disabled {
  opacity: 0.5;
}

/* —— Payment processing —— */
.screen-processing {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  background: var(--white);
}

.spinner {
  width: 64px;
  height: 64px;
  border: 5px solid var(--line);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1.5rem;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.processing-hint {
  max-width: 320px;
  color: var(--muted);
  font-weight: 600;
  line-height: 1.5;
}

/* —— Success —— */
.screen-success {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  background: linear-gradient(180deg, #ecfdf5 0%, var(--white) 50%);
}

.success-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
}

.order-number {
  font-size: 3rem;
  font-weight: 900;
  color: var(--red);
  margin: 0.5rem 0 1rem;
}

.btn-new-order {
  margin-top: 2rem;
  border: none;
  background: var(--yellow);
  color: var(--ink);
  font-family: inherit;
  font-weight: 900;
  font-size: 1.15rem;
  padding: 1.15rem 2rem;
  border-radius: 999px;
  cursor: pointer;
}

@media (orientation: portrait), (max-width: 900px) {
  .menu-body {
    flex-direction: column;
  }

  .menu-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--line);
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    flex-shrink: 0;
  }

  .cat-btn {
    white-space: nowrap;
    border-left: none;
    border-bottom: 4px solid transparent;
    flex-shrink: 0;
  }

  .cat-btn.active {
    border-left: none;
    border-bottom-color: var(--red);
  }

  .product-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 901px) and (orientation: landscape) {
  :root {
    --sidebar: 240px;
  }
}
