#meal-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px 20px;
  margin-block: 0 18px;
}

.mode-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mode-switch button {
  min-height: 46px;
  padding: 10px 16px;
  border: 1px solid #9aa285;
  border-radius: 10px;
  background: var(--cream);
  color: var(--olive);
  font-weight: 850;
  line-height: 1.2;
}

.mode-switch button[aria-pressed="true"],
.mode-switch button[aria-selected="true"],
.mode-switch button.active {
  border-color: var(--olive);
  background: var(--olive);
  color: var(--cream);
}

.mode-switch button:hover { border-color: var(--deep-olive); }
.mode-switch button:not([aria-pressed="true"]):not([aria-selected="true"]):not(.active):hover { background: var(--green); }

.people-picker {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px 10px;
  color: var(--olive);
  font-size: .9rem;
  font-weight: 800;
}

.people-picker select {
  min-height: 46px;
  max-width: 100%;
  padding: 8px 32px 8px 12px;
  border: 1px solid #9aa285;
  border-radius: 9px;
  background: var(--cream);
  color: var(--ink);
  font: inherit;
}

.people-picker select:focus-visible,
.pantry-check input:focus-visible {
  outline: 3px solid #a44e2e;
  outline-offset: 3px;
}

.scene:has(.shop-pork) {
  height: auto;
  min-height: 285px;
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 11px 4%;
  padding: 16px 5% 29px;
}

