:root {
  --paper: #f1f4ec;
  --card: #ffffff;
  --ink: #18241b;
  --soft: #5a685d;
  --line: #d9e0d3;
  --herb: #17573a;
  --herb-deep: #0e3d28;
  --herb-pale: #dcebdd;
  --chili: #d63f22;
  --chili-deep: #ad2d14;
  --radius: 1.1rem;
  --display: Bahnschrift, "DIN Alternate", "Roboto Condensed", "Segoe UI", sans-serif;
  --text: "Segoe UI Variable Text", "Segoe UI", Roboto, sans-serif;
}

/* Розмір усього залежить від екрана: однаково зручно на планшеті й на великому кіоску */
html { font-size: clamp(14px, calc(8px + .95vmin), 24px); }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

body {
  margin: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden;
  background: var(--paper); color: var(--ink); font-family: var(--text); line-height: 1.3;
  user-select: none; -webkit-user-select: none; touch-action: manipulation; overscroll-behavior: none;
}
main { flex: 1; min-height: 0; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3, .price, .num { font-family: var(--display); line-height: 1.08; text-wrap: balance; }
.price, .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; text-align: inherit; }
button:active:not(:disabled) { transform: scale(.98); }
button:focus-visible { outline: .25rem solid var(--ink); outline-offset: .15rem; }
svg { display: block; width: 100%; height: 100%; }
.muted { color: var(--soft); }

