/* ============ Fonts ============ */
@font-face {
  font-family: "Knockout";
  src: url("../../font/Knockout-Regular.otf") format("opentype");
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: "UniversCn";
  src: url("../../font/UniversCnRg.ttf") format("truetype");
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: "UniversCn";
  src: url("../../font/UniversCnBold.ttf") format("truetype");
  font-weight: 700; font-display: swap;
}

:root {
  --gold: #eaa93b;
  --gold-light: #f6c65b;
  --text: #f4f7fa;
  --muted: #cfd8e0;
  --s: 0.35;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: #05070a; }
body {
  font-family: "UniversCn", "Arial Narrow", Arial, sans-serif;
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }

/* ============ Scaled fixed canvas (1080 x 1920) ============ */
#fitwrap {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
}
#fit {
  position: relative;
  margin: 0 auto;
  overflow: hidden;
  /* pre-JS fallback: fit to width via viewport units */
  width: 100%;
  height: calc((100vw - 0px) * 1920 / 1080);
  max-height: 100vh;
  max-height: 100dvh;
  visibility: hidden;
}
#fit.ready { visibility: visible; }
#stage {
  position: absolute;
  top: 0; left: 0;
  width: 1080px;
  height: 1920px;
  transform-origin: top left;
  overflow: hidden;
}

.page {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 54px 80px 70px;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-color: #05070a;
}
.page--landing { background-image: url("../../images/bg-page1.png"); padding-bottom: 46px; }
.page--std     { background-image: url("../../images/bg-app.png"); }
.page--stamp   { background-image: url("../../images/bg-stamp.jpg"); }

.grow { flex: 1 1 auto; }

/* ============ Common bits ============ */
.logo { width: 273px; margin: 6px auto 0; }

.bottom-line {
  position: absolute;
  left: 0; bottom: 0;
  width: 1080px;
  max-width: none;
}

.head {
  margin: 0 auto;
  width: auto;
  max-width: 920px;
}
.head--landing { width: 720px; margin-top: 76px; }
.head--journey { width: 800px; margin-top: 40px; }
.head--register { width: 620px; margin-top: 26px; }
.head--login   { width: 560px; margin-top: 0; }
.head--scanqr  { width: 640px; margin-top: 24px; }
.head--congrats { width: 900px; margin-top: 40px; }

/* ============ Image buttons ============ */
.btn-img {
  display: block;
  border: 0; background: none; padding: 0; cursor: pointer;
  margin: 0 auto;
  transition: transform 0.08s ease, filter 0.2s ease;
}
.btn-img img { width: 100%; display: block; }
.btn-img:active { transform: scale(0.97); }
.btn-img[disabled] { filter: grayscale(0.7) opacity(0.55); cursor: not-allowed; }

.btn-start, .btn-login { width: 430px; }
.btn-continue { width: 450px; }
.btn-scanqr, .btn-claim { width: 560px; }
.btn-back { width: 500px; }

.stack { display: flex; flex-direction: column; align-items: center; gap: 40px; }

.footer-text { width: 560px; margin: 24px auto 8px; }
.footer-hint { width: 720px; margin: 22px auto 6px; }
.below-btn { width: 430px; margin: 22px auto 0; }

/* ============ Forms ============ */
.form { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 26px; }
.form .head { margin-bottom: 8px; }

/* login: wider spacing to match the reference rhythm */
.form--login { gap: 0; }
.form--login .head--login { margin-bottom: 104px; }
.form--login .form-error { margin-bottom: 24px; }
.form--login .field { margin-bottom: 176px; }
.form--login .btn-continue { margin-bottom: 24px; }