.scene:has(.shop-pork) .shop { margin-bottom: 0; }
.scene:has(.shop-pork) .shop-sign { min-height: 26px; }
.scene:has(.shop-pork) .awning { height: 20px; }
.scene:has(.shop-pork) .shop-wares { min-height: 53px; border-bottom-width: 12px; }
.scene:has(.shop-pork) .shop-wares canvas { display: block; width: min(100%, 135px); height: auto; max-height: 70px; object-fit: contain; }
.scene:has(.shop-pork) .scene-floor { top: 40%; }
.shop-pork { --stripe: #c68983; }
.shop-chicken { --stripe: #d1b071; }
.shop-noodles { --stripe: #a9a171; }
.scene[data-stall="pork"] .shop-pork,
.scene[data-stall="chicken"] .shop-chicken,
.scene[data-stall="noodles"] .shop-noodles { outline: 3px solid #596648; outline-offset: 3px; }

.craving-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.craving-picker .tile {
  padding: 15px;
  min-height: 106px;
  align-content: center;
  gap: 5px;
}

.craving-picker .tile strong { font-size: 1rem; }
.craving-picker .tile small { line-height: 1.4; }
.craving-picker .tile .tile-icon { font-size: 1.8rem; margin: 0 0 3px; }

.basket { min-width: 0; }
.basket-head { gap: 7px; }
.basket-head h2 { font-size: 1.4rem; }
.basket-for { margin: 3px 0 14px; color: var(--muted); font-size: .85rem; }
.basket-visual {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
  gap: 2px;
  min-height: 96px;
  margin-block: 13px 18px;
  padding: 9px 7px 12px;
  border: 2px solid #b39764;
  border-bottom-width: 8px;
  border-radius: 9px 9px 26px 26px;
  background:
    repeating-linear-gradient(0deg, #99794816 0 2px, transparent 2px 12px),
    repeating-linear-gradient(90deg, #b197661c 0 2px, transparent 2px 18px),
    #eddfbc;
}

.basket-visual > p { grid-column: 1 / -1; margin: 9px; text-align: center; font-size: .85rem; }
.basket-produce { min-width: 0; text-align: center; font-size: .7rem; line-height: 1.25; }
.basket-produce canvas { display: block; width: 100%; height: auto; transform: scale(1.15); }
.basket-produce small { display: block; color: var(--muted); }

.meal-summary { margin-top: 15px; }
.meal-summary h3 { margin: 0 0 6px; font-size: 1.05rem; line-height: 1.25; letter-spacing: -.02em; }
.meal-summary p { margin-bottom: 8px; font-size: .86rem; line-height: 1.45; }
.meal-summary > strong { display: block; margin-bottom: 5px; font-size: 1rem; color: var(--olive); }
.portion-plates { display: flex; flex-wrap: wrap; gap: 6px; margin-block: 10px 12px; }
.plate {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid #bcb698;
  border-radius: 50%;
  box-shadow: inset 0 0 0 4px var(--cream), inset 0 0 0 5px #d8d0b5;
  background: #eee8d6;
  color: var(--ink);
  font-size: .72rem;
  font-weight: 800;
}
.plate.filled { border-color: #809063; background: #b9c78c; box-shadow: inset 0 0 0 4px #fffdf6, inset 0 0 0 5px #a5b582; }

.meal-checklist { list-style: none; padding: 0; margin: 11px 0 15px; }
.meal-checklist li { display: grid; gap: 5px; padding-block: 8px; border-bottom: 1px solid var(--line); font-size: .83rem; }
.meal-checklist li:last-child { border-bottom: 0; }
.meal-checklist li strong { font-weight: 800; }
.meal-checklist li small { color: var(--muted); line-height: 1.35; }
.meal-checklist .part-status { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: .8rem; }
.meal-checklist .part-status > :last-child { text-align: right; font-variant-numeric: tabular-nums; }
.meal-checklist progress { height: 6px; }
.meal-checklist li.complete { color: var(--olive); }

.pantry-check { display: flex; align-items: center; gap: 9px; min-height: 44px; margin-block: 9px; padding-block: 9px; border-block: 1px solid var(--line); font-size: .85rem; line-height: 1.35; cursor: pointer; }
.pantry-check h3 { margin: 0 0 5px; font-size: .94rem; }
.pantry-check label { display: flex; align-items: center; gap: 9px; min-height: 44px; font-size: .85rem; line-height: 1.35; cursor: pointer; }
.pantry-check input { flex: 0 0 auto; margin: 0; width: 19px; height: 19px; accent-color: var(--olive); }
.pantry-check p { margin: 0; color: var(--muted); font-size: .8rem; }

.basket-edit-list { list-style: none; margin: 13px 0 0; padding: 0; }
.basket-edit-list li { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 2px 8px; padding-block: 10px; border-bottom: 1px solid var(--line); }
.basket-edit-list li:last-child { border-bottom: 0; }
.basket-item-art { grid-row: 1 / 3; align-self: start; padding-top: 3px; }
.basket-item-art canvas { display: block; width: 48px; height: auto; transform: scale(1.25); }
.basket-item-details { min-width: 0; align-self: center; }
.basket-item-details strong { display: block; font-size: .86rem; line-height: 1.3; overflow-wrap: anywhere; }
.basket-item-details small { display: block; margin-top: 2px; color: var(--muted); font-size: .78rem; line-height: 1.35; }
.basket-item-actions { grid-column: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-top: 4px; }
.basket-item-actions button { display: inline-flex; justify-content: center; align-items: center; min-height: 44px; min-width: 44px; padding: 3px 7px; border: 1px solid #a8b092; border-radius: 8px; background: var(--cream); color: var(--olive); font-size: .84rem; font-weight: 800; }
.basket-item-actions button:hover { background: var(--green); }
.basket-item-actions .secondary,
.basket-item-actions button[data-action="remove"],
.basket-item-actions button[data-action="remove-item"] { border-color: transparent; text-decoration: underline; text-underline-offset: .18em; font-size: .75rem; padding-inline: 2px; }
.basket-item-actions output { font-size: .8rem; text-align: center; min-width: 1.5rem; }
.selected-produce { display: flex; justify-content: center; align-items: center; margin-block: 4px; }
.selected-produce canvas { display: block; width: min(100%, 210px); height: auto; }

.market-counter[data-market="pork"] {
  --wall: #dfbdb2;
  --wall-grout: #f3dfd3;
  --wall-ink: #583d34;
  --worktop: #bd9d90;
  --metal-light: #e4d5c5;
  --metal-edge: #97756b;
  --rail: #785348;
  --bin: #cdb6a9;
  --bin-edge: #957f75;
  --liner: #e8dcd0;
  --label: #fff1d6;
}
.market-counter[data-market="chicken"] {
  --wall: #e0cba3;
  --wall-grout: #f5e8cc;
  --wall-ink: #51432d;
  --worktop: #bca580;
  --metal-light: #e5d8bd;
  --metal-edge: #8e7b5d;
  --rail: #6f5d3c;
  --bin: #ccba98;
  --bin-edge: #978468;
  --liner: #f0e4cd;
  --label: #fff2d1;
}
.market-counter[data-market="noodles"] {
  --wall: #d1cfaa;
  --wall-grout: #f0ebce;
  --wall-ink: #44452c;
  --worktop: #aba57d;
  --metal-light: #dedbb9;
  --metal-edge: #7f8060;
  --rail: #5d6143;
  --bin: #c4c19a;
  --bin-edge: #88866b;
  --liner: #eeebd0;
  --label: #fff3d7;
}

@media (min-width: 751px) {
  .game-grid .basket,
  .game-grid:has(.market-counter) .basket {
    position: sticky;
    top: 14px;
    max-height: calc(100dvh - 28px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: #a1a888 var(--cream);
  }
  .basket .basket-head { position: sticky; top: -1px; z-index: 1; padding-block: 3px 8px; background: var(--cream); }
}

@media (max-width: 750px) {
  #meal-controls { align-items: stretch; gap: 10px; }
  .scene:has(.shop-pork) { min-height: 256px; padding: 12px 4% 28px; gap: 10px 3%; }
  .scene:has(.shop-pork) .shop-sign { min-height: 23px; }
  .scene:has(.shop-pork) .shop-wares { min-height: 45px; }
  .basket-visual { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 440px) {
  .mode-switch { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mode-switch button { padding-inline: 8px; font-size: .9rem; }
  .people-picker { width: 100%; justify-content: space-between; }
  .people-picker select { min-width: 100px; }
  .craving-picker { gap: 8px; }
  .craving-picker .tile { padding: 12px; min-height: 110px; }
  .craving-picker .tile strong { font-size: .93rem; }
  .basket-edit-list li { grid-template-columns: 52px minmax(0, 1fr); }
  .basket-item-art canvas { width: 52px; }
}

@media (max-width: 360px) {
  .scene:has(.shop-pork) { min-height: 238px; padding-inline: 10px; }
  .scene:has(.shop-pork) .shop-wares { min-height: 39px; }
  .scene:has(.shop-pork) .shop-sign { font-size: .58rem; letter-spacing: 0; }
  .craving-picker .tile { padding: 10px; }
  .basket-visual { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
