:root {
  --background: #050505;
  --text-primary: #f1eee7;
  --text-muted: rgba(241, 238, 231, 0.48);
  --glow-intensity: 0.32;
  --number-size: clamp(3.7rem, 18vw, 12rem);
  --gradient-speed: 9s;
  --grain-intensity: 0.035;
  --halo-opacity: 0.18;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--background);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow: hidden;
  background: var(--background);
  color: var(--text-primary);
  font-family: "Inter Tight", "Space Grotesk", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

[hidden] {
  display: none !important;
}

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

.ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 48%, rgba(206, 213, 226, var(--halo-opacity)) 0%, transparent 42%),
    var(--background);
}

.ambient::after {
  position: absolute;
  inset: -50%;
  content: "";
  opacity: var(--grain-intensity);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.82'/%3E%3C/svg%3E");
  animation: grain-shift 0.25s steps(2) infinite;
}

.access,
.counter {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
}

.access {
  display: grid;
  place-items: center;
  padding: max(1.5rem, env(safe-area-inset-top)) max(1.5rem, env(safe-area-inset-right)) max(1.5rem, env(safe-area-inset-bottom)) max(1.5rem, env(safe-area-inset-left));
}

.access__form {
  display: grid;
  justify-items: center;
  gap: 1rem;
  width: min(100%, 17rem);
}

.access__input {
  width: 100%;
  height: 3.15rem;
  padding: 0 1rem;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 999px;
  outline: none;
  background: rgba(255, 255, 255, 0.035);
  color: var(--text-primary);
  text-align: center;
  letter-spacing: 0.24em;
  caret-color: var(--text-primary);
  transition: border-color 220ms ease, background-color 220ms ease, box-shadow 220ms ease;
}

.access__input:focus {
  border-color: rgba(255, 255, 255, 0.34);
  background: rgba(255, 255, 255, 0.055);
  box-shadow: 0 0 2rem rgba(255, 255, 255, 0.05);
}

.access__input.is-invalid {
  border-color: rgba(205, 110, 110, 0.55);
  animation: shake 360ms ease;
}

.access__button,
.redeem-button {
  border: 0;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.access__button {
  padding: 0.65rem 1.1rem;
  color: rgba(241, 238, 231, 0.68);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  transition: color 180ms ease, transform 180ms var(--ease-out);
}

.access__button:hover,
.access__button:focus-visible {
  color: var(--text-primary);
}

.access__button:active {
  transform: scale(0.95);
}

.access__feedback {
  min-height: 1rem;
  margin: -0.25rem 0 0;
  color: rgba(205, 145, 145, 0.72);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
}

.counter {
  display: grid;
  place-items: center;
  padding: max(1.5rem, env(safe-area-inset-top)) max(1.15rem, env(safe-area-inset-right)) max(1.3rem, env(safe-area-inset-bottom)) max(1.15rem, env(safe-area-inset-left));
}

.counter__center {
  display: grid;
  justify-items: center;
  gap: clamp(1.4rem, 5vh, 2.6rem);
  width: 100%;
  transform: translateY(-1vh);
}

.counter__value {
  max-width: calc(100% - 0.18em);
  padding-inline: 0.09em;
  font-size: var(--number-size);
  font-weight: 510;
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
  line-height: 0.86;
  letter-spacing: -0.075em;
  white-space: nowrap;
  background: linear-gradient(112deg, #c7c4be 5%, #fffdf7 43%, #d4d2cc 67%, #f8f4eb 92%);
  background-size: 240% 100%;
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  filter:
    drop-shadow(0 0 calc(1.3rem * var(--glow-intensity)) rgba(255, 255, 255, 0.7))
    drop-shadow(0 1.2rem 3.8rem rgba(0, 0, 0, 0.8));
  animation: sheen var(--gradient-speed) ease-in-out infinite alternate;
  will-change: contents, transform, filter;
}

.counter__value.is-redeemed {
  animation: redeem-pulse 650ms var(--ease-out), sheen var(--gradient-speed) ease-in-out infinite alternate;
}

.redeem-button {
  min-width: 4.1rem;
  padding: 0.67rem 1.05rem;
  border: 1px solid rgba(255, 255, 255, 0.11);
  background: rgba(255, 255, 255, 0.035);
  color: rgba(241, 238, 231, 0.62);
  font-size: 0.71rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: color 180ms ease, border-color 180ms ease, background-color 180ms ease, transform 180ms var(--ease-out);
}

.redeem-button:hover,
.redeem-button:focus-visible {
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  outline: none;
}

.redeem-button:active {
  transform: scale(0.91);
}

.counter__total {
  position: absolute;
  bottom: max(1.3rem, env(safe-area-inset-bottom));
  left: 50%;
  padding: 0.55rem 0.75rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-size: clamp(0.66rem, 2.5vw, 0.78rem);
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
  letter-spacing: 0.045em;
  white-space: nowrap;
  transform: translateX(-50%);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 180ms ease, background-color 180ms ease;
}

.counter__total:hover,
.counter__total:focus-visible {
  background: rgba(255, 255, 255, 0.035);
  color: rgba(241, 238, 231, 0.72);
  outline: none;
}

.counter__version {
  position: absolute;
  right: max(0.85rem, env(safe-area-inset-right));
  bottom: max(0.85rem, env(safe-area-inset-bottom));
  color: rgba(241, 238, 231, 0.22);
  font-size: 0.58rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.045em;
  user-select: none;
}

.redeem {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-primary);
}

.redeem::backdrop {
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: backdrop-in 280ms ease;
}

.redeem__panel {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  justify-items: center;
  width: min(calc(100% - 2rem), 25rem);
  padding: 2.2rem 1.5rem 1.4rem;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 1.5rem;
  background: rgba(15, 15, 15, 0.96);
  box-shadow: 0 2rem 7rem rgba(0, 0, 0, 0.72), 0 0 4rem rgba(255, 255, 255, 0.035);
  transform: translate(-50%, -50%);
  animation: redeem-in 480ms var(--ease-out);
}

.redeem__close {
  position: absolute;
  top: 0.7rem;
  right: 0.85rem;
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
}

.redeem__eyebrow {
  margin: 0 0 1.15rem;
  color: var(--text-muted);
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.redeem__amount-wrap {
  width: 100%;
}

.redeem__amount,
.redeem__concept {
  width: 100%;
  border: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0;
  outline: 0;
  background: transparent;
  color: var(--text-primary);
  text-align: center;
}

.redeem__amount {
  padding: 0.25rem 0 0.8rem;
  font-size: clamp(2.8rem, 15vw, 5rem);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.055em;
}

.redeem__concept {
  margin-top: 1rem;
  padding: 0.75rem 0;
  font-size: 0.9rem;
}

.redeem__amount::placeholder,
.redeem__concept::placeholder {
  color: rgba(241, 238, 231, 0.22);
}

.redeem__amount:focus,
.redeem__concept:focus {
  border-bottom-color: rgba(255, 255, 255, 0.4);
}

.redeem__submit {
  margin-top: 1.4rem;
  padding: 0.7rem 1.25rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.055);
  color: rgba(241, 238, 231, 0.8);
  font-size: 0.72rem;
  cursor: pointer;
  transition: transform 180ms var(--ease-out), background-color 180ms ease;
}

.redeem__submit:active {
  transform: scale(0.93);
}

.redeem__submit:disabled {
  opacity: 0.4;
  cursor: wait;
}

.redeem__status {
  min-height: 1rem;
  margin: 0.7rem 0 -0.35rem;
  color: rgba(205, 145, 145, 0.78);
  font-size: 0.68rem;
}

.history {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-primary);
}

