:root {
  --bg: #0e1020;
  --panel: #191c31;
  --panel-solid: #232744;
  --text: #f3f4fa;
  --muted: #9aa0bd;
  --accent: #ff7a3d;
  --accent-2: #ff3d81;
  --green: #22c55e;
  --green-dark: #15803d;
  --red: #ef4444;
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

/* Verhindert Textmarkierung, Kontextmenü & Lupe beim langen Drücken */
body {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
button:disabled { cursor: default; }
img { -webkit-user-drag: none; }

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.screen[hidden] { display: none; }

/* ============================ MENÜ ============================ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 12px) 16px 6px;
}
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand-title {
  font-size: 1.45rem;
  font-weight: 900;
  letter-spacing: .01em;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-sub { color: var(--muted); font-weight: 600; }
.icon-btn {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--panel);
  font-size: 1.2rem;
}

.chips {
  display: flex;
  gap: 8px;
  padding: 8px 16px 10px;
  overflow-x: auto;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-weight: 700;
  font-size: .95rem;
  transition: background .15s, color .15s;
}
.chip.active {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: #fff;
}

.grid {
  flex: 1;
  overflow-y: auto;
  padding: 4px 16px 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  grid-auto-rows: max-content; /* sonst werden die Zeilen auf die Höhe des Rasters gestaucht */
  gap: 12px;
  align-content: start;
  -webkit-overflow-scrolling: touch;
}

.tile {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: radial-gradient(120% 90% at 50% 28%, #3a4070 0%, #1d2140 62%, #161930 100%);
}
.tile::before { content: ""; display: block; padding-top: 100%; } /* quadratisch */
.tile-main {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  padding: 0;
  text-align: left;
  transition: transform .1s;
}
.tile-main:active { transform: scale(.955); }
.tile-main img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  pointer-events: none;
}
/* Freigestelltes Getränk (Bild ohne Hintergrund): schwebt über dem Farbverlauf */
.tile-main img.cutout {
  inset: auto;
  top: 7%; left: 8%;
  width: 84%; height: 64%;
  object-fit: contain;
  filter: drop-shadow(0 8px 10px rgba(0,0,0,.55));
}
.shade {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 34px 11px 10px;
  display: flex; flex-direction: column; gap: 1px;
  background: linear-gradient(to top, rgba(8,9,20,.92) 12%, rgba(8,9,20,0));
}
.name { font-weight: 800; font-size: 1.02rem; line-height: 1.15; text-shadow: 0 1px 4px rgba(0,0,0,.6); }
.price { font-weight: 600; font-size: .85rem; color: #ffc9a8; }

.badge {
  position: absolute; top: 8px; right: 8px;
  min-width: 34px; height: 34px; padding: 0 9px;
  display: grid; place-items: center;
  border-radius: 17px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-weight: 900; font-size: 1.05rem;
  box-shadow: 0 2px 10px rgba(0,0,0,.5);
  pointer-events: none;
}
.badge[hidden], .minus[hidden] { display: none; }
.minus {
  position: absolute; top: 8px; left: 8px;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: rgba(10,11,25,.72);
  font-size: 1.5rem; font-weight: 700; line-height: 1;
  box-shadow: 0 2px 10px rgba(0,0,0,.4);
}
.minus:active { background: rgba(239,68,68,.85); }

.tile.pop { animation: pop .28s ease-out; }
.tile.pop .badge { animation: bump .28s ease-out; }
@keyframes pop { 40% { transform: scale(.94); } 100% { transform: scale(1); } }
@keyframes bump { 40% { transform: scale(1.35); } 100% { transform: scale(1); } }

/* ---------- Warenkorb-Leiste ---------- */
.cartbar {
  background: var(--panel);
  border-radius: 22px 22px 0 0;
  padding: 6px 14px calc(var(--safe-bottom) + 12px);
  box-shadow: 0 -8px 30px rgba(0,0,0,.45);
}
.cart-summary {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 2px;
  text-align: left;
}
.cart-icon { font-size: 1.25rem; }
.cart-count { flex: 1; font-weight: 700; color: var(--muted); }
.cart-summary.has-items .cart-count { color: var(--text); }
.cart-total { font-weight: 900; font-size: 1.2rem; }
.cart-chev { color: var(--muted); font-size: .75rem; transition: transform .2s; }
.cart-summary[aria-expanded="true"] .cart-chev { transform: rotate(180deg); }

.cart-list {
  max-height: 34vh;
  overflow-y: auto;
  padding: 4px 0 6px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.cart-list[hidden] { display: none; }
.cart-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 0;
}
.cart-row .cr-name { flex: 1; font-weight: 700; }
.cart-row .cr-sum { min-width: 64px; text-align: right; color: var(--muted); font-weight: 600; }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--panel-solid);
  font-size: 1.3rem; font-weight: 700;
}
.stepper span { min-width: 26px; text-align: center; font-weight: 900; }

