:root {
  --bg:   #14171c;
  --card: #1c2027;
  --line: #2b313a;
  --ink:  #e8eaed;
  --dim:  #838b96;
  --acc:  #f0a733;
  --ok:   #46c17f;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, sans-serif;

  /* Verhindert Pull-to-Refresh. Ein Nutzer, der das Handy zum Scannen
     hochhaelt, loest das sonst versehentlich aus - und laedt neu. */
  overscroll-behavior-y: contain;
}

main {
  max-width: 480px;
  margin: 0 auto;
  padding: 32px 20px calc(32px + env(safe-area-inset-bottom));
}

header { margin-bottom: 28px; }

h1 {
  margin: 0 0 2px;
  font-size: 21px;
  letter-spacing: -0.01em;
}

#status {
  margin: 0;
  font: 500 13px/1 ui-monospace, SFMono-Regular, monospace;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--acc);
}

ul { list-style: none; margin: 0 0 28px; padding: 0; }

li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
  color: var(--dim);
}

li::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line);
  flex: none;
}

li .id {
  margin-left: auto;
  font: 12px/1 ui-monospace, monospace;
  opacity: 0.55;
}

li[data-got="1"] { color: var(--ink); }
li[data-got="1"]::before { background: var(--ok); }

#cam[hidden], #actions[hidden] { display: none; }

#cam {
  margin-bottom: 20px;
}

.frame {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #000;
}

/* Halbe Hoehe: 3/4 (h = 1.33 * b) -> 3/2 (h = 0.67 * b).
   Der Decoder scannt jetzt exakt diesen Ausschnitt, nicht mehr das volle
   Sensorbild - sonst wuerden Codes ausserhalb des sichtbaren Bereichs
   erkannt und ihr Rahmen laege neben der Anzeige. */
video, #overlay {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
}

video { object-fit: cover; }

/* Deckungsgleich ueber dem Video. pointer-events: none, sonst schluckt
   das Canvas die Taps auf die Buttons darunter. */
#overlay {
  position: absolute;
  inset: 0;
  height: 100%;
  pointer-events: none;
}

/* Zielfenster. Reine Optik - der Decoder prueft das ganze Bild. */
.reticle {
  position: absolute;
  inset: 8% 22%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 10px;
  pointer-events: none;
}

#actions { display: grid; gap: 10px; }

button {
  width: 100%;
  padding: 15px;
  font: 600 15px/1 inherit;
  color: var(--bg);
  background: var(--acc);
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button.ghost {
  margin-top: 10px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
}

button[hidden] { display: none; }

#hint {
  margin: 16px 0 0;
  min-height: 1.5em;
  font-size: 13px;
  color: var(--dim);
}


/* ---------------------------------------------------------------
   Bestaetigung nach erkanntem Code
   --------------------------------------------------------------- */
#cam-actions { display: grid; gap: 10px; }

/* Eingefroren: Zielfenster weg, Bild leicht abgedunkelt - der gruene
   Rahmen um den erkannten Code bleibt stehen. */
#cam.frozen .reticle { display: none; }
#cam.frozen video    { filter: brightness(0.55); }
#cam.frozen #cam-actions { display: none; }

#result {
  margin-top: 14px;
  padding: 16px;
  display: grid;
  gap: 4px;
  background: var(--card);
  border: 1px solid var(--ok);
  border-radius: 12px;
}

#result[hidden] { display: none; }

#result strong {
  font-size: 16px;
  color: var(--ok);
}

#result span {
  font-size: 13px;
  color: var(--dim);
  margin-bottom: 8px;
}
