*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-alt: #f1f5f9;
  --text: #1e293b;
  --text-muted: #64748b;
  --accent: #2563eb;
  --accent-light: #3b82f6;
  --green: #16a34a;
  --yellow: #ca8a04;
  --muted: #94a3b8;
  --border: #e2e8f0;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
}

html {
  font-size: 16px;
}

body {
  font-family: "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 1.5rem;
}

.header {
  text-align: center;
  margin-bottom: 2rem;
}

.header__title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text);
}

.header__subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

/* Loading */

.loading {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
  font-size: 1rem;
}

.loading-spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 0.5rem;
  vertical-align: middle;
}

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

/* Form */

.form-section {
  max-width: 900px;
  margin: 0 auto 2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem;
}

.form-label {
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  color: var(--text-muted);
  gap: 0.4rem;
}

.form-select {
  appearance: none;
  background: var(--bg-card-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  cursor: pointer;
}

.form-select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-diagnose {
  display: block;
  width: 100%;
  max-width: 280px;
  margin: 1.25rem auto 0;
  padding: 0.85rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-diagnose:hover:not(:disabled) {
  background: var(--accent-light);
}

.btn-diagnose:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Report */

.report {
  max-width: 900px;
  margin: 0 auto;
  animation: fadeIn 0.4s ease;
}

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

.report__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.card__title {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Score */

.card--score {
  text-align: center;
}

.score-gauge {
  width: 180px;
  margin: 0 auto;
}

.gauge-svg {
  width: 100%;
  height: auto;
}

.score-number {
  font-size: 2.8rem;
  font-weight: 800;
  line-height: 1;
  margin-top: 0.5rem;
}

.score-unit {
  font-size: 1rem;
  font-weight: 400;
  color: var(--text-muted);
}

.score-label {
  font-size: 1.1rem;
  font-weight: 700;
  margin-top: 0.4rem;
}

.score-comment {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
  line-height: 1.5;
}

/* Density */

.card__headline {
  font-size: 1rem;
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

.card__headline strong {
  color: var(--accent);
  font-size: 1.3rem;
}

.chart-container {
  position: relative;
  height: 200px;
}

.chart-container--small {
  height: 160px;
}

/* Per capita */

.stat-big {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.2;
}

.stat-sub {
  font-size: 1rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.stat-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  line-height: 1.5;
}

/* Population */

.pop-stats {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1rem;
}

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

.pop-stat__label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.pop-stat__value {
  font-size: 1.4rem;
  font-weight: 700;
  margin-top: 0.15rem;
}

/* Map */

.card--map {
  margin-bottom: 1rem;
}

.map-container {
  height: 360px;
  border-radius: 8px;
  overflow: hidden;
}

.map-summary {
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

.map-summary strong {
  color: var(--accent);
}

.competitor-pin {
  background: none;
  border: none;
}

.pin-dot {
  width: 14px;
  height: 14px;
  background: rgba(239, 68, 68, 0.7);
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.center-pin {
  background: none;
  border: none;
}

.center-dot {
  width: 20px;
  height: 20px;
  background: var(--accent);
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.5), 0 1px 4px rgba(0, 0, 0, 0.3);
}

/* Talk */

.card--talk {
  margin-bottom: 1rem;
}

.talk-box {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  background: var(--bg-card-alt);
  border-radius: 8px;
  padding: 1rem 1.25rem;
}

.talk-text {
  flex: 1;
  font-size: 1rem;
  line-height: 1.7;
}

.btn-copy {
  flex-shrink: 0;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.btn-copy:hover {
  background: var(--accent-light);
}

/* Footer */

.report__footer {
  text-align: center;
  padding: 1.5rem 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Responsive */

@media (max-width: 768px) {
  .form-row {
    grid-template-columns: 1fr;
  }

  .report__grid {
    grid-template-columns: 1fr;
  }

  .score-number {
    font-size: 2.2rem;
  }
}

/* Print */

@media print {
  body {
    background: #fff;
    color: #1a1a1a;
    padding: 0;
  }

  .form-section {
    display: none;
  }

  .card {
    border: 1px solid #ddd;
    box-shadow: none;
    break-inside: avoid;
  }

  .card__title {
    color: #666;
  }

  .btn-copy {
    display: none;
  }

  .report {
    animation: none;
  }
}
