:root {
  --green-dark: #1b4332;
  --green-mid: #2d6a4f;
  --green-light: #52b788;
  --green-pale: #d8f3dc;
  --green-bg: #f0f9f4;
  --text: #1a1a2e;
  --text-soft: #555;
  --radius: 12px;
  --shadow: 0 2px 16px rgba(0,0,0,.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: #f0f9f4; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  background: transparent;
  color: var(--text);
  min-height: 100vh;
  padding: 16px;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: url('challenge_background.jpg') center top / cover no-repeat;
  opacity: 0.25;
  z-index: -1;
  pointer-events: none;
}

.card {
  background: transparent;
  border-radius: var(--radius);
  padding: 28px 24px;
  max-width: 480px;
  margin: 0 auto;
}

.card + .card { margin-top: 16px; }

h1 {
  font-size: 22px;
  color: var(--green-dark);
  margin-bottom: 6px;
}

h2 {
  font-size: 17px;
  color: var(--green-mid);
  margin-bottom: 12px;
}

p { color: var(--text-soft); line-height: 1.5; margin-bottom: 12px; }

.badge {
  display: inline-block;
  background: var(--green-pale);
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  margin-bottom: 16px;
}

/* Habit checkboxes */
.habit-list { list-style: none; margin: 16px 0; }

.habit-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 10px;
  border: 2px solid #e8f5e9;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all .15s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.habit-item:active { transform: scale(.98); }

.habit-item input[type="checkbox"] {
  width: 24px;
  height: 24px;
  accent-color: var(--green-mid);
  cursor: pointer;
  flex-shrink: 0;
}

.habit-item.checked {
  background: var(--green-pale);
  border-color: var(--green-light);
}

.habit-label {
  flex: 1;
}

.habit-label strong { display: block; font-size: 16px; }
.habit-label span { font-size: 13px; color: var(--text-soft); }

.habit-pts {
  font-size: 13px;
  font-weight: 700;
  color: var(--green-mid);
  white-space: nowrap;
}

/* Points preview */
.points-preview {
  text-align: center;
  padding: 16px;
  background: var(--green-pale);
  border-radius: 10px;
  margin: 16px 0;
}

.points-preview .big { font-size: 40px; font-weight: 800; color: var(--green-dark); }
.points-preview .label { font-size: 13px; color: var(--text-soft); margin-top: 2px; }

/* Buttons */
.btn {
  display: block;
  width: 100%;
  background: var(--green-mid);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 16px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: background .15s;
  margin-top: 8px;
}

.btn:hover { background: var(--green-dark); }
.btn:disabled { background: #aaa; cursor: not-allowed; }
.btn-outline {
  background: transparent;
  border: 2px solid var(--green-mid);
  color: var(--green-mid);
}
.btn-outline:hover { background: var(--green-pale); }

/* Form fields */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 16px;
  transition: border-color .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--green-light);
}

/* Weight input */
.weight-input-wrap {
  display: flex;
  align-items: center;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
}
.weight-input-wrap input {
  border: none;
  flex: 1;
  padding: 16px;
  font-size: 28px;
  font-weight: 700;
  text-align: center;
}
.weight-input-wrap input:focus { outline: none; }
.weight-unit {
  padding: 0 16px;
  font-size: 16px;
  color: var(--text-soft);
  font-weight: 600;
}

/* Status messages */
.msg {
  padding: 16px;
  border-radius: 10px;
  font-weight: 600;
  text-align: center;
  margin: 12px 0;
}
.msg-error { background: #fce4e4; color: #b71c1c; }
.msg-success { background: var(--green-pale); color: var(--green-dark); }
.msg-info { background: #e3f2fd; color: #0d47a1; }

/* Success screen */
.success-icon { font-size: 56px; text-align: center; margin: 8px 0; }

/* Leaderboard table */
.leaderboard { width: 100%; border-collapse: collapse; }
.leaderboard th {
  background: var(--green-mid);
  color: #fff;
  padding: 10px 12px;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
}
.leaderboard th:last-child, .leaderboard td:last-child { text-align: right; }
.leaderboard td { padding: 12px; border-bottom: 1px solid #f0f0f0; font-size: 15px; }
.leaderboard tr:last-child td { border-bottom: none; }
.leaderboard tr:nth-child(even) td { background: #fafafa; }
.leaderboard .rank { font-weight: 800; color: var(--green-mid); width: 32px; }
.leaderboard .total { font-weight: 800; color: var(--green-dark); }
.leaderboard .top1 td { background: #fffde7 !important; }

/* Nav */
.nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 0 auto 16px;
  max-width: 480px;
}
.nav a {
  color: var(--green-mid);
  font-size: 14px;
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--green-pale);
  background: #fff;
}
.nav a:hover { background: var(--green-pale); }

/* Spinner */
.spinner {
  text-align: center;
  padding: 40px;
  color: var(--text-soft);
  font-size: 15px;
}

/* Toggle row */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid #f0f0f0;
}
.toggle-row:last-child { border-bottom: none; }

@media (max-width: 400px) {
  .card { padding: 20px 16px; }
  h1 { font-size: 20px; }
}
