/* ==========================================================================
   UNDERGROUND — базовые стили, тема, фон, навигация, компоненты.
   Mobile-first: проектируем от 320px, десктоп — это mobile-app контейнер
   по центру экрана.
   ========================================================================== */

:root {
  --bg-black: #08060c;
  --surface-1: #120e1a;
  --surface-2: #171222;
  --surface-glass: rgba(255, 255, 255, 0.05);
  --border-soft: rgba(255, 255, 255, 0.08);

  --purple: #9b5cff;
  --purple-strong: #b57bff;
  --purple-dim: rgba(155, 92, 255, 0.35);
  --purple-glow: rgba(155, 92, 255, 0.45);

  --text-primary: #f4f2f8;
  --text-secondary: #a9a3b8;
  --text-muted: #74708a;

  --success: #9b5cff;
  --danger: #ff6b7a;

  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;

  --app-max-width: 480px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

/* КРИТИЧЕСКИ ВАЖНО: без этого правила элементы с атрибутом [hidden]
   (переключение вкладок через JS) не скрываются, потому что ниже в файле
   классы .screen/.admin-section и т.п. задают свой display, а авторские
   правила всегда перебивают базовый браузерный [hidden]{display:none},
   независимо от специфичности. Из-за этого все экраны показывались
   одновременно (страница просто скроллилась вниз вместо переключения). */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-black);
  color: var(--text-primary);
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button, input {
  font-family: inherit;
}

a { color: inherit; text-decoration: none; }

/* ---------------- Анимированный фон ---------------- */

.bg-layer {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.55;
  will-change: transform;
}

.blob-1 {
  width: 60vw; height: 60vw; max-width: 420px; max-height: 420px;
  background: radial-gradient(circle at 30% 30%, var(--purple) 0%, transparent 70%);
  top: -10%; left: -20%;
  animation: float-1 22s ease-in-out infinite;
}

.blob-2 {
  width: 70vw; height: 70vw; max-width: 480px; max-height: 480px;
  background: radial-gradient(circle at 60% 40%, #5b2e91 0%, transparent 70%);
  bottom: -15%; right: -25%;
  animation: float-2 26s ease-in-out infinite;
}

.blob-3 {
  width: 50vw; height: 50vw; max-width: 360px; max-height: 360px;
  background: radial-gradient(circle at 50% 50%, #3a2050 0%, transparent 70%);
  top: 40%; left: 30%;
  animation: float-3 30s ease-in-out infinite;
}

@keyframes float-1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(6%, 8%) scale(1.08); }
}
@keyframes float-2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-5%, -6%) scale(1.05); }
}
@keyframes float-3 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-8%, 5%) scale(1.1); }
}

@media (prefers-reduced-motion: reduce) {
  .blob { animation: none !important; }
}

/* ---------------- Grain / noise ---------------- */

.grain-layer {
  position: fixed;
  inset: -10%;
  z-index: 1;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain-shift 8s steps(4) infinite;
}

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

@media (prefers-reduced-motion: reduce) {
  .grain-layer { animation: none; }
}

/* ---------------- App shell (mobile-app container) ---------------- */

.app-shell {
  position: relative;
  z-index: 2;
  max-width: var(--app-max-width);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  animation: screen-in 0.28s ease;
}

@keyframes screen-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.topbar {
  padding: calc(18px + var(--safe-top)) 20px 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wordmark {
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 0.14em;
}

.wordmark-sm {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.12em;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.screen-content {
  flex: 1;
  padding: 12px 20px calc(120px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---------------- Компоненты ---------------- */

.card {
  background: var(--surface-glass);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 20px;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.hero {
  padding: 28px 4px 8px;
  text-align: center;
}

.hero-title {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 0.02em;
  margin: 8px 0 12px;
  background: linear-gradient(135deg, #fff, var(--purple-strong));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-subtitle {
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.5;
  margin: 0 0 24px;
}

.section-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  margin: 0 0 14px;
  text-transform: uppercase;
}

.muted { color: var(--text-muted); font-size: 14px; line-height: 1.5; }

.eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--purple-strong);
  text-transform: uppercase;
  margin: 0 0 6px;
  text-align: center;
}

.steps-list {
  list-style: none;
  margin: 0; padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.steps-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14.5px;
  color: var(--text-primary);
}

.step-num {
  flex: none;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--purple-dim);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 13px;
}

/* ---------------- Кнопки ---------------- */

.btn {
  border: none;
  border-radius: var(--radius-md);
  padding: 16px 20px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
}

.btn:active { transform: scale(0.97); }
.btn-block { width: 100%; display: block; text-align: center; }

.btn-primary {
  background: linear-gradient(135deg, var(--purple), #7b3fe0);
  color: #fff;
  box-shadow: 0 8px 24px var(--purple-glow);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-soft);
  color: var(--text-primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------------- Нижняя навигация (floating glass island) ---------------- */

.tabbar {
  position: fixed;
  left: 50%;
  bottom: calc(16px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 10;
  width: calc(100% - 32px);
  max-width: 340px;
  display: flex;
  justify-content: space-between;
  background: rgba(20, 16, 30, 0.65);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 999px;
  padding: 6px;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 10px 30px rgba(0,0,0,0.4), 0 0 24px rgba(155,92,255,0.12);
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 12px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background 0.25s ease, color 0.25s ease;
  min-height: 44px;
}

.tab-btn.active {
  background: var(--purple-dim);
  color: #fff;
  box-shadow: 0 0 16px var(--purple-glow);
}

/* ---------------- Auth screens ---------------- */

.auth-shell { justify-content: center; }
.auth-content {
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: calc(40px + var(--safe-top));
}
.auth-wordmark { text-align: center; margin-bottom: 8px; }
.auth-title { text-align: center; font-size: 26px; margin: 0 0 4px; }

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 20px;
}

.field-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.field-input {
  background: var(--surface-glass);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  color: var(--text-primary);
  font-size: 15px;
  min-height: 44px;
}

.field-input:focus {
  outline: none;
  border-color: var(--purple);
}

.error-text {
  color: var(--danger);
  font-size: 13px;
  margin: 8px 0 0;
}

.link-center {
  text-align: center;
  display: block;
  margin-top: 18px;
  font-size: 14px;
  text-decoration: underline;
}

/* ---------------- Профиль ---------------- */

.profile-head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.avatar-circle {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--purple), #5b2e91);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  font-size: 20px;
  flex: none;
}

.profile-name { font-weight: 700; font-size: 17px; }
.profile-phone { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

.stats-row {
  display: flex;
  gap: 10px;
}

.stat-box {
  flex: 1;
  background: var(--surface-glass);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 14px 8px;
  text-align: center;
}

.stat-value { font-size: 22px; font-weight: 800; }
.stat-label { font-size: 10.5px; color: var(--text-muted); letter-spacing: 0.08em; margin-top: 2px; }

.prizes-list, .notifications-list {
  list-style: none;
  margin: 0; padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.prizes-list li, .notifications-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-soft);
}

.prizes-list li:last-child, .notifications-list li:last-child { border-bottom: none; }

.prize-amount { color: var(--purple-strong); font-weight: 700; }
