/* ============================================================
   PlayHub — компоненты интерфейса
   ============================================================ */

/* ---- Кнопки ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  font-weight: 650;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: transform 0.15s var(--ease), background 0.2s, border-color 0.2s, box-shadow 0.25s, opacity 0.2s;
  white-space: nowrap;
  user-select: none;
}
.btn:hover {
  background: var(--surface-3);
  transform: translateY(-1px);
}
.btn:active {
  transform: translateY(0) scale(0.98);
}
.btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}
.btn-primary {
  background: var(--grad-accent);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 24px rgba(var(--accent-rgb), 0.35);
}
.btn-primary:hover {
  box-shadow: 0 12px 34px rgba(var(--accent-rgb), 0.5);
  background: var(--grad-accent);
}
.btn-danger {
  color: #fff;
  background: linear-gradient(135deg, #fb7185, #f43f5e);
  border-color: transparent;
}
.btn-ghost {
  background: transparent;
  border-color: var(--border);
}
.btn-ghost:hover {
  background: var(--surface);
}
.btn-sm {
  padding: 7px 13px;
  font-size: 0.85rem;
  border-radius: 9px;
}
.btn-lg {
  padding: 15px 26px;
  font-size: 1.05rem;
  border-radius: var(--radius);
}
.btn-block {
  width: 100%;
}
.btn-icon {
  padding: 0;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  flex: 0 0 auto;
}

/* ---- Карточки ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: clamp(18px, 3vw, 26px);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  box-shadow: var(--shadow);
}
.card-hover {
  transition: transform 0.25s var(--ease), border-color 0.25s, box-shadow 0.25s;
}
.card-hover:hover {
  transform: translateY(-4px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-lg);
}

/* ---- Верхняя навигация ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 clamp(16px, 4vw, 30px);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(22px) saturate(1.4);
  -webkit-backdrop-filter: blur(22px) saturate(1.4);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 850;
  font-size: 1.28rem;
  letter-spacing: -0.03em;
}
.brand__logo {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--grad-accent);
  box-shadow: 0 6px 18px rgba(var(--accent-rgb), 0.5);
  font-size: 20px;
}
.nav-links {
  display: none;
  align-items: center;
  gap: 4px;
  margin-left: 10px;
}
@media (min-width: 768px) {
  .nav-links {
    display: flex;
  }
}
.nav-link {
  padding: 9px 15px;
  border-radius: 11px;
  font-weight: 600;
  color: var(--text-dim);
  transition: color 0.2s, background 0.2s;
}
.nav-link:hover {
  color: var(--text);
  background: var(--surface);
}
.nav-link.active {
  color: var(--text);
  background: var(--surface-2);
}
.nav-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Профиль-чип в шапке */
.profile-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 5px 12px 5px 5px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: border-color 0.2s, background 0.2s;
}
.profile-chip:hover {
  border-color: var(--border-strong);
  background: var(--surface-3);
}
.profile-chip__meta {
  display: none;
  line-height: 1.1;
}
@media (min-width: 560px) {
  .profile-chip__meta {
    display: block;
  }
}
.profile-chip__name {
  font-weight: 700;
  font-size: 0.9rem;
}
.profile-chip__lvl {
  font-size: 0.72rem;
  color: var(--text-faint);
}

/* ---- Нижняя навигация (моб.) ---- */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(22px) saturate(1.4);
  -webkit-backdrop-filter: blur(22px) saturate(1.4);
  border-top: 1px solid var(--border);
}
@media (min-width: 768px) {
  .bottom-nav {
    display: none;
  }
}
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-faint);
  transition: color 0.2s;
}
.bottom-nav a .ic {
  font-size: 21px;
  line-height: 1;
  transition: transform 0.2s var(--ease);
}
.bottom-nav a.active {
  color: var(--text);
}
.bottom-nav a.active .ic {
  transform: translateY(-2px) scale(1.12);
}

/* ---- Аватары ---- */
.avatar {
  --size: 42px;
  width: var(--size);
  height: var(--size);
  flex: 0 0 auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: calc(var(--size) * 0.5);
  color: #fff;
  background: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
  overflow: hidden;
}
.avatar-lg {
  --size: 88px;
}
.avatar-xl {
  --size: 112px;
}
.avatar-sm {
  --size: 34px;
}

/* ---- Поля ввода ---- */
.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
}
.input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.input::placeholder {
  color: var(--text-faint);
}
.input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface-3);
  box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.18);
}
textarea.input {
  resize: vertical;
  min-height: 90px;
}

