:root {
  --bg: #fff0f5;
  --bg-alt: #ffffff;
  --text: #3a2430;
  --muted: #9c7a89;
  --primary: #ff5c93;
  --primary-dark: #d94f7c;
  --accent: #2fb8a6;
  --locked: #f4d9e4;
  --card-shadow: 0 4px 16px rgba(58, 36, 48, 0.08);
  --radius: 18px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #241820;
    --bg-alt: #34222c;
    --text: #f7e9f0;
    --muted: #c9a3b7;
    --locked: #4a3340;
    --card-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 40px;
}

header.top {
  padding: 28px 20px 18px;
  text-align: center;
}

header.top h1 {
  margin: 0;
  font-size: 1.5rem;
}

header.top p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.hero {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border-radius: var(--radius);
  padding: 28px 22px;
  text-align: center;
  box-shadow: var(--card-shadow);
}

.hero .total {
  font-size: 3rem;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.hero .total span { font-size: 1.4rem; font-weight: 600; opacity: 0.85; }

.hero .sub {
  margin-top: 6px;
  opacity: 0.9;
  font-size: 0.92rem;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (min-width: 420px) {
  .stat-row {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat-chip {
  background: var(--bg-alt);
  border-radius: 14px;
  padding: 12px 8px;
  text-align: center;
  box-shadow: var(--card-shadow);
}

.stat-chip .value { font-size: 1.2rem; font-weight: 700; }
.stat-chip .label { font-size: 0.72rem; color: var(--muted); margin-top: 2px; }

section.card {
  background: var(--bg-alt);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--card-shadow);
}

section.card h2 {
  margin: 0 0 12px;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

form.run-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

form.run-form .row {
  display: flex;
  gap: 10px;
}

input, select, textarea {
  font: inherit;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--locked);
  background: var(--bg);
  color: var(--text);
  width: 100%;
}

button {
  font: inherit;
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  background: var(--primary);
  color: white;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.2s ease;
}

button:active { transform: scale(0.97); }
button.secondary {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}
button.ghost {
  background: transparent;
  color: var(--muted);
  padding: 6px 10px;
  font-weight: 500;
}

.run-list, .goal-list, .surprise-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.run-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 4px;
  border-bottom: 1px solid var(--locked);
}
.run-item:last-child { border-bottom: none; }
.run-item .meta { font-size: 0.8rem; color: var(--muted); }
.run-item .km { font-weight: 700; }

.goal-item, .surprise-item {
  border-radius: 14px;
  padding: 14px;
  background: var(--bg);
}

.goal-item.achieved, .surprise-item.unlocked {
  background: linear-gradient(135deg, rgba(47,184,166,0.15), rgba(47,184,166,0.05)), var(--bg);
}

.swipe-wrap {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
}

.swipe-bg {
  position: absolute;
  inset: 0;
  background: var(--primary-dark);
  color: white;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 18px;
  font-weight: 600;
  font-size: 0.85rem;
}

.swipe-wrap .goal-item, .swipe-wrap .surprise-item {
  position: relative;
  touch-action: pan-y;
  cursor: grab;
  transition: transform 0.25s ease, opacity 0.2s ease;
}

.swipe-hint {
  font-size: 0.72rem;
  color: var(--muted);
  text-align: center;
  margin: 8px 0 0;
}

#hidden-goal-list .goal-item, #hidden-surprise-list .surprise-item {
  opacity: 0.85;
}

#hidden-goal-list .goal-item button, #hidden-surprise-list .surprise-item button {
  margin-top: 8px;
}

.goal-title, .surprise-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  margin-bottom: 6px;
}

.progress-track {
  height: 10px;
  border-radius: 6px;
  background: var(--locked);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 6px;
  width: 0%;
  transition: width 0.9s cubic-bezier(.22,1,.36,1);
}

.progress-label {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 4px;
}

.surprise-item.locked {
  border: 1.5px dashed var(--locked);
}

.surprise-icon { font-size: 1.1rem; }

.surprise-reward {
  margin-top: 8px;
  font-size: 0.95rem;
  padding: 10px 12px;
  background: var(--bg-alt);
  border-radius: 10px;
}

.empty-hint {
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
  padding: 8px 0;
}

.footer-link {
  text-align: center;
  padding: 10px;
}
.footer-link a { color: var(--muted); font-size: 0.8rem; text-decoration: none; }

/* --- Reveal overlay --- */
#reveal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 12, 0.72);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 24px;
}
#reveal-overlay.show { display: flex; }

.reveal-card {
  background: var(--bg-alt);
  border-radius: 24px;
  padding: 30px 26px;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  animation: pop-in 0.5s cubic-bezier(.22,1.4,.36,1);
}

@keyframes pop-in {
  from { transform: scale(0.7) rotate(-4deg); opacity: 0; }
  to { transform: scale(1) rotate(0); opacity: 1; }
}

.reveal-card .kicker {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  font-weight: 700;
  margin-bottom: 8px;
}

.reveal-card h3 { margin: 0 0 12px; font-size: 1.3rem; }
.reveal-card p { margin: 0 0 18px; color: var(--text); font-size: 1.05rem; }

canvas#confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 60;
}

.pin-screen {
  max-width: 340px;
  margin: 80px auto;
  text-align: center;
  padding: 0 20px;
}
.pin-screen input {
  text-align: center;
  font-size: 1.4rem;
  letter-spacing: 0.3em;
}
.error-text { color: #d1483a; font-size: 0.85rem; min-height: 1.2em; margin-top: 8px; }

.condition-hint {
  font-size: 0.72rem;
  color: var(--muted);
}
