:root {
  --red: #b20e0e;
  --red-dark: #8a0a0a;
  --green: #264825;
  --ink: #1d1b19;
  --ink-2: #57524c;
  --ink-3: #8a847c;
  --paper: #f8f7f0;
  --line: #e4e0d8;
  --steel: #d9dbdc;
  --cardboard: #c79a63;
  --cardboard-dark: #a87943;
  --ok: #264825;
  --warn: #c77700;
  --radius: 10px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-logo: "Archivo Black", "Arial Black", sans-serif;
  --font-mono: "Courier Prime", "Courier New", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  min-height: 100vh;
  background: var(--tablecloth);
}
:root {
  /* Pizzeria-Tischdecke: zwei halbtransparente rote Streifenlagen ergeben das Karo,
     darüber Stoffstruktur, Mehlstaub und eine leichte Vignette */
  --check: 56px;
  --check-red: rgba(178, 14, 14, .58);
  --tablecloth:
    radial-gradient(ellipse 120% 90% at 50% 40%, transparent 55%, rgba(40, 0, 0, .35) 100%) fixed,
    radial-gradient(ellipse 28% 18% at 86% 10%, rgba(255,255,255,.35), transparent 70%) fixed,
    radial-gradient(ellipse 22% 14% at 10% 90%, rgba(255,255,255,.25), transparent 70%) fixed,
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .3 0 0 0 0 .2 0 0 0 0 .2 0 0 0 .35 0'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E") fixed,
    repeating-linear-gradient(0deg, rgba(0,0,0,.035) 0 1px, transparent 1px 3px) fixed,
    repeating-linear-gradient(90deg, rgba(0,0,0,.035) 0 1px, transparent 1px 3px) fixed,
    linear-gradient(90deg, var(--check-red) 50%, transparent 50%) 0 0 / var(--check) var(--check) fixed,
    linear-gradient(var(--check-red) 50%, transparent 50%) 0 0 / var(--check) var(--check) fixed,
    #f6f1e7;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Logo ---------- */
.logo { display: inline-flex; justify-content: center; text-decoration: none; }
.logo img { display: block; width: 120px; height: auto; mix-blend-mode: multiply; /* Creme-Hintergrund des Logos verschmilzt mit dem Papier */ }
.receipt .logo img { width: 175px; margin: -22px auto -16px; }
.closed .logo img { width: 220px; margin: -24px 0 -18px; }
.tagline { flex: 1 1 120px; background: var(--paper); font-size: 12px; padding: 7px 10px; border-radius: 3px; box-shadow: 0 2px 6px rgba(0,0,0,.18); line-height: 1.35; }

/* ---------- Gäste-Layout ---------- */
.app { display: grid; grid-template-columns: minmax(250px, 300px) 1fr minmax(280px, 330px); gap: 28px; padding: 18px 26px 26px; min-height: 100vh; align-items: start; }
.brand-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 22px; }
.brand-row .logo { overflow: hidden; background: var(--paper); padding: 2px; border-radius: 6px; box-shadow: 0 2px 6px rgba(0,0,0,.2); }
.brand-row .logo img { width: 136px; margin: -14px -12px -12px; }

