:root {
  --purple: #6d28d9;
  --purple-light: #8b5cf6;
  --bg: #f5f3ff;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --gold: #f59e0b;
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, "Heebo", sans-serif;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}

.topbar {
  background: linear-gradient(135deg, var(--purple), var(--purple-light));
  color: white;
  padding: calc(16px + env(safe-area-inset-top)) 20px 18px;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}

.outings-counter {
  background: var(--card);
  color: var(--purple);
  text-align: center;
  font-weight: 700;
  font-size: 14px;
  padding: 10px 16px;
  border-bottom: 1px solid #ece9f8;
  letter-spacing: 0.2px;
}
.outings-counter.warn {
  color: #d97706;
}
.outings-counter.full {
  color: #dc2626;
}

.tabs {
  display: flex;
  background: var(--card);
  position: sticky;
  top: 0;
  z-index: 9;
  border-bottom: 1px solid #ece9f8;
}
.tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 14px 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
}
.tab-btn.active {
  color: var(--purple);
  border-bottom-color: var(--purple);
}

main {
  flex: 1;
  padding: 16px;
  padding-bottom: 32px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.banner {
  background: linear-gradient(135deg, #fde68a, #f59e0b);
  color: #452c00;
  padding: 14px 16px;
  border-radius: var(--radius);
  font-weight: 700;
  margin-bottom: 16px;
  text-align: center;
  font-size: 15px;
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.leader-row {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.leader-row.top {
  background: linear-gradient(135deg, #ede9fe, #ddd6fe);
  border: 2px solid var(--purple-light);
}
.leader-name {
  font-weight: 700;
  font-size: 17px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.leader-score {
  font-size: 20px;
  font-weight: 800;
  color: var(--purple);
}
.crown { font-size: 18px; }

.hint {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  margin-top: 18px;
  line-height: 1.6;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: none;
  padding: 0;
  margin: 0;
}
.field span, .field legend {
  font-weight: 600;
  font-size: 14px;
  color: var(--muted);
  padding: 0;
}
.field input {
  font-size: 16px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #ddd6fe;
  background: #faf9ff;
  color: var(--text);
  width: 100%;
}
.field input:focus {
  outline: none;
  border-color: var(--purple-light);
}

.checkbox-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #faf9ff;
  border: 1px solid #ddd6fe;
  border-radius: 10px;
  padding: 12px;
  font-weight: 600;
  cursor: pointer;
}
.check-item input {
  width: 20px;
  height: 20px;
  accent-color: var(--purple);
}
.check-item.checked {
  background: #ede9fe;
  border-color: var(--purple);
}

.primary-btn {
  background: var(--purple);
  color: white;
  border: none;
  padding: 14px;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
.primary-btn:active { opacity: 0.85; }

.msg {
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  min-height: 18px;
}
.msg.success { color: #16a34a; }
.msg.error { color: #dc2626; }

.search-bar { margin-bottom: 14px; }
.search-bar input {
  width: 100%;
  font-size: 15px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #ddd6fe;
  background: var(--card);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-item {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  position: relative;
}
.history-item .hi-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}
.history-item .hi-date {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}
.history-item .hi-dest {
  font-size: 16px;
  font-weight: 700;
  margin: 2px 0 8px;
}
.history-item .hi-attendees {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.attendee-chip {
  background: #ede9fe;
  color: var(--purple);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
}
.hi-delete {
  position: absolute;
  left: 12px;
  top: 12px;
  background: none;
  border: none;
  color: #d1d5db;
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
}
.hi-delete:active { color: #dc2626; }

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 40px 10px;
  font-size: 14px;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1f2937;
  color: white;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 100;
  max-width: 90%;
  text-align: center;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
