:root {
  --teal-deep: #2a5560;
  --teal: #49828d;
  --teal-bright: #5dc1c0;
  --teal-glow: rgba(93, 193, 192, 0.35);
  --gold: #d4a24c;
  --gold-bright: #f0c674;
  --gold-soft: rgba(212, 162, 76, 0.15);
  --bg-deepest: #071418;
  --bg-deep: #0b1e24;
  --bg-panel: #0f2930;
  --bg-panel-lighter: #143640;
  --border: rgba(93, 193, 192, 0.12);
  --border-strong: rgba(93, 193, 192, 0.25);
  --text: #e8f4f4;
  --text-dim: #8fa8ac;
  --text-dimmer: #5a7478;
  --success: #5dc1c0;
  --warn: #f0c674;
  --err-bg: rgba(220, 70, 70, 0.1);
  --err-border: rgba(220, 70, 70, 0.4);
  --err-text: #f4a8a8;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

html, body {
  background: var(--bg-deepest);
  color: var(--text);
  font-family: 'Fraunces', Georgia, serif;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* Atmospheric background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(73, 130, 141, 0.18), transparent 60%),
    radial-gradient(ellipse 70% 50% at 85% 90%, rgba(93, 193, 192, 0.08), transparent 60%),
    radial-gradient(ellipse 60% 40% at 50% 50%, rgba(212, 162, 76, 0.04), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(93, 193, 192, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(93, 193, 192, 0.03) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
  z-index: 0;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 80%);
}

/* Main layout */
.page {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding: 40px 24px 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Brand header */
.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 32px;
  animation: fadeDown 0.7s ease-out;
}

.brand-logo-img {
  display: block;
  width: auto;
  height: auto;
  max-width: 180px;
  max-height: 100px;
  object-fit: contain;
  filter: drop-shadow(0 18px 40px rgba(0, 0, 0, 0.6));
}

.brand-fallback {
  padding: 14px 22px;
  background: linear-gradient(180deg, #0a1e26 0%, #061419 100%);
  border-top: 1px solid rgba(212, 162, 76, 0.25);
  border-bottom: 1px solid rgba(212, 162, 76, 0.25);
  border-radius: 4px;
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 20px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text);
  font-variation-settings: "opsz" 144;
}

.hero-glass-fallback {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(72px, 14vw, 110px);
  filter: drop-shadow(0 20px 30px rgba(0, 0, 0, 0.55));
  animation: heroFloat 5s ease-in-out infinite;
}

/* Shared card */
.card {
  width: 100%;
  max-width: 480px;
  background:
    linear-gradient(180deg, rgba(20, 54, 64, 0.6) 0%, rgba(15, 41, 48, 0.9) 100%);
  backdrop-filter: blur(24px);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  padding: 40px 36px;
  position: relative;
  box-shadow:
    0 1px 0 0 rgba(255, 255, 255, 0.04) inset,
    0 40px 80px -20px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(212, 162, 76, 0.04);
  animation: fadeUp 0.7s ease-out 0.1s both;
}

/* Gold corner accents */
.card::before,
.card::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border: 1px solid var(--gold);
  opacity: 0.5;
}
.card::before {
  top: 14px; left: 14px;
  border-right: none; border-bottom: none;
}
.card::after {
  bottom: 14px; right: 14px;
  border-left: none; border-top: none;
}

