:root {
  font-family: system-ui, "Segoe UI", sans-serif;
  color: #1f2937;
  background: #f5f7f8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 0;
  padding-bottom: calc(140px + env(safe-area-inset-bottom, 0px));
}

button, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .65; }
button:focus-visible, textarea:focus-visible {
  outline: 3px solid #0f766e;
  outline-offset: 2px;
}

header {
  background: #2d1814;
  color: #fff;
  padding: 22px 12px 19px;
  text-align: center;
}
header h1 { margin: 0; font-size: 26px; line-height: 1.2; }
header p { margin: 5px 0 0; font-size: 16px; font-weight: 700; }
#accountStatus { margin-top: 10px; }
#accountStatus[hidden] { display: none; }
#accountMessage { display: block; font-size: 15px; font-weight: 700; }
#accountTotal { display: block; margin-top: 3px; font-size: 27px; font-weight: 800; line-height: 1.2; }

nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px;
  overflow: visible;
}
nav button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  min-height: 54px;
  padding: 8px 5px;
  border: 2px solid #c74b0c;
  border-radius: 8px;
  background: #d9550f;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  overflow-wrap: anywhere;
  letter-spacing: 0;
}
nav button[aria-pressed="true"] {
  background: #9f3208;
  border-color: #732407;
  box-shadow: inset 0 0 0 2px #fff;
}
nav button:hover { background: #b63f09; }

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 4px 12px 24px;
}
.card {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  min-width: 0;
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
}
.card img {
  display: block;
  width: 96px;
  height: 96px;
  border-radius: 5px;
  object-fit: cover;
}
.card > div { min-width: 0; }
.card small { color: #8d390c; font-weight: 700; }
.card h3 {
  margin: 4px 0 6px;
  font-size: 17px;
  line-height: 1.25;
  overflow-wrap: break-word;
}
.card p { margin: 0 0 8px; color: #475569; line-height: 1.4; }
.card p:empty { display: none; }
.card b { display: block; margin-top: 8px; font-size: 17px; }

.add, #submit, #openCart, .flavor, .decision {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 700;
}
.add {
  display: block;
  float: none;
  width: 100%;
  margin-top: 12px;
  background: #16803d;
  color: #fff;
}
.add:hover { background: #116b34; }
#submit, #openCart, .decision { background: #d9550f; color: #fff; }

aside {
  position: fixed;
  z-index: 10;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto auto;
  align-items: center;
  column-gap: 12px;
  padding: 11px 12px calc(11px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid #6f4938;
  background: #241c1a;
  color: #fff;
}
aside strong { grid-column: 1; grid-row: 1; text-transform: uppercase; }
aside span { grid-column: 1; grid-row: 2; color: #e2e8f0; }
#cartTotal { grid-row: 3; font-weight: 700; }
#openCart { grid-column: 2; grid-row: 1 / 4; }

dialog {
  width: min(calc(100% - 24px), 520px);
  max-height: calc(100dvh - 32px);
  overflow: auto;
  border: 0;
  border-radius: 8px;
  padding: 22px;
  color: #1f2937;
}
dialog::backdrop { background: #111827b8; }
dialog .close { float: right; font-size: 24px; border: 0; background: transparent; }
textarea { width: 100%; min-height: 80px; padding: 8px; }
.observation { display: block; margin: 10px 0; font-size: 14px; font-weight: 700; }
.observation textarea { display: block; min-height: 58px; margin-top: 4px; }
.cartline { padding: 8px; border-bottom: 1px solid #e2e8f0; }
.cartline small { display: block; color: #6b4a3d; }
.cart-total { margin: 14px 0 0; text-align: right; font-size: 18px; font-weight: 800; }
.flavor {
  display: block;
  width: 100%;
  margin: 8px 0;
  border: 1px solid #e7c8b9;
  background: #fff;
  color: #24120d;
  text-align: left;
}
.decision { margin: 6px 6px 0 0; }
.decision.secondary { background: #4b5563; }
.pizza-image { display: block; width: 100%; max-height: 250px; margin: 0 0 14px; object-fit: cover; }
.pizza-image[hidden] { display: none; }
.pizza-summary { color: #6b4a3d; font-weight: 700; }
.order-confirmation { padding: 8px 0; text-align: center; }
.order-confirmation p:first-child { color: #117a38; font-size: 18px; font-weight: 800; }
.order-confirmation p { margin: 10px 0; line-height: 1.45; }
.order-confirmation .decision { margin-top: 12px; }
.pizza-config { grid-column: 1 / -1; grid-template-columns: minmax(0, 1fr); }
.pizza-config > div { width: 100%; }
.pizza-config .add { min-height: 56px; font-size: 16px; white-space: normal; }
#pizzaDialog { width: min(calc(100% - 20px), 560px); padding: 20px; }
#pizzaDialog h2 { overflow-wrap: anywhere; }
#flavorChoices { width: 100%; }
.flavor { min-height: 54px; padding: 12px 14px; font-size: 16px; line-height: 1.3; overflow-wrap: anywhere; white-space: normal; }
#pizzaDecision { display: grid; grid-template-columns: 1fr; gap: 8px; width: 100%; }
.decision { width: 100%; min-height: 54px; margin: 0; white-space: normal; }

@media (min-width: 360px) {
  nav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  nav button { font-size: 16px; }
}
@media (min-width: 600px) {
  nav { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
  nav button { font-size: 17px; }
  main { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 950px) {
  nav { grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); }
  main { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 359px) {
  .card { grid-template-columns: minmax(0, 1fr); }
  .card img { width: 100%; height: auto; aspect-ratio: 16 / 9; }
}
@media (max-width: 420px) {
  .card { grid-template-columns: 82px minmax(0, 1fr); gap: 10px; padding: 10px; }
  .card img { width: 82px; height: 82px; }
  .card h3 { font-size: 16px; }
  .card p { overflow-wrap: anywhere; }
  .pizza-config { grid-template-columns: minmax(0, 1fr); }
  .pizza-config img { width: 100%; height: auto; max-height: 190px; aspect-ratio: 16 / 9; }
}
