/* Konkurs MiniApp – Glass morphism, Telegram theme adaptive */

:root {
  --bg: var(--tg-theme-bg-color, #0f0f12);
  --bg-secondary: var(--tg-theme-secondary-bg-color, #1a1a1f);
  --text: var(--tg-theme-text-color, #ffffff);
  --hint: var(--tg-theme-hint-color, #8b8b9a);
  --link: var(--tg-theme-link-color, #5b9dff);
  --btn: var(--tg-theme-button-color, #5b9dff);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --destructive: var(--tg-theme-destructive-text-color, #ff5c5c);
  --glass: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-strong: rgba(255, 255, 255, 0.14);
  --success: #34c759;
  --radius: 16px;
  --radius-sm: 12px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: light) {
  :root {
    --glass: rgba(255, 255, 255, 0.55);
    --glass-border: rgba(0, 0, 0, 0.08);
    --glass-strong: rgba(255, 255, 255, 0.75);
  }
}

/* Light theme overrides from Telegram */
body.theme-light {
  --glass: rgba(255, 255, 255, 0.65);
  --glass-border: rgba(0, 0, 0, 0.08);
  --glass-strong: rgba(255, 255, 255, 0.85);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  line-height: 1.45;
}

#app {
  min-height: 100%;
  padding: 16px 16px calc(24px + var(--safe-bottom));
  max-width: 480px;
  margin: 0 auto;
}

/* Screens */
.screen {
  display: none;
  animation: fadeIn 0.28s ease;
}
.screen.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Glass card */
.glass {
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

.card {
  padding: 20px;
  margin-bottom: 14px;
}

/* Typography */
h1 { font-size: 1.45rem; font-weight: 700; margin-bottom: 8px; }
h2 { font-size: 1.2rem; font-weight: 650; margin-bottom: 8px; }
h3 { font-size: 1rem; font-weight: 600; margin-bottom: 10px; }
.muted { color: var(--hint); font-size: 0.9rem; }
.hidden { display: none !important; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s, opacity 0.12s, background 0.15s;
  width: 100%;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; pointer-events: none; }

.btn-primary {
  background: var(--btn);
  color: var(--btn-text);
}
.btn-secondary {
  background: var(--glass-strong);
  color: var(--text);
  border: 1px solid var(--glass-border);
  width: auto;
  min-width: 100px;
}
.btn-ghost {
  background: transparent;
  color: var(--hint);
  border: 1px solid var(--glass-border);
}
.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-lg { min-height: 52px; font-size: 1.05rem; margin-top: 8px; }
.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}
.btn-row .btn { flex: 1; }

/* Loader */
.loader {
  width: 36px;
  height: 36px;
  border: 3px solid var(--glass-border);
  border-top-color: var(--btn);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 12px;
}
.loader.sm {
  width: 18px;
  height: 18px;
  border-width: 2px;
  margin: 0;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

#screen-loading {
  text-align: center;
  padding-top: 40vh;
}

.check-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
  color: var(--hint);
  font-size: 0.9rem;
}

/* Channel */
.channel-card { text-align: center; padding: 28px 20px; }
.channel-avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  margin: 0 auto 14px;
  overflow: hidden;
  background: var(--glass-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--glass-border);
}
.channel-avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-fallback { font-size: 2rem; }
.channel-title { margin-bottom: 6px; }

.success-card { text-align: center; padding: 36px 20px; }
.success-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--success);
  color: #fff;
  font-size: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-weight: 700;
}

/* Hero */
.hero-card { position: relative; }
.badge {
  position: absolute;
  top: 14px;
  right: 14px;
  font-size: 1.4rem;
}
.prize-box {
  background: var(--glass-strong);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 14px 0 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.prize-label { font-size: 0.75rem; color: var(--hint); text-transform: uppercase; letter-spacing: 0.04em; }
.prize-value { font-size: 1.15rem; font-weight: 700; }
.meta-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--glass-strong);
  font-size: 0.8rem;
  color: var(--hint);
}
.chip.points { color: var(--text); font-weight: 600; }
.chip.sm { font-size: 0.75rem; padding: 2px 8px; }

/* Task list */
.task-list { list-style: none; }
.task-list.compact li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--glass-border);
  font-size: 0.9rem;
}
.task-list.compact li:last-child { border-bottom: none; }
.task-points { color: var(--btn); font-weight: 600; font-size: 0.85rem; }

/* Instagram */
.input-group {
  display: flex;
  gap: 8px;
  margin: 14px 0;
}
.input-group input {
  flex: 1;
  min-height: 48px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: var(--bg-secondary);
  color: var(--text);
  font-size: 1rem;
  outline: none;
}
.input-group input:focus {
  border-color: var(--btn);
}
.ig-preview {
  margin-top: 16px;
  text-align: center;
  padding-top: 12px;
  border-top: 1px solid var(--glass-border);
}
.ig-photo {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--glass-border);
  margin-bottom: 8px;
}
.ig-info { display: flex; flex-direction: column; gap: 2px; align-items: center; margin-bottom: 10px; }
.confirm-q { margin: 8px 0 4px; font-weight: 500; }

/* Tasks full */
.points-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  margin-bottom: 14px;
  font-size: 0.95rem;
}
.points-bar strong { font-size: 1.25rem; color: var(--btn); }

.task-card {
  padding: 16px;
  margin-bottom: 12px;
  transition: opacity 0.2s, filter 0.2s;
}
.task-card.locked {
  opacity: 0.45;
  filter: blur(1.5px);
  pointer-events: none;
}
.task-card.done {
  border-color: rgba(52, 199, 89, 0.35);
}
.task-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}
.task-title { font-weight: 600; font-size: 0.98rem; }
.task-ball {
  background: var(--btn);
  color: var(--btn-text);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 8px;
  white-space: nowrap;
}
.task-hint { font-size: 0.82rem; color: var(--hint); margin-bottom: 12px; }
.task-actions { display: flex; gap: 8px; }
.task-actions .btn { min-height: 42px; font-size: 0.92rem; }
.task-done-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--success);
  font-weight: 600;
  font-size: 0.9rem;
}
.task-done-badge::before {
  content: '✓';
  display: inline-flex;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--success);
  color: #fff;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
}
.invite-stats {
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--hint);
}
.invite-stats strong { color: var(--text); }

/* Responsive */
@media (max-width: 360px) {
  #app { padding: 12px 12px calc(20px + var(--safe-bottom)); }
  h1 { font-size: 1.25rem; }
  .btn { min-height: 44px; }
}
