/* Единая дизайн-система Mini App ЦСП АРТ с 5 визуальными ступенями (data-tier="0..4"). */
:root {
  --bg: #0f1e3b;
  --bg-glow: radial-gradient(110% 45% at 50% 0%, #162b52 0%, #0f1e3b 55%, #0c1831 100%);
  --card: rgba(20, 38, 74, 0.88);
  --card-hero: linear-gradient(145deg, #18305e 0%, #122447 100%);
  --line: rgba(169, 180, 204, 0.17);
  --hero-line: rgba(169, 180, 204, 0.28);
  --hero-shadow: 0 10px 26px rgba(5, 11, 25, 0.32);
  --ink: #f3efe6;
  --soft: #a4b1cb;
  --gold: #d9b978;
  --gold-bright: #ecd49d;
  --gold-deep: #9c7426;
  --cream: #fff6dc;
  --ok: #72d9a5;
  --warn: #e57373;
  --avatar-ring: rgba(169, 180, 204, 0.35);
  --avatar-glow: none;
  --display: 'Playfair Display', Georgia, serif;
  --body: 'Inter', system-ui, -apple-system, sans-serif;
}

/* Ступень 1 («Участник»): мягкое золотое окаймление и тепло на акцентах */
body[data-tier="1"] {
  --bg-glow: radial-gradient(115% 50% at 50% 0%, #19315e 0%, #0f1e3b 52%, #0c172e 100%);
  --hero-line: rgba(217, 185, 120, 0.38);
  --avatar-ring: rgba(217, 185, 120, 0.6);
}

/* Ступень 2 («Практик»): сапфировый градиент и стеклянная глубина */
body[data-tier="2"] {
  --bg-glow: radial-gradient(120% 55% at 50% 0%, #1d386b 0%, #0f1e3b 48%, #0b162d 100%);
  --card-hero: linear-gradient(135deg, #21407a 0%, #142954 55%, #0f1e3b 100%);
  --line: rgba(217, 185, 120, 0.16);
  --hero-line: rgba(217, 185, 120, 0.5);
  --hero-shadow: 0 14px 32px rgba(4, 10, 24, 0.42);
  --avatar-ring: #d9b978;
  --avatar-glow: 0 0 0 4px rgba(217, 185, 120, 0.15);
}

/* Ступень 3 («Мастер»): благородный бархатный индиго и золотой ореол */
body[data-tier="3"] {
  --bg-glow: radial-gradient(125% 58% at 50% 0%, rgba(217, 185, 120, 0.14) 0%, #152b57 30%, #0b162c 100%);
  --card: rgba(18, 35, 68, 0.9);
  --card-hero: linear-gradient(135deg, #223f77 0%, #13254b 50%, #1b325f 100%);
  --line: rgba(217, 185, 120, 0.22);
  --hero-line: rgba(236, 212, 157, 0.58);
  --hero-shadow: 0 16px 38px rgba(4, 9, 22, 0.5), 0 0 24px rgba(217, 185, 120, 0.1);
  --avatar-ring: #ecd49d;
  --avatar-glow: 0 0 0 4px rgba(217, 185, 120, 0.22), 0 0 16px rgba(217, 185, 120, 0.22);
}

/* Ступень 4 («Резидент АРТ»): коллекционный обсидиан и шампань-золото */
body[data-tier="4"] {
  --bg: #091326;
  --bg-glow: radial-gradient(130% 60% at 50% 0%, rgba(236, 212, 157, 0.18) 0%, #112346 32%, #081122 100%);
  --card: rgba(14, 28, 55, 0.92);
  --card-hero: linear-gradient(135deg, #1d3564 0%, #0d1a35 50%, #1e3766 100%);
  --line: rgba(236, 212, 157, 0.25);
  --hero-line: rgba(236, 212, 157, 0.72);
  --hero-shadow: 0 18px 44px rgba(2, 6, 15, 0.65), 0 0 32px rgba(217, 185, 120, 0.16);
  --gold: #ebd39a;
  --avatar-ring: #f2dfb1;
  --avatar-glow: 0 0 0 4px rgba(235, 211, 154, 0.28), 0 0 22px rgba(235, 211, 154, 0.3);
}

/* Ключевой партнёр АРТ: коллекционный графит, платина и мягкое золотое свечение */
body[data-partner="key_partner"] {
  --bg: #070b14;
  --bg-glow: radial-gradient(125% 58% at 50% 0%, rgba(236, 212, 157, 0.22) 0%, #141c30 34%, #060912 100%);
  --card: rgba(15, 21, 36, 0.92);
  --card-hero: linear-gradient(135deg, #212a40 0%, #0d1322 52%, #1d263b 100%);
  --line: rgba(226, 210, 174, 0.28);
  --hero-line: rgba(242, 223, 177, 0.78);
  --hero-shadow: 0 20px 48px rgba(0, 0, 0, 0.72), 0 0 36px rgba(235, 211, 154, 0.2);
  --gold: #f1dca6;
  --gold-bright: #faebc2;
  --avatar-ring: #faebc2;
  --avatar-glow: 0 0 0 4px rgba(241, 220, 166, 0.3), 0 0 26px rgba(241, 220, 166, 0.36);
}

body[data-partner="key_partner"] .card.hero::after {
  content: "";
  position: absolute;
  inset: -40% -80%;
  background: linear-gradient(115deg, transparent 42%, rgba(250, 235, 194, 0.14) 50%, transparent 58%);
  animation: shimmer 6.5s infinite linear;
  pointer-events: none;
}

.pill.partner {
  background: linear-gradient(135deg, rgba(241, 220, 166, 0.25), rgba(169, 180, 204, 0.16));
  color: var(--gold-bright);
  border: 1px solid rgba(241, 220, 166, 0.55);
}

.round-hdr {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold);
  margin: 14px 0 8px;
}

.game-table-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 10px;
}
.game-table-card.mine {
  border-color: var(--gold);
  background: rgba(217, 185, 120, 0.1);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  background-image: var(--bg-glow);
  background-attachment: fixed;
  color: var(--ink);
  font: 15px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
  transition: background 0.4s ease;
}
a { color: var(--gold); text-decoration: none; }

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(12, 24, 49, 0.8);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 6;
}
.brand { display: flex; flex-direction: column; line-height: 1.1; }
.brand__mark { font-family: var(--display); font-size: 22px; font-weight: 700; color: var(--gold); letter-spacing: 2.2px; }
.brand__sub { font-size: 9px; letter-spacing: 1.3px; text-transform: uppercase; color: var(--soft); }
.who { display: flex; align-items: center; gap: 9px; text-align: right; max-width: 55%; }
.who__meta { overflow: hidden; }
.who__name { font-size: 13px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who__tier { font-size: 10px; color: var(--gold); letter-spacing: 0.04em; }

.view { padding: 16px 16px 104px; max-width: 720px; margin: 0 auto; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; margin: 0 0 8px; }
h1 { font-size: 24px; }
h2 { font-size: 18px; margin-top: 18px; }
h3 { font-size: 16px; }

.muted { color: var(--soft); font-size: 13px; }
.ok { color: var(--ok); }
.warn { color: var(--warn); }

@keyframes tabFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.tab-stage { animation: tabFadeIn 0.24s cubic-bezier(0.22, 1, 0.36, 1); }

@keyframes shimmer {
  0% { transform: translateX(-45%); }
  100% { transform: translateX(45%); }
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  margin: 0 0 12px;
  backdrop-filter: blur(10px);
  position: relative;
  transition: border-color 0.25s ease, transform 0.2s ease;
}
.card.hero {
  border-color: var(--hero-line);
  background: var(--card-hero);
  box-shadow: var(--hero-shadow);
  overflow: hidden;
}
body[data-tier="3"] .card.hero::after,
body[data-tier="4"] .card.hero::after {
  content: "";
  position: absolute;
  inset: -40% -80%;
  background: linear-gradient(115deg, transparent 43%, rgba(236, 212, 157, 0.1) 50%, transparent 57%);
  animation: shimmer 7s infinite linear;
  pointer-events: none;
}
.card.notice {
  border-color: rgba(217, 185, 120, 0.45);
  background: linear-gradient(135deg, rgba(217, 185, 120, 0.14) 0%, rgba(20, 38, 74, 0.92) 72%);
}

.row { display: flex; gap: 10px; align-items: center; }
.spread { justify-content: space-between; }
.wrap { flex-wrap: wrap; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--cream);
}
.pill.gold { background: rgba(217, 185, 120, 0.18); color: var(--gold-bright); border: 1px solid rgba(217, 185, 120, 0.4); }
.pill.ok { background: rgba(114, 217, 165, 0.15); color: var(--ok); border: 1px solid rgba(114, 217, 165, 0.3); }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid rgba(217, 185, 120, 0.55);
  color: var(--gold-bright);
  background: rgba(217, 185, 120, 0.08);
  padding: 10px 15px;
  border-radius: 12px;
  font: 600 14px var(--body);
  cursor: pointer;
  min-height: 42px;
  transition: transform 0.14s cubic-bezier(0.22, 1, 0.36, 1), filter 0.16s ease, background 0.16s ease;
  user-select: none;
}
.btn:active { transform: scale(0.96); }
.btn.primary {
  background: linear-gradient(180deg, #e7cb8f 0%, #cfa75a 100%);
  border-color: transparent;
  color: #0f1e3b;
  box-shadow: 0 4px 14px rgba(217, 185, 120, 0.25);
}
.btn.ghost { border-color: var(--line); background: rgba(255, 255, 255, 0.04); color: var(--ink); }
.btn.danger { border-color: rgba(239, 108, 108, 0.5); background: rgba(239, 108, 108, 0.14); color: #ffb3b3; }
.btn.small { padding: 7px 12px; min-height: 36px; font-size: 13px; }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.guide-img { width: 100%; border-radius: 12px; border: 1px solid var(--line); display: block; margin-bottom: 12px; background: #0b152a; }
.guide-dots { display: flex; justify-content: center; gap: 6px; margin: 10px 0 12px; }
.guide-dots i { width: 8px; height: 8px; border-radius: 99px; background: rgba(255, 255, 255, 0.22); display: block; }
.guide-dots i.on { width: 24px; background: var(--gold); }
.custom-title-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: #f6e1ad;
  background: linear-gradient(135deg, rgba(217, 185, 120, 0.28), rgba(217, 185, 120, 0.1));
  border: 1px solid rgba(217, 185, 120, 0.58);
  box-shadow: 0 2px 10px rgba(217, 185, 120, 0.16);
}

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--soft); margin-bottom: 5px; }
input[type="text"], input[type="tel"], input[type="number"], textarea, select {
  width: 100%;
  background: rgba(9, 19, 40, 0.85);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font: 14px var(--body);
  outline: none;
  transition: border-color 0.18s ease;
}
input:focus, textarea:focus, select:focus { border-color: var(--gold); }
textarea { min-height: 76px; resize: vertical; }

.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 10px;
  font-size: 13px;
  cursor: pointer;
}
.check input { margin-top: 3px; accent-color: var(--gold); }

.money-bar { height: 6px; border-radius: 99px; background: rgba(255, 255, 255, 0.1); margin: 8px 0; overflow: hidden; }
.money-bar > i {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #b89042, var(--gold-bright));
  transition: width 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.subblock {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* Аватар и монограмма */
.avatar-circle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1.5px solid var(--avatar-ring);
  box-shadow: var(--avatar-glow);
  background: linear-gradient(135deg, #1b3464, #0f1e3b);
  color: var(--gold-bright);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  overflow: hidden;
  flex-shrink: 0;
}
.avatar-circle.lg { width: 68px; height: 68px; font-size: 22px; font-family: var(--display); border-width: 2px; }
.avatar-circle img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Живое превью подарочного сертификата */
.gift-preview {
  background: linear-gradient(135deg, #162b54 0%, #0d1a36 60%, #162c56 100%);
  border: 1.5px solid var(--gold);
  border-radius: 18px;
  padding: 18px;
  margin-bottom: 14px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 14px 28px rgba(4, 10, 24, 0.45);
}
.gift-preview::after {
  content: "";
  position: absolute;
  inset: -40% -80%;
  background: linear-gradient(115deg, transparent 42%, rgba(236, 212, 157, 0.12) 50%, transparent 58%);
  animation: shimmer 6s infinite linear;
  pointer-events: none;
}

.qr-box {
  background: #ffffff;
  border-radius: 14px;
  padding: 14px;
  max-width: 240px;
  margin: 12px auto;
}
.qr-box svg { width: 100%; height: auto; display: block; }

/* Плавающая нижняя панель вкладок */
.tabs {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: max(10px, env(safe-area-inset-bottom));
  max-width: 696px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  background: rgba(13, 25, 50, 0.92);
  backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 6px;
  box-shadow: 0 12px 30px rgba(4, 9, 22, 0.55);
  z-index: 10;
}
.tabs button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: transparent;
  border: 0;
  border-radius: 16px;
  padding: 8px 4px;
  color: var(--soft);
  font: 500 11px var(--body);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.14s ease;
}
.tabs button:active { transform: scale(0.94); }
.tabs button.on {
  background: rgba(217, 185, 120, 0.16);
  color: var(--gold-bright);
  font-weight: 600;
}

/* Нижняя шторка */
@keyframes fadeBg { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet {
  position: fixed;
  inset: 0;
  background: rgba(5, 11, 24, 0.72);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
  animation: fadeBg 0.18s ease;
}
.sheet__box {
  background: #14264a;
  border-top: 1px solid var(--hero-line);
  width: 100%;
  max-width: 720px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
  border-radius: 24px 24px 0 0;
  animation: sheetUp 0.26s cubic-bezier(0.22, 1, 0.36, 1);
}
.sheet__handle {
  width: 40px;
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.2);
  margin: 0 auto 14px;
}

/* Тост */
.toast-host {
  position: fixed;
  top: 66px;
  left: 16px;
  right: 16px;
  max-width: 688px;
  margin: 0 auto;
  z-index: 30;
  pointer-events: none;
}
.alert {
  padding: 11px 14px;
  border-radius: 14px;
  margin-bottom: 10px;
  font-size: 13px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.42);
  animation: tabFadeIn 0.2s ease;
}
.alert.err { background: rgba(58, 22, 30, 0.96); border: 1px solid rgba(229, 115, 115, 0.55); color: #ffb4b4; }
.alert.ok { background: rgba(16, 38, 74, 0.96); border: 1px solid var(--gold); color: var(--ink); }

/* Скелетон загрузки */
@keyframes pulseSkel {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 0.85; }
}
.skel-card {
  height: 110px;
  border-radius: 18px;
  background: rgba(24, 45, 86, 0.7);
  border: 1px solid var(--line);
  margin-bottom: 12px;
  animation: pulseSkel 1.4s ease-in-out infinite;
}
.skel-tall { height: 220px; }

/* Звания, Карта пути, пресеты и звёзды */
.ach-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.ach-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 8px;
  text-align: center;
  background: rgba(10, 20, 42, 0.48);
}
.ach-item.earned {
  border-color: rgba(217, 185, 120, 0.5);
  background: rgba(217, 185, 120, 0.12);
}
.ach-icon { font-size: 20px; color: var(--gold-bright); }

.path-list { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.path-row { display: flex; flex-direction: column; gap: 4px; }

.preset-row { display: flex; flex-wrap: wrap; gap: 7px; margin: 6px 0 10px; }
.preset-btn {
  border: 1px solid var(--line);
  background: rgba(9, 19, 40, 0.75);
  color: var(--ink);
  border-radius: 10px;
  padding: 7px 11px;
  font: 600 12px var(--body);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.16s ease, background 0.16s ease;
}
.preset-btn:active { transform: scale(0.95); }
.preset-btn.on { border-color: var(--gold); color: #0f1e3b; background: linear-gradient(180deg, #e7cb8f 0%, #cfa75a 100%); }

.star-row { display: flex; gap: 6px; margin: 8px 0; }
.star-btn {
  border: 1px solid var(--line);
  background: rgba(9, 19, 40, 0.75);
  color: var(--soft);
  border-radius: 11px;
  width: 42px;
  height: 40px;
  font: 600 18px var(--body);
  cursor: pointer;
  transition: transform 0.15s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.star-btn.on {
  border-color: var(--gold);
  color: var(--gold-bright);
  background: rgba(217, 185, 120, 0.2);
  transform: translateY(-2px);
}

.ref-box {
  background: rgba(9, 19, 40, 0.75);
  border: 1px dashed rgba(217, 185, 120, 0.45);
  border-radius: 12px;
  padding: 10px 12px;
  margin: 10px 0;
  word-break: break-all;
  font-size: 12px;
  color: var(--cream);
}
