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

:root {
  --bg: #ffffff;
  --bg-tint: #f8f7f5;
  --bg-card: #ffffff;
  --border: #eae8e4;
  --border-light: #f3f1ee;
  --accent: #6b8f5e;
  --accent-hover: #5a7a4f;
  --sage: #8aaa7c;
  --text: #303030;
  --text-secondary: #888;
  --text-tertiary: #bbb;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 6px 24px rgba(0, 0, 0, 0.06);
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* === Header === */
.header {
  text-align: center;
  padding: 3.5rem 1rem 1rem;
}

.logo {
  font-size: 3.5rem;
  margin-bottom: 0.4rem;
  line-height: 1;
  display: inline-block;
  animation: wobble 3s ease-in-out infinite;
}

@keyframes wobble {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(6deg); }
  75% { transform: rotate(-6deg); }
}

.title {
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.035em;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 400;
  margin-top: 0.2rem;
  font-style: normal;
}

/* === Spinner === */
.spinner-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1rem 1rem;
}

.origin-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.spinner-viewport {
  position: relative;
  width: min(88vw, 360px);
  height: 68px;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--bg-tint);
  border: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.spinner-strip {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  will-change: transform;
}

.spinner-strip__item {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 1rem;
}

.spinner-strip__item--target {
  color: var(--accent);
}

.spinner-mask {
  position: absolute;
  left: 0;
  right: 0;
  height: 18px;
  z-index: 2;
  pointer-events: none;
}

.spinner-mask--top {
  top: 0;
  background: linear-gradient(to bottom, var(--bg-tint), transparent);
}

.spinner-mask--bottom {
  bottom: 0;
  background: linear-gradient(to top, var(--bg-tint), transparent);
}

/* === Buttons === */
.action-section {
  display: flex;
  justify-content: center;
  padding: 0.5rem 1rem 2rem;
}

.btn-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.spin-btn {
  padding: 1rem 3.5rem;
  border: none;
  border-radius: 980px;
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.spin-btn:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.spin-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.spin-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.reset-btn {
  padding: 1rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: 980px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.reset-btn:hover {
  color: var(--text);
  border-color: var(--text-secondary);
}

/* === Filter === */
.filter-section {
  max-width: 380px;
  margin: 0 auto;
  padding: 0 1rem 1.5rem;
}

.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.filter-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}

.filter-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
}

.filter-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2.5px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
  transition: transform 0.1s ease;
}

.filter-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.filter-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2.5px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.filter-value {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  min-width: 44px;
  text-align: right;
}

.type-toggle {
  display: flex;
  justify-content: center;
  gap: 0.25rem;
  margin-top: 0.75rem;
}

.type-btn {
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.35rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 980px;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.type-btn:hover {
  color: var(--text-secondary);
  border-color: var(--text-tertiary);
}

.type-btn--active {
  color: var(--accent);
  border-color: var(--accent);
  background: #edf5f0;
}

.filter-count {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-top: 0.4rem;
}

/* === Result Card === */
.result-section {
  padding: 0.5rem 1rem 1.5rem;
  max-width: 460px;
  margin: 0 auto;
}

.result-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  animation: cardAppear 0.3s ease-out;
  position: relative;
  overflow: hidden;
}

.result-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--sage));
}

@keyframes cardAppear {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.result-header {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.result-name {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.025em;
}

.result-badge {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}

.result-badge--city {
  background: #edf5f2;
  color: var(--sage);
}

.result-badge--village {
  background: #f0ece4;
  color: #8a7a5a;
}

.result-province {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 0.15rem;
}

.result-stats {
  display: flex;
  gap: 2rem;
  margin-top: 1.1rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--border-light);
}

.stat {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.stat-label {
  font-size: 0.65rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
}

/* === Map === */
.map-section {
  padding: 0 1rem 2.5rem;
  max-width: 600px;
  margin: 0 auto;
}

.map-container {
  height: 320px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

/* === Footer === */
.footer {
  text-align: center;
  padding: 2.5rem 1rem 2rem;
  position: relative;
}

.footer::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 500px;
  max-width: 60%;
  height: 1px;
  background: var(--border);
}

.footer-built {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-tertiary);
  letter-spacing: 0.08em;
  margin-bottom: 0.3rem;
}

.footer-built a {
  color: var(--text-secondary);
  font-weight: 600;
  text-decoration: none;
}

.footer-built a:hover {
  color: var(--accent);
}

.footer-credits {
  font-size: 0.68rem;
  color: var(--text-tertiary);
}

.footer-credits a {
  color: var(--text-tertiary);
}

.footer-credits a:hover {
  color: var(--text-secondary);
}

/* === Bounce animation === */
@keyframes bounce {
  0% { transform: translateY(0); }
  30% { transform: translateY(-5px); }
  50% { transform: translateY(0); }
  70% { transform: translateY(-2px); }
  100% { transform: translateY(0); }
}

.result-card--bounce {
  animation: cardAppear 0.3s ease-out, bounce 0.35s ease 0.3s;
}

/* === Responsive === */
@media (max-width: 480px) {
  .header {
    padding-top: 2.5rem;
  }

  .logo {
    font-size: 2.8rem;
  }

  .spinner-viewport {
    height: 58px;
  }

  .spinner-strip__item {
    height: 58px;
    font-size: 1.05rem;
  }

  .spin-btn {
    font-size: 1.05rem;
    padding: 0.85rem 2.5rem;
  }

  .filter-bar {
    gap: 0.4rem;
  }

  .result-name {
    font-size: 1.2rem;
  }

  .result-stats {
    gap: 1.25rem;
  }

  .map-container {
    height: 250px;
  }
}
