:root {
  --bg: #1b1d22;
  --wall-1: #2a2d34;
  --wall-2: #17181c;
  --text: #f2efe8;
  --muted: #a3a6ae;
  --line: rgba(255, 255, 255, 0.09);
  --red: #d01f24;
  --red-dark: #8f0d12;
  --red-light: #f0504a;
  --paper: #f6f1e4;
  --paper-shade: #e4dcc8;
  --ink: #23201b;
  --ink-red: #c4161c;
  --accent: #ffb547;
  --ok: #3ccf7f;
  --led: #ff3b2e;
  --panel: rgba(28, 30, 36, 0.78);
  --radius: 18px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* ---------- Raum ---------- */
.room {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(ellipse 60% 55% at 38% 42%, rgba(255, 214, 160, 0.13), transparent 70%),
    linear-gradient(180deg, transparent 72%, rgba(0, 0, 0, 0.45) 72.2%, rgba(0, 0, 0, 0.25) 100%),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.018) 0 1px, transparent 1px 120px),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.018) 0 1px, transparent 1px 120px),
    linear-gradient(180deg, var(--wall-1), var(--wall-2));
}
.room::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(0,0,0,0.55) 100%);
}

/* ---------- Kopfzeile ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: 0.02em; }
.brand-mark {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(160deg, var(--red-light), var(--red-dark)); font-size: 15px;
  box-shadow: 0 4px 12px rgba(208, 31, 36, 0.35);
}
.clock { font-family: "Share Tech Mono", monospace; color: var(--muted); font-size: 18px; letter-spacing: 0.08em; }
.admin-btn {
  width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(255,255,255,0.04); color: var(--muted);
  display: grid; place-items: center; transition: all .2s;
}
.admin-btn:hover { color: var(--text); background: rgba(255,255,255,0.09); transform: rotate(-12deg); }

/* ---------- Bühne ---------- */
.stage {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 90px 32px 40px; gap: 34px;
}
.scene { display: flex; align-items: flex-start; gap: 80px; }

/* ---------- LED-Anzeige ---------- */
.board {
  display: flex; align-items: center; gap: 22px;
  padding: 12px 22px; border-radius: 14px;
  background: linear-gradient(180deg, #121316, #0b0b0d);
  border: 1px solid #2c2e34;
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.8), 0 12px 30px rgba(0,0,0,0.45), 0 1px 0 rgba(255,255,255,0.06);
}
.board-label, .board-meta { font-size: 12px; text-transform: uppercase; letter-spacing: 0.16em; color: var(--muted); }
.board-meta span { color: var(--text); font-weight: 700; }
.led {
  position: relative; font-family: "Share Tech Mono", monospace; font-size: 54px; line-height: 1;
  padding: 6px 14px; background: #120404; border-radius: 6px;
  box-shadow: inset 0 0 18px rgba(0,0,0,0.9);
}
.led-ghost { color: rgba(255, 59, 46, 0.07); }
.led-value {
  position: absolute; inset: 6px 14px; color: var(--led);
  text-shadow: 0 0 6px rgba(255, 59, 46, 0.85), 0 0 18px rgba(255, 59, 46, 0.45);
  text-align: right;
}
.led.flash .led-value { animation: ledFlash .9s steps(2) 2; }
@keyframes ledFlash { 50% { opacity: .15; } }

