:root {
  color-scheme: dark;
  --bg: #101114;
  --panel: #191b20;
  --panel-2: #22252b;
  --text: #f6f6f4;
  --muted: #a8abb3;
  --accent: #f3d24b;
  --accent-dark: #18160a;
  --success: #63d991;
  --danger: #ff6b6b;
  --line: rgba(255,255,255,.09);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body {
  min-height: 100svh;
  background:
    radial-gradient(circle at 80% -10%, rgba(243,210,75,.14), transparent 32%),
    var(--bg);
}
button { font: inherit; }

.app-shell {
  width: min(100%, 480px);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(22px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.eyebrow { margin: 0 0 4px; color: var(--accent); font-size: .72rem; font-weight: 900; letter-spacing: .19em; }
h1 { margin: 0; font-size: 1.35rem; line-height: 1.1; letter-spacing: -.02em; }
.status-dot { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: .72rem; }
.status-dot span { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px rgba(99,217,145,.12); }
.status-dot.offline span { background: var(--danger); box-shadow: 0 0 0 4px rgba(255,107,107,.12); }

.counter-card {
  margin-top: 22px;
  padding: 15px 18px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(255,255,255,.045);
  border: 1px solid var(--line);
  border-radius: 18px;
  backdrop-filter: blur(14px);
}
.counter-card div { flex: 1; display: flex; flex-direction: column; align-items: center; }
.counter-card strong { font-size: 1.35rem; line-height: 1; }
.counter-card span { margin-top: 5px; color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; }
.counter-card i { width: 1px; height: 28px; background: var(--line); }

.state { display: none; flex: 1; flex-direction: column; align-items: center; justify-content: center; text-align: center; animation: enter .25s ease both; }
.state.active { display: flex; }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

#home-state { padding: 42px 8px 8px; }
.scan-symbol { position: relative; width: 142px; height: 142px; display: grid; place-items: center; margin-bottom: 28px; }
.scan-symbol::before { content: ""; position: absolute; inset: 13px; border-radius: 29px; background: linear-gradient(145deg, rgba(243,210,75,.18), rgba(243,210,75,.03)); }
.scan-symbol span { position: absolute; width: 32px; height: 32px; border-color: var(--accent); border-style: solid; }
.scan-symbol span:nth-child(1) { top: 0; left: 0; border-width: 4px 0 0 4px; border-radius: 12px 0 0; }
.scan-symbol span:nth-child(2) { top: 0; right: 0; border-width: 4px 4px 0 0; border-radius: 0 12px 0 0; }
.scan-symbol span:nth-child(3) { bottom: 0; left: 0; border-width: 0 0 4px 4px; border-radius: 0 0 0 12px; }
.scan-symbol span:nth-child(4) { bottom: 0; right: 0; border-width: 0 4px 4px 0; border-radius: 0 0 12px; }
.scan-symbol svg { width: 62px; fill: var(--accent); }
.state h2 { margin: 0; font-size: 1.7rem; letter-spacing: -.04em; }
.state > p { max-width: 310px; margin: 12px 0 26px; color: var(--muted); line-height: 1.5; }

.primary-button, .secondary-button {
  width: 100%; min-height: 58px; border: 0; border-radius: 17px; font-weight: 850; cursor: pointer; transition: transform .1s ease, opacity .15s ease;
}
.primary-button { display: flex; justify-content: center; align-items: center; gap: 11px; background: var(--accent); color: var(--accent-dark); box-shadow: 0 11px 30px rgba(243,210,75,.17); }
.primary-button svg { width: 23px; fill: currentColor; }
.primary-button:active, .secondary-button:active { transform: scale(.98); }
.primary-button:disabled { opacity: .55; cursor: wait; }
.secondary-button { margin-top: 10px; background: transparent; color: var(--muted); border: 1px solid var(--line); }

#camera-state { justify-content: flex-start; padding-top: 24px; }
.camera-header { width: 100%; display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; color: var(--muted); font-size: .85rem; }
.live-dot { display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: #ff4949; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.icon-button { width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-size: 1.8rem; line-height: 1; }
#reader { width: 100%; overflow: hidden; min-height: 330px; border-radius: 24px; background: #050506; border: 1px solid var(--line); }
#reader video { object-fit: cover !important; border-radius: 24px; }
#reader img[alt="Info icon"] { display: none; }
#reader__scan_region { min-height: 310px; }
#reader__dashboard { display: none; }
.camera-hint { margin-top: 18px !important; font-size: .86rem; }

.guest-card, .success-card, .error-card { padding-top: 32px; }
.guest-badge { padding: 8px 12px; border-radius: 999px; background: rgba(99,217,145,.12); color: var(--success); font-size: .74rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.guest-badge.warning { color: var(--danger); background: rgba(255,107,107,.12); }
.avatar { width: 82px; height: 82px; display: grid; place-items: center; margin: 26px 0 18px; border-radius: 50%; background: var(--panel-2); border: 1px solid var(--line); color: var(--accent); font-size: 1.4rem; font-weight: 900; }
.guest-company { min-height: 1.4em; margin: 7px 0 0 !important; }
.guest-meta { width: 100%; margin: 24px 0 10px; padding: 15px; background: var(--panel); border-radius: 14px; color: var(--muted); font-size: .9rem; }
.guest-message { min-height: 1.4em; margin: 4px 0 20px; color: var(--danger); font-size: .86rem; }
.confirm { margin-top: auto; }

.success-check { width: 104px; height: 104px; display: grid; place-items: center; margin-bottom: 28px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 16px rgba(99,217,145,.09), 0 0 0 32px rgba(99,217,145,.04); }
.success-check svg { width: 54px; fill: #092114; }
.success-card .primary-button, .error-card .primary-button { margin-top: auto; }
.error-icon { width: 88px; height: 88px; display: grid; place-items: center; margin-bottom: 24px; border-radius: 50%; background: rgba(255,107,107,.13); color: var(--danger); font-size: 2.8rem; font-weight: 900; }

.confetti { position: fixed; inset: 0; z-index: 50; pointer-events: none; overflow: hidden; }
.confetti-piece { position: absolute; top: -18px; width: 9px; height: 15px; border-radius: 2px; animation: confetti-fall var(--duration) cubic-bezier(.2,.7,.35,1) forwards; }
@keyframes confetti-fall { to { transform: translate3d(var(--drift), 110vh, 0) rotate(var(--spin)); opacity: .85; } }

@media (min-width: 560px) {
  body { padding: 22px; }
  .app-shell { min-height: calc(100svh - 44px); border: 1px solid var(--line); border-radius: 32px; background: rgba(16,17,20,.86); box-shadow: 0 30px 80px rgba(0,0,0,.35); }
}

@media (max-height: 700px) {
  .app-shell { padding-top: 16px; }
  .counter-card { margin-top: 14px; padding: 11px; }
  #home-state { padding-top: 24px; }
  .scan-symbol { width: 112px; height: 112px; margin-bottom: 18px; }
  .scan-symbol svg { width: 48px; }
}
