*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100%;
  background: #f7f8fa;
  font-family: 'DM Sans', sans-serif;
  color: #111;
  overflow: hidden;
}

/* ── LOADING ── */
.loading-screen {
  position: fixed; inset: 0; background: #fff;
  display: flex; align-items: center; justify-content: center;
  z-index: 999; flex-direction: column; gap: 14px;
}
.loading-screen.hidden { display: none; }
.spinner {
  width: 36px; height: 36px;
  border: 3px solid #eee; border-top-color: #00c47a;
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-label { font-size: 13px; color: #bbb; font-weight: 500; }

/* ── SCAN IDLE SCREEN ── */
.scan-screen {
  position: fixed; inset: 0;
  background: #fff;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 32px;
  transition: opacity 0.3s;
}
.scan-screen.hidden { display: none; }

.scan-icon-wrap {
  position: relative;
  width: 110px; height: 110px;
  background: #f0fdf8;
  border-radius: 32px;
  border: 2px solid rgba(0,196,122,0.2);
  display: flex; align-items: center; justify-content: center;
}
.scan-icon-wrap svg {
  width: 52px; height: 52px;
  color: #00c47a;
}
.scan-line {
  position: absolute;
  left: 16px; right: 16px;
  height: 2.5px;
  background: linear-gradient(90deg, transparent, #00c47a, transparent);
  border-radius: 2px;
  animation: scanDown 2s ease-in-out infinite;
  top: 20px;
}
@keyframes scanDown {
  0%   { top: 20px; opacity: 0; }
  15%  { opacity: 1; }
  85%  { opacity: 1; }
  100% { top: 88px; opacity: 0; }
}

.scan-heading {
  text-align: center;
  display: flex; flex-direction: column; gap: 8px;
}
.scan-heading h1 {
  font-size: 32px; font-weight: 800;
  color: #111; letter-spacing: -1px;
}
.scan-heading p {
  font-size: 15px; color: #bbb; font-weight: 500;
}

.scan-ready {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 20px;
  background: #f0fdf8;
  border: 1.5px solid rgba(0,196,122,0.3);
  border-radius: 50px;
  font-size: 13px; font-weight: 600;
  color: #00904f;
}
.ready-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #00c47a;
  animation: livePulse 1.5s infinite;
}
@keyframes livePulse {
  0%   { box-shadow: 0 0 0 0 rgba(0,196,122,0.5); }
  70%  { box-shadow: 0 0 0 8px rgba(0,196,122,0); }
  100% { box-shadow: 0 0 0 0 rgba(0,196,122,0); }
}

.scan-screen.shake { animation: shake 0.4s ease; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25%      { transform: translateX(-10px); }
  75%      { transform: translateX(10px); }
}

.scan-error {
  font-size: 14px; font-weight: 600;
  color: #ff4e6a;
  min-height: 22px;
  opacity: 0; transition: opacity 0.2s;
  text-align: center;
}
.scan-error.show { opacity: 1; }

/* ── DISPLAY SCREEN ── */
.display-screen {
  position: fixed; inset: 0;
  background: #fff;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 40px 24px; gap: 32px;
  overflow-y: auto;
}
.display-screen.hidden { display: none; }

/* ── SCAN NEXT BANNER (shown on display screen) ── */
.scan-next-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #f0fdf8;
  border-top: 1.5px solid rgba(0,196,122,0.2);
  padding: 12px 24px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 13px; font-weight: 600; color: #00904f;
  z-index: 10;
}
.scan-next-bar .ready-dot { width: 7px; height: 7px; }

/* Flash overlay when a new scan comes in on the display screen */
.scan-flash {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,196,122,0.08);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}
.scan-flash.active { opacity: 1; }

/* Error toast — shown on display screen too */
.toast-error {
  position: fixed;
  bottom: 60px; left: 50%; transform: translateX(-50%) translateY(16px);
  background: #ff4e6a; color: #fff;
  padding: 10px 22px; border-radius: 50px;
  font-size: 13px; font-weight: 700;
  white-space: nowrap;
  opacity: 0; transition: opacity 0.2s, transform 0.2s;
  pointer-events: none; z-index: 600;
}
.toast-error.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ID badge */
.id-badge {
  display: flex; flex-direction: column;
  align-items: center; gap: 4px;
}
.id-badge-label {
  font-size: 10px; font-weight: 700;
  letter-spacing: 2.5px; text-transform: uppercase;
  color: #ccc;
}
.id-badge-value {
  font-family: 'Space Mono', monospace;
  font-size: 28px; font-weight: 700;
  color: #00904f;
  letter-spacing: 3px;
  background: #f0fdf8;
  border: 2px solid rgba(0,196,122,0.25);
  border-radius: 14px;
  padding: 10px 24px;
  line-height: 1;
}

.identity { text-align: center; }
.member-name {
  font-size: 46px; font-weight: 800;
  color: #111; letter-spacing: -2px; line-height: 1.05;
}
.member-phone {
  font-size: 18px; color: #bbb;
  font-weight: 500; letter-spacing: 2px; margin-top: 8px;
}