/* ---- Бейджи / чипы ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.badge-accent {
  background: rgba(var(--accent-rgb), 0.16);
  border-color: rgba(var(--accent-rgb), 0.4);
  color: var(--violet-2);
}
.badge-green {
  background: rgba(52, 211, 153, 0.15);
  border-color: rgba(52, 211, 153, 0.4);
  color: #34d399;
}
.chip {
  padding: 9px 16px;
  border-radius: 999px;
  font-weight: 650;
  font-size: 0.9rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  transition: all 0.18s var(--ease);
}
.chip:hover {
  border-color: var(--border-strong);
  color: var(--text);
}
.chip.active {
  background: var(--grad-accent);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 18px rgba(var(--accent-rgb), 0.4);
}
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

/* ---- Прогресс ---- */
.progress {
  height: 9px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}
.progress__bar {
  height: 100%;
  border-radius: 999px;
  background: var(--grad-accent);
  transition: width 0.7s var(--ease);
}

/* ---- Плитки статистики ---- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
}
.stat {
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  text-align: center;
}
.stat__num {
  font-size: 1.7rem;
  font-weight: 850;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.stat__label {
  font-size: 0.78rem;
  color: var(--text-faint);
  margin-top: 3px;
}

/* ---- Заголовки секций ---- */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 6px 0 16px;
}
.section-head h2 {
  font-size: clamp(1.25rem, 3vw, 1.6rem);
}

/* ---- Карточки игр ---- */
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: clamp(14px, 2.4vw, 22px);
}
.game-card {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: transform 0.28s var(--ease), border-color 0.28s, box-shadow 0.28s;
  isolation: isolate;
}
.game-card:hover {
  transform: translateY(-6px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-lg);
}
.game-card__cover {
  position: relative;
  aspect-ratio: 16 / 9;
  display: grid;
  place-items: center;
  font-size: clamp(48px, 9vw, 68px);
  overflow: hidden;
}
.game-card__cover::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 40%, rgba(0, 0, 0, 0.35));
}
.game-card__cover .emoji {
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.4));
  transition: transform 0.4s var(--ease);
}
.game-card:hover .game-card__cover .emoji {
  transform: scale(1.12) rotate(-4deg);
}
.game-card__shine {
  position: absolute;
  top: -60%;
  left: -30%;
  width: 60%;
  height: 220%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.18), transparent);
  transform: rotate(18deg);
  transition: transform 0.7s var(--ease);
}
.game-card:hover .game-card__shine {
  transform: rotate(18deg) translateX(320%);
}
.game-card__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 15px 16px 17px;
}
.game-card__title {
  font-size: 1.12rem;
  font-weight: 750;
  letter-spacing: -0.02em;
}
.game-card__desc {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-top: 3px;
  min-height: 2.4em;
}
.game-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto; /* прижать бейджи к нижнему краю карточки */
  padding-top: 12px;
}

/* ---- Список (друзья, лидеры, поиск) ---- */
.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.list-item {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 11px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}
.list-item:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}
.list-item__body {
  flex: 1;
  min-width: 0;
}
.list-item__title {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-item__sub {
  font-size: 0.8rem;
  color: var(--text-faint);
}
.list-item__actions {
  display: flex;
  gap: 7px;
  flex: 0 0 auto;
}
.rank-badge {
  width: 30px;
  text-align: center;
  font-weight: 850;
  font-size: 1.05rem;
  color: var(--text-faint);
  flex: 0 0 auto;
}
.rank-1 {
  color: #fbbf24;
}
.rank-2 {
  color: #cbd5e1;
}
.rank-3 {
  color: #f0955b;
}

/* ---- Табы ---- */
.tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.tab {
  padding: 8px 16px;
  border-radius: 10px;
  font-weight: 650;
  font-size: 0.9rem;
  color: var(--text-dim);
  transition: color 0.2s, background 0.2s;
}
.tab.active {
  color: var(--text);
  background: var(--surface-3);
}

/* ---- Пустое состояние ---- */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
}
.empty__icon {
  font-size: 44px;
  margin-bottom: 10px;
  opacity: 0.85;
}

/* ---- Тосты ---- */
.toast-root {
  position: fixed;
  top: calc(var(--nav-h) + 12px);
  right: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(92vw, 380px);
}
@media (max-width: 560px) {
  .toast-root {
    left: 12px;
    right: 12px;
    max-width: none;
  }
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px 15px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--bg-soft) 85%, transparent);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  animation: toastIn 0.35s var(--ease) both;
  border-left: 3px solid var(--accent);
}
.toast.leaving {
  animation: toastOut 0.3s var(--ease) forwards;
}
.toast__icon {
  font-size: 18px;
  line-height: 1.3;
}
.toast__msg {
  font-size: 0.9rem;
  line-height: 1.4;
}
.toast--success {
  border-left-color: var(--green);
}
.toast--error {
  border-left-color: var(--red);
}
.toast--info {
  border-left-color: var(--cyan);
}
@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
}
@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateX(30px);
  }
}

