/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f1f5f9;
  --card-bg: #ffffff;
  --header-bg: #1e3a5f;
  --header-text: #ffffff;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #16a34a;
  --success-hover: #15803d;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --warning: #d97706;
  --muted: #64748b;
  --border: #e2e8f0;
  --radius: 12px;
  --shadow: 0 1px 4px rgba(0,0,0,.08);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html { font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: #1e293b;
  min-height: 100vh;
  overscroll-behavior: none;
}

/* ── Header ── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  color: var(--header-text);
  padding: 14px 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

.header-counter {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.counter-main {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -.5px;
  line-height: 1.2;
}

.counter-sub {
  font-size: 12px;
  opacity: .75;
  font-weight: 400;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.edit-toggle {
  padding: 7px 14px;
  border-radius: 20px;
  border: 2px solid rgba(255,255,255,.4);
  background: transparent;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  white-space: nowrap;
}

.edit-toggle.active {
  background: rgba(255,255,255,.2);
  border-color: #fff;
}

.resort-btn {
  padding: 7px 10px;
  border-radius: 20px;
  border: 2px solid rgba(255,255,255,.4);
  background: transparent;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  transition: background .15s;
}

.resort-btn:hover { background: rgba(255,255,255,.15); }

/* ── Main scroll area ── */
.main {
  padding: 12px 12px 80px;
  max-width: 500px;
  margin: 0 auto;
}

/* ── Year cards ── */
.year-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.year-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 14px 10px;
  border-bottom: 1px solid var(--border);
}

.year-label {
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
  min-width: 48px;
}

.badge-manual {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  border-radius: 4px;
  padding: 2px 6px;
}

.year-count {
  font-size: 12px;
  color: var(--muted);
  margin-left: auto;
}

.empty-year-btn {
  font-size: 12px;
  padding: 4px 10px;
  margin-left: auto;
  border-radius: 8px;
  border: 1px solid var(--danger);
  background: #fff;
  color: var(--danger);
  cursor: pointer;
  font-weight: 500;
  white-space: nowrap;
  transition: background .12s;
}

.empty-year-btn:hover { background: #fef2f2; }

/* ── Country list ── */
.country-list { padding: 4px 0; }

.country-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 14px;
  gap: 8px;
  border-bottom: 1px solid #f8fafc;
}

.country-item:last-child { border-bottom: none; }

.country-name {
  font-size: 14px;
  color: #1e293b;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.country-score {
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
}

.visited-btn {
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 8px;
  border: 1px solid var(--success);
  background: #fff;
  color: var(--success);
  cursor: pointer;
  font-weight: 500;
  flex-shrink: 0;
  white-space: nowrap;
  transition: background .12s;
}

.visited-btn:hover { background: #f0fdf4; }

/* ── Add country search ── */
.add-country-section {
  padding: 8px 12px 12px;
  border-top: 1px solid var(--border);
}

.add-country-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  margin-bottom: 6px;
}

.search-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
  background: #f8fafc;
}

.search-input:focus {
  border-color: var(--primary);
  background: #fff;
}

.search-results {
  margin-top: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow);
}

.search-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  font-size: 14px;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
  transition: background .1s;
  gap: 8px;
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: #f0f9ff; }

.search-result-item .region-tag {
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
}

.no-results {
  padding: 10px 12px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

/* ── Visited section ── */
.visited-section {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-top: 4px;
}

.visited-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--border);
}

.visited-header h2 {
  font-size: 16px;
  font-weight: 700;
  flex: 1;
}

.visited-toggle-icon {
  font-size: 13px;
  color: var(--muted);
  transition: transform .2s;
}

.visited-toggle-icon.open { transform: rotate(180deg); }

.visited-list { padding: 4px 0; }

.visited-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 14px;
  border-bottom: 1px solid #f8fafc;
  gap: 8px;
}

.visited-item:last-child { border-bottom: none; }

.visited-item .country-name { color: var(--muted); }

.unmark-btn {
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .12s, color .12s;
}

.unmark-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background .15s, transform .1s;
}

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

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-full { width: 100%; }

/* ── Modal ── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(2px);
}

.modal-box {
  position: relative;
  background: #fff;
  border-radius: 16px;
  padding: 28px 24px 24px;
  width: calc(100% - 48px);
  max-width: 360px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}

.modal-box h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
  text-align: center;
}

.modal-box input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  outline: none;
  margin-bottom: 12px;
  transition: border-color .15s;
}

.modal-box input:focus { border-color: var(--primary); }

.auth-error {
  font-size: 13px;
  color: var(--danger);
  text-align: center;
  margin-bottom: 10px;
  margin-top: -4px;
}

.auth-error.hidden { display: none; }

/* ── Loading ── */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 16px;
  color: var(--muted);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

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

/* ── Empty year card ── */
.empty-year-msg {
  padding: 12px 14px;
  font-size: 13px;
  color: var(--muted);
  font-style: italic;
}

/* ── Score dot ── */
.score-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Visited pre-count note ── */
.pre-count-note {
  font-size: 12px;
  color: var(--muted);
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  font-style: italic;
}

/* ── Section divider ── */
.section-divider {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--muted);
  padding: 12px 0 6px;
}
