:root {
  --bg: #0f1420;
  --panel: #171d2b;
  --panel-2: #1e2536;
  --border: #2a3348;
  --text: #e7ecf5;
  --muted: #8b96ab;
  --accent: #4f8cff;
  --accent-2: #2fbf85;
  --danger: #ff5d5d;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden; /* kiosk: no accidental scrolling of the whole page */
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

/* This layout assumes the viewport itself is already portrait (tall) —
   either a naturally portrait tablet, or a desktop monitor whose display
   orientation was rotated in Windows settings, NOT via CSS. */
#app {
  width: 100vw;
  height: 100dvh;
  position: relative;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 32px 24px;
  overflow-y: auto;
  background: var(--bg);
  opacity: 0;
  transform: translateY(10px) scale(0.99);
  pointer-events: none;
  z-index: 1;
  transition: opacity 0.32s ease, transform 0.32s ease;
}
.screen.active {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  z-index: 2;
}

.welcome-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
}

h1 { font-size: 42px; margin: 0; }
h2 { font-size: 22px; margin: 0; }
.subtitle { font-size: 18px; color: var(--muted); margin: 0; }
.subtitle.small { font-size: 14px; }

.lang-row {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.lang-btn {
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--muted);
  font-size: 16px;
  transition: color 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}
.lang-btn.active { color: var(--accent); border-color: var(--accent); }
.lang-btn[disabled] { opacity: .4; }
.lang-btn:active:not([disabled]) { transform: scale(0.95); }

.btn-huge {
  margin-top: 24px;
  padding: 28px 48px;
  font-size: 26px;
  font-weight: 700;
  border-radius: 18px;
  border: none;
  background: var(--accent);
  color: white;
  min-width: 260px;
  transition: transform 0.15s ease;
}
.btn-huge:active { transform: scale(0.97); }

/* Welcome screen: "Scan my pass" (pre-registered guests - the main path)
   above "Register now" (walk-ins), stacked full width for easy tapping. */
.welcome-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 16px;
  margin-top: 24px;
  width: min(520px, 100%);
}
.welcome-actions .btn-huge { margin-top: 0; }
.welcome-actions .btn-huge.btn-huge-secondary {
  background: transparent;
  color: var(--accent);
  border: 2px solid var(--accent);
}
.qr-scan-status.warn { color: #d97706; font-weight: 600; }

.screen-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}
.btn-back {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  transition: transform 0.15s ease;
}
.btn-back:active { transform: scale(0.9); }

.form-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  overflow-y: auto;
  padding-bottom: 20px;
}

.field-group label {
  display: block;
  font-size: 15px;
  color: var(--muted);
  margin-bottom: 8px;
}
.field-group .required-star { color: var(--danger); margin-left: 3px; }

.field-group input,
.field-group select {
  width: 100%;
  padding: 16px 14px;
  font-size: 18px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
}
.field-group input:focus,
.field-group select:focus {
  outline: none;
  border-color: var(--accent);
}
.field-group.invalid input,
.field-group.invalid select {
  border-color: var(--danger);
}
.field-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 6px;
  display: none;
}
.field-group.invalid .field-error { display: block; }