/* ---- Модальные окна ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(4, 4, 10, 0.62);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fade 0.25s ease both;
}
.modal {
  width: min(94vw, 440px);
  max-height: 88vh;
  overflow-y: auto;
  padding: clamp(20px, 4vw, 30px);
  border-radius: var(--radius-xl);
  background: var(--bg-soft);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  animation: modalPop 0.32s var(--ease) both;
}
.modal--wide {
  width: min(94vw, 620px);
}
.modal__title {
  font-size: 1.4rem;
  margin-bottom: 6px;
}
.modal__close {
  position: absolute;
  top: 14px;
  right: 14px;
}
@keyframes fade {
  from {
    opacity: 0;
  }
}
@keyframes modalPop {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.97);
  }
}

/* ---- Разное ---- */
.divider {
  height: 1px;
  background: var(--border);
  margin: 18px 0;
}
.link {
  color: var(--violet-2);
  font-weight: 650;
  cursor: pointer;
}
.link:hover {
  text-decoration: underline;
}
.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-3) 37%, var(--surface) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: 8px;
}
@keyframes shimmer {
  to {
    background-position: -135% 0;
  }
}
.spinner-inline {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--surface-3);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}
.btn-soft {
  background: var(--surface-2);
}

/* ============================================================
   Экраны: главная (герой), авторизация, профиль, игра
   ============================================================ */

/* ---- Герой ---- */
.hero {
  text-align: center;
  max-width: 780px;
  margin: 0 auto;
  padding: clamp(24px, 6vw, 64px) 0 12px;
}
.hero__badge {
  display: inline-block;
  padding: 6px 15px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 22px;
}
.hero__title {
  font-size: clamp(2.1rem, 7vw, 3.7rem);
  font-weight: 850;
  letter-spacing: -0.035em;
}
.hero__sub {
  color: var(--text-dim);
  font-size: clamp(1rem, 2.4vw, 1.18rem);
  margin: 18px auto 0;
  max-width: 60ch;
}
.hero__cta {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 30px;
}
.hero__features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-top: 48px;
  text-align: left;
}
.hero__feature {
  display: flex;
  gap: 13px;
  align-items: center;
  padding: 15px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
}
.hero__feature-ic {
  font-size: 26px;
  flex: 0 0 auto;
}

/* ---- Авторизация ---- */
.auth-wrap {
  min-height: calc(100vh - var(--nav-h) - 130px);
  display: grid;
  place-items: center;
  padding: 20px 0;
}
.auth-card {
  width: min(94vw, 430px);
}
.auth-head {
  margin-bottom: 18px;
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.auth-error {
  color: #fff;
  background: rgba(251, 113, 133, 0.16);
  border: 1px solid rgba(251, 113, 133, 0.42);
  padding: 10px 13px;
  border-radius: 11px;
  font-size: 0.88rem;
}

/* ---- Профиль ---- */
.profile-hero {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.profile-hero__info {
  flex: 1;
  min-width: 220px;
}
.list-item--me {
  border-color: rgba(var(--accent-rgb), 0.5);
  background: rgba(var(--accent-rgb), 0.08);
}
@media (max-width: 560px) {
  .profile-hero {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  .profile-hero__info .row {
    justify-content: center;
  }
}

/* ---- Пикеры в модалке профиля ---- */
.swatch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}
.swatch {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid transparent;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
  transition: transform 0.15s var(--ease);
}
.swatch:hover {
  transform: scale(1.1);
}
.swatch.active {
  border-color: var(--text);
  transform: scale(1.14);
}
.emoji-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.emoji-pick {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  font-size: 21px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: all 0.15s var(--ease);
}
.emoji-pick:hover {
  background: var(--surface-3);
}
.emoji-pick.active {
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), 0.18);
}

/* ---- Экран игры ---- */
.game-view {
  max-width: 760px;
  margin: 0 auto;
}
.game-header {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-bottom: 16px;
}
.game-title-row {
  display: flex;
  align-items: center;
  gap: 14px;
}
.game-diff {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.game-status {
  text-align: center;
  font-weight: 650;
  min-height: 1.6em;
  margin-bottom: 12px;
  color: var(--text);
  font-size: 1.05rem;
}
.board-host {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
