/* Базовые переменные и каркас. Дизайн пока черновой — красоту наводим позже,
   поэтому все цвета собраны здесь: поменять палитру = поменять переменные.
   Внутри Telegram подхватываются цвета темы игрока (--tg-theme-*). */

:root {
  /* Формат «только телефон»: ВСЁ приложение (шапка, экран, нижнее меню)
     живёт в колонке шириной с телефон. На широком мониторе — «телефон»
     по центру, по бокам пусто. Отдельного десктоп-дизайна нет (ПЛАН §6). */
  --app-max-w: 430px;
  --bg: var(--tg-theme-bg-color, #16110d);
  --bg-card: var(--tg-theme-secondary-bg-color, #221a14);
  --text: var(--tg-theme-text-color, #f2e9df);
  --text-dim: var(--tg-theme-hint-color, #a89a8c);
  --accent: var(--tg-theme-button-color, #c98a4b);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --danger: #e05d5d;
  --ok: #6aa84f;
  --radius: 14px;
  --header-h: 64px;
  --nav-h: 62px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: var(--app-max-w);
  margin: 0 auto;
  background: var(--bg);
}

/* В широком окне (комп) вокруг «телефона» — тёмное поле и рамка */
@media (min-width: 480px) {
  body { background: #0b0806; }
  #app {
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 70px rgba(0, 0, 0, 0.6);
  }
}

.hidden { display: none !important; }

/* Невидимый, но место в сетке занимает (для кнопки «назад» в шапке,
   иначе аватар съезжает из центра в освободившуюся колонку). */
.invisible { visibility: hidden !important; }

/* ── Шапка ─────────────────────────────────────────── */

#header {
  position: sticky;
  top: 0;
  z-index: 10;
  height: calc(var(--header-h) + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  display: grid;
  grid-template-columns: 56px 1fr 56px;
  align-items: center;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.header-btn {
  width: 44px;
  height: 44px;
  margin: 0 auto;
  border: none;
  border-radius: 50%;
  background: var(--bg-card);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
}

.avatar-btn {
  border: none;
  background: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  justify-self: center;
}

.avatar-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.25);
}

.avatar-circle img { width: 100%; height: 100%; object-fit: cover; }

.header-cafe-name {
  font-size: 11px;
  color: var(--text-dim);
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Экран ─────────────────────────────────────────── */

#screen {
  flex: 1;
  padding: 16px 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom));
  width: 100%;
}

/* ── Нижняя навигация ──────────────────────────────── */

#zone-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--app-max-w);
  z-index: 10;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.nav-item {
  flex: 1;
  border: none;
  background: none;
  color: var(--text-dim);
  font-size: 11px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
}

.nav-item .nav-emoji { font-size: 22px; }

.nav-item.active { color: var(--text); }

.nav-item.active .nav-emoji {
  transform: translateY(-2px) scale(1.12);
  transition: transform 0.15s ease;
}

/* ── Общие блоки ───────────────────────────────────── */

.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
}

.muted { color: var(--text-dim); }

.btn {
  display: inline-block;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-text);
  font-size: 15px;
  font-weight: 600;
  padding: 12px 18px;
  cursor: pointer;
}

.btn.secondary { background: var(--bg-card); color: var(--text); }

/* ── Тосты и загрузка ──────────────────────────────── */

#toast-holder {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--app-max-w);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 100;
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  animation: toast-in 0.2s ease;
}

.toast.error { border-left: 3px solid var(--danger); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.skeleton {
  border-radius: var(--radius);
  background: linear-gradient(100deg, var(--bg-card) 40%, rgba(255, 255, 255, 0.06) 50%, var(--bg-card) 60%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite linear;
}

@keyframes shimmer {
  from { background-position: 130% 0; }
  to { background-position: -30% 0; }
}
