:root {
  --tg-bg: var(--tg-theme-bg-color, #0f1115);
  --tg-text: var(--tg-theme-text-color, #f4f4f6);
  --tg-hint: var(--tg-theme-hint-color, #8a8d94);
  --tg-link: var(--tg-theme-link-color, #6ab7ff);
  --tg-button: var(--tg-theme-button-color, #6c5ce7);
  --tg-button-text: var(--tg-theme-button-text-color, #ffffff);
  --tg-secondary-bg: var(--tg-theme-secondary-bg-color, #1b1e26);
  --card-radius: 16px;
  --accent: #ff6b6b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--tg-bg);
  color: var(--tg-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px 100px;
}

.screen[hidden] { display: none; }

.app-header { text-align: center; margin-bottom: 20px; }
.app-header h1 { font-size: 24px; margin: 4px 0; }
.subtitle { color: var(--tg-hint); margin: 0; font-size: 14px; }

.results-header {
  position: relative;
  text-align: center;
}
.back-btn {
  position: absolute;
  left: 0;
  top: 4px;
  background: none;
  border: none;
  color: var(--tg-link);
  font-size: 15px;
  padding: 4px 0;
}

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

.field-label {
  display: block;
  font-size: 14px;
  color: var(--tg-hint);
  margin-bottom: 10px;
}

.stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
}
.step-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--tg-button);
  color: var(--tg-button-text);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.step-btn:active { opacity: 0.8; }
.step-value {
  font-size: 28px;
  font-weight: 700;
  min-width: 48px;
  text-align: center;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.cringe-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  gap: 10px;
}
.cringe-badge {
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 4px 12px;
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
}
.cringe-caption {
  color: var(--tg-hint);
  font-size: 13px;
  text-align: right;
}

.price-preview {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 4px 4px 16px;
  color: var(--tg-hint);
  font-size: 15px;
}
.price-preview strong { color: var(--tg-text); font-size: 18px; }

.primary-btn {
  width: 100%;
  padding: 15px;
  border: none;
  border-radius: 14px;
  background: var(--tg-button);
  color: var(--tg-button-text);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
.primary-btn:disabled { opacity: 0.5; }
.primary-btn:active { opacity: 0.85; }

.error-text {
  color: #ff6b6b;
  font-size: 14px;
  text-align: center;
  margin-top: 10px;
}

.results-summary {
  text-align: center;
  color: var(--tg-hint);
  font-size: 14px;
  margin-bottom: 16px;
}

.results-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.contest-card {
  background: var(--tg-secondary-bg);
  border-radius: var(--card-radius);
  padding: 16px;
}
.contest-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}
.contest-title { font-size: 17px; font-weight: 700; margin: 0; }
.contest-badges {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge-cringe { background: var(--accent); color: #fff; }
.badge-category { background: rgba(255,255,255,0.08); color: var(--tg-hint); }

.contest-text {
  font-size: 14px;
  line-height: 1.5;
  color: var(--tg-text);
  margin: 0 0 10px;
}

.contest-meta {
  font-size: 12px;
  color: var(--tg-hint);
  margin-bottom: 10px;
}

.audio-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.audio-row audio {
  width: 100%;
  height: 34px;
}
.audio-missing {
  font-size: 12px;
  color: var(--tg-hint);
  font-style: italic;
}

.pay-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-width: 560px;
  margin: 0 auto;
  background: var(--tg-bg);
  border-top: 1px solid rgba(255,255,255,0.08);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pay-price {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
#pay-price-value { font-size: 20px; font-weight: 800; }
.pay-price-sub { font-size: 12px; color: var(--tg-hint); }

.pay-note {
  font-size: 12px;
  color: var(--tg-hint);
  text-align: center;
  margin: 6px 0 0;
}
