:root {
  --gold: #f9d56b;
  --cream: #fff5c8;
  --border: rgba(255, 226, 133, 0.5);
  --danger: #ffcfbf;
  --muted: rgba(255, 245, 200, 0.8);

  --art-ratio: 0.46;
  --stage-w: min(100vw, max(100vh * 0.46, 380px));
  --band-top: 32.6%;
  --band-bottom: 46%;
  --u: calc(var(--stage-w) / 100);
  --card-w: min(calc(var(--u) * 84), 360px);
  --card-pad: clamp(12px, calc(var(--u) * 3.4), 18px);
  --control-h: clamp(40px, calc(var(--u) * 10.8), 48px);
  --gap: clamp(6px, calc(var(--u) * 1.8), 10px);
}

@supports (height: 100dvh) {
  :root {
    --stage-w: min(100vw, max(100dvh * 0.46, 380px));
  }
}

@media (max-width: 600px) and (orientation: portrait) {
  :root {
    --stage-w: 100vw;
  }
}

* {
  box-sizing: border-box;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

html {
  background-color: #2a0705;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--cream);
  background-color: #2a0705;
  overflow-x: hidden;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  -webkit-tap-highlight-color: transparent;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.fixed-campaign-background {
  position: fixed;
  inset: -40px;
  z-index: 0;
  background: url("assets/master-delight-bg.png") center / cover no-repeat;
  filter: blur(28px) brightness(0.55) saturate(1.1);
  pointer-events: none;
}

.campaign-shell {
  position: relative;
  z-index: 1;
  isolation: isolate;
  width: var(--stage-w);
  aspect-ratio: 552 / 1200;
  flex-shrink: 0;
  background: url("assets/master-delight-bg.png") top center / 100% auto no-repeat;
  box-shadow: 0 0 80px rgba(0, 0, 0, 0.55);
}

.screen,
.modal {
  position: absolute;
  left: 0;
  right: 0;
  top: var(--band-top);
  bottom: var(--band-bottom);
  display: none;
  align-items: center;
  align-items: safe center;
  justify-content: center;
  padding: 0 calc(var(--u) * 4);
}

.active-screen,
.modal.show-modal {
  display: flex;
}

.modal {
  z-index: 30;
}

body.otp-open .login-card {
  visibility: hidden;
}

.glass-card {
  position: relative;
  width: var(--card-w);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--gap);
  padding: var(--card-pad);
  border: 1px solid var(--border);
  border-radius: clamp(18px, calc(var(--u) * 5.5), 26px);
  background: transparent;
  text-align: center;
}

h2 {
  margin: 0;
  font-family: "Bebas Neue", Impact, sans-serif;
  font-weight: 400;
  font-size: clamp(1.5rem, calc(var(--u) * 7.4), 2.2rem);
  line-height: 1;
  letter-spacing: 0.05em;
  color: var(--gold);
  text-shadow: 0 2px 12px rgba(40, 10, 0, 0.6);
}

.campaign-line {
  margin: 0;
  color: rgba(255, 248, 207, 0.9);
  font-size: clamp(0.76rem, calc(var(--u) * 3.3), 0.92rem);
  line-height: 1.35;
}

.campaign-message-card {
  min-height: 88px;
  align-items: center;
  justify-content: center;
  padding: clamp(18px, calc(var(--u) * 5), 26px);
  border-color: rgba(255, 226, 133, 0.72);
  background: linear-gradient(135deg, rgba(47, 13, 5, 0.92), rgba(25, 6, 2, 0.88));
  box-shadow: 0 12px 32px rgba(15, 3, 0, 0.4), inset 0 1px rgba(255, 245, 200, 0.08);
  backdrop-filter: blur(8px);
}

.campaign-status-message {
  width: 100%;
  margin: 0;
  color: var(--cream);
  font-size: clamp(1.05rem, calc(var(--u) * 4.4), 1.3rem);
  font-weight: 700;
  line-height: 1.45;
  overflow-wrap: anywhere;
  text-align: center;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}

.campaign-line strong,
.hint-text strong,
.user-pill strong {
  color: var(--gold);
}

.campaign-form {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
}

.login-card .campaign-form,
.scanner-card .campaign-form,
.modal-card .campaign-form {
  gap: 8px;
}

.login-card .hint-text {
  margin: 2px 0 0;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--control-h);
  padding: 0 14px;
  border: 1px solid rgba(255, 224, 124, 0.45);
  border-radius: 14px;
  background: rgba(25, 6, 2, 0.6);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.input-wrap:focus-within {
  border-color: rgba(255, 233, 150, 0.95);
  box-shadow: 0 0 0 3px rgba(255, 216, 98, 0.22), inset 0 1px 2px rgba(0, 0, 0, 0.35);
  background: rgba(25, 6, 2, 0.72);
}

.input-wrap span {
  flex-shrink: 0;
  padding-right: 10px;
  border-right: 1px solid rgba(255, 224, 124, 0.35);
  color: var(--gold);
  font-weight: 800;
  font-size: max(16px, calc(var(--u) * 4));
}

.input-wrap input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  padding: 0;
  color: #fff9d6;
  background: transparent;
  font-weight: 700;
  letter-spacing: 0.04em;
  font-size: max(16px, calc(var(--u) * 4));
}

