:root {
  color-scheme: light;
  --ink: #1b1f23;
  --muted: #65717f;
  --paper: #f7f4ee;
  --surface: #ffffff;
  --line: #d9d2c6;
  --red: #b3261e;
  --indigo: #263b62;
  --green: #2f6f63;
  --gold: #b8872d;
  --shadow: 0 18px 50px rgba(31, 37, 45, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(120deg, rgba(179, 38, 30, 0.08), transparent 32%),
    linear-gradient(240deg, rgba(47, 111, 99, 0.12), transparent 36%),
    var(--paper);
  color: var(--ink);
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  min-height: calc(100vh - 88px);
  margin: 32px auto 16px;
  display: grid;
  grid-template-columns: minmax(300px, 0.9fr) minmax(320px, 1fr);
  grid-template-rows: auto minmax(360px, 1fr);
  gap: 18px;
}

.control-panel,
.result-panel,
.map-panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.control-panel {
  padding: 28px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 28px;
}

.headline {
  display: grid;
  gap: 12px;
}

.kicker {
  margin: 0;
  color: var(--red);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2.45rem, 4vw, 4.3rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.lead {
  max-width: 34rem;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.75;
}

.controls {
  display: grid;
  gap: 18px;
}

.mode-group {
  min-width: 0;
  margin: 0;
  padding: 5px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f1ede5;
}

.mode-group legend {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.mode-option {
  min-height: 48px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.mode-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-option:has(input:checked) {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 2px 9px rgba(31, 37, 45, 0.12);
}

.mode-option:focus-within {
  outline: 3px solid rgba(47, 111, 99, 0.28);
  outline-offset: 2px;
}

.draw-button {
  min-height: 56px;
  border: 0;
  border-radius: 8px;
  background: var(--red);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(179, 38, 30, 0.22);
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background-color 160ms ease;
}

.draw-button:hover {
  background: #981c17;
  transform: translateY(-1px);
  box-shadow: 0 16px 28px rgba(179, 38, 30, 0.26);
}

.draw-button:active {
  transform: translateY(0);
}

.draw-button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.stats-strip > div {
  min-height: 76px;
  padding: 14px;
  border-left: 4px solid var(--gold);
  background: #fbfaf6;
}

.stat-value,
.stat-label {
  display: block;
}

.stat-value {
  font-size: 1.35rem;
  font-weight: 800;
}

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

.result-panel {
  padding: 28px;
  display: grid;
  align-content: center;
}

.result-empty {
  display: grid;
  gap: 8px;
  color: var(--muted);
  line-height: 1.7;
}

.empty-title {
  color: var(--ink);
  font-size: 1.35rem;
  font-weight: 800;
}

.result-content {
  display: grid;
  gap: 20px;
}

.hidden {
  display: none;
}

.result-prefecture {
  color: var(--green);
  font-weight: 800;
}

h2 {
  overflow-wrap: anywhere;
  font-size: clamp(2rem, 3vw, 3.3rem);
  line-height: 1.12;
  letter-spacing: 0;
}

.metric-grid {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.metric-grid div {
  min-height: 92px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf6;
}

.metric-grid dt {
  color: var(--muted);
  font-size: 0.82rem;
}

.metric-grid dd {
  margin: 8px 0 0;
  display: grid;
  gap: 5px;
  overflow-wrap: anywhere;
  font-size: 1.16rem;
  font-weight: 800;
}

.metric-rank {
  color: var(--green);
  font-size: 0.84rem;
  font-weight: 800;
}

.map-link {
  width: fit-content;
  min-height: 44px;
  padding: 10px 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--indigo);
  border-radius: 8px;
  color: var(--indigo);
  font-weight: 800;
  text-decoration: none;
}

.map-link:hover {
  background: var(--indigo);
  color: #fff;
}

.map-panel {
  grid-column: 1 / -1;
  min-height: 360px;
  overflow: hidden;
}

.map-panel iframe {
  width: 100%;
  height: 100%;
  min-height: 360px;
  display: block;
  border: 0;
}

.site-footer {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto 28px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.7;
}

@media (max-width: 780px) {
  .app-shell {
    width: min(100% - 20px, 560px);
    min-height: auto;
    margin-top: 10px;
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    gap: 12px;
  }

  .control-panel,
  .result-panel {
    padding: 20px;
  }

  .stats-strip,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .mode-group {
    grid-template-columns: 1fr;
  }

  .map-panel,
  .map-panel iframe {
    min-height: 300px;
  }

  .site-footer {
    width: min(100% - 20px, 560px);
  }
}