.bottom-bar {
  padding-top: 16px;
}
.btn-primary {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 14px;
  font-size: 20px;
  font-weight: 700;
  padding: 18px;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.btn-primary:active:not(:disabled) { transform: scale(0.97); }
.btn-primary:disabled { opacity: .5; }
.btn-full { width: 100%; }
.btn-secondary {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  font-size: 18px;
  padding: 16px;
  width: 100%;
  margin-bottom: 10px;
  transition: transform 0.15s ease;
}
.btn-secondary:active { transform: scale(0.97); }

.camera-stage {
  flex: 1;
  border-radius: 18px;
  overflow: hidden;
  background: black;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
#camera-video, #camera-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
#camera-video { transform: scaleX(-1); } /* mirror the live preview only — the captured frame is saved unmirrored */
#qr-scan-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* not mirrored — this camera is reading a QR code held up to it, not framing the guest's own face */
}
.qr-scan-status {
  position: absolute;
  bottom: 16px;
  left: 16px;
  right: 16px;
  text-align: center;
  color: #fff;
  background: rgba(15, 20, 32, 0.55);
  border-radius: 10px;
  padding: 10px 14px;
  margin: 0;
}
.hidden { display: none !important; }
.camera-error {
  position: absolute;
  padding: 16px;
  text-align: center;
  color: var(--danger);
}
.camera-controls { display: flex; flex-direction: column; }

.countdown-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(15, 20, 32, 0.35);
  pointer-events: none; /* never blocks a manual capture tap underneath */
}
.countdown-number {
  font-size: 110px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
  line-height: 1;
}
.countdown-number.pulse {
  animation: countdown-pulse 1s ease-out;
}
@keyframes countdown-pulse {
  0%   { transform: scale(1.6); opacity: 0; }
  30%  { transform: scale(1);   opacity: 1; }
  80%  { transform: scale(1);   opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.85; }
}
.countdown-hint {
  color: #fff;
  font-size: 18px;
  margin: 0;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
}

.card-preview-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
#card-preview-img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  animation: card-reveal 0.5s ease-out;
}
@keyframes card-reveal {
  0%   { opacity: 0; transform: scale(0.92) translateY(12px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
.card-preview-controls { display: flex; flex-direction: column; gap: 10px; }
.btn-text {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 15px;
  padding: 10px;
  text-decoration: underline;
  transition: opacity 0.15s ease;
}
.btn-text:active { opacity: 0.6; }

.spinner {
  width: 56px; height: 56px;
  border-radius: 50%;
  border: 5px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.printer-icon {
  font-size: 56px;
  margin-bottom: 4px;
  animation: printer-bob 1.6s ease-in-out infinite;
}
@keyframes printer-bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}
.progress-track {
  width: 100%;
  max-width: 320px;
  height: 14px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-top: 8px;
}
.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.checkmark {
  width: 84px; height: 84px;
  border-radius: 50%;
  background: rgba(47,191,133,.15);
  color: var(--accent-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 44px;
  margin-bottom: 8px;
  animation: checkmark-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes checkmark-pop {
  0%   { transform: scale(0.3); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.checkmark.error {
  background: rgba(255,93,93,.15);
  color: var(--danger);
}

/* ---------- step indicator ---------- */

.step-bar {
  display: none;
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 20;
  align-items: flex-start;
  padding: 16px 20px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.step-bar.visible { display: flex; }

/* Only the currently-active screen needs the extra top clearance, and only
   while the bar is actually showing (welcome/error skip both). */
#app.step-bar-visible .screen.active { padding-top: 104px; }

.step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}
.step-circle {
  position: relative;
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--panel-2);
  color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  font-weight: 700;
  transition: border-color 0.3s, background 0.3s, color 0.3s, box-shadow 0.3s;
}
.step-check { display: none; }
.step-item.completed .step-circle {
  border-color: var(--accent-2);
  background: var(--accent-2);
  color: #fff;
}
.step-item.completed .step-number { display: none; }
.step-item.completed .step-check { display: inline; }
.step-item.active .step-circle {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(79, 140, 255, 0.25);
  animation: step-pulse 1.6s ease-in-out infinite;
}
@keyframes step-pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(79, 140, 255, 0.25); }
  50%      { box-shadow: 0 0 0 8px rgba(79, 140, 255, 0.12); }
}
.step-label {
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  transition: color 0.3s;
}
.step-item.active .step-label { color: var(--text); font-weight: 700; }
.step-item.completed .step-label { color: var(--accent-2); }

.step-connector {
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: var(--border);
  margin: 14px 2px 0;
  overflow: hidden;
}
.step-connector-fill {
  height: 100%;
  width: 0%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transition: width 0.5s ease;
}