.cart-actions { display: flex; gap: 10px; margin-top: 4px; }

.btn {
  height: 58px;
  border-radius: 16px;
  padding: 0 18px;
  font-size: 1.15rem;
  font-weight: 800;
  transition: transform .1s, opacity .15s, filter .15s;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .35; }
.btn-cancel {
  flex: 1;
  background: rgba(239,68,68,.14);
  color: #ff8a8a;
  box-shadow: inset 0 0 0 2px rgba(239,68,68,.45);
}
.btn-pay {
  flex: 1.5;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff;
  box-shadow: 0 6px 20px rgba(34,197,94,.3);
}
.btn-ghost { flex: 1; background: var(--panel-solid); }
.btn-danger { flex: 1; background: var(--red); color: #fff; }

/* ============================ BEZAHLEN ============================ */
.checkout { animation: slideUp .25s ease-out; padding-bottom: var(--safe-bottom); }
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } }

.co-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--safe-top) + 12px) 12px 8px;
}
.co-head h2 { font-size: 1.3rem; font-weight: 900; }
.co-head .link, .co-spacer { width: 90px; }
.link {
  color: var(--muted);
  font-weight: 700;
  padding: 10px 6px;
  text-align: left;
}
.link.danger { color: #ff8a8a; text-align: center; }

.co-list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  padding: 4px 16px;
}
.co-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.co-list img {
  width: 52px; height: 52px; border-radius: 12px;
  object-fit: cover; flex: none;
  pointer-events: none;
}
.co-list img.cutout {
  object-fit: contain;
  padding: 4px;
  background: radial-gradient(120% 90% at 50% 28%, #3a4070 0%, #1d2140 100%);
}
.co-qty { font-weight: 900; font-size: 1.2rem; min-width: 34px; color: var(--accent); }
.co-name { flex: 1; font-weight: 700; font-size: 1.1rem; }
.co-sum { font-weight: 700; color: var(--muted); }

.co-total {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 14px 20px 8px;
  border-top: 2px solid rgba(255,255,255,.12);
  font-size: 1.1rem; color: var(--muted); font-weight: 700;
}
.co-total strong { color: var(--text); font-size: 2.1rem; font-weight: 900; }

.co-pay { padding: 8px 16px 12px; display: flex; flex-direction: column; gap: 4px; }

/* ---------- Der große Halte-Button ---------- */
.hold {
  position: relative;
  width: 100%;
  height: 128px;
  border-radius: 30px;
  overflow: hidden;
  background: var(--panel-solid);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.14);
  touch-action: none;                 /* wichtig: kein Scrollen/Zoomen beim Halten */
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  animation: idle 2.4s ease-in-out infinite;
}
@keyframes idle {
  0%, 100% { box-shadow: inset 0 0 0 2px rgba(255,255,255,.14), 0 0 0 0 rgba(34,197,94,0); }
  50%      { box-shadow: inset 0 0 0 2px rgba(34,197,94,.55), 0 0 22px 2px rgba(34,197,94,.28); }
}
.hold.holding { animation: none; box-shadow: inset 0 0 0 2px rgba(255,255,255,.4); }