.history::backdrop {
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.history__panel {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  max-height: min(76vh, 42rem);
  padding: 1.35rem max(1.2rem, env(safe-area-inset-right)) max(1.3rem, env(safe-area-inset-bottom)) max(1.2rem, env(safe-area-inset-left));
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-bottom: 0;
  border-radius: 1.35rem 1.35rem 0 0;
  background: rgba(12, 12, 12, 0.96);
  box-shadow: 0 -1.5rem 5rem rgba(0, 0, 0, 0.58);
  animation: sheet-in 320ms var(--ease-out);
}

.history__header,
.history__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.history__header {
  margin-bottom: 1rem;
}

.history__title {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 550;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.history__close,
.history__delete {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.history__close {
  padding: 0.45rem;
  font-size: 0.7rem;
}

.history__list {
  display: grid;
}

.history__item {
  gap: 1rem;
  min-height: 3.65rem;
  border-top: 1px solid rgba(255, 255, 255, 0.075);
}

.history__details {
  display: grid;
  gap: 0.25rem;
  min-width: 0;
}

.history__amount {
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

.history__concept {
  overflow: hidden;
  color: rgba(241, 238, 231, 0.72);
  font-size: 0.75rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history__date {
  color: var(--text-muted);
  font-size: 0.66rem;
}

.history__delete {
  padding: 0.7rem 0;
  font-size: 0.66rem;
  transition: color 180ms ease;
}

.history__delete:hover,
.history__delete:focus-visible {
  color: rgba(224, 148, 148, 0.9);
  outline: none;
}

.history__delete:disabled {
  opacity: 0.35;
  cursor: wait;
}

.history__empty,
.history__status {
  margin: 1.5rem 0 0;
  color: var(--text-muted);
  font-size: 0.7rem;
  text-align: center;
}

.history__status {
  min-height: 1rem;
  margin-top: 0.75rem;
}

@keyframes sheet-in {
  from { opacity: 0; transform: translateY(1.5rem); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes redeem-in {
  from { opacity: 0; transform: translate(-50%, -44%) scale(0.9); filter: blur(8px); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); filter: blur(0); }
}

@keyframes sheen {
  from { background-position: 0% 50%; }
  to { background-position: 100% 50%; }
}

@keyframes grain-shift {
  0% { transform: translate3d(0, 0, 0); }
  25% { transform: translate3d(2%, -1%, 0); }
  50% { transform: translate3d(-1%, 2%, 0); }
  75% { transform: translate3d(1%, 1%, 0); }
  100% { transform: translate3d(-2%, -1%, 0); }
}

@keyframes redeem-pulse {
  0% { opacity: 1; transform: scale(1); }
  32% { opacity: 0.18; transform: scale(0.94); filter: blur(5px); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-0.28rem); }
  75% { transform: translateX(0.28rem); }
}

@media (min-width: 48rem) {
  .counter__center {
    transform: translateY(-2vh);
  }
}

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