.field {
  width: 100%;
  display: flex;
  align-items: center;
  background: rgba(38, 32, 18, 0.5);
  border: 3px solid var(--gold);
  border-radius: 34px;
  padding: 0 34px;
  height: 138px;
  box-shadow: 0 0 26px rgba(233, 169, 60, 0.16) inset;
}
.field svg { width: 54px; height: 54px; flex: 0 0 54px; fill: #fff; margin-right: 28px; opacity: 0.95; }
.field input {
  flex: 1; min-width: 0;
  border: 0; outline: 0; background: transparent;
  color: #fff; font-family: inherit; font-size: 44px; font-weight: 400;
}
.field input::placeholder { color: #dfe4e9; opacity: 0.92; }

.agree {
  width: 100%;
  display: flex; align-items: flex-start; gap: 22px;
  font-size: 32px; line-height: 1.3; color: var(--text);
  margin: 2px 4px;
}
.agree input { width: 40px; height: 40px; flex: 0 0 40px; margin-top: 2px; accent-color: var(--gold); }
.agree a { color: var(--gold); text-decoration: none; }

.form-error {
  width: 100%;
  background: rgba(214, 51, 51, 0.16);
  border: 2px solid rgba(224, 74, 74, 0.65);
  color: #ffdada;
  border-radius: 18px;
  padding: 18px 22px;
  font-size: 30px;
  text-align: center;
}

/* ============ Stamp grid ============ */
.stamp-grid {
  width: 850px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  column-gap: 92px;
  row-gap: 56px;
  margin: 0 auto;
}
.stamp {
  position: relative;
  filter: drop-shadow(0 10px 16px rgba(0, 0, 0, 0.45));
}
.stamp > img { width: 100%; display: block; }
.stamp > span {
  position: absolute;
  left: 8%; right: 8%;
  top: 50%;
  transform: translateY(-50%);
  text-align: center;
  font-family: "UniversCn", "Arial Narrow", Arial, sans-serif;
  font-weight: 700;
  font-size: 37px;
  letter-spacing: 0.5px;
  line-height: 1;
  color: #1f1f1f;
  white-space: nowrap;
}
.stamp.done > span { color: #3a2600; }

/* ============ Scan page ============ */
.scan-box {
  position: relative;
  width: 820px; height: 820px;
  margin: 0 auto;
  border: 7px solid var(--gold);
  border-radius: 44px;
  overflow: hidden;
  background: rgba(30, 24, 12, 0.45);
}
/* html5-qrcode fills the whole yellow frame */
.scan-box #reader {
  position: absolute; inset: 0;
  width: 100% !important; height: 100% !important;
  border: 0 !important; padding: 0 !important;
}
.scan-box #reader video {
  position: absolute; inset: 0;
  width: 100% !important; height: 100% !important;
  object-fit: cover;
}
.scan-box #reader__scan_region {
  position: absolute; inset: 0;
  width: 100% !important; height: 100% !important;
  min-height: 0 !important;
  background: transparent !important;
}
/* hide the library's QR hint image and shaded overlay */
.scan-box #reader__scan_region img { display: none !important; }
.scan-box #reader__dashboard { display: none !important; }
.scan-box #qr-shaded-region { display: none !important; }
.scan-state { text-align: center; color: var(--muted); font-size: 26px; padding: 10px; max-width: 820px; }
.manual-bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; gap: 14px; padding: 18px; background: rgba(0, 0, 0, 0.62);
}
.manual-bar input { flex: 1; min-width: 0; padding: 16px 20px; border: 0; border-radius: 14px; font-size: 32px; font-family: inherit; }
.manual-bar button { padding: 16px 30px; border: 0; border-radius: 14px; background: var(--gold); color: #3a2600; font-weight: 700; font-size: 32px; }

/* ============ Result ============ */
.qr-card {
  background: #fff;
  padding: 40px;
  border-radius: 16px;
  width: 600px;
  margin: 40px auto 20px;
}
.qr-card > div { width: 100%; }
.qr-card canvas, .qr-card img { width: 100% !important; height: auto !important; }
.result-note { text-align: center; color: var(--text); font-size: 32px; line-height: 1.4; margin: 16px auto; max-width: 820px; }
.result-note strong { color: var(--gold); }
.result-who {
  font-size: 42px;
  font-weight: 700;
  opacity: 0.95;
  margin: 10px auto 6px;
  letter-spacing: 0.5px;
}
.badge-redeemed { text-align: center; color: #7CFC98; font-weight: 700; font-size: 36px; margin-top: 16px; }

.done-panel {
  width: 100%;
  border: 3px solid #5ad07f;
  background: rgba(46, 160, 90, 0.14);
  border-radius: 26px;
  padding: 30px 28px;
  text-align: center;
  margin-bottom: 20px;
}
.done-title {
  font-family: "Knockout", "UniversCn", Arial, sans-serif;
  font-size: 46px; color: #7CFC98; margin: 0 0 10px; letter-spacing: 0.5px;
}
.done-sub { color: var(--text); font-size: 30px; line-height: 1.4; margin: 0; }
.qr-card.is-dim { opacity: 0.5; }
.link-exit { color: var(--gold); text-decoration: none; font-size: 60px; font-weight: 700; margin-top: 16px; letter-spacing: 1px; }

/* ============ Popup ============ */
.overlay {
  position: fixed; inset: 0;
  background: rgba(2, 5, 9, 0.8);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 26px; z-index: 100;
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
}
.overlay.show { opacity: 1; pointer-events: auto; }
.popup {
  width: 100%; max-width: 380px;
  background: linear-gradient(180deg, #10161e, #0a0e14);
  border: 2px solid var(--gold);
  border-radius: 22px;
  padding: 26px 24px 24px;
  text-align: center;
  box-shadow: 0 0 44px rgba(233, 169, 60, 0.4);
  transform: translateY(14px) scale(0.94);
  transition: transform 0.24s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}
.overlay.show .popup { transform: none; }
.popup .icon { width: 116px; margin: 0 auto 6px; }
.popup h3 {
  font-family: "Knockout", "UniversCn", Arial, sans-serif;
  font-weight: 400; font-size: 27px; letter-spacing: 0.5px;
  margin: 6px 0; color: #fff;
}
.popup h3.gold { color: var(--gold); }
.popup p { color: var(--muted); font-size: 16px; line-height: 1.45; margin: 6px 0 18px; }
.popup-btns { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.popup .btn-ok {
  border: 0; cursor: pointer;
  font-family: "Knockout", Arial, sans-serif; font-size: 20px; letter-spacing: 1px;
  color: #3a2600;
  background: linear-gradient(180deg, var(--gold-light), var(--gold));
  border-radius: 999px; padding: 12px 40px;
  box-shadow: 0 6px 0 #a9781f;
}
.popup .btn-ok:active { transform: translateY(3px); box-shadow: 0 3px 0 #a9781f; }
.popup .btn-ok.btn-ghost {
  color: #f4f7fa;
  background: transparent;
  border: 2px solid rgba(233, 169, 60, 0.7);
  box-shadow: none;
}
.popup .btn-ok.btn-ghost:active { transform: translateY(2px); }

#popBody { margin: 4px 0 20px; }
.confirm-list {
  text-align: left;
  background: rgba(233, 169, 60, 0.08);
  border: 1px solid rgba(233, 169, 60, 0.35);
  border-radius: 14px;
  padding: 14px 16px;
  margin: 0;
}
.confirm-list div {
  display: flex; justify-content: space-between; gap: 14px;
  padding: 7px 0; font-size: 15px; line-height: 1.3;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.confirm-list div:last-child { border-bottom: 0; }
.confirm-list dt { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; flex: 0 0 auto; }
.confirm-list dd { margin: 0; color: #fff; font-weight: 700; text-align: right; word-break: break-word; }

.noscript-warn {
  position: fixed; inset: 0; background: #05070a; color: #fff;
  display: flex; align-items: center; justify-content: center; text-align: center;
  font-size: 18px; padding: 40px; z-index: 999;
}