/* ---------- REDEEM FORM STATE ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px 7px 10px;
  background: var(--gold-soft);
  border: 1px solid rgba(212, 162, 76, 0.3);
  border-radius: 100px;
  color: var(--gold-bright);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 22px;
}
.pill svg { width: 14px; height: 14px; }

.heading {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 36px;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 12px;
  font-variation-settings: "opsz" 144;
}
.heading .italic {
  font-style: italic;
  font-weight: 400;
  color: var(--gold-bright);
}

.sub {
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 32px;
}

.field { margin-bottom: 20px; }
.field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--teal-bright);
  margin-bottom: 10px;
}
.field-label .hint {
  color: var(--text-dimmer);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: none;
  font-size: 11px;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.input-icon {
  position: absolute;
  left: 16px;
  color: var(--text-dimmer);
  pointer-events: none;
  transition: color 0.2s;
}
.input-icon svg { width: 16px; height: 16px; display: block; }

input.field-input {
  width: 100%;
  background: rgba(7, 20, 24, 0.6);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 16px 16px 44px;
  color: var(--text);
  font-family: 'Fraunces', Georgia, serif;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: all 0.25s ease;
  outline: none;
}
input.field-input::placeholder { color: var(--text-dimmer); font-weight: 400; }
input.field-input:hover { border-color: var(--border-strong); }
input.field-input:focus {
  border-color: var(--teal-bright);
  background: rgba(7, 20, 24, 0.9);
  box-shadow: 0 0 0 4px rgba(93, 193, 192, 0.1);
}
.input-wrap:focus-within .input-icon { color: var(--teal-bright); }

#coupon-input {
  font-family: 'Fraunces', serif;
  font-weight: 500;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  font-size: 16px;
}

.form-error {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--err-bg);
  border: 1px solid var(--err-border);
  color: var(--err-text);
  font-size: 13px;
  line-height: 1.45;
}

.btn-redeem {
  width: 100%;
  min-height: 52px;
  padding: 17px 24px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-bright) 100%);
  color: #051015;
  font-family: 'Fraunces', Georgia, serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.3s ease;
  box-shadow:
    0 1px 0 0 rgba(255, 255, 255, 0.3) inset,
    0 12px 30px -8px rgba(93, 193, 192, 0.5),
    0 0 0 1px rgba(212, 162, 76, 0.2);
  margin-top: 8px;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
}
.btn-redeem:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow:
    0 1px 0 0 rgba(255, 255, 255, 0.35) inset,
    0 18px 40px -8px rgba(93, 193, 192, 0.65),
    0 0 0 1px rgba(212, 162, 76, 0.3);
}
.btn-redeem:active:not(:disabled) { transform: translateY(0); }
.btn-redeem:disabled { opacity: 0.7; cursor: not-allowed; }
.btn-redeem .btn-label { position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 10px; }
.btn-redeem svg { width: 16px; height: 16px; }

.btn-redeem::before {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  transition: left 0.6s ease;
}
.btn-redeem:hover:not(:disabled)::before { left: 100%; }

.btn-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  position: relative;
  z-index: 1;
}
.btn-redeem.is-loading .btn-label { opacity: 0; }
.btn-redeem.is-loading .btn-spinner {
  display: inline-block;
  position: absolute;
  top: 50%;
  left: 50%;
  margin: -8px 0 0 -8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.footer-note {
  margin-top: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-dimmer);
  font-size: 12px;
  letter-spacing: 0.04em;
}
.footer-note svg { width: 13px; height: 13px; color: var(--teal-bright); }

/* ---------- REDEEMED STATE ---------- */
.redeemed { text-align: center; }

.ticket {
  position: relative;
  width: 240px;
  margin: 0 auto 32px;
  aspect-ratio: 16 / 9;
}
.ticket-glow {
  position: absolute;
  inset: -20%;
  background: radial-gradient(circle, var(--teal-glow) 0%, transparent 60%);
  filter: blur(20px);
  animation: pulse 3s ease-in-out infinite;
}
.ticket-svg {
  position: relative;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 15px 35px rgba(0, 0, 0, 0.5));
  animation: ticketFloat 6s ease-in-out infinite;
}
.stamp {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-12deg);
  padding: 8px 18px;
  border: 2.5px solid var(--gold-bright);
  border-radius: 6px;
  color: var(--gold-bright);
  font-family: 'Fraunces', serif;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  background: rgba(7, 20, 24, 0.4);
  backdrop-filter: blur(2px);
  opacity: 0.95;
  z-index: 2;
  animation: stampIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.3s both;
}
.stamp::before,
.stamp::after {
  content: '';
  position: absolute;
  background: var(--gold-bright);
  width: 6px; height: 6px;
  border-radius: 50%;
}
.stamp::before { top: -3px; left: -3px; }
.stamp::after { bottom: -3px; right: -3px; }

