:root {
  --bg-color: var(--tg-theme-bg-color, #0f141c);
  --secondary-bg-color: var(--tg-theme-secondary-bg-color, #18202c);
  --text-color: var(--tg-theme-text-color, #ffffff);
  --hint-color: var(--tg-theme-hint-color, #8e9cae);
  --button-color: var(--tg-theme-button-color, #2481cc);
  --button-text-color: var(--tg-theme-button-text-color, #ffffff);
  
  --accent-cyan: #00d2ff;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
  --accent-red: #ef4444;
  --card-border: rgba(255, 255, 255, 0.08);
  --card-glow: rgba(36, 129, 204, 0.15);
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  min-height: 100vh;
  padding: 16px 14px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.app-container {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

/* Loading Overlay */
.loader-overlay {
  position: fixed;
  inset: 0;
  background-color: var(--bg-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: opacity 0.3s ease;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--button-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loader-text {
  margin-top: 16px;
  font-size: 15px;
  font-weight: 500;
  color: var(--hint-color);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.hidden {
  display: none !important;
}

/* Header Card */
.header-card {
  background: linear-gradient(145deg, var(--secondary-bg-color), rgba(24, 32, 44, 0.7));
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 20px 18px;
  margin-bottom: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(10px);
}

.badge-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.badge {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  letter-spacing: 0.3px;
  display: inline-flex;
  align-items: center;
}

.badge-active {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-prize {
  background: rgba(0, 210, 255, 0.12);
  color: var(--accent-cyan);
  border: 1px solid rgba(0, 210, 255, 0.25);
}

.title {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.35;
  margin-bottom: 10px;
  color: var(--text-color);
}

.description {
  font-size: 14px;
  line-height: 1.5;
  color: var(--hint-color);
  word-break: break-word;
}

/* Steps Cards */
.card {
  background-color: var(--secondary-bg-color);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.step-num {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--button-color), #00b4d8);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(36, 129, 204, 0.4);
}

.card-title-group h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-color);
}

.card-title-group .subtitle {
  font-size: 12px;
  color: var(--hint-color);
}

.status-indicator {
  margin-left: auto;
  font-size: 18px;
}

/* Notice Box */
.notice-box {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.45;
  margin-bottom: 14px;
}

.notice-warning {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.25);
  color: #fbbf24;
}

.notice-success {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: #34d399;
}

/* Buttons */
.button-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  width: 100%;
  height: 48px;
  background: linear-gradient(135deg, var(--button-color), #0099ff);
  color: var(--button-text-color);
  font-size: 15px;
  box-shadow: 0 4px 14px rgba(36, 129, 204, 0.4);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-color);
  border: 1px solid var(--card-border);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn-outline {
  background: rgba(36, 129, 204, 0.12);
  color: #38bdf8;
  border: 1px solid rgba(36, 129, 204, 0.3);
}

/* Progress Container */
.progress-container {
  margin-bottom: 16px;
}

.progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
}

.progress-val {
  color: var(--accent-cyan);
}

.progress-bar-bg {
  height: 10px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #00d2ff, #10b981);
  border-radius: 20px;
  transition: width 0.5s ease-out;
}

/* Status Banner */
.status-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 500;
}

.banner-pending {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.25);
  color: #fbbf24;
}

.banner-eligible {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #34d399;
}

.status-icon {
  font-size: 20px;
}

/* Referral Box */
.ref-link-box {
  margin-bottom: 16px;
}

.input-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--hint-color);
  margin-bottom: 6px;
}

.copy-input-row {
  display: flex;
  gap: 8px;
}

.copy-input-row input {
  flex: 1;
  height: 42px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  color: var(--text-color);
  font-size: 13px;
  outline: none;
}

.btn-copy {
  width: 44px;
  height: 42px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  color: var(--text-color);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-copy:active {
  background: rgba(255, 255, 255, 0.18);
}

/* Footer Info */
.footer-info {
  font-size: 12px;
  color: var(--hint-color);
  line-height: 1.6;
  text-align: center;
  padding: 10px 0;
}

/* Toast */
.toast {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30, 41, 59, 0.95);
  color: #fff;
  padding: 10px 18px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 2000;
  animation: fadeIn 0.25s ease-out;
  pointer-events: none;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-icon {
  font-size: 56px;
  margin-bottom: 16px;
}

.empty-state h2 {
  font-size: 20px;
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 14px;
  color: var(--hint-color);
}

/* Participate Section */
.participate-section {
  background: linear-gradient(145deg, var(--secondary-bg-color), rgba(36, 129, 204, 0.08));
  border: 1px solid rgba(36, 129, 204, 0.25);
}

.btn-participate {
  width: 100%;
  padding: 16px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.3px;
  margin-top: 6px;
  position: relative;
  overflow: hidden;
  transition: all 0.25s ease;
  border-radius: var(--radius-md);
  cursor: pointer;
}

.btn-participate.btn-ready {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  border: none;
  box-shadow: 0 4px 20px rgba(16, 185, 129, 0.4);
  animation: pulseGreen 2s infinite;
}

.btn-participate.btn-confirmed {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
  border: 1px solid rgba(16, 185, 129, 0.4);
  box-shadow: none;
  cursor: default;
}

.btn-participate.btn-locked {
  background: rgba(255, 255, 255, 0.08);
  color: var(--hint-color);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: none;
  cursor: pointer;
}

@keyframes pulseGreen {
  0% { transform: scale(1); box-shadow: 0 4px 15px rgba(16, 185, 129, 0.35); }
  50% { transform: scale(1.02); box-shadow: 0 6px 24px rgba(16, 185, 129, 0.6); }
  100% { transform: scale(1); box-shadow: 0 4px 15px rgba(16, 185, 129, 0.35); }
}