.test { background: var(--ink); color: #fff; text-align: center; padding: .45rem 1rem; font-weight: 600; }

.btn {
  min-height: 4.4rem; padding: .8rem 1.8rem; border-radius: var(--radius); font-weight: 650; font-size: 1.25rem;
  display: inline-flex; align-items: center; justify-content: center; gap: 1rem; text-align: center;
}
.btn.main { background: var(--chili); color: #fff; }
.btn.main:active { background: var(--chili-deep); }
.btn.main:disabled { background: #c9d0c5; color: #4f5b52; cursor: default; }
.btn.plain { background: var(--card); box-shadow: inset 0 0 0 2px var(--line); }

/* ---------- Початок ---------- */
.start { height: 100%; background: var(--herb); color: #fff; display: grid; grid-template-rows: minmax(0, 1fr) auto; }
.start-top {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2.2rem;
  padding: 2rem; min-height: 0; text-align: center;
}
.start-art { width: min(52rem, 88%, 70vh); aspect-ratio: 8 / 5; min-height: 0; flex-shrink: 1; }
.start h1 { font-size: clamp(4rem, 15vmin, 10rem); letter-spacing: -.02em; }
.start-top p { font-size: 1.5rem; color: #d7ead9; margin-top: .8rem; }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; padding: 0 1.6rem 1.6rem; }
.mode {
  background: var(--paper); color: var(--ink); border-radius: 1.6rem; padding: 1.8rem 1rem; min-height: 13rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem;
  font-family: var(--display); font-size: 2.1rem; font-weight: 600;
}
.mode span { width: 6.5rem; height: 6.5rem; }
@media (min-aspect-ratio: 5/4) {
  .start { grid-template-rows: none; grid-template-columns: 1.1fr 1fr; }
  .modes { padding: 2rem; grid-template-columns: 1fr; }
}

/* ---------- Меню ---------- */
.shop { height: 100%; display: grid; grid-template: minmax(0, 1fr) auto / clamp(6.6rem, 17vw, 14rem) minmax(0, 1fr); }
.rail { background: var(--card); border-right: 1px solid var(--line); overflow-y: auto; scrollbar-width: none; padding: .6rem; }
.rail button {
  width: 100%; min-height: 6.6rem; padding: .7rem .3rem; border-radius: var(--radius); margin-bottom: .3rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .35rem;
  font-weight: 600; text-align: center; line-height: 1.12; overflow-wrap: anywhere;
}
.rail span { width: 3.9rem; height: 3.9rem; }
.rail button[aria-current="true"] { background: var(--herb); color: #fff; }

.list { overflow-y: auto; padding: 1.6rem; overscroll-behavior: contain; }
.list h1 { font-size: 2.7rem; margin-bottom: 1.3rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 13.5rem), 1fr)); }
.item {
  background: var(--card); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column;
  box-shadow: 0 1px 0 var(--line);
}
.pic { position: relative; aspect-ratio: 16 / 10; overflow: hidden; flex-shrink: 0; display: grid; place-items: center; }
.pic > i { width: 58%; height: 88%; }
.pic img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.pic .art { object-fit: contain; }
.start-art img { width: 100%; height: 100%; object-fit: contain; }
.note { margin-top: 1.4rem; }
.item-text { padding: .9rem 1rem 1.1rem; flex: 1; display: flex; flex-direction: column; justify-content: space-between; gap: .7rem; }
.item-name { font-weight: 600; font-size: 1.12rem; overflow-wrap: break-word; }
.item .price { font-size: 1.5rem; font-weight: 600; color: var(--herb); }
.item small { font-size: 1rem; font-weight: 400; color: var(--soft); }

.bar {
  grid-column: 1 / -1; background: var(--card); border-top: 1px solid var(--line); padding: 1rem 1.2rem;
  display: flex; gap: 1rem; align-items: stretch;
}
.bar .main { flex: 1; justify-content: space-between; min-width: 0; }

/* ---------- Страва ---------- */
.back { position: fixed; inset: 0; background: rgb(12 28 18 / .58); display: grid; place-items: end center; z-index: 5; }
.sheet {
  background: var(--paper); width: min(100%, 52rem); max-height: 94vh; max-height: 94dvh; border-radius: 1.8rem 1.8rem 0 0;
  display: flex; flex-direction: column; overflow: hidden; animation: up .22s ease-out;
}
@keyframes up { from { transform: translateY(3rem); opacity: 0; } }
.sheet-body { overflow-y: auto; min-height: 0; overscroll-behavior: contain; }
.sheet .pic { aspect-ratio: auto; height: min(15rem, 26vh); }
.sheet .pic > i { width: 13rem; height: 88%; }
.sheet-in { padding: 1.5rem; }
.sheet h2 { font-size: 2.3rem; }
.group { margin-top: 1.6rem; }
.group h3 { font-size: 1.45rem; }
.group p { margin: .2rem 0 .8rem; }
.opts { display: grid; gap: .7rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr)); }
.opt {
  background: var(--card); min-height: 4.2rem; padding: .7rem 1rem; border-radius: .9rem; box-shadow: inset 0 0 0 2px var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: .8rem; font-weight: 550;
}
.opt[aria-pressed="true"] { background: var(--herb-pale); box-shadow: inset 0 0 0 .2rem var(--herb); }
.opt:disabled { opacity: .5; cursor: default; }
.sheet-foot { background: var(--card); border-top: 1px solid var(--line); padding: 1rem 1.2rem; display: flex; gap: 1rem; flex-wrap: wrap; }
.sheet-foot .main { flex: 1 1 16rem; justify-content: space-between; }

.qty { display: inline-flex; align-items: center; background: var(--paper); border-radius: var(--radius); flex-shrink: 0; }
.qty button { width: 4.2rem; height: 4.2rem; font-size: 2rem; text-align: center; border-radius: var(--radius); }
.qty button:disabled { opacity: .3; cursor: default; }
.qty .num { min-width: 2.4rem; text-align: center; font-size: 1.5rem; }

/* ---------- Кошик ---------- */
.cart { height: 100%; display: grid; grid-template-rows: minmax(0, 1fr) auto; }
.cart-in { overflow-y: auto; padding: 1.8rem 1.4rem; }
.cart-in > * { max-width: 56rem; margin-inline: auto; }
.cart h1 { font-size: 2.9rem; }
.place { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; background: #dfe6da; padding: .4rem; border-radius: 1.3rem; margin-block: 1.3rem; }
.place button { min-height: 3.8rem; border-radius: 1rem; text-align: center; font-weight: 600; font-size: 1.15rem; }
.place button[aria-pressed="true"] { background: var(--card); box-shadow: 0 1px 3px rgb(0 0 0 / .18); }
.line {
  background: var(--card); border-radius: var(--radius); padding: 1.1rem; margin-bottom: .8rem;
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: .8rem 1.4rem;
}
.line b { font-size: 1.2rem; }
.line .price { font-size: 1.4rem; min-width: 6.2rem; text-align: right; }
@media (max-width: 40rem) {
  .line { grid-template-columns: auto 1fr; }
  .line > div:first-child { grid-column: 1 / -1; }
}
.more { margin-top: 2rem; }
.more h2 { font-size: 1.7rem; margin-bottom: 1rem; }
.more .row { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); }
.sum { width: 100%; max-width: 56rem; margin-inline: auto; display: grid; gap: .9rem; }
.sum-line { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.sum-line .price { font-size: 2.4rem; }
.sum-btns { display: flex; gap: 1rem; flex-wrap: wrap; }
.sum-btns .btn.main { flex: 1 1 16rem; justify-content: center; }

/* ---------- Готово та повідомлення ---------- */
.done {
  height: 100%; overflow-y: auto; padding: 2rem; text-align: center;
  display: flex; flex-direction: column; align-items: center; justify-content: safe center; gap: 1.6rem;
}
.done.ok { background: var(--herb); color: #fff; }
.done h1 { font-size: 3rem; max-width: 18em; }
.done p { font-size: 1.5rem; max-width: 30em; }
.ticket { background: var(--card); color: var(--ink); border-radius: 1.8rem; padding: 1.6rem 4rem 2rem; }
.ticket p { color: var(--soft); }
.ticket .num { font-size: clamp(7rem, 24vmin, 15rem); font-weight: 700; line-height: 1; }

.box {
  align-self: center; background: var(--card); border-radius: 1.6rem; padding: 2.2rem; margin: 1.2rem;
  width: min(100% - 2.4rem, 36rem); text-align: center; display: grid; gap: 1.4rem;
}
.box h2 { font-size: 2.1rem; }
.box p { font-size: 1.25rem; }
.box-btns { display: flex; flex-wrap: wrap; gap: .8rem; }
.box-btns .btn { flex: 1 1 12rem; }
#overlay .back { z-index: 10; }
.spin { width: 4.5rem; height: 4.5rem; margin: auto; border: .5rem solid var(--herb-pale); border-top-color: var(--herb); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(1turn); } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } .spin { animation-duration: 4s; } }