.redeemed .heading { text-align: center; }
.redeemed .sub { text-align: center; max-width: 360px; margin-left: auto; margin-right: auto; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  background: rgba(240, 198, 116, 0.08);
  border: 1px solid rgba(240, 198, 116, 0.3);
  border-radius: 100px;
  color: var(--gold-bright);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 8px auto 32px;
}
.status-pill svg { width: 14px; height: 14px; }
.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--gold-bright);
  box-shadow: 0 0 10px var(--gold-bright);
}

.divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 8px 0 24px;
  color: var(--text-dimmer);
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 12px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
}
.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-strong), transparent);
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.action {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  min-height: 56px;
  background: rgba(7, 20, 24, 0.5);
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
  text-align: left;
  touch-action: manipulation;
}
.action:active { transform: scale(0.98); }
.action:hover {
  border-color: var(--teal-bright);
  background: rgba(20, 54, 64, 0.6);
  transform: translateX(2px);
}
.action-icon {
  width: 42px; height: 42px;
  flex-shrink: 0;
  border-radius: 11px;
  background: linear-gradient(135deg, rgba(73, 130, 141, 0.4), rgba(93, 193, 192, 0.2));
  border: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--teal-bright);
  transition: all 0.25s ease;
}
.action-icon svg { width: 18px; height: 18px; }
.action:hover .action-icon {
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-bright) 100%);
  color: #051015;
  border-color: var(--gold);
}
.action-text { flex: 1; }
.action-title {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  margin-bottom: 2px;
  letter-spacing: 0.01em;
}
.action-sub {
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}
.action-arrow {
  color: var(--text-dimmer);
  transition: all 0.25s ease;
}
.action-arrow svg { width: 16px; height: 16px; display: block; }
.action:hover .action-arrow {
  color: var(--gold-bright);
  transform: translateX(4px);
}

/* ---------- SUCCESS STATE ---------- */
.success { text-align: center; position: relative; }

/* Confetti canvas sits behind card content but within the card */
.confetti {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  border-radius: inherit;
  z-index: 0;
}
.confetti span {
  position: absolute;
  top: -20px;
  width: 8px;
  height: 14px;
  opacity: 0;
  animation: confettiFall linear forwards;
  will-change: transform, opacity;
}
.confetti span:nth-child(odd) { border-radius: 50%; width: 7px; height: 7px; }
.confetti span:nth-child(4n) { width: 4px; height: 12px; border-radius: 2px; }

@keyframes confettiFall {
  0%   { transform: translate3d(0, 0, 0) rotate(0deg); opacity: 0; }
  10%  { opacity: 1; }
  100% { transform: translate3d(var(--drift, 20px), 700px, 0) rotate(720deg); opacity: 0; }
}

/* Margarita hero */
.hero-glass {
  position: relative;
  width: 160px;
  height: 180px;
  margin: 4px auto 24px;
  z-index: 1;
}
.hero-halo {
  position: absolute;
  inset: -30%;
  background: radial-gradient(circle, rgba(93, 193, 192, 0.28) 0%, transparent 65%);
  filter: blur(24px);
  animation: haloPulse 3s ease-in-out infinite;
}
.hero-glass-img {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 20px 30px rgba(0, 0, 0, 0.55));
  animation: heroFloat 5s ease-in-out infinite;
}
@keyframes haloPulse {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50%      { opacity: 1;   transform: scale(1.12); }
}
@keyframes heroFloat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

/* Success pill (teal) */
.success-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 11px 20px;
  background: linear-gradient(135deg, rgba(93, 193, 192, 0.18), rgba(73, 130, 141, 0.12));
  border: 1px solid rgba(93, 193, 192, 0.45);
  border-radius: 100px;
  color: var(--teal-bright);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin: 6px auto 28px;
  position: relative;
  z-index: 1;
  box-shadow: 0 8px 24px -10px rgba(93, 193, 192, 0.45);
}
.success-pill .check-circle {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--teal-bright);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #051015;
  animation: checkPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s both;
}
.success-pill .check-circle svg { width: 11px; height: 11px; }
@keyframes checkPop {
  0%   { transform: scale(0); }
  100% { transform: scale(1); }
}

