@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@500;700&display=swap');

:root {
  --bg: #0A0A0C;
  --bg-soft: #0F0E12;
  --surface: #16151B;
  --surface-2: #1E1D24;
  --border: #2A2830;
  --pink: #FF008A;
  --pink-deep: #B4005F;
  --pink-glow: rgba(255, 0, 138, 0.35);
  --text: #F5F3F0;
  --text-muted: #948F9A;
  --text-faint: #5C5964;
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

body {
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(255,0,138,0.12), transparent 60%),
    var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 20px 20px calc(28px + env(safe-area-inset-bottom));
}

/* ---------- Header ---------- */
.brand-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 4px 24px;
}
.brand-header img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--border);
}
.brand-header .brand-name {
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  font-size: 19px;
  letter-spacing: 0.2px;
  line-height: 1.05;
}
.brand-header .brand-name span {
  display: block;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.3px;
  margin-top: 2px;
}

/* ---------- Screens ---------- */
.screen {
  flex: 1;
  display: none;
  flex-direction: column;
  animation: rise 0.35s ease both;
}
.screen.active { display: flex; }

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

/* ---------- Onboarding ---------- */
.hero-copy h1 {
  font-family: 'Fredoka', sans-serif;
  font-size: 30px;
  line-height: 1.15;
  margin: 4px 0 10px;
}
.hero-copy h1 em {
  font-style: normal;
  color: var(--pink);
}
.hero-copy p {
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.55;
  margin: 0 0 28px;
}

.field {
  margin-bottom: 14px;
}
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 8px;
}
.field input {
  width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--text);
  font-size: 16px;
  font-family: 'Inter', sans-serif;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  outline: none;
  transition: border-color 0.15s ease;
}
.field input::placeholder { color: var(--text-faint); }
.field input:focus { border-color: var(--pink); }

.btn {
  border: none;
  border-radius: 999px;
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 15px;
  padding: 16px 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.12s ease, opacity 0.15s ease, box-shadow 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(135deg, var(--pink), var(--pink-deep));
  color: #fff;
  box-shadow: 0 8px 24px -8px var(--pink-glow);
}
.btn-primary:disabled {
  opacity: 0.35;
  box-shadow: none;
  cursor: not-allowed;
}
.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
}
.btn-block { width: 100%; }

.legal-note {
  color: var(--text-faint);
  font-size: 12px;
  text-align: center;
  margin-top: 16px;
  line-height: 1.5;
}

.greeting {
  font-family: 'Fredoka', sans-serif;
  font-size: 15px;
  color: var(--text-muted);
  margin: 0 2px 14px;
}
.greeting strong { color: var(--text); font-weight: 600; }

/* ---------- Card screen ---------- */
.card-wrap { flex: 1; display: flex; flex-direction: column; }

.balance-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 24px 26px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.balance-card::before {
  content: '';
  position: absolute;
  inset: -40% -20% auto -20%;
  height: 70%;
  background: radial-gradient(circle, var(--pink-glow), transparent 70%);
  filter: blur(10px);
  pointer-events: none;
}

.ring-wrap {
  position: relative;
  width: 208px;
  height: 208px;
  margin: 4px auto 22px;
}
.ring-wrap svg { transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--surface-2); stroke-width: 12; }
.ring-fill {
  fill: none;
  stroke: url(#ringGradient);
  stroke-width: 12;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s cubic-bezier(.4,0,.2,1);
}
.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.ring-center .amount {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 40px;
  letter-spacing: -0.5px;
}
.ring-center .amount .cents { font-size: 22px; color: var(--text-muted); }
.ring-center .label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 4px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
}
.status-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--pink); }

.card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 22px;
}
.card-actions .btn { padding: 15px 12px; font-size: 14px; }

.section-title {
  font-family: 'Fredoka', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin: 28px 0 12px 2px;
}

.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  font-size: 13.5px;
}
.history-item .meta { color: var(--text-muted); }
.history-item .val { font-family: 'JetBrains Mono', monospace; font-weight: 700; color: var(--pink); }

/* ---------- Scanner ---------- */
.scanner-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 50;
  display: none;
  flex-direction: column;
}
.scanner-overlay.active { display: flex; }
.scanner-overlay video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.scan-frame {
  position: absolute;
  top: 50%; left: 50%;
  width: 240px; height: 240px;
  transform: translate(-50%, -50%);
  border: 3px solid var(--pink);
  border-radius: 24px;
  box-shadow: 0 0 0 2000px rgba(0,0,0,0.55);
}
.scanner-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  padding: 20px;
  padding-top: calc(20px + env(safe-area-inset-top));
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 2;
}
.scanner-top .close-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}
.scanner-hint {
  position: absolute;
  bottom: calc(48px + env(safe-area-inset-bottom));
  left: 0; right: 0;
  text-align: center;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  z-index: 2;
}

/* ---------- Redeem Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 60;
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal-sheet {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 24px 24px 0 0;
  padding: 12px 22px calc(24px + env(safe-area-inset-bottom));
  animation: sheetUp 0.3s cubic-bezier(.4,0,.2,1);
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-handle {
  width: 40px; height: 4px;
  background: var(--border);
  border-radius: 999px;
  margin: 6px auto 16px;
}
.modal-sheet h2 {
  font-family: 'Fredoka', sans-serif;
  font-size: 20px;
  margin: 0 0 4px;
}
.modal-sub {
  color: var(--text-muted);
  font-size: 13.5px;
  margin: 0 0 18px;
}
.choice-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 6px;
}
.choice-btn {
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 12px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.choice-btn.selected {
  border-color: var(--pink);
  background: rgba(255,0,138,0.10);
}
.choice-title { font-weight: 700; font-size: 14.5px; color: var(--text); }
.choice-desc { font-size: 11.5px; color: var(--text-muted); }

.address-fields { margin-top: 16px; }
.address-fields .field-row {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 10px;
}
.address-fields .field-row .field { margin-bottom: 0; }

#btn-redeem-submit { margin-top: 18px; }
#btn-redeem-cancel { margin-top: 10px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 20px; right: 20px;
  bottom: calc(24px + env(safe-area-inset-bottom));
  max-width: 440px;
  margin: 0 auto;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  transform: translateY(140%);
  transition: transform 0.3s cubic-bezier(.4,0,.2,1);
  z-index: 100;
  box-shadow: 0 12px 30px -10px rgba(0,0,0,0.6);
}
.toast.show { transform: translateY(0); }
.toast .icon {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.toast.success .icon { background: rgba(255,0,138,0.18); color: var(--pink); }
.toast.error .icon { background: rgba(255,255,255,0.08); color: var(--text-muted); }
.toast .msg { font-size: 13.5px; line-height: 1.4; color: var(--text); }

.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  .screen, .toast, .ring-fill { animation: none !important; transition: none !important; }
}
