:root {
  --bg: #fff6ea;
  --ink: #2b2118;
  --card: #fffdf8;
  --orange: #ff8a2a;
  --pink: #ff4f7b;
  --yellow: #ffe14a;
  --green: #1d2b22;
  --mint: #d8ff6a;
  --teal: #14b8a6;
  --muted: #6d5848;
  --line: #eadcc8;
  color-scheme: light;
  font-family: ui-rounded, "Avenir Next", "Trebuchet MS", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background:
    radial-gradient(circle at 18px 18px, rgba(255, 176, 92, 0.35) 2px, transparent 3px) 0 0 / 26px 26px,
    var(--bg);
}

body {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

button, input { font-family: inherit; color: inherit; }

button { cursor: pointer; }

input { user-select: text; -webkit-user-select: text; }

:focus-visible {
  outline: 3px solid #2f6fed;
  outline-offset: 2px;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  background: var(--orange);
  border-bottom: 3px solid var(--ink);
  padding: calc(8px + env(safe-area-inset-top)) 12px 10px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: clamp(22px, 3vw, 32px);
  font-weight: 900;
  letter-spacing: -0.03em;
}

.today {
  margin-left: auto;
  background: white;
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 900;
  font-size: 16px;
  white-space: nowrap;
}

.icon-btn {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: 16px;
  border: 3px solid var(--ink);
  background: white;
  font-size: 26px;
  box-shadow: 3px 3px 0 var(--ink);
}

.icon-btn.armed {
  width: auto;
  padding: 0 12px;
  font-size: 18px;
}

.icon-btn:active,
.tab:active,
.product:active,
.btn:active,
.pay-btn:active,
.money-btn:active,
.key:active,
.chip:active,
.expand:active,
.quick-pay:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  padding: 10px 12px 8px;
  overflow-x: auto;
}

.tab {
  flex: 1;
  min-width: 132px;
  min-height: 54px;
  border: 3px solid var(--ink);
  background: white;
  border-radius: 999px;
  font-size: 18px;
  font-weight: 900;
}

