@font-face {
  font-family: "Figtree";
  src: url("figtree-latin-wght-normal.woff2") format("woff2");
  font-weight: 300 900;
  font-display: swap;
}

:root {
  --night: #081633;
  --deep: #0e2654;
  --gold: #f2c14e;
  --ink: #eef2ff;
  --muted: #b5c1e3;
  --ok: #128a3e;
  --warn: #d26a00;
  --bad: #c4162a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--night);
  color: var(--ink);
  font-family: "Figtree", system-ui, sans-serif;
  font-size: 17px;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.btn {
  font: inherit; font-weight: 700;
  min-height: 48px; padding: 0 1.1rem;
  border-radius: 12px; border: 2px solid rgba(238,242,255,.35);
  background: var(--deep); color: var(--ink);
}
.btn--primary { background: var(--gold); color: var(--night); border-color: var(--gold); width: 100%; }
.btn--ghost { background: transparent; min-height: 40px; }
.error { color: #ff9aa5; min-height: 1.4em; margin: .8rem 0 0; }

/* Anmeldung */
#login {
  min-height: 100%;
  display: flex; flex-direction: column; justify-content: center;
  padding: max(2rem, env(safe-area-inset-top)) 1.25rem 2rem;
  max-width: 26rem; margin: 0 auto;
}
.login__logo { width: 9.5rem; height: auto; }
#login h1 { margin: 1.4rem 0 .2rem; font-size: 1.8rem; }
.login__sub { color: var(--muted); margin: 0 0 1.8rem; }
#login label { display: block; font-weight: 700; margin: 1rem 0 .4rem; }
.opt { font-weight: 400; color: var(--muted); }
#login input {
  width: 100%; font: inherit; font-size: 1.2rem;
  padding: .8rem .9rem; border-radius: 12px;
  border: 2px solid rgba(238,242,255,.3); background: var(--deep); color: var(--ink);
}
#pin { letter-spacing: .3em; }
#login .btn--primary { margin-top: 1.6rem; }

/* Scanner */
#scanner { height: 100%; display: flex; flex-direction: column; }
.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: calc(.7rem + env(safe-area-inset-top)) 1rem .7rem;
  background: var(--deep);
}
.count { line-height: 1.3; }
.count strong { font-size: 1.4rem; color: var(--gold); }
.count__detail { display: block; font-size: .85rem; color: var(--muted); }
.icon-btn { background: none; border: 0; width: 48px; height: 48px; color: var(--ink); }
.icon-btn svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }

.menu {
  position: absolute; z-index: 5; right: .75rem; top: calc(4.2rem + env(safe-area-inset-top));
  background: var(--deep); border: 1px solid rgba(238,242,255,.2); border-radius: 14px;
  padding: .5rem; min-width: 16rem; box-shadow: 0 16px 40px rgba(0,0,0,.5);
}
.menu__device { margin: .5rem .75rem .75rem; color: var(--muted); font-size: .9rem; }
.menu__item {
  display: block; width: 100%; text-align: left;
  font: inherit; color: var(--ink); text-decoration: none;
  background: none; border: 0; border-radius: 10px; padding: .85rem .75rem;
}
.menu__item:active { background: rgba(238,242,255,.08); }

.view { position: relative; flex: 1; min-height: 0; background: #000; overflow: hidden; }
#video { width: 100%; height: 100%; object-fit: cover; display: block; }
.frame {
  position: absolute; left: 50%; top: 50%;
  width: min(68vw, 46vh); aspect-ratio: 1; transform: translate(-50%, -50%);
  border-radius: 18px;
  box-shadow: 0 0 0 100vmax rgba(8,22,51,.45);
  outline: 3px solid var(--gold);
}
.cam-msg {
  position: absolute; inset: 0; display: grid; place-content: center; gap: 1rem;
  padding: 2rem; text-align: center; background: var(--night);
}

.dock { padding: .75rem 1rem calc(.75rem + env(safe-area-inset-bottom)); background: var(--deep); }
.manual { display: flex; gap: .5rem; }
.manual input {
  flex: 1; min-width: 0; font: inherit; padding: 0 .9rem; min-height: 48px;
  border-radius: 12px; border: 2px solid rgba(238,242,255,.3); background: var(--night); color: var(--ink);
  text-transform: uppercase;
}
.manual input::placeholder { text-transform: none; }
.last {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  margin-top: .65rem; font-size: .92rem; color: var(--muted);
}
.last.confirm .btn--ghost { background: var(--bad); border-color: var(--bad); color: #fff; }

/* Ergebnis (vollflächig, auf Distanz lesbar) */
.result {
  position: fixed; inset: 0; z-index: 10;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 2rem 1.5rem; text-align: center; color: #fff;
}
.result.ok { background: var(--ok); }
.result.verwendet { background: var(--warn); }
.result.ungueltig { background: var(--bad); }
.result h2 { font-size: clamp(2.4rem, 11vw, 4rem); line-height: 1.05; margin: 1rem 0 .6rem; }
.result__ticket { font-size: clamp(1.4rem, 6vw, 2rem); font-weight: 800; margin: 0; }
.result__detail { font-size: 1.15rem; margin: .6rem 0 0; max-width: 22rem; }
.result__hint { position: absolute; bottom: calc(1.5rem + env(safe-area-inset-bottom)); margin: 0; opacity: .8; font-size: .95rem; }
.result__icon { width: 6.5rem; height: 6.5rem; border-radius: 50%; border: 6px solid #fff; position: relative; }
.result.ok .result__icon::after {
  content: ""; position: absolute; left: 30%; top: 16%; width: 30%; height: 52%;
  border: solid #fff; border-width: 0 8px 8px 0; transform: rotate(45deg);
}
.result.verwendet .result__icon::after, .result.ungueltig .result__icon::after {
  content: "!"; position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 4rem; font-weight: 900;
}
.result.ungueltig .result__icon::after { content: "✕"; font-size: 3.4rem; }
