:root {
  --bg: #0E0F13;
  --card: #232323;
  --card-2: #1b1c20;
  --line: rgba(255, 255, 255, .85);
  --text: #fff;
  --muted: #9a9ca5;
  --yellow: #FFCC00;
  --gold-1: #E5A924;
  --gold-2: #FFF1A8;
  --gold-3: #D48E16;
  --green: #22c55e;
  --font: "Montserrat", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-weight: 400;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
[hidden] { display: none !important; }

.app {
  position: relative;
  max-width: 430px;
  min-height: 100vh;
  margin: 0 auto;
  background: linear-gradient(180deg, #17171c 0%, #1f1f1f 40%, #232323 100%);
  overflow-x: hidden;
}
.app--wall { padding-bottom: 120px; }

/* Header */
.hero {
  position: relative;
  min-height: 232px;
  padding: 28px 20px 24px;
  background: linear-gradient(135deg, #1a1a2c 0%, #13131c 55%, #0E0F13 100%);
  overflow: hidden;
}
.hero__eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--yellow);
}
.hero__title {
  margin-top: 14px;
  max-width: 260px;
  font-size: 28px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -.01em;
}
.hero__subtitle {
  margin-top: 24px;
  max-width: 170px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
}
.hero__bird {
  position: absolute;
  right: 6px;
  bottom: 0;
  width: 150px;
  height: auto;
  pointer-events: none;
  filter: drop-shadow(0 0 22px rgba(255, 204, 0, .35));
}

.content { padding: 12px 16px 24px; }

/* Ticker */
.ticker {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.ticker__badge {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--green);
  font-size: 10px;
  font-weight: 700;
}
.ticker__badge::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #fff;
}
.ticker__viewport {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  mask-image: linear-gradient(90deg, transparent 0, #000 10%, #000 90%, transparent 100%);
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 10%, #000 90%, transparent 100%);
}
.ticker__track {
  display: inline-flex;
  width: max-content;
  min-height: 1em;
  will-change: transform;
}
.ticker__track.is-running { animation: marquee 60s linear infinite; }
.ticker__item {
  padding-right: 28px;
  font-size: 11px;
  color: #B8BDC9;
}
.ticker__item--vip { color: #F5C95B; font-weight: 700; }
@keyframes marquee {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* Form card */
.card {
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card);
}
.card__to { font-size: 14px; font-weight: 700; }
.field { margin-top: 18px; }
.field__label {
  display: block;
  margin-bottom: 10px;
  font-size: 17px;
  color: #d8d9de;
}
.field__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.field__row .field__label { margin: 0; }
.input, .textarea {
  width: 100%;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: transparent;
  font-size: 16px;
  outline: none;
}
.input::placeholder, .textarea::placeholder { color: #6e7079; }
.input:focus, .textarea:focus { border-color: var(--yellow); box-shadow: 0 0 0 2px rgba(255, 204, 0, .2); }
.textarea { display: block; height: 116px; resize: none; }
.field__tools {
  display: flex;
  align-items: center;
  gap: 10px;
}
.counter { font-size: 12px; color: var(--muted); }
.btn-rofl {
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.btn-rofl:active { transform: scale(.96); }
.btn-rofl:disabled { opacity: .4; cursor: not-allowed; }
.btn-rofl:disabled:active { transform: none; }

/* VIP toggle */
.vip {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 14px 16px;
  border: 3px solid var(--yellow);
  border-radius: 18px;
  background: #1c1c1c;
  cursor: pointer;
  transition: box-shadow .25s, background .25s, border-color .25s;
}
.vip__input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.vip__box {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border: 1px solid var(--yellow);
  border-radius: 6px;
  color: var(--yellow);
  font-size: 24px;
  line-height: 1;
}
.vip__box::after { content: "✓"; opacity: 0; transition: opacity .2s; }
.vip__text { position: relative; flex: 1; min-width: 0; text-align: center; padding-right: 38px; }
.vip__title {
  display: block;
  font-size: clamp(14px, 4.2vw, 17px);
  font-weight: 800;
  color: var(--yellow);
}
.vip__sub {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  font-weight: 700;
  color: #6b6b6b;
}
.vip.is-active {
  border-color: #FFD83A;
  background: linear-gradient(180deg, #2a2208, #1c1c1c);
  box-shadow: 0 0 22px rgba(255, 204, 0, .45), inset 0 0 18px rgba(255, 204, 0, .12);
}
.vip.is-active .vip__box::after { opacity: 1; }
.vip.is-active .vip__sub { color: #b9a35a; }
.vip__mascot {
  position: absolute;
  right: -10px;
  bottom: -18px;
  width: 96px;
  height: auto;
  pointer-events: none;
  z-index: 2;
}

/* Pay */
.btn-pay {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 14px 10px;
  border-radius: 18px;
  background: var(--yellow);
  color: #111;
  font-size: 28px;
  font-weight: 800;
  box-shadow: 0 0 26px rgba(255, 204, 0, .5);
  transition: transform .1s, box-shadow .2s;
}
.btn-pay:active { transform: scale(.98); }
.btn-pay:disabled { opacity: .6; cursor: not-allowed; }
.btn-pay--stars {
  margin-top: 10px;
  font-size: 20px;
  background: var(--card-2);
  color: var(--yellow);
  border: 2px solid var(--yellow);
  box-shadow: none;
}
.pay-note {
  margin-top: 16px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}
.btn-wall {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  font-size: 14px;
}
.btn-wall__count { color: var(--yellow); font-size: 14px; }

/* Wall */
.search {
  position: relative;
  margin-top: 4px;
}
.search__input {
  width: 100%;
  padding: 15px 48px 15px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  font-size: 14px;
  outline: none;
}
.search__input::placeholder { color: #8b8d96; }
.search__input:focus { border-color: var(--yellow); }
.search__icon {
  position: absolute;
  right: 16px; top: 50%;
  width: 20px; height: 20px;
  transform: translateY(-50%);
  pointer-events: none;
}
.filters {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
.filter {
  flex: 1 1 auto;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.filter.is-active {
  background: var(--yellow);
  border-color: var(--yellow);
  color: #111;
}
.wishes {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 14px;
  list-style: none;
}
.wish {
  position: relative;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
}
.wish__head {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.wish__user {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  font-weight: 700;
}
.wish__time { flex: none; white-space: nowrap; font-size: 14px; color: var(--muted); }
.wish__time::before { content: "•"; margin-right: 4px; }
.wish__vip { display: none; }
.wish__num {
  flex-shrink: 0;
  white-space: nowrap;
  margin-left: auto;
  font-size: 15px;
  font-weight: 700;
  color: var(--yellow);
}
.wish__text {
  margin-top: 8px;
  padding-right: 4px;
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.wish__actions { display: flex; justify-content: flex-end; margin-top: 8px; }
.btn-cert {
  padding: 12px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
}

.wish--vip {
  border-color: #ffe27a;
  background: linear-gradient(115deg, var(--gold-1) 0%, var(--gold-2) 50%, var(--gold-3) 100%);
  color: #1a1204;
  box-shadow: 0 0 26px rgba(229, 169, 36, .45);
}
.wish--vip .wish__time { color: rgba(26, 18, 4, .7); }
.wish--vip .wish__num { color: #1a1204; }
.wish--vip .wish__vip {
  display: inline-block;
  flex-shrink: 0;
  white-space: nowrap;
  padding: 3px 8px;
  margin-left: auto;
  margin-right: 10px;
  border-radius: 8px;
  background: #1c1c22;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}
.wish--vip .wish__num { margin-left: 0; }
.wish--vip .btn-cert {
  border: 0;
  background: linear-gradient(115deg, var(--gold-3), #f3c24a, var(--gold-1));
  color: #1a1204;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .3);
}

.load-more { display: flex; justify-content: center; margin-top: 16px; }
.btn-more {
  padding: 12px 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
}
.empty { margin-top: 24px; text-align: center; color: var(--muted); }

/* Bottom bar */
.bottom-bar {
  position: fixed;
  left: 50%; bottom: 0;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 430px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(14, 15, 19, 0), rgba(14, 15, 19, .95) 35%);
  z-index: 20;
}
.btn-back {
  flex: none;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #1c1c1c;
  font-size: 15px;
  font-weight: 600;
}
.btn-write {
  flex: 1;
  min-width: 0;
  padding: 14px 12px;
  border-radius: 14px;
  background: var(--yellow);
  color: #111;
  font-size: clamp(14px, 4.6vw, 18px);
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  text-wrap: balance;
  box-shadow: 0 4px 16px rgba(255, 204, 0, .3);
}
.btn-write:active { transform: scale(.98); }
.bottom-bar__mascot {
  position: absolute;
  right: 8px;
  bottom: calc(100% - 26px);
  width: 104px;
  height: auto;
  pointer-events: none;
}

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, .78);
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s, visibility .2s;
}
.modal.is-open { opacity: 1; visibility: visible; }
.modal__dialog {
  width: 100%;
  max-width: 390px;
  max-height: 100%;
  overflow: auto;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, .25);
  border-radius: 20px;
  background: var(--card-2);
  transform: translateY(12px) scale(.97);
  transition: transform .2s;
}
.modal.is-open .modal__dialog { transform: none; }
.modal__preview {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
  background: #111;
}
.modal__actions { display: flex; gap: 10px; margin-top: 14px; }
.modal__btn {
  flex: 1;
  padding: 13px 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  text-align: center;
  font-size: 15px;
  font-weight: 700;
}
.modal__btn--primary { border-color: var(--yellow); background: var(--yellow); color: #111; }
.modal__dialog--center { text-align: center; padding: 28px 20px; }
.modal__title { font-size: 18px; font-weight: 800; }
.modal__text { margin-top: 8px; font-size: 13px; color: var(--muted); line-height: 1.4; }
.spinner {
  width: 44px; height: 44px;
  margin: 0 auto 16px;
  border: 4px solid rgba(255, 255, 255, .15);
  border-top-color: var(--yellow);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

body.is-modal-open { overflow: hidden; }

/* Tilt + блик превью сертификата */
.modal__actions--second { margin-top: 10px; }
.modal__btn--ghost { background: rgba(255, 255, 255, .06); }
.cert-tilt {
  --mx: .5; --my: .5; --rx: 0; --ry: 0; --glare: 0;
  perspective: 900px;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.cert-tilt__card {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  transform: rotateX(calc(var(--rx) * 1deg)) rotateY(calc(var(--ry) * 1deg));
  transition: transform .4s ease-out, box-shadow .4s ease-out;
  box-shadow: calc(var(--ry) * -1px) calc(var(--rx) * 1px + 6px) 24px rgba(0, 0, 0, .45);
  will-change: transform;
}
.cert-tilt.is-tilting .cert-tilt__card { transition: transform .08s linear, box-shadow .08s linear; }
.cert-tilt__glare,
.cert-tilt__shine {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
}
.cert-tilt__glare {
  background: radial-gradient(circle at calc(var(--mx) * 100%) calc(var(--my) * 100%),
    rgba(255, 255, 255, .5) 0%, rgba(255, 255, 255, .12) 35%, rgba(255, 255, 255, 0) 60%);
  opacity: var(--glare);
  transition: opacity .3s;
  mix-blend-mode: soft-light;
}
.cert-tilt__shine { display: none; }
.cert-tilt.is-vip .cert-tilt__shine {
  display: block;
  background:
    linear-gradient(110deg,
      rgba(255, 215, 0, 0) 10%, rgba(255, 215, 0, .55) 26%, rgba(255, 90, 170, .4) 38%,
      rgba(70, 230, 255, .45) 50%, rgba(140, 110, 255, .4) 62%, rgba(255, 215, 0, .55) 76%,
      rgba(255, 215, 0, 0) 90%);
  background-size: 260% 260%;
  background-position: calc(var(--mx) * 100%) calc(var(--my) * 100%);
  mix-blend-mode: color-dodge;
  opacity: calc(.18 + var(--glare) * .5);
  transition: opacity .3s;
}
.cert-tilt.is-vip .cert-tilt__glare {
  mix-blend-mode: overlay;
  background: radial-gradient(circle at calc(var(--mx) * 100%) calc(var(--my) * 100%),
    rgba(255, 246, 214, .85) 0%, rgba(255, 220, 120, .25) 35%, rgba(255, 220, 120, 0) 62%);
}

/* Конфетти и тост */
.confetti-canvas {
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  z-index: 300;
  max-width: calc(100% - 40px);
  padding: 12px 18px;
  border-radius: 999px;
  background: rgba(28, 28, 34, .96);
  border: 1px solid rgba(255, 255, 255, .25);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity .2s, transform .2s;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* Скелетоны (shimmer) */
.wish--skeleton { pointer-events: none; }
.sk {
  border-radius: 8px;
  background: linear-gradient(100deg, rgba(255, 255, 255, .06) 30%, rgba(255, 255, 255, .16) 50%, rgba(255, 255, 255, .06) 70%);
  background-size: 250% 100%;
  animation: shimmer 1.3s linear infinite;
}
.sk--head { width: 60%; height: 18px; }
.sk--line { width: 100%; height: 13px; margin-top: 12px; }
.sk--short { width: 70%; }
.sk--btn { width: 130px; height: 42px; margin: 14px 0 0 auto; border-radius: 14px; }
@keyframes shimmer { from { background-position: 125% 0; } to { background-position: -125% 0; } }

@media (prefers-reduced-motion: reduce) {
  .ticker__track, .spinner { animation-duration: 60s; }
  .sk { animation: none; }
  .cert-tilt__card, .toast { transition: none; }
}