.divider { width: 100%; max-width: 560px; height: 1px; background: #f0f2f5; }

.passes-wrap { width: 100%; max-width: 560px; display: flex; flex-direction: column; gap: 12px; }
.passes-label {
  font-size: 11px; font-weight: 700;
  letter-spacing: 2px; text-transform: uppercase;
  color: #ccc; text-align: center;
}

/* ── COUPON ── */
.coupon {
  display: flex; align-items: stretch;
  border-radius: 16px; overflow: hidden;
  min-height: 96px; position: relative;
}
.coupon.green    { border: 1.5px solid rgba(0,196,122,0.2); box-shadow: 0 2px 16px rgba(0,196,122,0.1); }
.coupon.yellow   { border: 1.5px solid rgba(255,181,69,0.25); box-shadow: 0 2px 16px rgba(255,181,69,0.08); }
.coupon.redeemed { border: 1.5px solid #e8eaed; box-shadow: none; opacity: 0.6; }

.coupon-bar { width: 8px; flex-shrink: 0; }
.coupon.green    .coupon-bar { background: #00c47a; }
.coupon.yellow   .coupon-bar { background: #ffb545; }
.coupon.redeemed .coupon-bar { background: #ccc; }

.coupon-body {
  flex: 1; padding: 18px 22px;
  display: flex; align-items: center;
  justify-content: space-between; gap: 16px;
}
.coupon.green    .coupon-body { background: linear-gradient(135deg, #f0fdf8, #fff); }
.coupon.yellow   .coupon-body { background: linear-gradient(135deg, #fffdf0, #fff); }
.coupon.redeemed .coupon-body { background: #fafafa; }

.coupon-left { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.coupon-title { font-size: 17px; font-weight: 700; color: #111; }
.coupon-sub   { font-size: 12px; color: #bbb; font-weight: 500; }

.coupon-right { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; flex-shrink: 0; }

.coupon-badge {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 16px; border-radius: 50px;
  font-size: 12px; font-weight: 700; white-space: nowrap;
}
.coupon.green    .coupon-badge { background: #e4faf1; color: #00904f; }
.coupon.yellow   .coupon-badge { background: #fff8e6; color: #b37900; }
.coupon.redeemed .coupon-badge { background: #f0f2f5; color: #999; }

.badge-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.coupon.green    .badge-dot { background: #00c47a; animation: livePulse 1.5s infinite; }
.coupon.yellow   .badge-dot { background: #ffb545; }
.coupon.redeemed .badge-dot { background: #ccc; }

.no-passes {
  text-align: center; padding: 32px 0;
  color: #ccc; font-size: 14px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.no-passes svg { color: #e0e0e0; }

.scan-again-btn {
  font-size: 13px; color: #ccc; font-weight: 500;
  cursor: pointer; padding: 10px 24px;
  border-radius: 50px; border: 1.5px solid #eee;
  background: transparent; transition: all 0.15s;
  font-family: 'DM Sans', sans-serif;
  margin-bottom: 56px; /* room for scan-next-bar */
}
.scan-again-btn:hover { border-color: #00c47a; color: #00c47a; }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}
.display-screen:not(.hidden) > * {
  animation: slideUp 0.35s ease both;
}
.display-screen:not(.hidden) > *:nth-child(1) { animation-delay: 0.00s; }
.display-screen:not(.hidden) > *:nth-child(2) { animation-delay: 0.05s; }
.display-screen:not(.hidden) > *:nth-child(3) { animation-delay: 0.08s; }
.display-screen:not(.hidden) > *:nth-child(4) { animation-delay: 0.11s; }
.display-screen:not(.hidden) > *:nth-child(5) { animation-delay: 0.14s; }

/* ── DEBUG MODE ── */
.debug-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 9999;
  background: #ffffff;
  border-bottom: 2px solid #8f8f8f;
  padding: 8px 16px;
  display: flex; align-items: center; gap: 12px;
  font-family: 'Space Mono', monospace;
  font-size: 11px; color: #000000;
  transform: translateY(-100%);
  transition: transform 0.25s ease;
}
.debug-bar.visible { transform: translateY(0); }
.debug-bar-icon { font-size: 14px; flex-shrink: 0; }
.debug-bar label { color: #000000; opacity: 0.7; white-space: nowrap; }
.debug-input {
  background: #b9b9b9; border: 1px solid #ffffff;
  color: #000000; font-family: 'Space Mono', monospace;
  font-size: 11px; padding: 3px 8px; border-radius: 4px;
  outline: none; width: 120px;
}
.debug-time-input {
  background: #b9b9b9; border: 1px solid #8b8b8b;
  color: #000000; font-family: 'Space Mono', monospace;
  font-size: 11px; padding: 3px 8px; border-radius: 4px;
  outline: none; width: 90px;
}
.debug-bar-divider { width: 1px; height: 16px; background: #ffb54540; flex-shrink: 0; }
.debug-apply-btn {
  background: #b9b9b9; color: #1a1200;
  border: none; border-radius: 4px;
  font-family: 'Space Mono', monospace; font-size: 10px;
  font-weight: 700; padding: 4px 10px; cursor: pointer;
  white-space: nowrap; transition: opacity 0.15s;
}
.debug-apply-btn:hover { opacity: 0.85; }
.debug-close-btn {
  background: transparent; border: 1px solid #b9b9b9;
  color: #b9b9b9; border-radius: 4px;
  font-family: 'Space Mono', monospace; font-size: 10px;
  padding: 3px 8px; cursor: pointer; margin-left: auto;
  white-space: nowrap; transition: all 0.15s;
}
.debug-close-btn:hover { border-color: #ffffff; background: #2a1e00; }
.debug-badge {
  position: fixed; bottom: 12px; right: 12px; z-index: 9998;
  background: #1a1200; border: 1px solid #b9b9b9;
  color: #b9b9b9; font-family: 'Space Mono', monospace;
  font-size: 10px; padding: 4px 10px; border-radius: 20px;
  pointer-events: none; display: none;
}
.debug-badge.visible { display: block; }
body.debug-open .scan-screen,
body.debug-open .display-screen,
body.debug-open .loading-screen { padding-top: 44px; }       