:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-muted: rgba(255, 255, 255, 0.65);
  --primary: #af4b2f;
  --primary-dark: #873820;
  --text: #2a2b2e;
  --text-muted: #6d6f75;
  --radius-lg: 32px;
  --radius-md: 22px;
  --radius-sm: 16px;
  --shadow-lg: 0 30px 60px rgba(137, 48, 15, 0.18);
  --shadow-md: 0 18px 32px rgba(67, 42, 32, 0.16);
  --shadow-sm: 0 8px 18px rgba(67, 42, 32, 0.12);
  --border: rgba(42, 43, 46, 0.08);
}

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

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "Poppins", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: 0 clamp(18px, 4vw, 28px) clamp(18px, 4vw, 28px);
}

.page-shell {
  width: min(560px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: clamp(32px, 6vw, 48px);
  padding-bottom: clamp(48px, 8vw, 72px);
}

.pizza-stage {
  --fade-height: clamp(120px, 28vw, 180px);
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: clamp(48px, 10vw, 64px) clamp(18px, 5vw, 28px) clamp(24px, 5vw, 36px);
  background: #ffffff;
  z-index: 10;
  overflow: hidden;
}

.pizza-stage-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  position: relative;
  z-index: 3;
}

.pizza-stage::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  pointer-events: none;
  z-index: 2;
}

.pizza-stage::after {
  bottom: 0;
  height: var(--fade-height);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
}

.pizza-canvas {
  position: relative;
  width: min(320px, 76vw);
  aspect-ratio: 1 / 1;
  background: radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 1) 58%, rgba(255, 255, 255, 0) 100%);
  z-index: 3;
}

.pizza-base,
.pizza-canvas .layer img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.layer {
  pointer-events: none;
}

.clear-button {
  border: 1px solid rgba(42, 43, 46, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 6px 14px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.clear-button:hover {
  color: var(--primary);
  background: rgba(175, 75, 47, 0.12);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.clear-button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.page-content {
  display: flex;
  flex-direction: column;
  gap: clamp(28px, 6vw, 40px);
  padding: 0 clamp(18px, 5vw, 28px) clamp(48px, 8vw, 72px);
}

.card-header {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 16px;
  text-align: center;
}

.card-header > div {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.card-title {
  margin: 0;
  font-size: clamp(1.6rem, 5vw, 2rem);
  font-weight: 700;
  color: var(--text);
}

.card-subtitle {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.card-description {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.6;
  font-size: 0.95rem;
}

.builder-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-heading {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  text-align: center;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.section-hint {
  display: none;
}

.base-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.base-grid .ingredient-card:first-child {
  grid-column: 1 / -1;
}

.base-grid .ingredient-card {
  width: 100%;
}

.ingredient-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 360px) {
  .ingredient-grid,
  .base-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.ingredient-card {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  background: rgba(244, 242, 240, 0.9);
  border: 1px solid transparent;
  text-align: center;
  cursor: pointer;
  position: relative;
  touch-action: manipulation;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.ingredient-card input[type="checkbox"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.ingredient-text {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.ingredient-card:has(input:checked),
.ingredient-card.is-selected {
  border-color: rgba(175, 75, 47, 0.4);
  background: rgba(175, 75, 47, 0.08);
  box-shadow: var(--shadow-sm);
  transform: translateY(-4px);
}


.ingredient-card.extras-toggle {
  width: 100%;
  background: rgba(175, 75, 47, 0.12);
  border: 1px dashed rgba(175, 75, 47, 0.4);
  color: var(--primary-dark);
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.ingredient-card.extras-toggle:hover,
.ingredient-card.extras-toggle:focus-visible {
  background: rgba(175, 75, 47, 0.18);
  border-color: rgba(175, 75, 47, 0.6);
  color: var(--primary);
  transform: translateY(-2px);
  outline: none;
}

.ingredient-card.extras-toggle.is-open {
  background: rgba(175, 75, 47, 0.22);
  border-color: rgba(175, 75, 47, 0.7);
  color: var(--primary);
}

.ingredient-card.base-suggestion {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  cursor: auto;
  text-align: left;
}
.base-grid .ingredient-card.base-suggestion {
  grid-column: 1 / -1;
}

.base-suggestion-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.ingredient-card.base-suggestion input[type="text"] {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(42, 43, 46, 0.16);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.9);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ingredient-card.base-suggestion input[type="text"]:focus-visible {
  outline: none;
  border-color: rgba(175, 75, 47, 0.6);
  box-shadow: 0 0 0 2px rgba(175, 75, 47, 0.18);
}

.extras-panel {
  display: none;
  margin-top: 8px;
  width: 100%;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(42, 43, 46, 0.16);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
  gap: 8px;
}

.extras-panel.is-open {
  display: flex;
  flex-direction: column;
}

.extras-panel label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.extras-panel textarea {
  resize: vertical;
  min-height: 80px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(42, 43, 46, 0.16);
  padding: 10px;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.4;
  color: var(--text);
}

.extras-panel textarea:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}


.finish-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.finish-card {
  position: relative;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: rgba(244, 242, 240, 0.85);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  border: 1px solid transparent;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.finish-card input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.finish-icon {
  font-size: 1.4rem;
}

.finish-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  text-transform: capitalize;
}

.finish-card:has(input:checked),
.finish-card.is-selected {
  border-color: rgba(175, 75, 47, 0.4);
  background: rgba(175, 75, 47, 0.08);
  box-shadow: var(--shadow-sm);
  transform: translateY(-3px);
}

.card-footer {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-top: clamp(12px, 4vw, 20px);
}

.cta-button {
  border: none;
  border-radius: 999px;
  background: var(--primary);
  color: #ffffff;
  font-size: 1rem;
  font-weight: 600;
  padding: 15px clamp(40px, 15vw, 72px);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.cta-button:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.card-credit {
  margin: 0;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.card-credit a {
  color: inherit;
  font-weight: 600;
  text-decoration: none;
}

.card-credit a:hover,
.card-credit a:focus-visible {
  text-decoration: underline;
  color: var(--primary);
}

dialog {
  border: none;
  border-radius: var(--radius-md);
  padding: 0;
  box-shadow: var(--shadow-lg);
  max-width: min(420px, 90vw);
}

dialog::backdrop {
  background: rgba(42, 43, 46, 0.35);
}

.dialog-message {
  margin: 12px 0 18px;
  color: var(--text-muted);
}

.dialog-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 0.95rem;
  color: var(--text);
}

.dialog-field span {
  font-weight: 600;
}

.dialog-field input {
  border-radius: var(--radius-sm);
  border: 1px solid rgba(42, 43, 46, 0.16);
  padding: 12px;
  font-size: 1rem;
  line-height: 1.3;
}

.dialog-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 20px;
  font-size: 1rem;
  color: var(--text-muted);
}

.dialog-checkbox input {
  margin-top: 4px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.dialog-secondary,
.dialog-primary {
  border: none;
  border-radius: 999px;
  font-weight: 600;
  padding: 12px 20px;
  cursor: pointer;
}

.dialog-secondary {
  background: rgba(42, 43, 46, 0.1);
  color: var(--text);
}

.dialog-primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: var(--shadow-md);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.dialog-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

#orderForm {
  padding: 24px;
}
