:root {
  color-scheme: light;
  --red: #be153e;
  --red-dark: #94102f;
  --ink: #191615;
  --paper: #f6f0e7;
  --cream: #fffaf3;
  --line: #ded3c5;
  --green: #117b4b;
  --green-bg: #e8f6ee;
  --error: #a92222;
  --error-bg: #fff0ed;
  --shadow: 0 18px 48px rgba(40, 23, 18, .12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); }
body { margin: 0; min-height: 100%; color: var(--ink); background: radial-gradient(circle at top right, #fff 0, transparent 35%), var(--paper); }
button, input, select { font: inherit; }
button, select, label[for="qrImage"] { touch-action: manipulation; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.offline-banner { position: sticky; z-index: 30; top: 0; padding: 10px 16px; background: #2b2725; color: #fff; text-align: center; font-weight: 800; font-size: .82rem; }
.shell { width: min(760px, 100%); min-height: 100vh; margin: 0 auto; padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) calc(32px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.brand-bar { min-height: 82px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 11px; background: var(--red); color: white; font-weight: 950; letter-spacing: -.08em; font-size: 1.15rem; transform: rotate(-2deg); }
.brand strong { display: block; letter-spacing: .04em; }
.brand small { display: block; margin-top: 2px; color: #786b62; font-size: .68rem; letter-spacing: .12em; font-weight: 800; }
.quiet-button { border: 1px solid var(--line); border-radius: 999px; padding: 10px 13px; background: rgba(255,255,255,.65); color: var(--ink); font-weight: 750; font-size: .78rem; }

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 5px; font-size: clamp(1.75rem, 6vw, 2.6rem); line-height: .98; letter-spacing: -.045em; }
h2 { margin-bottom: 3px; font-size: 1.08rem; }
.eyebrow { margin-bottom: 8px; color: var(--red); font-size: .73rem; font-weight: 900; letter-spacing: .14em; }
.muted, .section-heading p, .location-card p { margin: 0; color: #766960; font-size: .9rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.center-card { margin: 9vh auto 0; max-width: 480px; padding: clamp(24px, 7vw, 42px); border: 1px solid rgba(95, 73, 60, .15); border-radius: 24px; background: rgba(255, 250, 243, .96); box-shadow: var(--shadow); }
.spinner { width: 34px; height: 34px; margin-bottom: 22px; border: 4px solid #eadfd2; border-top-color: var(--red); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.login-form { display: grid; gap: 10px; margin-top: 26px; }
.login-form label, .code-label { font-size: .78rem; font-weight: 850; text-transform: uppercase; letter-spacing: .08em; }
.login-form input { width: 100%; min-height: 56px; border: 2px solid var(--line); border-radius: 13px; padding: 12px 14px; background: white; font-size: 1.2rem; }
.login-form input:focus, select:focus, .code-input:focus { outline: 3px solid rgba(190, 21, 62, .2); border-color: var(--red); }
.primary-button, .secondary-button { min-height: 54px; border: 0; border-radius: 13px; padding: 13px 18px; font-weight: 950; letter-spacing: .035em; }
.primary-button { background: var(--red); color: white; box-shadow: 0 8px 20px rgba(190,21,62,.24); }
.primary-button:active { background: var(--red-dark); transform: translateY(1px); }
.secondary-button { background: #eee5db; color: var(--ink); }

.welcome-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 16px 0 20px; }
.online-pill { display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px; border: 1px solid #afd4bf; border-radius: 999px; background: var(--green-bg); color: var(--green); font-size: .75rem; font-weight: 850; }
.online-pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.location-card, .redeem-card { border: 1px solid rgba(95, 73, 60, .15); border-radius: 20px; background: var(--cream); box-shadow: 0 9px 25px rgba(40,23,18,.07); }
.location-card { display: grid; grid-template-columns: 1fr minmax(230px, 45%); gap: 16px; align-items: center; padding: 17px; }
.location-card > div, .section-heading { display: flex; align-items: center; gap: 12px; }
.step-number { flex: 0 0 auto; display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: #eadfd2; color: var(--red); font-weight: 950; }
.step-number.light { background: rgba(255,255,255,.18); color: white; }
select { width: 100%; min-height: 50px; border: 2px solid var(--line); border-radius: 12px; padding: 9px 36px 9px 12px; background: white; color: var(--ink); font-weight: 750; }
.redeem-card { margin-top: 14px; padding: 17px; }
.section-heading { margin-bottom: 18px; }
.mode-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 5px; border-radius: 13px; background: #eee5db; }
.mode-tab { min-height: 47px; border: 0; border-radius: 9px; background: transparent; color: #6f6259; font-size: .79rem; font-weight: 950; letter-spacing: .03em; }
.mode-tab.active { background: white; color: var(--red); box-shadow: 0 3px 10px rgba(40,23,18,.08); }

.scanner-frame { position: relative; width: 100%; aspect-ratio: 4 / 3; max-height: 430px; margin-top: 14px; overflow: hidden; border-radius: 16px; background: #191615; }
#camera { width: 100%; height: 100%; object-fit: cover; }
.camera-placeholder { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 20px; background: linear-gradient(145deg, #282220, #151211); color: white; text-align: center; }
.camera-placeholder span { color: #c9beb8; font-size: .85rem; }
.qr-symbol { font-size: 3.2rem; line-height: 1; color: #fff; }
.scan-guide { position: absolute; inset: 15% 22%; z-index: 2; pointer-events: none; }
.scan-guide span { position: absolute; width: 35px; height: 35px; border-color: white; border-style: solid; filter: drop-shadow(0 2px 4px rgba(0,0,0,.4)); }
.scan-guide span:nth-child(1) { top: 0; left: 0; border-width: 4px 0 0 4px; border-radius: 8px 0 0 0; }
.scan-guide span:nth-child(2) { top: 0; right: 0; border-width: 4px 4px 0 0; border-radius: 0 8px 0 0; }
.scan-guide span:nth-child(3) { bottom: 0; left: 0; border-width: 0 0 4px 4px; border-radius: 0 0 0 8px; }
.scan-guide span:nth-child(4) { right: 0; bottom: 0; border-width: 0 4px 4px 0; border-radius: 0 0 8px 0; }
.scan-actions { display: grid; grid-template-columns: 1.2fr 1fr; gap: 9px; margin-top: 10px; }
.camera-button, .photo-button { display: grid; place-items: center; min-height: 50px; border: 0; border-radius: 12px; text-align: center; font-size: .77rem; font-weight: 950; letter-spacing: .03em; }
.camera-button { background: var(--ink); color: white; }
.photo-button { border: 2px solid var(--line); background: white; color: var(--ink); cursor: pointer; }
.microcopy { margin: 9px 0 0; color: #786b62; text-align: center; font-size: .76rem; }

#manualPanel { padding-top: 18px; }
.code-input { width: 100%; min-height: 70px; margin-top: 8px; border: 2px solid var(--line); border-radius: 14px; background: white; color: var(--ink); text-align: center; font-size: clamp(1.8rem, 9vw, 3.1rem); font-weight: 950; letter-spacing: .18em; text-transform: uppercase; }
.touch-keyboard { display: grid; grid-template-columns: repeat(8, 1fr); gap: 5px; margin-top: 16px; }
.touch-keyboard button { aspect-ratio: 1; min-width: 0; border: 1px solid #d8cdc0; border-radius: 9px; background: white; color: var(--ink); font-size: clamp(.78rem, 3vw, 1.04rem); font-weight: 900; }
.touch-keyboard button:active { background: var(--red); color: white; transform: scale(.96); }
.key-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.key-actions button { min-height: 44px; border: 0; border-radius: 10px; background: #eee5db; color: #554a44; font-size: .74rem; font-weight: 900; }

.message { margin-top: 13px; padding: 12px 14px; border-radius: 11px; background: #efe7dc; color: #5f5149; font-weight: 750; }
.message.error { background: var(--error-bg); color: var(--error); }
.message.success { background: var(--green-bg); color: var(--green); }
.redeem-button { display: flex; align-items: center; justify-content: center; gap: 11px; width: 100%; min-height: 68px; margin-top: 14px; border: 0; border-radius: 17px; background: var(--red); color: white; box-shadow: 0 12px 26px rgba(190,21,62,.28); font-size: 1rem; font-weight: 950; letter-spacing: .05em; }
.redeem-button:disabled { background: #aaa097; box-shadow: none; cursor: not-allowed; opacity: .72; }
.result-card { margin-top: 14px; padding: 30px 22px; border: 2px solid transparent; border-radius: 20px; background: white; text-align: center; box-shadow: var(--shadow); }
.result-card.success { border-color: #67ad86; background: var(--green-bg); }
.result-card.error { border-color: #d9877d; background: var(--error-bg); }
.result-icon { display: grid; place-items: center; width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 50%; background: var(--ink); color: white; font-size: 2rem; font-weight: 950; }
.result-card.success .result-icon { background: var(--green); }
.result-card.error .result-icon { background: var(--error); }
.result-card h2 { font-size: 1.8rem; }
.result-card .primary-button { margin-top: 10px; }

.confirm-dialog { width: min(520px, calc(100% - 24px)); border: 0; border-radius: 22px; padding: 0; background: var(--cream); color: var(--ink); box-shadow: 0 30px 90px rgba(0,0,0,.3); }
.confirm-dialog::backdrop { background: rgba(20, 15, 13, .72); backdrop-filter: blur(3px); }
.confirm-dialog form { padding: clamp(22px, 7vw, 34px); }
.confirm-dialog h2 { font-size: 1.7rem; }
.confirm-dialog dl { margin: 22px 0; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.confirm-dialog dl div { display: grid; grid-template-columns: 90px 1fr; gap: 12px; padding: 13px; background: white; }
.confirm-dialog dl div + div { border-top: 1px solid var(--line); }
.confirm-dialog dt { color: #766960; font-size: .78rem; font-weight: 800; text-transform: uppercase; }
.confirm-dialog dd { margin: 0; font-weight: 900; }
.warning-copy { padding: 12px; border-radius: 10px; background: #fff0d8; color: #7c4a11; font-size: .88rem; font-weight: 700; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1.3fr; gap: 9px; }

@media (max-width: 580px) {
  .shell { padding-left: 12px; padding-right: 12px; }
  .brand-bar { min-height: 72px; }
  .location-card { grid-template-columns: 1fr; }
  .welcome-row { align-items: center; }
  .online-pill { padding: 7px 9px; }
  .touch-keyboard { grid-template-columns: repeat(6, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; animation-duration: .001ms !important; }
}