.input-wrap input::placeholder {
  color: rgba(255, 247, 204, 0.5);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.input-wrap input:-webkit-autofill,
.input-wrap input:-webkit-autofill:hover,
.input-wrap input:-webkit-autofill:focus {
  -webkit-text-fill-color: #fff9d6;
  caret-color: #fff9d6;
  box-shadow: 0 0 0 1000px rgba(25, 6, 2, 0.95) inset;
  transition: background-color 9999s ease-in-out 0s;
}

.otp-wrap input,
.code-input-wrap input {
  text-align: center;
}

.otp-wrap input {
  font-size: max(20px, calc(var(--u) * 6));
  letter-spacing: 0.5em;
  text-indent: 0.5em;
}

.code-input-wrap input {
  text-transform: uppercase;
  letter-spacing: 0.25em;
}

.code-input-wrap input::placeholder {
  text-transform: none;
}

.field-error {
  min-height: 1.35em;
  margin: 0;
  color: var(--danger);
  font-size: clamp(0.7rem, calc(var(--u) * 3), 0.8rem);
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
}

.field-error:empty {
  display: none;
}

.consent-group {
  gap: 6px;
  margin-top: 2px;
}

.consent-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  color: rgba(255, 247, 204, 0.5);
  font-size: clamp(0.74rem, calc(var(--u) * 3.2), 0.86rem);
  font-weight: 500;
  line-height: 1.4;
  text-align: left;
}

.consent-check input[type="checkbox"] {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  accent-color: var(--gold);
  cursor: pointer;
}

.consent-check input[type="checkbox"]:focus-visible {
  outline: 2px solid #fff3b0;
  outline-offset: 2px;
}