.hold-fill {
  position: absolute; inset: 0;
  background: linear-gradient(90deg, #16a34a, #34d670);
  transform-origin: left center;
  transform: scaleX(var(--p, 0));
  transition: transform .25s ease-out;
}
.hold.holding .hold-fill { transition: none; }

.hold-label {
  position: relative;
  height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  pointer-events: none;
}
.hold-title { font-size: 1.7rem; font-weight: 900; letter-spacing: .01em; }
.hold-sub { font-size: .95rem; font-weight: 600; color: rgba(255,255,255,.72); }

/* Scan-Wellen */
.wave {
  position: absolute; left: 50%; top: 50%;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,.55);
  transform: translate(-50%, -50%) scale(0);
  opacity: 0;
  pointer-events: none;
}
.hold.holding .wave { animation: wave 1.1s ease-out infinite; }
.hold.holding .wave.w2 { animation-delay: .55s; }
@keyframes wave {
  0%   { transform: translate(-50%, -50%) scale(0.2); opacity: .9; }
  100% { transform: translate(-50%, -50%) scale(11);  opacity: 0; }
}

/* ============================ BEZAHLT ============================ */
.paid {
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #fff;
  background: radial-gradient(circle at 50% 38%, #3fe382 0%, #18c25a 55%, #0f9d46 100%);
}
.paid-inner { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 0 24px; }
.check { width: min(58vw, 260px); height: auto; overflow: visible; }
.check-bg { fill: #fff; transform-origin: 60px 60px; }
.check-ring { fill: none; stroke: rgba(255,255,255,.7); stroke-width: 2; transform-origin: 60px 60px; }
.check-mark {
  fill: none; stroke: #16a34a; stroke-width: 11;
  stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 100; stroke-dashoffset: 100;
}
.paid h1 {
  margin-top: 14px;
  font-size: clamp(2.6rem, 13vw, 4.2rem);
  font-weight: 900;
  letter-spacing: .08em;
  text-shadow: 0 3px 16px rgba(0,60,20,.35);
}
.paid p { font-size: 1.15rem; font-weight: 700; opacity: .92; }

.paid.play { animation: flash .45s ease-out; }
.paid.play .check-bg   { animation: popIn .5s cubic-bezier(.2,1.5,.4,1) both; }
.paid.play .check-ring { animation: ring 1s ease-out both; }
.paid.play .check-mark { animation: draw .45s .28s ease-out forwards; }
.paid.play h1, .paid.play p { animation: rise .5s .35s ease-out both; }
@keyframes flash { from { filter: brightness(1.7); } }
@keyframes popIn { from { transform: scale(0); } }
@keyframes ring  { from { transform: scale(1); opacity: 1; } to { transform: scale(1.5); opacity: 0; } }
@keyframes draw  { to { stroke-dashoffset: 0; } }
@keyframes rise  { from { transform: translateY(14px); opacity: 0; } }

.btn-new {
  position: absolute; left: 20px; right: 20px;
  bottom: calc(var(--safe-bottom) + 24px);
  height: 58px; border-radius: 16px;
  background: rgba(255,255,255,.22);
  color: #fff; font-weight: 800; font-size: 1.1rem;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.55);
  transition: opacity .3s;
}
.btn-new:disabled { opacity: 0; pointer-events: none; }

/* ============================ MODAL ============================ */
.modal {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  padding: 24px;
  background: rgba(4,5,14,.72);
  animation: fade .15s;
}
.modal[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }
.modal-box {
  width: 100%; max-width: 380px;
  background: var(--panel);
  border-radius: 22px;
  padding: 24px 20px 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.modal-box h3 { font-size: 1.3rem; font-weight: 900; margin-bottom: 8px; }
.modal-box p { color: var(--muted); font-weight: 600; margin-bottom: 20px; line-height: 1.35; }
.modal-actions { display: flex; gap: 10px; }

@media (min-width: 700px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
  .cartbar, .co-list, .co-total, .co-pay { max-width: 640px; width: 100%; margin-left: auto; margin-right: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .hold, .wave { animation: none !important; }
}