/* Reveal code chip on success */
.code-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 8px 12px;
  margin: 0 auto 20px;
  background: rgba(7, 20, 24, 0.6);
  border: 1px dashed rgba(212, 162, 76, 0.5);
  border-radius: 100px;
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.25em;
  color: var(--gold-bright);
  position: relative;
  z-index: 1;
}
.code-chip .code-label {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dimmer);
  padding-right: 10px;
  border-right: 1px solid var(--border-strong);
}

.success .heading,
.success .sub,
.success .actions,
.success .divider,
.success .footer-note { position: relative; z-index: 1; }

.view { display: none; }
.view.active { display: block; animation: fadeUp 0.5s ease-out; }

/* Animations */
@keyframes fadeDown {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 0.8; transform: scale(1.08); }
}
@keyframes ticketFloat {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-6px) rotate(-3deg); }
}
@keyframes stampIn {
  from { opacity: 0; transform: translate(-50%, -50%) rotate(-12deg) scale(2); }
  to { opacity: 0.95; transform: translate(-50%, -50%) rotate(-12deg) scale(1); }
}

/* ===================== MOBILE ===================== */
@media (max-width: 640px) {
  .page { padding: 40px 14px 48px; }
  .brand { margin-bottom: 28px; gap: 8px; }
  .brand-logo-img { max-width: 150px; max-height: 85px; }

  .card { padding: 30px 22px; border-radius: 18px; }
  .card::before, .card::after { width: 12px; height: 12px; }

  .pill { font-size: 10px; padding: 6px 12px 6px 9px; margin-bottom: 18px; }
  .heading { font-size: 28px; line-height: 1.08; }
  .sub { font-size: 13.5px; margin-bottom: 26px; }

  .field { margin-bottom: 16px; }
  .field-label { font-size: 10px; }
  .field-label .hint { font-size: 10px; }
  input.field-input { font-size: 16px; padding: 14px 14px 14px 42px; }
  #coupon-input { font-size: 15px; letter-spacing: 0.28em; }

  .btn-redeem { padding: 16px 20px; font-size: 13px; letter-spacing: 0.12em; }

  .ticket { width: 210px; margin-bottom: 26px; }
  .stamp { font-size: 14px; padding: 6px 14px; letter-spacing: 0.18em; }
  .status-pill { font-size: 11px; padding: 9px 14px; margin-bottom: 26px; }
  .divider { font-size: 11px; letter-spacing: 0.22em; margin: 6px 0 20px; }

  .hero-glass { width: 120px; height: 140px; margin-bottom: 16px; }
  .success-pill { font-size: 11px; padding: 10px 16px; margin-bottom: 24px; }
  .code-chip { font-size: 12px; padding: 7px 12px 7px 10px; }
  .code-chip .code-label { font-size: 9px; }

  .action { padding: 14px 14px; gap: 12px; border-radius: 12px; }
  .action-icon { width: 38px; height: 38px; border-radius: 10px; }
  .action-icon svg { width: 16px; height: 16px; }
  .action-title { font-size: 14px; }
  .action-sub { font-size: 11.5px; line-height: 1.4; }

  .footer-note { font-size: 11px; margin-top: 22px; }
}

@media (max-width: 380px) {
  .page { padding: 36px 12px 40px; }
  .card { padding: 26px 18px; }
  .heading { font-size: 24px; }
  .sub { font-size: 13px; }
  .ticket { width: 190px; }
  .hero-glass { width: 108px; height: 124px; }
  .brand-logo-img { max-width: 130px; max-height: 75px; }
  .action-sub { font-size: 11px; }
}

@media (max-height: 680px) and (min-width: 641px) {
  .page { padding: 28px 24px 40px; }
  .brand { margin-bottom: 24px; }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .ticket-svg, .ticket-glow, .hero-glass-img, .hero-halo { animation: none; }
}