.primary-btn {
  width: 100%;
  min-height: var(--control-h);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 18px;
  border: 0;
  border-radius: 999px;
  color: #3f1a04;
  font-size: max(15px, calc(var(--u) * 4.1));
  font-weight: 800;
  letter-spacing: 0.03em;
  background: linear-gradient(105deg, #fff5ae 0%, #ffd55e 45%, #e58d17 100%);
  box-shadow:
    0 10px 24px rgba(30, 8, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.primary-btn:hover:not(:disabled) {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.primary-btn:active:not(:disabled) {
  transform: translateY(1px) scale(0.99);
}

.primary-btn:disabled {
  opacity: 0.72;
  cursor: wait;
}

.primary-btn:focus-visible,
.link-btn:focus-visible,
.modal-close:focus-visible {
  outline: 2px solid #fff3b0;
  outline-offset: 3px;
}

.link-btn {
  align-self: center;
  margin-top: 6px;
  padding: 4px 8px;
  border: 0;
  background: transparent;
  color: var(--gold);
  font-size: clamp(0.78rem, calc(var(--u) * 3.3), 0.88rem);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link-btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  text-decoration: none;
}

.hint-text {
  margin: 8px 0 0;
  color: rgba(255, 248, 214, 0.72);
  font-size: clamp(0.7rem, calc(var(--u) * 3), 0.8rem);
  line-height: 1.4;
}

.user-pill {
  align-self: center;
  padding: 4px 12px;
  border: 1px solid rgba(255, 224, 124, 0.35);
  border-radius: 999px;
  background: rgba(25, 6, 2, 0.5);
  color: #fff2b8;
  font-size: clamp(0.68rem, calc(var(--u) * 2.9), 0.8rem);
  white-space: nowrap;
}

.loading-card {
  align-items: center;
  justify-content: center;
  min-height: 180px;
}

.loader-ring {
  width: 42px;
  height: 42px;
  border: 3px solid rgba(255, 234, 138, 0.2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.success-ring {
  width: clamp(38px, calc(var(--u) * 11), 52px);
  height: clamp(38px, calc(var(--u) * 11), 52px);
  display: grid;
  place-items: center;
  margin: 0 auto;
  border-radius: 50%;
  color: #4f1a02;
  background: linear-gradient(135deg, #fff6b1, #edbb42);
  font-size: clamp(1rem, calc(var(--u) * 5), 1.4rem);
  font-weight: 900;
  box-shadow: 0 10px 26px rgba(30, 8, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.reward-badge {
  width: 100%;
  padding: clamp(8px, calc(var(--u) * 2.6), 14px) 12px;
  border-radius: 16px;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.28), transparent 40%),
    linear-gradient(135deg, #fff6b8, #f1bf45 48%, #a4540d 100%);
  color: #4a1702;
  box-shadow: 0 12px 30px rgba(30, 8, 0, 0.35);
}

.reward-badge strong {
  display: block;
  font-family: "Bebas Neue", Impact, sans-serif;
  font-weight: 400;
  font-size: clamp(1.25rem, calc(var(--u) * 6.4), 1.9rem);
  line-height: 1.05;
  letter-spacing: 0.03em;
}

.mega-strip {
  margin: 0;
  padding: 8px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 234, 138, 0.3);
  background: rgba(255, 229, 107, 0.1);
  color: #fff3b8;
  font-size: clamp(0.7rem, calc(var(--u) * 3), 0.84rem);
  font-weight: 700;
  line-height: 1.35;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: transparent;
}

.modal-card {
  z-index: 1;
  gap: calc(var(--gap) * 0.8);
  padding-top: calc(var(--card-pad) + 4px);
  animation: modalPop 0.22s ease both;
}

.modal-card .campaign-form {
  gap: 8px;
  margin-top: 4px;
}

.modal-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255, 224, 124, 0.34);
  border-radius: 50%;
  background: rgba(25, 6, 2, 0.5);
  color: #fff3bd;
  font-size: 1.1rem;
  line-height: 1;
}

@keyframes modalPop {
  from { transform: translateY(10px) scale(0.98); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 40;
  width: min(calc(100% - 32px), 420px);
  transform: translate(-50%, 120px);
  opacity: 0;
  border: 1px solid rgba(255, 224, 124, 0.38);
  border-radius: 16px;
  padding: 12px 16px;
  color: #fff7cf;
  background: rgba(40, 10, 2, 0.92);
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.4);
  text-align: center;
  font-size: 0.9rem;
  font-weight: 700;
  pointer-events: none;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.toast.show-toast {
  opacity: 1;
  transform: translate(-50%, 0);
}

.reveal-up {
  animation: revealUp 0.48s ease both;
}

@keyframes revealUp {
  from { transform: translateY(14px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