.tab.active { box-shadow: 3px 3px 0 var(--ink); }
.tab[data-cat="getraenke"].active { background: #8fddff; }
.tab[data-cat="essen"].active { background: #ffd36b; }
.tab[data-cat="spielzeug"].active { background: #ffb3d1; }
.tab[data-cat="eigene"].active { background: #b6f5c6; }

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr minmax(300px, 380px);
}

.catalog {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.grid {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 14px;
  align-content: start;
  padding: 8px 14px 18px;
}

.product {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 168px;
  padding: 14px 8px;
  background: var(--card);
  border: 3px solid var(--ink);
  border-radius: 24px;
  box-shadow: 4px 4px 0 var(--ink);
}

.product .emoji { font-size: 58px; line-height: 1; }

.product .name {
  font-size: 18px;
  font-weight: 900;
  text-align: center;
  line-height: 1.15;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product .price {
  margin-top: 4px;
  font-size: 20px;
  font-weight: 900;
  background: var(--yellow);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 2px 10px;
  font-variant-numeric: tabular-nums;
}

.product.pop { animation: pop 0.22s ease; }

.badge {
  position: absolute;
  top: 8px;
  right: 8px;
  min-width: 32px;
  height: 32px;
  padding: 0 6px;
  display: grid;
  place-items: center;
  background: var(--pink);
  color: white;
  border: 3px solid var(--ink);
  border-radius: 999px;
  font-weight: 900;
}

.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 16px 24px;
  font-size: 26px;
  font-weight: 900;
}

.empty span {
  display: block;
  font-size: 72px;
  margin-bottom: 8px;
}

.ticket {
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #fffaf2;
  border-left: 3px solid var(--ink);
}

.ticket-handle { display: none; }

.ticket-body {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 12px 14px calc(14px + env(safe-area-inset-bottom));
}

.ticket-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ticket-head h2 {
  margin: 0;
  font-size: 24px;
}

.lines {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.hint {
  margin: 18px 4px;
  color: var(--muted);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.35;
}

.line {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 2px;
  border-bottom: 2px dashed var(--line);
}

.line-emoji { font-size: 36px; line-height: 1; }

.line-main { flex: 1; min-width: 0; }

.line-name {
  font-size: 18px;
  font-weight: 900;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.line-meta { color: var(--muted); font-weight: 800; font-size: 15px; }

.line-sum {
  font-size: 18px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.stepper button {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  border: 3px solid var(--ink);
  background: white;
  font-size: 28px;
  font-weight: 900;
  box-shadow: 2px 2px 0 var(--ink);
}

.stepper button:active { transform: translate(1px, 1px); box-shadow: none; }

.stepper span {
  min-width: 28px;
  text-align: center;
  font-size: 22px;
  font-weight: 900;
}

.total-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 2px 8px;
  font-size: 18px;
  font-weight: 900;
}

.total-box strong,
.display strong {
  font-variant-numeric: tabular-nums;
}

.total-box strong {
  font-size: 34px;
  background: var(--green);
  color: var(--mint);
  border-radius: 16px;
  padding: 6px 14px;
}

.total-box strong.pop { animation: pop 0.22s ease; }

.pay-btn {
  min-height: 72px;
  border: 3px solid var(--ink);
  border-radius: 20px;
  background: var(--pink);
  color: white;
  font-size: 28px;
  font-weight: 900;
  box-shadow: 4px 4px 0 var(--ink);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 18px 18px, rgba(255, 176, 92, 0.35) 2px, transparent 3px) 0 0 / 26px 26px,
    var(--bg);
}

.modal[hidden],
.toast[hidden] { display: none !important; }

.modal > * { flex: 1; min-height: 0; }

.result-screen { position: relative; }

.pay-screen,
.result-screen,
.pin-screen,
.parent-screen,
.form-screen {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  padding:
    calc(10px + env(safe-area-inset-top))
    16px
    calc(12px + env(safe-area-inset-bottom));
}

.screen-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.screen-top h2 {
  margin: 0;
  font-size: clamp(26px, 4vw, 36px);
}

.pay-scroll,
.parent-scroll,
.form-scroll,
.result-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.displays {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.display {
  background: var(--green);
  color: var(--mint);
  border-radius: 18px;
  padding: 8px 12px 10px;
  border: 3px solid #152019;
}

.display span {
  display: block;
  color: #b7d98a;
  font-size: 16px;
  font-weight: 800;
}

.display strong {
  display: block;
  font-size: clamp(32px, 5vw, 56px);
  line-height: 1.05;
}

.money-status {
  min-height: 32px;
  text-align: center;
  font-size: 22px;
  font-weight: 900;
}

.money-status.bad { color: #d23b55; }
.money-status.good { color: #1f8a45; }

.secondary-actions,
.pay-actions,
.form-actions,
.result-actions {
  display: grid;
  gap: 10px;
  flex-shrink: 0;
}

.secondary-actions,
.form-actions,
.result-actions { grid-template-columns: 1fr 1fr; }

.pay-actions { grid-template-columns: 1fr 1.4fr; }

.money-pad {
  width: min(100%, 760px);
  margin: 4px auto 0;
}

.bills {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.coins {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
  justify-items: center;
}

.money-btn,
.money-face {
  position: relative;
  display: grid;
  place-items: center;
  align-content: center;
  border: 3px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  font-weight: 900;
  line-height: 1;
  color: var(--ink);
  background: white;
}

.money-btn.coin {
  border-radius: 50%;
  width: min(128px, 100%);
  aspect-ratio: 1;
  height: auto;
}

.money-face.coin {
  border-radius: 50%;
  width: 112px;
  height: 112px;
  flex-shrink: 0;
}

.money-btn.note,
.money-face.note {
  border-radius: 14px;
  min-height: 70px;
}

.money-btn .face,
.money-face .face { font-size: 28px; }

.money-btn .unit,
.money-face .unit {
  margin-top: 3px;
  font-size: 11px;
  letter-spacing: 0.08em;
}

.money-btn .times {
  position: absolute;
  top: -8px;
  right: -4px;
  min-width: 26px;
  height: 26px;
  padding: 0 5px;
  display: grid;
  place-items: center;
  background: var(--pink);
  color: white;
  border: 2px solid var(--ink);
  border-radius: 999px;
  font-size: 13px;
}

.c1, .c2, .c5 { background: #e6a06a; }
.c10, .c20, .c50 { background: #f2cb4d; }
.e1 { background: radial-gradient(circle, #f2cb4d 0 46%, #dedede 48%); }
.e2 { background: radial-gradient(circle, #dedede 0 46%, #f2cb4d 48%); }
.n5 { background: #d5dde3; color: #243038; }
.n10 { background: #e4544a; color: white; }
.n20 { background: #3c7eae; color: white; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 44px;
  margin-top: 10px;
  align-content: flex-start;
}

.chips .hint { margin: 6px 0; }

.chip {
  border: 3px solid var(--ink);
  background: white;
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 900;
  font-size: 16px;
  box-shadow: 2px 2px 0 var(--ink);
}

.btn {
  min-height: 64px;
  border-radius: 18px;
  border: 3px solid var(--ink);
  background: white;
  font-size: 20px;
  font-weight: 900;
  box-shadow: 3px 3px 0 var(--ink);
  padding: 8px 10px;
  text-align: center;
}

.btn.primary { background: var(--pink); color: white; }
.btn.good { background: #3dbe6a; color: white; }
.btn.teal { background: var(--teal); color: white; }
.btn.danger { background: #ffe1e6; }
.btn.wide { grid-column: 1 / -1; }

.praise {
  margin: 0;
  text-align: center;
  font-size: clamp(32px, 5vw, 46px);
  line-height: 1.1;
}

.eq {
  display: grid;
  gap: 8px;
  width: min(100%, 720px);
  margin: 0 auto;
}

.eq-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: white;
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 10px 14px;
  font-weight: 900;
  font-size: 20px;
}

.eq-row strong { font-size: 28px; font-variant-numeric: tabular-nums; }

.eq-row.back {
  background: var(--green);
  color: var(--mint);
  border-color: var(--green);
}

.eq-row.back strong { font-size: clamp(32px, 5vw, 44px); }

.words {
  margin: 4px 0 0;
  text-align: center;
  font-size: 22px;
  font-weight: 900;
}

.change-coins {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 8px;
}

.change-coin { position: relative; }

.count-pill {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  background: var(--pink);
  color: white;
  border: 2px solid var(--ink);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 900;
}

.money-face.note {
  width: 148px;
  height: 86px;
  flex-shrink: 0;
}

.result-scroll {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
}

.confetti {
  pointer-events: none;
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.confetti span {
  position: absolute;
  left: calc(var(--i) * 8%);
  top: -8%;
  font-size: 32px;
  animation: fall 1.15s ease-in forwards;
  animation-delay: calc(var(--i) * 35ms);
}

.pin-screen { justify-content: center; gap: 18px; }

.pin-copy {
  margin: 0;
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  color: var(--muted);
}

.dots {
  display: flex;
  gap: 14px;
  justify-content: center;
}

.dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid var(--ink);
  background: white;
}

.dot.on { background: var(--ink); }

.pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: min(100%, 460px);
  margin: 0 auto;
}

.key {
  min-height: 74px;
  border-radius: 18px;
  border: 3px solid var(--ink);
  background: white;
  font-size: 32px;
  font-weight: 900;
  box-shadow: 3px 3px 0 var(--ink);
}

.stats-line {
  margin: 0;
  font-size: 20px;
  font-weight: 900;
}

.parent-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0;
}

.parent-row {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 2px dashed var(--line);
}

.parent-row .meta { flex: 1; min-width: 0; font-weight: 900; font-size: 18px; }

.parent-row .meta small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-weight: 800;
}

.parent-scroll h3 { margin: 16px 0 4px; font-size: 20px; }

label.field {
  display: block;
  margin: 8px 0;
  font-weight: 900;
}

input[type="text"] {
  width: 100%;
  margin-top: 6px;
  font-size: 22px;
  font-weight: 800;
  padding: 12px 14px;
  border-radius: 16px;
  border: 3px solid var(--ink);
  background: white;
}

.price-display {
  margin-top: 6px;
  background: var(--green);
  color: var(--mint);
  border-radius: 16px;
  text-align: center;
  font-size: 40px;
  font-weight: 900;
  padding: 8px;
  font-variant-numeric: tabular-nums;
}

.price-hint {
  margin: 6px 0 8px;
  color: var(--muted);
  font-weight: 800;
}

.cats { display: flex; flex-wrap: wrap; gap: 8px; }

.cat, .pick {
  border: 3px solid transparent;
  background: white;
  border-radius: 14px;
  font-weight: 900;
}

.cat {
  min-height: 48px;
  padding: 8px 12px;
  border-color: var(--ink);
  font-size: 16px;
}

.emoji-pick {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 8px;
}

.pick { min-height: 56px; font-size: 30px; }

.cat.selected,
.pick.selected {
  border-color: var(--ink);
  background: var(--yellow);
  box-shadow: 2px 2px 0 var(--ink);
}

.toast {
  position: fixed;
  z-index: 50;
  left: 50%;
  top: calc(14px + env(safe-area-inset-top));
  transform: translateX(-50%);
  max-width: min(92vw, 520px);
  margin: 0;
  padding: 14px 18px;
  border-radius: 16px;
  background: var(--ink);
  color: white;
  font-size: 20px;
  font-weight: 900;
  text-align: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.shake { animation: shake 0.35s linear; }

@keyframes pop {
  50% { transform: scale(1.06); }
}

@keyframes shake {
  25% { transform: translateX(-8px); }
  50% { transform: translateX(8px); }
  75% { transform: translateX(-4px); }
}

@keyframes fall {
  to { transform: translateY(72vh) rotate(28deg); opacity: 0.15; }
}

@media (max-width: 699px) {
  .workspace { display: block; }
  .catalog {
    height: 100%;
    padding-bottom: calc(108px + env(safe-area-inset-bottom));
  }
  .ticket {
    position: fixed;
    z-index: 8;
    left: 10px;
    right: 10px;
    bottom: calc(8px + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column-reverse;
    max-height: calc(100dvh - 90px);
    background: transparent;
    border: 0;
  }
  .ticket-handle {
    display: flex;
    gap: 8px;
    align-items: center;
  }
  .ticket-body {
    display: none;
    flex: none;
    margin-bottom: 8px;
    background: #fffaf2;
    border: 3px solid var(--ink);
    border-radius: 22px;
    box-shadow: 4px 4px 0 var(--ink);
    max-height: 58dvh;
  }
  .ticket.open .ticket-body { display: flex; }
  .ticket.open .lines { max-height: 34dvh; }
  .expand {
    flex: 1;
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 14px;
    border: 3px solid var(--ink);
    border-radius: 18px;
    background: var(--yellow);
    font-size: 20px;
    font-weight: 900;
    box-shadow: 3px 3px 0 var(--ink);
  }
  .quick-pay {
    width: 84px;
    height: 72px;
    border: 3px solid var(--ink);
    border-radius: 18px;
    background: var(--pink);
    font-size: 32px;
    box-shadow: 3px 3px 0 var(--ink);
  }
}

@media (max-height: 820px) {
  .money-btn.coin { width: min(112px, 100%); }
  .money-btn.note { min-height: 58px; }
  .money-btn .face,
  .money-face .face { font-size: 24px; }
  .display strong { font-size: 40px; }
  .pay-screen,
  .result-screen { gap: 8px; }
  .key { min-height: 62px; }
  .product { min-height: 148px; }
  .product .emoji { font-size: 48px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