.intro { background: var(--paper); border-radius: 6px; padding: 14px 16px 12px; box-shadow: 0 6px 14px rgba(0,0,0,.25); margin-bottom: 4px; }
.picker h1 { font-family: var(--font-logo); color: var(--red); font-size: 28px; line-height: 1.1; margin: 0; letter-spacing: -.5px; }
.picker .hint { margin: 6px 0 0; font-size: 13px; color: var(--ink-2); }
.picker .group-title { display: inline-block; background: var(--paper); color: var(--ink); padding: 3px 8px; border-radius: 3px; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.group-title { font-size: 11px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: rgba(0,0,0,.6); margin: 16px 0 8px; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }

.tile { position: relative; background: none; border: 0; padding: 0; text-align: left; -webkit-tap-highlight-color: transparent; }
.tile .tray {
  position: relative; aspect-ratio: 1.15; border-radius: 9px; overflow: hidden;
  background: linear-gradient(145deg, #f2f3f3, #bfc3c5 55%, #e7e9ea);
  padding: 6px; box-shadow: 0 6px 12px rgba(0,0,0,.28), inset 0 0 0 1px rgba(255,255,255,.6);
  transition: transform .15s ease, box-shadow .15s ease;
}
.tile .tray-inner { width: 100%; height: 100%; border-radius: 5px; background: linear-gradient(160deg, #cfd2d4, #e9ebec); box-shadow: inset 0 2px 6px rgba(0,0,0,.3); overflow: hidden; display: grid; place-items: center; }
.tile-svg { width: 118%; height: 118%; }
.tile:hover .tray { transform: translateY(-2px); box-shadow: 0 10px 18px rgba(0,0,0,.3), inset 0 0 0 1px rgba(255,255,255,.6); }
.tile:active .tray { transform: scale(.97); }
.tile .badge {
  position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--paper); color: var(--ink); display: grid; place-items: center; font-weight: 700; font-size: 16px;
  box-shadow: 0 2px 4px rgba(0,0,0,.3); transition: background .15s, color .15s, transform .2s;
}
.tile.on .badge { background: var(--red); color: #fff; transform: rotate(360deg); }
.tile.on .tray { box-shadow: 0 0 0 3px var(--red), 0 8px 16px rgba(0,0,0,.3); }
.tile .label { display: inline-block; margin-top: 7px; background: var(--paper); font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 3px; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.tile[draggable="true"] { cursor: grab; }

/* Pizzakarton */
.stage { display: flex; flex-direction: column; align-items: center; gap: 14px; padding-top: 36px; }
.box {
  position: relative; width: min(100%, 620px); aspect-ratio: 1; padding: 4.5%;
  background: linear-gradient(135deg, #d4a873, var(--cardboard) 40%, #b88850);
  border-radius: 6px;
  box-shadow: 0 30px 50px rgba(0,0,0,.35), 0 8px 14px rgba(0,0,0,.25), inset 0 0 0 2px rgba(0,0,0,.08);
}
.box::before { /* Wellpappe-Kante */
  content: ""; position: absolute; inset: 2.2%; border-radius: 3px;
  box-shadow: inset 0 0 0 3px var(--cardboard-dark), inset 0 6px 14px rgba(0,0,0,.35);
}
.box::after { /* Lüftungsloch vorne */
  content: ""; position: absolute; bottom: .8%; left: 50%; width: 30px; height: 14px; transform: translateX(-50%);
  border: 2px solid rgba(0,0,0,.35); border-top: 0; border-radius: 0 0 16px 16px;
}
.parchment {
  position: relative; width: 100%; height: 100%; border-radius: 2px;
  background: linear-gradient(170deg, #f4efe6, #e8e0d2); transform: rotate(-1.2deg);
  box-shadow: 0 2px 6px rgba(0,0,0,.25); display: grid; place-items: center;
}
.pizza-wrap { position: relative; width: 92%; aspect-ratio: 1; transform: rotate(1.2deg); transition: transform .25s ease; }
.pizza-wrap.over { transform: rotate(1.2deg) scale(1.03); }
.pizza-wrap.over::after { content: ""; position: absolute; inset: 4%; border-radius: 50%; outline: 3px dashed rgba(178,14,14,.7); outline-offset: 4px; }
.pizza-svg { width: 100%; height: 100%; display: block; overflow: visible; }

.drop { animation: drop .45s cubic-bezier(.2,.9,.3,1.2) both; transform-box: fill-box; transform-origin: center; }
@keyframes drop { from { opacity: 0; transform: translateY(-14px) scale(1.7); } to { opacity: 1; transform: none; } }
.sauce-in { animation: sauce .6s ease-out both; transform-origin: 0 0; }
@keyframes sauce { from { transform: scale(.2) rotate(-90deg); opacity: .3; } to { transform: none; opacity: 1; } }

.caption { background: var(--paper); font-size: 13px; padding: 8px 16px; border-radius: 3px; box-shadow: 0 2px 6px rgba(0,0,0,.2); display: flex; gap: 14px; align-items: center; }
.link { background: none; border: 0; padding: 0; color: var(--red); text-decoration: underline; font-weight: 600; }

/* Kassenbon */
.receipt-col { padding-top: 36px; display: flex; flex-direction: column; gap: 18px; }
.receipt {
  background: var(--paper); padding: 22px 22px 18px; font-family: var(--font-mono); font-size: 13px;
  box-shadow: 0 14px 28px rgba(0,0,0,.28);
  --tooth: 8px;
  mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / var(--tooth) 100%;
  -webkit-mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / var(--tooth) 100%;
  padding-bottom: 26px;
}
.receipt .logo { width: 100%; }
.receipt .sub { text-align: center; letter-spacing: 3px; font-size: 10px; color: var(--ink-3); margin: 4px 0 16px; }
.receipt h2 { font-family: var(--font-mono); font-size: 15px; text-align: center; margin: 0 0 12px; }
.receipt hr { border: 0; border-top: 1.5px dashed #bdb7ad; margin: 12px 0; }
.r-line { display: flex; align-items: baseline; gap: 6px; padding: 3px 0; }
.r-line .dots { flex: 1; border-bottom: 1.5px dotted #c9c3b9; transform: translateY(-3px); }
.r-line .x { background: none; border: 0; color: var(--ink-3); padding: 0 2px; font-family: var(--font-mono); }
.r-line .x:hover { color: var(--red); }
.r-empty { color: var(--ink-3); font-style: italic; padding: 4px 0; }
.r-cat { font-size: 10px; letter-spacing: 1.5px; color: var(--ink-3); text-transform: uppercase; margin-top: 8px; }
.receipt label { display: block; font-size: 11px; color: var(--ink-2); margin: 10px 0 4px; }
.receipt input, .receipt textarea {
  width: 100%; border: 1.5px solid var(--line); background: #fff; border-radius: 4px; padding: 8px 10px; font-family: var(--font); font-size: 15px;
}
.receipt textarea { resize: vertical; min-height: 44px; font-size: 14px; }
.receipt input:focus, .receipt textarea:focus { outline: 2px solid var(--red); outline-offset: -1px; }
.total { display: flex; justify-content: space-between; font-weight: 700; font-size: 17px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 4px;
  background: var(--red); color: #fff; font-family: var(--font); font-weight: 700; padding: 12px 16px; transition: background .15s, transform .1s;
}
.btn:hover { background: var(--red-dark); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.block { width: 100%; margin-top: 14px; justify-content: space-between; font-size: 16px; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.ghost:hover { background: #f1eee8; }
.btn.small { padding: 7px 11px; font-size: 13px; }
.btn.dark { background: var(--ink); }
.btn.dark:hover { background: #000; }
.barcode { height: 34px; margin: 14px auto 4px; width: 75%;
  background: repeating-linear-gradient(90deg, var(--ink) 0 2px, transparent 2px 4px, var(--ink) 4px 5px, transparent 5px 8px, var(--ink) 8px 11px, transparent 11px 12px); }
.footnote { text-align: center; font-size: 11px; color: var(--ink-3); }
.error { color: var(--red); font-family: var(--font); font-size: 13px; margin-top: 8px; min-height: 1em; }

/* Bestellstatus */
.tracker { background: var(--paper); border-radius: 6px; padding: 14px 16px; box-shadow: 0 8px 18px rgba(0,0,0,.22); }
.tracker h3 { margin: 0 0 10px; font-size: 14px; }
.track { display: grid; grid-template-columns: 54px 1fr; gap: 12px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.track:first-of-type { border-top: 0; }
.track .mini { width: 54px; height: 54px; }
.track .who { font-weight: 600; font-size: 14px; }
.track .what { font-size: 12px; color: var(--ink-2); }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; border-radius: 99px; padding: 3px 9px; margin-top: 4px; }
.pill.new { background: #f1eee8; color: var(--ink-2); }
.pill.oven { background: #fde6cf; color: #8a3d00; }
.pill.done { background: #dff1df; color: #1f5e22; }
.pill.cancelled { background: #eee; color: #888; text-decoration: line-through; }
.pill.oven::before { content: "🔥"; }
.pill.done::before { content: "✓"; }


/* Geschlossen */
.closed { min-height: 100vh; display: grid; place-items: center; padding: 24px; text-align: center; }
.closed .box { width: min(80vw, 460px); }
.closed .parchment { flex-direction: column; gap: 10px; padding: 24px; }
.closed h1 { font-family: var(--font-logo); color: var(--red); margin: 0; font-size: clamp(22px, 5vw, 32px); }
.closed p { margin: 0; color: var(--ink-2); }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: transform .3s cubic-bezier(.2,.9,.3,1.2), opacity .2s; background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 8px; font-weight: 600; box-shadow: 0 10px 24px rgba(0,0,0,.35); z-index: 50; max-width: calc(100vw - 32px); }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .app { grid-template-columns: 1fr 1fr; }
  .stage { grid-column: 1 / -1; order: -1; padding-top: 0; }
  .brand-row { grid-column: 1 / -1; }
  .receipt-col { padding-top: 0; }
}
@media (max-width: 700px) {
  .app { grid-template-columns: 1fr; padding: 12px 16px 90px; gap: 18px; }
  .brand-row { margin-bottom: 0; justify-content: space-between; }
  .stage { position: sticky; top: 0; z-index: 5; padding: 8px 0 10px; margin: 0 -16px; gap: 8px;
    background: var(--tablecloth); box-shadow: 0 8px 14px -6px rgba(0,0,0,.35); }
  .box { width: min(70vw, 38vh); }
  .caption { font-size: 12px; padding: 6px 12px; }
  .tiles { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .tile .label { font-size: 11px; padding: 2px 6px; }
  .picker h1 { font-size: 24px; }
  .tagline { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .drop, .sauce-in { animation: none; }
}
.receipt label.r-check { display: flex; margin: 0; font-size: 13px; color: var(--ink); cursor: pointer; }
.r-check input { accent-color: var(--red); width: 15px; height: 15px; margin: 0 2px 0 0; transform: translateY(2px); }

/* Ofen-Warteschlange */
.queue .q-headline { font-family: var(--font-logo); color: var(--red); font-size: 18px; margin: -4px 0 6px; }
.q-row { display: grid; grid-template-columns: 22px 40px 1fr; gap: 10px; align-items: center; padding: 6px 6px; border-radius: 6px; }
.q-row + .q-row { border-top: 1px solid var(--line); }
.q-row .mini { width: 40px; height: 40px; }
.q-row .who { font-weight: 600; font-size: 14px; }
.q-row .what { font-size: 12px; color: var(--ink-2); }
.q-pos { font-family: var(--font-mono); font-weight: 700; font-size: 14px; color: var(--ink-3); text-align: center; }
.q-row.mine { background: #fff1f2; box-shadow: inset 3px 0 0 var(--red); }
.q-row.mine .q-pos { color: var(--red); }
.q-you { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: #fff; background: var(--red); border-radius: 99px; padding: 1px 7px; margin-left: 4px; vertical-align: 2px; }

/* ---------- Kartondeckel ---------- */
.stage { perspective: 1800px; }
.box { transform-style: preserve-3d; transition: width .45s ease; }
.lid {
  position: absolute; inset: 0; z-index: 4; border: 0; padding: 0; background: none; cursor: pointer;
  transform-origin: 50% 0; transform-style: preserve-3d; transform: translateZ(3px); will-change: transform;
  transition: transform .9s cubic-bezier(.55, 0, .25, 1);
  -webkit-tap-highlight-color: transparent;
}
.lid-face { position: absolute; inset: 0; border-radius: 6px; backface-visibility: hidden; -webkit-backface-visibility: hidden; transition: opacity .35s ease; }
.lid-front {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 8%;
  background:
    radial-gradient(ellipse 70% 60% at 50% 45%, rgba(255,255,255,.18), transparent 70%),
    linear-gradient(135deg, #d8ad78, #c99c64 45%, #ba8a52);
  box-shadow: 0 30px 50px rgba(0,0,0,.35), 0 8px 14px rgba(0,0,0,.25), inset 0 0 0 2px rgba(0,0,0,.08), inset 0 -10px 18px rgba(0,0,0,.12);
}
.lid-front::before { /* Falzkante des Deckels */
  content: ""; position: absolute; inset: 3.2%; border-radius: 3px; border: 2px solid rgba(120,80,35,.35); pointer-events: none;
}
.lid-front::after { /* Griffmulde vorne */
  content: ""; position: absolute; bottom: 0; left: 50%; width: 64px; height: 18px; transform: translateX(-50%);
  border-radius: 32px 32px 0 0; background: rgba(90,55,20,.28); box-shadow: inset 0 3px 5px rgba(0,0,0,.3);
}
.lid-front img { width: 58%; max-width: 300px; mix-blend-mode: multiply; opacity: .92; filter: saturate(1.1) contrast(1.05); margin: -6% 0 -3%; }
.lid-title { font-family: var(--font-logo); color: var(--red); font-size: clamp(20px, 3.4vw, 34px); letter-spacing: -.5px; mix-blend-mode: multiply; }
.lid-hint { font-size: 13px; color: rgba(60,35,10,.75); font-weight: 600; }
.lid-back { transform: rotateX(180deg); background: linear-gradient(#e2c79f, #d4b484); }
.lid:focus-visible .lid-front { outline: 3px solid var(--paper); outline-offset: 4px; }

/* Zu: Deckel wippt leicht, um zum Öffnen einzuladen */
.box:not(.open) .lid { animation: nudge 3.2s ease-in-out 1.2s infinite; }
@media (hover: hover) { /* nur mit Maus – auf Touch bleibt :hover sonst nach dem Tippen hängen */
  .box:not(.open) .lid:hover { animation: none; transform: translateZ(3px) rotateX(6deg); transition-duration: .25s; }
}
@keyframes nudge { 0%, 78%, 100% { transform: translateZ(3px); } 86% { transform: translateZ(3px) rotateX(6deg); } 93% { transform: translateZ(3px) rotateX(1deg); } }

/* Auf: Deckel klappt zum Betrachter hoch und verschwindet */
.box.open .lid { transform: translateZ(3px) rotateX(100deg); pointer-events: none; }
.box.open .lid-face { opacity: 0; transition: opacity .4s ease .45s; }

/* Solange der Karton zu ist, nur Karton und Bestellstatus zeigen */
.lid-closed .picker, .lid-closed .receipt, .lid-closed .caption { display: none; }
.app:not(.lid-closed) .picker, .app:not(.lid-closed) .receipt { animation: slide-in .5s ease .35s both; }
@keyframes slide-in { from { opacity: 0; transform: translateY(14px); } }
@media (max-width: 1100px) {
  .lid-closed .stage { padding-top: 24px; }
}
@media (max-width: 700px) {
  .lid-closed .stage { position: static; box-shadow: none; background: none; padding-top: 8px; }
  .lid-closed .box { width: min(88vw, 62vh); }
}
@media (prefers-reduced-motion: reduce) {
  .lid, .lid-face { transition: none; }
  .box:not(.open) .lid { animation: none; }
}
@media (min-width: 1101px) {
  /* feste Spalten, damit der Karton auch bei ausgeblendeter Zutatenliste mittig bleibt */
  .stage { grid-column: 2; }
  .receipt-col { grid-column: 3; }
}

/* „Als App speichern“ */
.install {
  position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 40;
  border: 0; border-radius: 99px; padding: 10px 16px; font-weight: 700; font-size: 14px;
  background: var(--paper); color: var(--ink); box-shadow: 0 6px 18px rgba(0,0,0,.3);
  animation: slide-in .5s ease 1.5s both;
}
.install:hover { background: #fff; }
.install[hidden] { display: none; }
/* Als installierte App: Platz für die Statusleiste lassen */
@media (display-mode: standalone) {
  .app, .closed { padding-top: calc(18px + env(safe-area-inset-top)); }
}
/* „Ofen aus“/Offline-Karton darf mitwachsen, wenn der Text auf schmalen Handys nicht passt */
.closed .box { aspect-ratio: auto; min-height: min(80vw, 460px); display: flex; }
.closed .parchment { height: auto; min-height: 100%; }
@media (max-width: 700px) { .closed .box { width: min(90vw, 460px); } .closed .logo img { width: 170px; } }