/* ---------- Spender ---------- */
.dispenser-wrap { position: relative; width: 300px; height: 620px; }
.wall-plate {
  position: absolute; left: 50%; top: 18px; transform: translateX(-50%);
  width: 120px; height: 250px; border-radius: 10px;
  background: linear-gradient(90deg, #8e939b, #d8dce1 30%, #f4f6f8 48%, #a6abb3 70%, #7c8188);
  box-shadow: 0 10px 25px rgba(0,0,0,0.5), inset 0 0 0 1px rgba(0,0,0,0.25);
}
.screw {
  position: absolute; left: 50%; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff, #8a8f96 60%, #5b5f66);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.3);
}
.screw::after { content: ""; position: absolute; inset: 6px 2px; background: rgba(0,0,0,0.45); border-radius: 1px; }
.screw:first-child { top: 14px; }
.screw:last-child { bottom: 14px; }

.dispenser { position: absolute; inset: 0; }
.housing {
  position: absolute; left: 20px; right: 20px; top: 50px; height: 290px; z-index: 3;
  border-radius: 46px 46px 60px 60px / 40px 40px 80px 80px;
  background:
    radial-gradient(ellipse 70% 45% at 50% 8%, rgba(255,255,255,0.35), transparent 70%),
    linear-gradient(90deg, #7d0a0e 0%, #c3161c 14%, #e42a2f 40%, #ef3c40 52%, #c8171d 78%, #6e080b 100%);
  box-shadow:
    0 30px 50px rgba(0,0,0,0.55),
    0 8px 14px rgba(0,0,0,0.35),
    inset 0 -18px 30px rgba(60, 0, 0, 0.55),
    inset 0 3px 2px rgba(255,255,255,0.25);
  transition: transform .12s;
}
.housing-shine {
  position: absolute; left: 22%; top: 14px; width: 22%; height: 70%;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,0.45), rgba(255,255,255,0) 80%);
  filter: blur(4px); transform: skewX(-6deg);
}
.label-plate {
  position: absolute; left: 50%; top: 62px; transform: translateX(-50%);
  width: 150px; padding: 16px 10px 14px; border-radius: 12px; text-align: center;
  background: linear-gradient(180deg, #fbfaf7, #e9e6df);
  color: var(--ink-red);
  box-shadow: inset 0 -2px 0 rgba(0,0,0,0.12), 0 2px 4px rgba(0,0,0,0.35);
}
.label-arrow { font-size: 14px; opacity: .8; margin-bottom: 4px; }
.label-text { font-weight: 800; font-size: 19px; line-height: 1.12; text-transform: uppercase; letter-spacing: 0.04em; }
.slot-lip {
  position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%);
  width: 178px; height: 18px; border-radius: 9px;
  background: linear-gradient(180deg, #050505, #1d1d1d 60%, #3a0a0c);
  box-shadow: inset 0 4px 6px rgba(0,0,0,0.9), 0 1px 0 rgba(255,255,255,0.25);
}

/* Papier: der Clip beginnt im Schlitz */
.paper-clip {
  position: absolute; left: 50%; top: 311px; transform: translateX(-50%);
  width: 170px; height: 300px; overflow: hidden; z-index: 4;
  padding: 0 4px;
}
.paper-clip::before { /* Schatten des Schlitzes auf dem Papier */
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 16px; z-index: 2;
  background: linear-gradient(180deg, rgba(0,0,0,0.55), transparent); pointer-events: none;
}
.paper {
  --pull: 0px;
  position: relative; width: 158px; height: 300px; margin: 0 auto;
  transform: translateY(calc(-246px + var(--pull)));
  background:
    linear-gradient(90deg, rgba(0,0,0,0.06), transparent 8%, transparent 92%, rgba(0,0,0,0.07)),
    var(--paper);
  color: var(--ink);
  box-shadow: 0 6px 14px rgba(0,0,0,0.4);
  cursor: grab; user-select: none; touch-action: none;
  border-radius: 0 0 3px 3px;
}
.paper.springing { transition: transform .5s cubic-bezier(.2, 1.6, .4, 1); }
.paper.feeding { transition: transform .45s cubic-bezier(.3, .8, .3, 1); }
.paper.dragging { cursor: grabbing; }
.paper.locked { cursor: not-allowed; }
.paper-inner {
  position: absolute; left: 0; right: 0; bottom: 54px; height: 230px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  padding: 18px 10px 12px; text-align: center;
}
.tk-head { font-size: 11px; font-weight: 800; letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink-red); }
.tk-sub { font-size: 10px; color: #6b655a; letter-spacing: .06em; }
.tk-number {
  font-weight: 800; font-size: 64px; line-height: 1; letter-spacing: -0.02em; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.tk-foot { font-size: 10px; color: #6b655a; font-family: "Share Tech Mono", monospace; }
.tk-perf {
  position: absolute; left: 6px; right: 6px; top: 6px; height: 0;
  border-top: 2px dotted rgba(0,0,0,0.18);
}
.pull-hint {
  position: absolute; left: 0; right: 0; bottom: 0; height: 54px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: #8a8273;
  border-top: 2px dotted rgba(0,0,0,0.15);
}
.pull-hint svg { animation: nudge 1.4s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateY(4px); } }
.paper.idle-wiggle { animation: wiggle 2.8s ease-in-out infinite; }
@keyframes wiggle {
  0%, 82%, 100% { transform: translateY(-246px); }
  88% { transform: translateY(-238px); }
  94% { transform: translateY(-244px); }
}
.dispenser.shake .housing, .dispenser.shake .paper-clip { animation: shake .4s; }
@keyframes shake {
  20% { translate: -6px 0; } 40% { translate: 6px 0; } 60% { translate: -4px 0; } 80% { translate: 3px 0; }
}

/* Abgerissene, fliegende Marke */
.flying {
  position: fixed; z-index: 60; pointer-events: none; overflow: hidden;
  background:
    linear-gradient(90deg, rgba(0,0,0,0.06), transparent 8%, transparent 92%, rgba(0,0,0,0.07)),
    var(--paper);
  color: var(--ink);
  box-shadow: 0 18px 40px rgba(0,0,0,0.5);
  border-radius: 0 0 3px 3px;
  transform-origin: 50% 0;
}
.flying .paper-inner { bottom: 54px; }

/* ---------- Seitenpanel ---------- */
.panel {
  width: 380px; margin-top: 50px; padding: 30px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  backdrop-filter: blur(14px);
  box-shadow: 0 30px 60px rgba(0,0,0,0.4);
}
.panel h1 { margin: 0 0 8px; font-size: 26px; letter-spacing: -0.01em; }
.lede { margin: 0 0 22px; color: var(--muted); line-height: 1.5; font-size: 15px; }
.field { display: grid; gap: 8px; font-size: 13px; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
input[type="text"], input[type="password"] {
  width: 100%; padding: 14px 16px; border-radius: 12px; font: inherit; font-size: 17px; color: var(--text);
  background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.12); outline: none; transition: border .2s, box-shadow .2s;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(255, 181, 71, 0.15); }
input.invalid { border-color: var(--red-light); box-shadow: 0 0 0 4px rgba(240, 80, 74, 0.18); }
.hint { min-height: 22px; margin-top: 8px; font-size: 13px; color: var(--red-light); }
.btn-ghost {
  border: 1px solid var(--line); background: rgba(255,255,255,0.04); color: var(--muted);
  padding: 10px 16px; border-radius: 10px; transition: all .2s;
}
.btn-ghost:hover { color: var(--text); background: rgba(255,255,255,0.09); }
.btn-primary {
  border: 0; color: #fff; font-weight: 700; padding: 11px 20px; border-radius: 10px;
  background: linear-gradient(180deg, var(--red-light), var(--red));
  box-shadow: 0 6px 18px rgba(208, 31, 36, 0.35), inset 0 1px 0 rgba(255,255,255,0.25);
  transition: transform .15s, filter .15s;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { filter: grayscale(.7) brightness(.7); cursor: default; }

/* Meine Marke */
.status-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px;
  font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  background: rgba(255, 181, 71, 0.12); color: var(--accent);
}
.status-chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: pulse 1.6s infinite; }
.status-chip.next { background: rgba(60, 207, 127, 0.15); color: var(--ok); }
.status-chip.done { background: rgba(255,255,255,0.08); color: var(--muted); }
.status-chip.done::before { animation: none; }
@keyframes pulse { 50% { opacity: .3; } }

.my-ticket {
  position: relative; margin: 18px 0 22px; padding: 18px 20px 22px; border-radius: 6px;
  background: var(--paper); color: var(--ink);
  box-shadow: 0 14px 30px rgba(0,0,0,0.35);
  transform: rotate(-1.2deg);
}
.my-ticket::before { /* Abrisskante oben */
  content: ""; position: absolute; left: 0; right: 0; top: -6px; height: 8px;
  background: linear-gradient(-45deg, var(--paper) 4px, transparent 0) 0 0 / 10px 8px,
              linear-gradient(45deg, var(--paper) 4px, transparent 0) 0 0 / 10px 8px;
}
.my-ticket-top { display: flex; justify-content: space-between; font-size: 11px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; color: var(--ink-red); }
.my-ticket-top span:last-child { font-family: "Share Tech Mono", monospace; color: #6b655a; letter-spacing: .05em; }
.my-number { font-size: 84px; font-weight: 800; line-height: 1; letter-spacing: -0.03em; margin-top: 8px; font-variant-numeric: tabular-nums; }
.my-name { font-size: 16px; font-weight: 600; color: #4b463d; margin-top: 4px; }
.status-msg { font-size: 26px; font-weight: 800; letter-spacing: -0.01em; line-height: 1.2; }
.status-msg.next { color: var(--ok); text-shadow: 0 0 22px rgba(60, 207, 127, 0.35); animation: pop .6s cubic-bezier(.2, 1.6, .4, 1); }
.status-msg.bump { animation: pop .5s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pop { 0% { transform: scale(.85); opacity: .2; } 100% { transform: scale(1); opacity: 1; } }
.status-sub { margin: 8px 0 18px; color: var(--muted); font-size: 14px; line-height: 1.5; }

/* ---------- Enthüllung ---------- */
.reveal {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: rgba(8, 8, 10, 0.6); backdrop-filter: blur(6px);
  animation: fadeIn .3s;
}
@keyframes fadeIn { from { opacity: 0; } }
.reveal-card {
  position: relative; width: 340px; padding: 30px 28px 26px; text-align: center; border-radius: 4px;
  background: var(--paper); color: var(--ink);
  box-shadow: 0 40px 80px rgba(0,0,0,0.6);
}
.reveal-card::before {
  content: ""; position: absolute; left: 0; right: 0; top: -7px; height: 8px;
  background: linear-gradient(-45deg, var(--paper) 4px, transparent 0) 0 0 / 10px 8px,
              linear-gradient(45deg, var(--paper) 4px, transparent 0) 0 0 / 10px 8px;
}
.reveal-number { font-size: 130px; font-weight: 800; letter-spacing: -0.04em; line-height: 1; margin: 10px 0 4px; font-variant-numeric: tabular-nums; }
.reveal-name { font-weight: 600; color: #4b463d; font-size: 18px; }
.reveal-msg {
  margin: 22px 0 22px; padding: 14px; border-radius: 10px;
  background: #1f1d1a; color: #fff; font-size: 24px; font-weight: 800;
}
.reveal-msg.next { background: #17663d; }
.reveal-card .btn-primary { width: 100%; padding: 14px; font-size: 16px; }

/* ---------- Modal / Login ---------- */
.modal {
  position: fixed; inset: 0; z-index: 70; display: grid; place-items: center;
  background: rgba(8, 8, 10, 0.65); backdrop-filter: blur(8px); animation: fadeIn .2s;
}
.modal-card {
  width: 380px; padding: 30px; border-radius: var(--radius); text-align: center;
  background: #22242a; border: 1px solid var(--line); box-shadow: 0 30px 70px rgba(0,0,0,0.6);
  animation: rise .3s cubic-bezier(.2, 1.2, .4, 1);
}
@keyframes rise { from { transform: translateY(16px) scale(.97); opacity: 0; } }
.modal-card h2 { margin: 12px 0 6px; }
.modal-card p { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
.modal-icon {
  width: 56px; height: 56px; margin: 0 auto; border-radius: 16px; display: grid; place-items: center;
  background: rgba(255, 181, 71, 0.12); color: var(--accent);
}
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }
.modal-card.wrong { animation: shake .4s; }

/* ---------- Admin ---------- */
.admin {
  position: fixed; inset: 0; z-index: 65; display: grid; place-items: center; padding: 40px;
  background: rgba(8, 8, 10, 0.7); backdrop-filter: blur(8px); animation: fadeIn .2s;
}
.admin-card {
  width: min(920px, 100%); max-height: calc(100vh - 80px); display: flex; flex-direction: column;
  background: #1f2126; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 40px 90px rgba(0,0,0,0.6); overflow: hidden; animation: rise .3s cubic-bezier(.2, 1.2, .4, 1);
}
.admin-head {
  display: flex; align-items: center; gap: 28px; padding: 22px 26px;
  border-bottom: 1px solid var(--line); background: rgba(255,255,255,0.02);
}
.admin-head > div:first-child { min-width: 0; }
.admin-head h2 { margin: 0; font-size: 22px; }
.admin-actions button { white-space: nowrap; }
.admin-date { color: var(--muted); font-size: 13px; margin-top: 2px; white-space: nowrap; }
.admin-date::after { content: "Nummern werden um Mitternacht zurückgesetzt"; display: block; font-size: 11px; opacity: .7; }
.admin-stats { display: flex; gap: 22px; margin-left: auto; }
.admin-stats div { display: grid; text-align: center; }
.admin-stats b { font-size: 22px; font-variant-numeric: tabular-nums; }
.admin-stats span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; }
.admin-actions { display: flex; gap: 8px; align-items: center; }
.icon-btn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--muted); }
.icon-btn:hover { color: var(--text); background: rgba(255,255,255,0.07); }

.admin-list { overflow-y: auto; padding: 10px 14px 18px; }
.admin-empty { padding: 60px 20px; text-align: center; color: var(--muted); }
.row {
  display: grid; grid-template-columns: 44px 84px 1fr 120px 190px; align-items: center; gap: 14px;
  padding: 12px 14px; border-radius: 12px; transition: background .2s, opacity .3s;
}
.row + .row { margin-top: 4px; }
.row:hover { background: rgba(255,255,255,0.035); }
.row.current { background: rgba(60, 207, 127, 0.09); box-shadow: inset 3px 0 0 var(--ok); }
.row.done { opacity: .45; }
.row.done .row-name { text-decoration: line-through; }
.row-num {
  font-family: "Share Tech Mono", monospace; font-size: 22px; padding: 4px 10px; border-radius: 6px; text-align: center;
  background: var(--paper); color: var(--ink);
}
.row-name { font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-time { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.row-state { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); text-align: right; }
.row.current .row-state { color: var(--ok); }

/* Abhak-Checkbox */
.check { position: relative; width: 28px; height: 28px; }
.check input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.check span {
  position: absolute; inset: 0; border-radius: 8px; border: 2px solid rgba(255,255,255,0.25);
  display: grid; place-items: center; transition: all .2s; pointer-events: none;
}
.check span::after {
  content: ""; width: 10px; height: 5px; border-left: 3px solid #0b2a19; border-bottom: 3px solid #0b2a19;
  transform: rotate(-45deg) scale(0); margin-top: -3px; transition: transform .2s cubic-bezier(.2, 1.6, .4, 1);
}
.check input:checked + span { background: var(--ok); border-color: var(--ok); }
.check input:checked + span::after { transform: rotate(-45deg) scale(1); }
.check input:focus-visible + span { box-shadow: 0 0 0 4px rgba(60, 207, 127, 0.3); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 90; transform: translate(-50%, 30px); opacity: 0;
  padding: 12px 20px; border-radius: 12px; background: #2b2e35; border: 1px solid var(--line);
  box-shadow: 0 16px 40px rgba(0,0,0,0.5); transition: all .3s; pointer-events: none; font-weight: 600;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 860px) {
  .scene { flex-direction: column; align-items: center; gap: 10px; }
  .panel { width: min(380px, 100%); margin-top: 0; }
  .row { grid-template-columns: 40px 70px 1fr 90px; }
  .row-time { display: none; }
  .admin-head { flex-wrap: wrap; }
}

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