/* Темизация под Telegram — переменные приходят от клиента */
:root {
  --bg: var(--tg-theme-bg-color, #18222d);
  --bg-secondary: var(--tg-theme-secondary-bg-color, #232e3c);
  --text: var(--tg-theme-text-color, #f5f5f5);
  --hint: var(--tg-theme-hint-color, #7d8b99);
  --link: var(--tg-theme-link-color, #62bcf9);
  --button: var(--tg-theme-button-color, #50a8eb);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --destructive: var(--tg-theme-destructive-text-color, #ff5d4f);
}

* { box-sizing: border-box; }

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

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-bottom: 68px; /* place for tabbar */
}

header#app-header {
  padding: 16px 16px 8px;
  background: var(--bg);
}
header h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}
.hint {
  color: var(--hint);
  font-size: 13px;
  margin-top: 2px;
}

main#screens {
  flex: 1;
  padding: 0 12px 12px;
}

.screen { display: none; }
.screen.active { display: block; }

/* Карточки */
.card {
  background: var(--bg-secondary);
  border-radius: 14px;
  padding: 16px;
  margin: 10px 0;
}
.card.error {
  border: 1px solid var(--destructive);
}
.card h2 {
  margin: 0 0 8px;
  font-size: 17px;
}

/* Профиль */
.profile-card { text-align: center; padding: 24px 16px; }
.profile-nick { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.profile-rank { color: var(--hint); margin-bottom: 16px; }
.stats { display: flex; justify-content: space-around; margin-top: 12px; }
.stat-label { color: var(--hint); font-size: 12px; }
.stat-value { font-size: 22px; font-weight: 600; margin-top: 2px; }
.profile-status { margin-top: 12px; color: var(--hint); font-size: 13px; }

.treasury-card { text-align: center; padding: 18px; }
.treasury-label { color: var(--hint); font-size: 13px; }
.treasury-value { font-size: 22px; font-weight: 700; margin-top: 4px; color: var(--link); }

/* Биржа */
.card-list { padding: 4px 0; }
.task-row {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 14px;
  margin: 8px 0;
  cursor: pointer;
  transition: opacity .12s;
}
.task-row:active { opacity: 0.6; }
.task-title { font-weight: 600; font-size: 15px; margin-bottom: 6px; }
.task-meta { color: var(--hint); font-size: 13px; }
.task-reward { color: var(--link); font-weight: 600; }

.empty-state {
  padding: 32px 16px;
  text-align: center;
  color: var(--hint);
}

/* Карточка задания (детально) */
#task-detail .task-title { font-size: 18px; margin-bottom: 12px; }
#task-detail .row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
#task-detail .row:last-child { border-bottom: none; }
#task-detail .row-key { color: var(--hint); }

button.primary {
  display: block;
  width: 100%;
  background: var(--button);
  color: var(--button-text);
  border: none;
  border-radius: 12px;
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 12px;
}
button.primary:active { opacity: 0.85; }
button.secondary {
  background: transparent;
  color: var(--link);
  border: 1px solid var(--link);
}

/* Tabbar */
nav#tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg-secondary);
  display: flex;
  border-top: 1px solid rgba(255,255,255,0.06);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--hint);
  padding: 10px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  font-size: 11px;
}
.tab .tab-icon { font-size: 20px; }
.tab.active { color: var(--link); }

.loader {
  text-align: center;
  padding: 48px 16px;
  color: var(--hint);
}
