:root {
  --bg: #111418;
  --panel: #1a1e23;
  --panel2: #242a31;
  --line: #333b44;
  --text: #f1f3f5;
  --muted: #9aa4ae;
  --accent: #e64980;
  --ok: #40c057;
  --warn: #fab005;
  --bad: #fa5252;
  --radius: 14px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  overscroll-behavior: none;
}
body { overflow: hidden; }

button {
  font: inherit;
  color: inherit;
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}
button:disabled { opacity: .4; cursor: default; }

input {
  font: inherit;
  color: var(--text);
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  -webkit-user-select: text;
  user-select: text;
}

h1, h2, h3 { margin: 0 0 12px; }

/* ---------- Allgemein ---------- */

.spacer { flex: 1; }

.icon {
  background: rgba(255,255,255,.08);
  border-radius: 10px;
  min-width: 48px;
  height: 44px;
  font-size: 22px;
}

.verbindung { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; }
.verbindung i { width: 12px; height: 12px; border-radius: 50%; background: var(--ok); display: inline-block; }
.verbindung em { font-style: normal; display: none; }
body.offline .verbindung i { background: var(--bad); animation: blink 1s infinite; }
body.offline .verbindung em { display: inline; color: var(--bad); }
.rolle-station.offline .verbindung em { color: #000; background: var(--bad); padding: 2px 8px; border-radius: 6px; }

@keyframes blink { 50% { opacity: .3; } }

/* Lang-druecken-Fortschritt */
.drueckbar { position: relative; overflow: hidden; }
.drueckbar.pressing::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.4);
  transform-origin: left;
  animation: lang .55s linear forwards;
  pointer-events: none;
}
@keyframes lang { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ---------- Dialoge ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 16px;
}
.dialog {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px;
  width: min(560px, 100%);
  max-height: calc(100dvh - 32px);
  overflow: auto;
}
.dialog.breit { width: min(900px, 100%); }
.dialog .zeile { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.dialog .zeile > button { flex: 1; }

.btn {
  background: var(--panel2);
  border-radius: 12px;
  padding: 16px 18px;
  font-weight: 600;
  font-size: 18px;
  min-height: 60px;
}
.btn.primaer { background: var(--ok); color: #08130a; }
.btn.gefahr { background: #4a1d1f; color: #ffc9c9; }
.btn.aktiv { background: var(--accent); color: #fff; }

.menue { display: grid; gap: 10px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #000;
  color: #fff;
  padding: 14px 22px;
  border-radius: 12px;
  font-weight: 600;
  z-index: 80;
  box-shadow: 0 6px 24px rgba(0,0,0,.5);
}
.toast.fehler { background: var(--bad); }

/* ---------- Startbildschirm ---------- */

.start {
  height: 100dvh;
  display: grid;
  place-content: center;
  gap: 18px;
  padding: 16px;
  text-align: center;
}
.start h1 { font-size: 40px; }
.start .rollen { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; width: min(900px, 92vw); }
.start .rollen button {
  height: 120px;
  border-radius: var(--radius);
  font-size: 24px;
  font-weight: 700;
  background: var(--farbe);
  color: #111;
}
.start .fehler { color: var(--bad); min-height: 1.2em; margin: 0; }
.start label { display: grid; gap: 6px; text-align: left; color: var(--muted); width: min(420px, 92vw); margin: 0 auto; }
.start a { color: var(--muted); }

/* ---------- Annahme ---------- */

.annahme {
  height: 100dvh;
  display: grid;
  grid-template-columns: 1fr minmax(330px, 34%);
  grid-template-rows: auto 1fr;
}
.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.topbar .titel { font-weight: 800; font-size: 20px; color: var(--accent); }
.warteschlange { background: var(--warn); color: #000; border-radius: 8px; padding: 4px 10px; font-weight: 700; font-size: 14px; }
.offen-info { color: var(--muted); font-weight: 600; }

.kacheln {
  overflow: auto;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  grid-auto-rows: minmax(112px, auto);
  gap: 10px;
  align-content: start;
}
.kachel {
  background: var(--farbe, #495057);
  border-radius: var(--radius);
  color: #fff;
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: left;
  box-shadow: inset 0 -5px rgba(0,0,0,.25);
  transition: transform .06s;
}
.kachel:active { transform: scale(.97); }
.k-name { font-size: 21px; font-weight: 700; line-height: 1.15; text-shadow: 0 1px 2px rgba(0,0,0,.4); }
.k-preis { font-size: 17px; font-weight: 600; opacity: .9; }
.k-plus { font-size: 13px; opacity: .8; }
.k-menge {
  position: absolute;
  top: 8px;
  right: 8px;
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border-radius: 17px;
  background: #fff;
  color: #000;
  font-weight: 800;
  font-size: 18px;
  display: grid;
  place-items: center;
}
.leer-hinweis { grid-column: 1 / -1; color: var(--muted); padding: 30px; text-align: center; }

.bon {
  background: var(--panel);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.bon-kopf {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 12px 16px;
  font-weight: 700;
  font-size: 18px;
  border-bottom: 1px solid var(--line);
}
.bon-nr { color: var(--muted); }
.bon-nr b { color: var(--text); font-size: 26px; }
.bon-liste { flex: 1; overflow: auto; list-style: none; margin: 0; padding: 0; }
.bon-liste li {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 19px;
}
.bon-liste li .menge { font-weight: 800; }
.bon-liste li small { display: block; color: var(--muted); font-size: 14px; }
.bon-liste li .betrag { font-variant-numeric: tabular-nums; font-weight: 600; }
.bon-liste li.rueck { color: #ffc078; }
.bon-liste .leer { color: var(--muted); text-align: center; display: block; padding: 40px 16px; border: 0; font-size: 16px; }

.bon-fuss { padding: 12px 16px 16px; border-top: 1px solid var(--line); display: grid; gap: 10px; }
.bon-knoepfe { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.schalter { background: var(--panel2); border-radius: 12px; min-height: 54px; font-weight: 700; font-size: 16px; padding: 6px 8px; }
.schalter.an { background: #fff; color: #000; }
.summe { display: flex; justify-content: space-between; align-items: baseline; font-size: 20px; }
.summe b { font-size: 36px; font-variant-numeric: tabular-nums; }
.pfand-info { color: var(--muted); font-size: 14px; text-align: right; min-height: 1.2em; margin-top: -8px; }
.bon-aktionen { display: grid; grid-template-columns: 76px 1fr; gap: 8px; }
.leeren { background: #4a1d1f; color: #ffc9c9; border-radius: 12px; font-size: 26px; }
.senden { background: var(--ok); color: #08130a; border-radius: 12px; height: 76px; font-size: 28px; font-weight: 800; }

/* Grog-Dialog */
.grog-grid { display: grid; grid-template-columns: auto repeat(4, 1fr); gap: 10px; align-items: stretch; }
.grog-grid .lbl { display: flex; flex-direction: column; justify-content: center; font-weight: 700; font-size: 18px; padding-right: 6px; }
.grog-grid .lbl small { color: var(--muted); font-weight: 500; font-size: 14px; }
.grog-grid .kopf { text-align: center; color: var(--muted); font-size: 14px; font-weight: 600; }
.opt {
  position: relative;
  background: var(--panel2);
  border-radius: 12px;
  min-height: 86px;
  font-size: 24px;
  font-weight: 800;
}
.opt.doppelt { background: #5c3310; }
.opt .k-menge { top: 4px; right: 4px; min-width: 28px; height: 28px; font-size: 15px; }

/* Bezahlen */
.bezahlen .nr-gross { text-align: center; font-size: 22px; color: var(--muted); }
.bezahlen .nr-gross b { display: block; font-size: 84px; line-height: 1; color: var(--text); }
.bezahlen .togo-hinweis { text-align: center; font-weight: 800; background: #fff; color: #000; border-radius: 8px; padding: 4px; margin: 8px auto 0; width: max-content; padding: 4px 14px; }
.betraege { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 18px 0; text-align: center; }
.betraege div { background: var(--panel2); border-radius: 12px; padding: 10px; }
.betraege span { display: block; color: var(--muted); font-size: 14px; }
.betraege b { font-size: 28px; font-variant-numeric: tabular-nums; }
.betraege .rueckgeld b { color: var(--ok); font-size: 34px; }
.betraege .fehlt b { color: var(--bad); }
.scheine { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.scheine button { background: var(--panel2); border-radius: 12px; height: 64px; font-size: 22px; font-weight: 700; }
.scheine .passend { background: #1c3a5e; }

/* Statistik */
.kennzahlen { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.kennzahlen div { background: var(--panel2); border-radius: 12px; padding: 12px; }
.kennzahlen span { display: block; color: var(--muted); font-size: 14px; }
.kennzahlen b { font-size: 26px; font-variant-numeric: tabular-nums; }
table.liste { width: 100%; border-collapse: collapse; font-size: 17px; }
table.liste th, table.liste td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; }
table.liste td.r, table.liste th.r { text-align: right; font-variant-numeric: tabular-nums; }
table.liste small { color: var(--muted); }
.hinweis { color: var(--muted); font-size: 14px; }

/* ---------- Stationen ---------- */

.station { height: 100dvh; display: flex; flex-direction: column; }
.st-kopf {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 6px 12px;
  background: var(--st);
  color: #111;
  font-weight: 800;
  font-size: 22px;
}
.st-kopf .titel { font-size: 26px; text-transform: uppercase; letter-spacing: .04em; }
.st-kopf .icon { background: rgba(0,0,0,.15); }
.st-kopf .verbindung i { border: 2px solid rgba(0,0,0,.4); }
.weitere { background: #111; color: #fff; padding: 2px 10px; border-radius: 8px; }
.weitere:empty { display: none; }
.uhr { font-variant-numeric: tabular-nums; }
.undo { background: rgba(0,0,0,.2); border-radius: 10px; height: 44px; padding: 0 14px; font-weight: 700; font-size: 18px; }

.slots { flex: 1; display: grid; gap: 10px; padding: 10px; min-height: 0; }
.slots.k12 { grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(3, minmax(0, 1fr)); }
.slots.k8 { grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(2, minmax(0, 1fr)); }

.slot-leer {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  color: var(--line);
  font-size: 44px;
  font-weight: 800;
}

.karte {
  position: relative;
  background: var(--panel2);
  border-radius: var(--radius);
  border-top: 10px solid var(--ok);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.karte.neu { animation: neu 1.2s ease-out 2; }
@keyframes neu { 0% { box-shadow: 0 0 0 6px #fff; } 100% { box-shadow: 0 0 0 0 transparent; } }
/* passt trotz kleinster Schrift nicht: deutlich markieren */
.karte.voll::after { content: "▼ MEHR"; position: absolute; left: 0; right: 0; bottom: 0; background: var(--bad); color: #fff; text-align: center; font-weight: 900; font-size: 13px; padding: 2px; }
.karte.gelb { border-top-color: var(--warn); }
.karte.rot { border-top-color: var(--bad); }
.karte.rot .k-zeit { color: var(--bad); }

.k-kopf { display: flex; justify-content: space-between; align-items: center; padding: 4px 12px 0; }
.k-nr { font-size: 32px; font-weight: 900; line-height: 1.1; }
.k-zeit { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--muted); }
.k-togo { margin: 0 12px; background: #fff; color: #000; font-weight: 900; letter-spacing: .08em; text-align: center; border-radius: 6px; font-size: 16px; padding: 2px; }
.k-pos { list-style: none; margin: 0; padding: 6px 12px 10px; overflow: hidden; flex: 1; font-size: clamp(17px, 2.1vw, 30px); font-weight: 700; line-height: 1.2; }
.k-pos li { padding: 2px 0; }
.k-pos li b { color: var(--st); margin-right: 4px; }
.k-pos li small { color: #ffd8a8; font-size: .78em; font-weight: 700; }
.k-pos li small::before { content: " · "; color: var(--muted); }
.k-pos .dot { display: inline-block; width: .55em; height: .55em; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.slot-nr { position: absolute; right: 10px; bottom: 6px; font-size: 13px; color: var(--muted); font-weight: 700; }

.rolle-station .karte { cursor: pointer; }
.ton-an { background: #111; color: #fff; animation: blink 1.4s infinite; }

/* Ausgabe: Status je Position / ganze Bestellung */
.k-pos li.ok { color: #8ce99a; }
.k-pos .dot.ok { width: auto; height: auto; background: none; color: var(--ok); font-weight: 900; font-size: .8em; }
.karte.komplett { border-top-color: var(--ok); background: #173a22; }
.k-bereit { background: var(--ok); color: #08130a; font-weight: 900; letter-spacing: .06em; border-radius: 6px; padding: 2px 10px; font-size: 18px; }
.k-best {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.88);
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 8px;
  padding: 10px;
  z-index: 2;
}
.k-best button { border-radius: 12px; font-size: 24px; font-weight: 800; }
.k-best .ok { background: var(--ok); color: #08130a; }
.k-best .abbr { background: var(--panel2); height: 54px; font-size: 18px; }

/* ---------- Hochformat / kleine Geraete ---------- */
@media (max-width: 760px) {
  .annahme { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
  .bon { border-left: 0; border-top: 1px solid var(--line); max-height: 48dvh; }
  .slots.k12, .slots.k8 { grid-template-columns: repeat(2, 1fr); grid-template-rows: none; grid-auto-rows: minmax(160px, auto); overflow: auto; }
  .scheine { grid-template-columns: repeat(3, 1fr); }
}
