:root {
  --ink: #172033;
  --muted: #5f6b7a;
  --surface: #ffffff;
  --canvas: #f3f6f8;
  --line: #d6dde5;
  --brand: #005a70;
  --brand-dark: #003f50;
  --accent: #f4c542;
  --success: #087443;
  --danger: #b42318;
  --focus: #ffbf47;
  --radius: 18px;
  --shadow: 0 12px 32px rgba(23, 32, 51, 0.1);
}

* { box-sizing: border-box; }

html { font-size: 18px; scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
}

button, input, select { font: inherit; }
button, a, input, select { touch-action: manipulation; }

:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.5rem;
  left: 0.5rem;
  padding: 0.75rem 1rem;
  color: #000;
  background: var(--focus);
  transform: translateY(-160%);
}
.skip-link:focus { transform: translateY(0); }

.site-header { color: #fff; background: #111827; }
.header-inner {
  width: min(100% - 2rem, 780px);
  min-height: 76px;
  margin: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.brand { display: flex; align-items: center; gap: 0.65rem; color: inherit; font-weight: 800; text-decoration: none; }
.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: #111827;
  background: var(--accent);
  border-radius: 50%;
  font-size: 0.78rem;
}
.icon-button { padding: 0.6rem 0.8rem; color: #fff; background: transparent; border: 1px solid #687386; border-radius: 10px; cursor: pointer; }

.page-shell { width: min(100% - 2rem, 780px); margin: 0 auto; padding: 2.5rem 0 3rem; }
.intro { margin-bottom: 2rem; }
.intro h1 { max-width: 650px; margin: 0.25rem 0 0.75rem; font-size: clamp(2rem, 7vw, 3.3rem); line-height: 1.08; letter-spacing: -0.04em; }
.intro > p:last-child { max-width: 650px; margin: 0; color: var(--muted); font-size: 1.08rem; }
.eyebrow { margin: 0; color: var(--brand); font-size: 0.78rem; font-weight: 850; letter-spacing: 0.12em; text-transform: uppercase; }

.card, .result-card { padding: clamp(1.2rem, 4vw, 2rem); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-heading { display: flex; align-items: flex-start; gap: 1rem; margin-bottom: 1.4rem; }
.card-heading h2 { margin: 0; font-size: 1.45rem; }
.card-heading p { margin: 0.2rem 0 0; color: var(--muted); }
.step { display: grid; flex: 0 0 42px; height: 42px; place-items: center; color: #fff; background: var(--brand); border-radius: 50%; font-weight: 850; }

.primary-action, .secondary-action {
  display: inline-flex;
  min-height: 54px;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  padding: 0.8rem 1.2rem;
  border-radius: 12px;
  border: 2px solid transparent;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}
.primary-action { width: 100%; color: #fff; background: var(--brand); }
.primary-action:hover { background: var(--brand-dark); }
.primary-action:disabled { color: #dae0e5; background: #667085; cursor: wait; }
.secondary-action { color: var(--brand-dark); background: #fff; border-color: var(--brand); }
.scan-card > .secondary-action { width: 100%; margin-top: 0.75rem; }

.scanner-panel { margin-top: 1rem; padding: 0.75rem; background: #0c111c; border-radius: 14px; }
#reader { overflow: hidden; min-height: 260px; border-radius: 10px; }
#reader video { object-fit: cover; }
#scanner-help { margin: 0.75rem 0 0; color: #fff; text-align: center; }
.scan-readout { margin-top: 1rem; padding: 1rem; background: #eef7f9; border: 2px solid var(--brand); border-radius: 12px; }
.scan-readout code { display: block; margin-top: 0.35rem; overflow-wrap: anywhere; color: #111827; font-size: 0.92rem; }
.scan-readout p { margin: 0.55rem 0 0; }
.photo-option { margin-top: 1.2rem; padding-top: 1.2rem; border-top: 1px solid var(--line); }
.photo-option > p { margin: 0 0 0.75rem; color: var(--muted); }
.photo-option .secondary-action { width: 100%; }
.ocr-progress { margin-top: 0.75rem !important; padding: 0.7rem; color: var(--ink) !important; background: #e9f3f5; border-radius: 8px; font-weight: 750; }

.divider { display: flex; align-items: center; gap: 0.8rem; margin: 1.2rem 0; color: var(--muted); }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.divider span { display: grid; width: 38px; height: 38px; place-items: center; background: #e3e8ed; border-radius: 50%; font-weight: 750; }

.field { margin-bottom: 1.2rem; }
.field label { display: block; margin-bottom: 0.4rem; font-weight: 800; }
.field input, .field select {
  width: 100%;
  min-height: 54px;
  padding: 0.65rem 0.8rem;
  color: var(--ink);
  background: #fff;
  border: 2px solid #9aa6b2;
  border-radius: 10px;
}
.field input:focus, .field select:focus { border-color: var(--brand); }
.field small { display: block; margin-top: 0.25rem; color: var(--muted); }
.fields-row { display: grid; grid-template-columns: 2fr 1fr; gap: 1rem; }
.check-action { margin-top: 0.4rem; }
.form-error { padding: 0.8rem; color: var(--danger); background: #fff1f0; border-left: 5px solid var(--danger); font-weight: 700; }

.result-card { margin-top: 1.5rem; text-align: center; border-top: 7px solid var(--brand); }
.result-card.winner { border-top-color: var(--success); }
.result-card.no-prize { border-top-color: #52606d; }
.result-icon { display: grid; width: 70px; height: 70px; margin: 0 auto 1rem; place-items: center; color: #fff; background: var(--brand); border-radius: 50%; font-size: 2rem; font-weight: 900; }
.winner .result-icon { background: var(--success); }
.no-prize .result-icon { background: #52606d; }
.result-card h2 { margin: 0.3rem 0 0.5rem; font-size: clamp(1.7rem, 6vw, 2.5rem); line-height: 1.15; }
.result-card > p { max-width: 620px; margin-left: auto; margin-right: auto; }
.coupon-summary { display: grid; grid-template-columns: repeat(2, 1fr); margin: 1.5rem 0; text-align: left; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.coupon-summary div { padding: 0.8rem 1rem; border-bottom: 1px solid var(--line); }
.coupon-summary div:nth-child(odd) { border-right: 1px solid var(--line); }
.coupon-summary div:nth-last-child(-n+2) { border-bottom: 0; }
.coupon-summary dt { color: var(--muted); font-size: 0.76rem; font-weight: 800; text-transform: uppercase; }
.coupon-summary dd { margin: 0.1rem 0 0; font-weight: 850; }
.result-card .secondary-action { margin: 0.25rem; }
.text-link { display: inline-block; margin: 0.75rem; color: var(--brand-dark); font-weight: 800; }
.disclaimer { color: var(--muted); font-size: 0.83rem; }

.notice { display: flex; align-items: flex-start; gap: 0.8rem; margin-top: 1.5rem; padding: 1rem; color: #523d00; background: #fff6d6; border: 1px solid #e6bf3d; border-radius: 12px; }
.notice > span { display: grid; flex: 0 0 30px; height: 30px; place-items: center; color: #fff; background: #725600; border-radius: 50%; font-weight: 900; }
.notice p { margin: 0; }

footer { padding: 1.5rem 1rem; color: #d5dae1; background: #111827; text-align: center; font-size: 0.82rem; }
.error-page { text-align: center; }
.error-page .primary-action { max-width: 320px; margin: auto; }
.hidden { display: none !important; }
.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; }

body.high-contrast {
  --ink: #fff;
  --muted: #fff;
  --surface: #000;
  --canvas: #000;
  --line: #fff;
  --brand: #ffea00;
  --brand-dark: #ffea00;
  --focus: #00ffff;
}
body.high-contrast .primary-action { color: #000; }
body.high-contrast .step, body.high-contrast .result-icon { color: #000; }
body.high-contrast .field input, body.high-contrast .field select { color: #000; }
body.high-contrast .divider span { color: #000; background: #fff; }
body.high-contrast .eyebrow, body.high-contrast .text-link { color: #ffea00; }
body.high-contrast .notice { color: #000; }
body.high-contrast .scan-readout { color: #000; background: #fff; }
body.high-contrast .ocr-progress { color: #000 !important; background: #fff; }

@media (max-width: 520px) {
  html { font-size: 17px; }
  .header-inner { min-height: 68px; }
  .icon-button { font-size: 0.8rem; }
  .fields-row { grid-template-columns: 1fr; gap: 0; }
  .coupon-summary { grid-template-columns: 1fr; }
  .coupon-summary div, .coupon-summary div:nth-child(odd) { border-right: 0; border-bottom: 1px solid var(--line); }
  .coupon-summary div:nth-last-child(2) { border-bottom: 1px solid var(--line); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
