:root {
  --blue-950: #031b48;
  --blue-900: #062a69;
  --blue-800: #07459f;
  --blue-700: #075dcc;
  --blue-600: #1678e8;
  --blue-100: #dceeff;
  --sky: #eff8ff;
  --gold: #f6c85f;
  --gold-deep: #ba7418;
  --red: #e33135;
  --red-deep: #a8131e;
  --ink: #10284e;
  --muted: #637594;
  --surface: #ffffff;
  --danger: #c82b36;
  --success: #157c59;
  --shadow: 0 20px 55px rgba(4, 48, 113, .18);
  --radius-lg: 28px;
  --radius-md: 20px;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: #d7e8f7; }

body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, sans-serif;
  background: #d7e8f7;
}

button, input { font: inherit; }
button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

.app-shell {
  position: relative;
  width: min(100%, 480px);
  min-height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background:
    radial-gradient(circle at 82% 5%, rgba(255,255,255,.92) 0 8%, transparent 24%),
    linear-gradient(180deg, #cdeaff 0%, #edf8ff 42%, #f8fbff 100%);
  box-shadow: 0 0 60px rgba(8, 47, 97, .16);
}

.sky-decor { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.cloud { position: absolute; width: 110px; height: 28px; border-radius: 50px; background: rgba(255,255,255,.7); filter: blur(.2px); }
.cloud::before, .cloud::after { content: ""; position: absolute; border-radius: 50%; background: inherit; }
.cloud::before { width: 46px; height: 46px; left: 20px; bottom: 0; }
.cloud::after { width: 58px; height: 58px; right: 12px; bottom: 0; }
.cloud-a { top: 92px; left: -54px; transform: scale(.72); }
.cloud-b { top: 210px; right: -62px; transform: scale(.58); opacity: .7; }
.spark { position: absolute; width: 8px; height: 8px; background: var(--gold); transform: rotate(45deg); border-radius: 2px; opacity: .75; }
.spark-a { top: 170px; right: 54px; }
.spark-b { top: 246px; left: 34px; width: 6px; height: 6px; }

.topbar {
  position: relative;
  z-index: 10;
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  min-height: 72px;
  padding: calc(env(safe-area-inset-top) + 8px) 20px 8px;
}

.brand { display: flex; align-items: center; gap: 8px; justify-self: start; white-space: nowrap; font-size: 14px; font-weight: 800; color: var(--blue-900); }
.brand-mark { display: grid; place-items: center; width: 28px; height: 28px; border: 2px solid var(--gold); border-radius: 9px; background: var(--blue-800); color: white; box-shadow: 0 5px 12px rgba(7,69,159,.22); }
.demo-chip { padding: 6px 9px; border: 1px solid rgba(7,69,159,.14); border-radius: 999px; color: var(--blue-800); background: rgba(255,255,255,.68); font-size: 11px; font-weight: 800; }

.icon-button { display: grid; place-items: center; width: 48px; height: 48px; margin-left: -12px; border: 0; border-radius: 50%; color: var(--blue-900); background: transparent; cursor: pointer; transition: background .2s ease, opacity .2s ease; }
.topbar .icon-button.is-hidden { display: grid !important; visibility: hidden; }
.icon-button:active { background: rgba(7,69,159,.1); }
.icon-button svg, .primary-button svg, .staff-link svg, .secondary-button svg, .admin-note svg, .privacy-warning svg, .scanner-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.is-hidden { display: none !important; }

.screen { position: relative; z-index: 2; display: none; min-height: calc(100dvh - 72px); padding: 12px 20px calc(env(safe-area-inset-bottom) + 28px); }
.screen.is-active { display: block; animation: screenIn .35s cubic-bezier(.2,.75,.25,1); }

.hero-copy { position: relative; z-index: 3; width: 72%; padding-top: 8px; }
.eyebrow { margin: 0 0 8px; color: var(--blue-700); font-size: 12px; font-weight: 900; letter-spacing: .18em; }
h1, h2, h3, p { overflow-wrap: anywhere; }
.hero-copy h1 { margin: 0; color: var(--blue-950); font-size: clamp(38px, 11vw, 50px); line-height: 1.08; letter-spacing: -.05em; }
.hero-copy h1 span { color: var(--blue-700); text-shadow: 0 3px 0 rgba(246,200,95,.65); }
.hero-subtitle { margin: 14px 0 0; color: #50698f; font-size: 14px; line-height: 1.65; }

.hero-visual { position: relative; height: 204px; margin: -66px -20px -14px; overflow: hidden; }
.cartoon-boy { position: absolute; z-index: 2; right: -12px; bottom: 2px; width: 208px; height: auto; filter: drop-shadow(0 14px 15px rgba(3,47,107,.2)); }
.halo { position: absolute; right: 22px; bottom: 52px; width: 180px; height: 180px; border: 2px solid rgba(255,255,255,.9); border-radius: 50%; box-shadow: 0 0 0 15px rgba(255,255,255,.18), 0 0 0 31px rgba(255,255,255,.1); }
.road { position: absolute; right: -20px; bottom: -96px; width: 350px; height: 190px; border: 18px solid rgba(43,137,228,.26); border-radius: 50%; transform: rotate(-7deg); }

.entry-card, .voucher-card, .redeem-card, .lookup-result {
  position: relative;
  z-index: 3;
  padding: 20px;
  border: 1px solid rgba(255,255,255,.9);
  border-radius: var(--radius-lg);
  background: rgba(255,255,255,.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}
.field-grid { display: grid; grid-template-columns: 1fr 92px; gap: 12px; }
.field { display: grid; gap: 8px; margin-bottom: 16px; }
.field > span { color: var(--ink); font-size: 13px; font-weight: 800; }
.field input { width: 100%; min-height: 52px; padding: 0 15px; border: 1.5px solid #d7e4f2; border-radius: 15px; outline: 0; color: var(--ink); background: #f8fbff; font-size: 16px; transition: border-color .2s ease, box-shadow .2s ease, background .2s ease; }
.field input:focus { border-color: var(--blue-600); background: #fff; box-shadow: 0 0 0 4px rgba(22,120,232,.12); }
.field small { color: var(--muted); font-size: 11px; line-height: 1.5; }
.form-error { min-height: 20px; margin: -6px 0 10px; color: var(--danger); font-size: 12px; font-weight: 700; }

.scan-card { display: grid; justify-items: center; text-align: center; }
.scan-mark { display: grid; place-items: center; width: 68px; height: 68px; margin-top: -4px; border: 2px solid rgba(246,200,95,.9); border-radius: 22px; color: white; background: var(--blue-700); box-shadow: 0 10px 24px rgba(7,93,204,.22); }
.scan-mark svg { width: 38px; height: 38px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.scan-copy { margin: 12px 0 18px; }
.scan-copy span { color: var(--blue-700); font-size: 11px; font-weight: 900; letter-spacing: .16em; }
.scan-copy h2 { margin: 4px 0 8px; color: var(--blue-950); font-size: 24px; }
.scan-copy p { max-width: 300px; margin: 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
.demo-helper { margin-top: 11px; color: var(--muted); font-size: 11px; line-height: 1.45; }

.code-card { padding-top: 18px; }
.code-heading { display: flex; align-items: center; gap: 13px; margin-bottom: 18px; }
.ticket-mark { display: grid; flex: 0 0 auto; place-items: center; width: 58px; height: 58px; border: 2px solid rgba(246,200,95,.92); border-radius: 19px; color: white; background: var(--blue-700); box-shadow: 0 9px 20px rgba(7,93,204,.2); }
.ticket-mark svg { width: 34px; height: 34px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.code-heading span { color: var(--blue-700); font-size: 10px; font-weight: 900; letter-spacing: .17em; }
.code-heading h2 { margin: 2px 0 0; color: var(--blue-950); font-size: 23px; }
.code-field input { text-align: center; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 24px; font-weight: 900; letter-spacing: .16em; }
.code-field input::placeholder { font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif; font-size: 15px; font-weight: 500; letter-spacing: 0; }
.field input[aria-invalid="true"] { border-color: var(--danger); background: #fff8f8; box-shadow: 0 0 0 4px rgba(200,43,54,.1); }
.code-card .demo-helper { display: block; text-align: center; }

.primary-button, .secondary-button, .confirm-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 54px;
  border: 0;
  border-radius: 17px;
  cursor: pointer;
  font-weight: 900;
  transition: opacity .2s ease, box-shadow .2s ease, transform .2s ease;
}
.primary-button { color: #fff; background: var(--blue-700); box-shadow: 0 12px 24px rgba(7,93,204,.24), inset 0 -3px 0 rgba(3,38,97,.2); }
.primary-button:active, .confirm-button:active { transform: translateY(1px); opacity: .9; }
.staff-link { display: flex; align-items: center; justify-content: center; gap: 7px; width: 100%; min-height: 48px; margin-top: 14px; border: 0; color: var(--blue-800); background: transparent; font-size: 13px; font-weight: 800; cursor: pointer; }

.open-heading, .result-heading, .admin-heading { text-align: center; }
.open-heading { padding-top: 32px; }
.open-heading h2, .admin-heading h2 { margin: 0; color: var(--blue-950); font-size: 28px; }
.open-heading p:last-child, .admin-heading p:last-child { margin: 10px 0 0; color: var(--muted); font-size: 14px; }
.red-envelope { position: relative; display: block; width: 242px; height: 322px; margin: 50px auto 20px; overflow: hidden; border: 0; border-radius: 38px; color: white; background: var(--red); box-shadow: 0 30px 55px rgba(147,18,31,.3), inset 0 -8px 0 rgba(122,10,21,.12); cursor: pointer; }
.red-envelope::before, .red-envelope::after { content: ""; position: absolute; width: 90px; height: 90px; border: 2px solid rgba(246,200,95,.3); border-radius: 50%; }
.red-envelope::before { left: -46px; bottom: 28px; }
.red-envelope::after { right: -46px; top: 132px; }
.envelope-top { position: absolute; inset: 0 0 auto; height: 152px; border-radius: 36px 36px 50% 50%; background: #f04a47; box-shadow: 0 5px 12px rgba(109,7,17,.14); }
.envelope-seal { position: absolute; z-index: 2; top: 111px; left: 50%; display: grid; place-items: center; width: 82px; height: 82px; border: 6px solid #f9db83; border-radius: 50%; color: var(--red-deep); background: var(--gold); box-shadow: 0 10px 24px rgba(103,8,16,.25); transform: translateX(-50%); }
.envelope-seal span { font-family: serif; font-size: 31px; font-weight: 900; }
.envelope-copy { position: absolute; left: 0; right: 0; bottom: 55px; font-size: 18px; font-weight: 900; letter-spacing: .18em; }
.red-envelope.is-opening { animation: envelopeOpen .75s cubic-bezier(.2,.8,.2,1); }
.tap-hint { margin: 0; text-align: center; color: var(--blue-800); font-size: 14px; font-weight: 800; animation: hintPulse 1.7s ease-in-out infinite; }
.progress-dots { display: flex; justify-content: center; gap: 8px; margin-top: 34px; }
.progress-dots span { width: 8px; height: 8px; border-radius: 50%; background: #bdd0e5; }
.progress-dots .is-current { width: 24px; border-radius: 999px; background: var(--blue-700); }

.screen-result { padding-top: 8px; }
.result-heading { position: relative; z-index: 2; }
.success-mark { display: grid; place-items: center; width: 52px; height: 52px; margin: 10px auto 12px; border: 3px solid rgba(246,200,95,.85); border-radius: 50%; color: white; background: var(--blue-700); box-shadow: 0 9px 20px rgba(7,93,204,.24); }
.success-mark svg, .lookup-icon svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.result-heading p { margin: 0; color: var(--blue-800); font-size: 14px; font-weight: 800; }
.result-heading h2 { margin: 2px 0 18px; color: var(--red); font-size: 62px; line-height: 1.1; letter-spacing: -.05em; text-shadow: 0 3px 0 rgba(246,200,95,.48); }
.result-heading h2 small { margin-left: 4px; color: var(--red-deep); font-size: 20px; letter-spacing: 0; }
.voucher-card { padding: 18px 20px 20px; border: 2px solid rgba(246,200,95,.72); }
.voucher-topline { display: flex; align-items: center; justify-content: space-between; color: var(--blue-950); font-size: 13px; font-weight: 900; }
.status-pill { padding: 6px 10px; border-radius: 999px; color: #a25a09; background: #fff2c9; font-size: 11px; }
.status-pill.is-redeemed { color: var(--success); background: #dff7ed; }
.qr-wrap { position: relative; display: grid; place-items: center; width: 196px; height: 196px; margin: 14px auto 8px; border: 1px solid #dce5ef; border-radius: 18px; background: white; }
#voucherQr, #voucherQr img, #voucherQr canvas { width: 176px !important; height: 176px !important; }
.qr-fallback { position: absolute; color: var(--muted); font-size: 12px; }
.voucher-code { margin: 8px 0 16px; text-align: center; color: var(--blue-900); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 15px; font-weight: 900; letter-spacing: .06em; }
.voucher-details { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px dashed #ced9e8; border-bottom: 1px dashed #ced9e8; }
.voucher-details div { display: grid; gap: 3px; padding: 13px 8px; text-align: center; }
.voucher-details div + div { border-left: 1px dashed #ced9e8; }
.voucher-details span { color: var(--muted); font-size: 11px; }
.voucher-details strong { color: var(--ink); font-size: 15px; }
.voucher-note { margin: 14px 0 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.privacy-warning { display: flex; gap: 10px; margin-top: 12px; padding: 12px; border: 1px solid #f1cf74; border-radius: 14px; color: #784a09; background: #fff8df; }
.privacy-warning svg { flex: 0 0 auto; margin-top: 1px; }
.privacy-warning p { margin: 0; font-size: 11px; line-height: 1.6; }
.privacy-warning strong { font-size: 12px; }
.secondary-button { margin-top: 14px; border: 1px solid rgba(7,69,159,.16); color: var(--blue-800); background: rgba(255,255,255,.72); box-shadow: none; }
.secondary-button[disabled], .primary-button[disabled] { cursor: wait; opacity: .55; }

.no-win-result { padding-top: 40px; text-align: center; }
.wish-orbit { display: grid; place-items: center; width: 112px; height: 112px; margin: 0 auto 22px; border: 3px solid rgba(246,200,95,.85); border-radius: 50%; color: var(--gold-deep); background: rgba(255,255,255,.82); box-shadow: 0 18px 36px rgba(4,48,113,.14), 0 0 0 14px rgba(255,255,255,.25); }
.wish-orbit svg { width: 58px; height: 58px; fill: #fff0b7; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.no-win-result h2 { margin: 4px 0 10px; color: var(--blue-950); font-size: 34px; }
.no-win-result > p:not(.eyebrow) { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.8; }
.wish-card { display: grid; gap: 6px; margin: 28px 0 20px; padding: 22px 18px; border: 1px solid rgba(246,200,95,.7); border-radius: 22px; color: var(--blue-900); background: rgba(255,255,255,.88); box-shadow: 0 14px 32px rgba(4,48,113,.1); }
.wish-card span { color: var(--gold-deep); font-size: 11px; font-weight: 900; letter-spacing: .12em; }
.wish-card strong { font-size: 20px; }

.confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.confetti i { position: absolute; top: -18px; width: 7px; height: 13px; border-radius: 2px; animation: confettiFall 2.8s linear infinite; }

.admin-heading { padding: 10px 0 20px; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.stats-grid div { display: grid; place-items: center; min-height: 92px; padding: 12px 5px; border: 1px solid rgba(255,255,255,.9); border-radius: 18px; background: rgba(255,255,255,.78); box-shadow: 0 10px 25px rgba(4,48,113,.08); }
.stats-grid span { color: var(--muted); font-size: 11px; }
.stats-grid strong { color: var(--blue-900); font-size: 25px; line-height: 1.2; }
.stats-grid small { color: var(--muted); font-size: 10px; }
.scanner-card { padding: 18px; border: 1px solid rgba(255,255,255,.9); border-radius: 22px; background: rgba(255,255,255,.92); box-shadow: var(--shadow); }
.scanner-heading { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.scanner-icon { display: grid; flex: 0 0 auto; place-items: center; width: 48px; height: 48px; border-radius: 15px; color: #fff; background: var(--blue-700); }
.scanner-heading span { color: var(--blue-700); font-size: 10px; font-weight: 900; letter-spacing: .14em; }
.scanner-heading h3 { margin: 2px 0 0; color: var(--blue-950); font-size: 17px; }
.scanner-stop { margin-top: 8px; }
.scanner-reader { width: 100%; min-height: 260px; margin-top: 12px; overflow: hidden; border: 2px solid var(--blue-600); border-radius: 18px; background: var(--blue-950); }
.scanner-reader video { width: 100% !important; border-radius: 16px; }
.scanner-reader img { display: none; }
.scanner-status { margin: 10px 2px 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.admin-divider { display: flex; align-items: center; gap: 12px; margin: 18px 0 12px; color: var(--muted); font-size: 11px; font-weight: 800; }
.admin-divider::before, .admin-divider::after { content: ""; flex: 1; height: 1px; background: #cbdced; }
.redeem-card { padding: 18px; border-radius: 22px; }
.redeem-card .field { margin-bottom: 12px; }
.lookup-result { display: grid; grid-template-columns: 50px 1fr; gap: 12px; align-items: center; margin-top: 14px; padding: 16px; border-radius: 22px; }
.lookup-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; color: white; background: var(--success); }
.lookup-copy span { color: var(--success); font-size: 11px; font-weight: 900; }
.lookup-copy h3 { margin: 2px 0; color: var(--blue-950); font-size: 25px; }
.lookup-copy p { margin: 0; color: var(--muted); font-size: 12px; }
.confirm-button { grid-column: 1 / -1; min-height: 50px; color: white; background: var(--success); }
.confirm-button[disabled] { cursor: not-allowed; opacity: .5; }
.admin-note { display: flex; gap: 10px; margin-top: 16px; padding: 14px; border: 1px solid #d4e2f1; border-radius: 17px; color: #526987; background: rgba(255,255,255,.58); }
.admin-note svg { flex: 0 0 auto; color: var(--blue-700); }
.admin-note p { margin: 0; font-size: 11px; line-height: 1.55; }

.toast { position: fixed; z-index: 50; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 24px); width: max-content; max-width: calc(100% - 48px); padding: 12px 17px; border-radius: 999px; color: white; background: rgba(3,27,72,.92); box-shadow: 0 12px 30px rgba(3,27,72,.25); font-size: 13px; font-weight: 800; opacity: 0; pointer-events: none; transform: translate(-50%, 14px); transition: opacity .25s ease, transform .25s ease; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@keyframes screenIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes envelopeOpen { 0% { transform: scale(1) rotate(0); } 25% { transform: scale(1.04) rotate(-3deg); } 50% { transform: scale(1.06) rotate(3deg); } 75% { transform: scale(.98) rotate(-1deg); } 100% { transform: scale(1.2); opacity: 0; } }
@keyframes hintPulse { 50% { opacity: .48; } }
@keyframes confettiFall { to { transform: translate3d(var(--drift), 110dvh, 0) rotate(720deg); } }

@media (max-width: 359px) {
  .screen { padding-inline: 14px; }
  .hero-copy h1 { font-size: 37px; }
  .entry-card { padding: 17px; }
  .hero-visual { margin-inline: -14px; }
}

@media (orientation: landscape) and (max-height: 560px) {
  .app-shell { width: min(100%, 760px); }
  .screen-entry.is-active { display: grid; grid-template-columns: .9fr 1.1fr; gap: 20px; align-items: center; }
  .hero-copy { width: 100%; }
  .hero-visual { position: absolute; opacity: .3; }
  .entry-card { grid-column: 2; }
  .staff-link { grid-column: 2; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

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