* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  width: 100%;
  overflow-x: hidden;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: "SF Pro Rounded", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #e8e8ea;
  background-color: #0f0f11;
  min-height: 100vh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.page {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 12px 32px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.card {
  position: relative;
  aspect-ratio: 4 / 5;
  border-radius: 20px;
  background: #1d1d22;
  cursor: pointer;
  transition: transform 0.15s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 10px 8px 12px;
  overflow: hidden;
}

.card__image-wrap {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 4px 8px;
  margin-top: 4px;
}

.card__image {
  max-width: 78%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.price {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 16px;
  min-height: 34px;
  border-radius: 999px;
  background: linear-gradient(180deg, #4a3a22 0%, #3c2e1b 100%);
  box-shadow:
    0 0 0 1px rgba(180, 140, 70, 0.35) inset,
    0 0 10px rgba(180, 130, 50, 0.2),
    0 2px 6px rgba(0, 0, 0, 0.4);
  color: #ffe29a;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.1px;
  white-space: nowrap;
  font-feature-settings: "tnum" 1;
}

.price__icon {
  width: 18px;
  height: 18px;
  object-fit: contain;
  filter: drop-shadow(0 0 3px rgba(255, 200, 100, 0.6));
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.price__value {
  line-height: 1;
  position: relative;
  z-index: 1;
}

/* Sparkles — particles flying out from the center of the price pill */
.price__sparkles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: visible;
}

.spark {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  opacity: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'><defs><radialGradient id='g' cx='50%25' cy='50%25' r='50%25'><stop offset='0%25' stop-color='%23fff3b0'/><stop offset='55%25' stop-color='%23ffd76a'/><stop offset='100%25' stop-color='%23ffcc33'/></radialGradient></defs><path d='M20 0 Q21 18 24 19 Q38 20 24 21 Q21 22 20 40 Q19 22 16 21 Q2 20 16 19 Q19 18 20 0 Z' fill='url(%23g)'/></svg>");
  background-size: 100% 100%;
  background-repeat: no-repeat;
  filter: drop-shadow(0 0 2px rgba(255, 215, 106, 0.9))
          drop-shadow(0 0 5px rgba(255, 190, 70, 0.55));
  will-change: transform, opacity;
}

/* size variation for natural feel */
.spark--2,
.spark--5,
.spark--8  { width: 6px; height: 6px; margin: -3px 0 0 -3px; }
.spark--4,
.spark--9  { width: 10px; height: 10px; margin: -5px 0 0 -5px; }
.spark--7  { width: 5px; height: 5px; margin: -2.5px 0 0 -2.5px; }

/* Fly-out animations — coprime durations + irrational-ratio delays for non-repeating chaos */
.spark--1  { animation: fly-1  1.37s ease-out infinite; animation-delay: -0.83s; }
.spark--2  { animation: fly-2  2.71s ease-out infinite; animation-delay: -2.14s; }
.spark--3  { animation: fly-3  1.93s ease-out infinite; animation-delay: -0.29s; }
.spark--4  { animation: fly-4  3.11s ease-out infinite; animation-delay: -1.67s; }
.spark--5  { animation: fly-5  1.61s ease-out infinite; animation-delay: -1.12s; }
.spark--6  { animation: fly-6  2.47s ease-out infinite; animation-delay: -0.04s; }
.spark--7  { animation: fly-7  1.79s ease-out infinite; animation-delay: -1.58s; }
.spark--8  { animation: fly-8  2.89s ease-out infinite; animation-delay: -2.61s; }
.spark--9  { animation: fly-9  1.43s ease-out infinite; animation-delay: -0.97s; }
.spark--10 { animation: fly-10 2.23s ease-out infinite; animation-delay: -1.85s; }

/* Each keyframe has its own peak moment (9–38%) so sparks don't all flare at the same phase */
@keyframes fly-1 {
  0%   { opacity: 0; transform: translate(0, 0) scale(0.2) rotate(0deg); }
  18%  { opacity: 1; transform: translate(-14px, -10px) scale(1) rotate(30deg); }
  100% { opacity: 0; transform: translate(-34px, -22px) scale(0.3) rotate(120deg); }
}

@keyframes fly-2 {
  0%   { opacity: 0; transform: translate(0, 0) scale(0.2) rotate(0deg); }
  31%  { opacity: 1; transform: translate(16px, -8px) scale(0.9) rotate(-25deg); }
  100% { opacity: 0; transform: translate(38px, -20px) scale(0.3) rotate(-100deg); }
}

@keyframes fly-3 {
  0%   { opacity: 0; transform: translate(0, 0) scale(0.2) rotate(0deg); }
  12%  { opacity: 1; transform: translate(-18px, 8px) scale(1) rotate(20deg); }
  100% { opacity: 0; transform: translate(-40px, 18px) scale(0.3) rotate(90deg); }
}

@keyframes fly-4 {
  0%   { opacity: 0; transform: translate(0, 0) scale(0.2) rotate(0deg); }
  38%  { opacity: 1; transform: translate(20px, 10px) scale(1.1) rotate(-30deg); }
  100% { opacity: 0; transform: translate(42px, 22px) scale(0.3) rotate(-110deg); }
}

@keyframes fly-5 {
  0%   { opacity: 0; transform: translate(0, 0) scale(0.2) rotate(0deg); }
  22%  { opacity: 1; transform: translate(-4px, -14px) scale(0.85) rotate(40deg); }
  100% { opacity: 0; transform: translate(-10px, -32px) scale(0.3) rotate(130deg); }
}

@keyframes fly-6 {
  0%   { opacity: 0; transform: translate(0, 0) scale(0.2) rotate(0deg); }
  27%  { opacity: 1; transform: translate(6px, 14px) scale(0.9) rotate(-35deg); }
  100% { opacity: 0; transform: translate(14px, 34px) scale(0.3) rotate(-125deg); }
}

@keyframes fly-7 {
  0%   { opacity: 0; transform: translate(0, 0) scale(0.2) rotate(0deg); }
  9%   { opacity: 1; transform: translate(-22px, 2px) scale(0.95) rotate(15deg); }
  100% { opacity: 0; transform: translate(-46px, 6px) scale(0.3) rotate(80deg); }
}

@keyframes fly-8 {
  0%   { opacity: 0; transform: translate(0, 0) scale(0.2) rotate(0deg); }
  34%  { opacity: 1; transform: translate(24px, 0px) scale(1) rotate(-15deg); }
  100% { opacity: 0; transform: translate(48px, -4px) scale(0.3) rotate(-85deg); }
}

@keyframes fly-9 {
  0%   { opacity: 0; transform: translate(0, 0) scale(0.2) rotate(0deg); }
  15%  { opacity: 1; transform: translate(10px, -16px) scale(0.85) rotate(45deg); }
  100% { opacity: 0; transform: translate(22px, -36px) scale(0.3) rotate(140deg); }
}

@keyframes fly-10 {
  0%   { opacity: 0; transform: translate(0, 0) scale(0.2) rotate(0deg); }
  25%  { opacity: 1; transform: translate(-12px, 16px) scale(0.9) rotate(-45deg); }
  100% { opacity: 0; transform: translate(-26px, 36px) scale(0.3) rotate(-135deg); }
}

.card:active {
  transform: scale(0.97);
}

@media (prefers-reduced-motion: reduce) {
  .spark {
    animation: none;
    opacity: 0;
  }
}

/* ===== Modal ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 12px;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.2s ease, visibility 0s linear 0.2s;
}

.modal--open {
  visibility: visible;
  opacity: 1;
  transition: opacity 0.2s ease;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
}

.modal__panel {
  position: relative;
  width: 88%;
  max-width: 420px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  border-radius: 28px;
  background: #1c1c1e;
  padding: 18px;
}

/* Header: close icon left, title centered */
.modal__header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  margin-bottom: 14px;
}

.modal__close {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: #2c2c2e;
  color: #8e8e93;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.modal__title {
  font-size: 17px;
  font-weight: 600;
  color: #ffffff;
  margin: 0;
  text-align: center;
}

.modal__section-label {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #8e8e93;
  margin: 0 0 10px;
}

.gift-card {
  background: #0d0d0d;
  border-radius: 16px;
  padding: 18px;
  margin: 16px auto 0;
  width: 82%;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.gift-card__image {
  width: 110px;
  height: 110px;
  object-fit: contain;
  margin-bottom: 14px;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.gift-card__title {
  font-size: 16px;
  font-weight: 600;
  color: #ffffff;
  margin: 0;
}

.gift-card__desc {
  font-size: 13px;
  color: #aeaeb2;
  line-height: 1.45;
  margin: 9px 0 0;
}

.btn-secondary {
  border: 0;
  border-radius: 20px;
  background: #1c1c1e;
  color: #ffffff;
  font-size: 14px;
  height: 38px;
  padding: 0 20px;
  margin-top: 14px;
  cursor: pointer;
  font-family: inherit;
}

.input-field {
  background: #2c2c2e;
  border-radius: 22px;
  height: 42px;
  padding: 0 16px;
  margin-top: 14px;
  display: flex;
  align-items: center;
}

.input-field input {
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  outline: none;
  color: #ffffff;
  font-size: 14px;
  font-family: inherit;
}

.input-field input::placeholder {
  color: #8e8e93;
}

/* Hide-name — rounded card holds only row (title + switch); description sits below, outside */
.hide-name {
  margin-top: 14px;
  margin-bottom: 18px;
}

.hide-name__card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: #2c2c2e;
  border-radius: 999px;
  padding: 8px 16px;
  min-height: 44px;
}

.hide-name__title {
  color: #ffffff;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.2;
}

.hide-name__desc {
  color: #8e8e93;
  font-size: 13px;
  line-height: 1.4;
  margin: 10px 4px 0;
  text-align: left;
}

/* Switch — iOS style */
.switch {
  position: relative;
  display: inline-block;
  width: 76px;
  height: 30px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.switch__track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #3a3a3d;
  transition: background 0.2s ease;
}

.switch__thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 46px;
  height: 26px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s ease;
}

.switch input:checked + .switch__track {
  background: #0a84ff;
}

.switch input:checked + .switch__track .switch__thumb {
  transform: translateX(26px);
}

/* Supply progress bar: dark track + gradient fill driven by remaining % */
.supply {
  margin-top: 18px;
  margin-bottom: 18px;
}

.supply__bar {
  position: relative;
  height: 46px;
  border-radius: 23px;
  background: #2c2c2e;
  overflow: hidden;
  color: #ffffff;
  font-size: 16px;
  font-weight: 600;
}

.supply__fill {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 0;
  border-radius: 23px;
  background: linear-gradient(90deg, #2bb3f3 0%, #1e8fe1 100%);
  display: flex;
  align-items: center;
  padding-left: 18px;
  transition: width 0.3s ease;
}

.supply__left {
  line-height: 1;
  white-space: nowrap;
}

.supply__right {
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  line-height: 1;
  white-space: nowrap;
}

.supply__desc {
  color: #8e8e93;
  font-size: 13px;
  line-height: 1.5;
  margin: 11px 4px 0;
  text-align: left;
}

.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 50px;
  margin-top: 0;
  padding: 0 20px;
  border: 0;
  border-radius: 26px;
  background: #0a84ff;
  color: #ffffff;
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: filter 0.15s ease, transform 0.1s ease;
}

.btn-primary:active {
  transform: scale(0.99);
  filter: brightness(0.95);
}



@media (max-width: 360px) {
  .page {
    padding: 12px 10px 24px;
  }
  .grid {
    gap: 10px;
  }
  .price {
    font-size: 13px;
    padding: 5px 14px;
    min-height: 27px;
  }
  .price__icon {
    width: 16px;
    height: 16px;
  }
}
