:root {
  color-scheme: light;
  --ink: #17231c;
  --muted: #647068;
  --paper: #f6f2ea;
  --panel: rgba(255, 255, 255, 0.86);
  --line: rgba(23, 35, 28, 0.14);
  --accent: #d94b35;
  --accent-dark: #a92d1c;
  --green: #244f3b;
  --shadow: 0 18px 50px rgba(29, 45, 36, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 0%, rgba(217, 75, 53, 0.12), transparent 30rem),
    linear-gradient(135deg, #fbf8f2 0%, #eef2e8 100%);
  font-family: "M PLUS Rounded 1c", "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
  font-weight: 400;
}

button,
select {
  font: inherit;
}

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

.daily-link {
  padding: 10px 16px;
  border-radius: 999px;
  color: white;
  background: var(--green);
  box-shadow: 0 8px 24px rgba(36, 79, 59, 0.18);
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none;
}

.daily-link:hover {
  background: #173c2b;
}

button,
select,
.leaflet-control a {
  outline-offset: 3px;
}

button:focus-visible,
select:focus-visible,
.leaflet-control a:focus-visible {
  outline: 3px solid rgba(217, 75, 53, 0.42);
}

.app-shell {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 16px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 12px;
}

.title-block {
  min-width: 0;
}

.eyebrow,
.status-label {
  margin: 0 0 3px;
  color: var(--accent-dark);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
}

h1 {
  display: flex;
  flex-wrap: wrap;
  margin: 0;
  font-size: clamp(1.25rem, 2.35vw, 1.5rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.08;
}

.title-accent {
  color: #000;
}

.municipality-name {
  color: var(--accent);
}

.lead {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: clamp(0.78rem, 1.5vw, 0.94rem);
}

.icon-button,
.map-reset,
.text-button,
.auto-button,
.start-button {
  border: 0;
  cursor: pointer;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
  box-shadow: 0 8px 28px rgba(29, 45, 36, 0.08);
  font-size: 1.25rem;
}

.game-panel {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  align-items: center;
  min-height: 106px;
  gap: 18px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 24px 24px 0 0;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.game-copy {
  min-width: 0;
}

.roulette {
  min-height: 2rem;
  overflow: hidden;
  font-size: clamp(1.3rem, 2.8vw, 2rem);
  font-weight: 800;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.answer {
  min-height: 1.25rem;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.controls {
  display: grid;
  grid-template-columns: minmax(116px, 1.2fr) minmax(88px, 0.8fr) auto auto;
  align-items: end;
  gap: 8px;
}

.prefecture-filter,
.time-filter {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
}

.prefecture-filter select,
.time-filter select {
  width: 100%;
  min-height: 44px;
  padding: 0 32px 0 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink);
  background: #fff;
}

.auto-button {
  display: grid;
  min-width: 72px;
  min-height: 44px;
  place-content: center;
  gap: 1px;
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink);
  background: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.05;
}

.auto-state {
  color: var(--muted);
  font-size: 0.62rem;
}

.auto-button[aria-pressed="true"] {
  border-color: var(--green);
  color: white;
  background: var(--green);
}

.auto-button[aria-pressed="true"] .auto-state {
  color: rgba(255, 255, 255, 0.78);
}

.start-button {
  min-width: 116px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  color: white;
  background: var(--accent);
  box-shadow: 0 10px 24px rgba(169, 45, 28, 0.24);
  font-weight: 700;
  letter-spacing: 0.06em;
  transition: transform 160ms ease, background 160ms ease;
}

.start-button:hover:not(:disabled) {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

.start-button:disabled,
.map-reset:disabled,
.prefecture-filter select:disabled,
.time-filter select:disabled {
  cursor: wait;
  opacity: 0.52;
}

.map-panel {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 24px 24px;
  background: #dfe7dc;
  box-shadow: var(--shadow);
}

#map {
  width: 100%;
  height: min(70vh, 720px);
  min-height: 480px;
  background: #e8ede6;
}

.countdown {
  position: absolute;
  z-index: 900;
  top: 24px;
  left: 50%;
  display: grid;
  width: 1.2em;
  height: 1.2em;
  place-items: center;
  pointer-events: none;
  color: var(--accent-dark);
  font-size: clamp(4.5rem, 8vw, 6rem);
  font-weight: 800;
  line-height: 1;
  transform: translateX(-50%);
}

.countdown[aria-hidden="true"] {
  visibility: hidden;
}

.map-reset {
  position: absolute;
  z-index: 800;
  top: 14px;
  right: 14px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 6px 18px rgba(29, 45, 36, 0.1);
  font-size: 0.8rem;
  font-weight: 700;
}

.round-progress {
  position: absolute;
  z-index: 800;
  right: 14px;
  bottom: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 6px 18px rgba(29, 45, 36, 0.1);
  font-size: 0.76rem;
  font-weight: 700;
}

.text-button {
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--accent-dark);
  background: transparent;
  font-size: 0.72rem;
  font-weight: 700;
}

footer {
  padding: 14px 4px 0;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.6;
}

footer p {
  margin: 0;
}

.leaflet-control-layers,
.leaflet-control-zoom {
  border: 0 !important;
  box-shadow: 0 6px 22px rgba(29, 45, 36, 0.16) !important;
}

.leaflet-control-layers-expanded {
  border-radius: 12px;
}

.municipality-shape {
  filter: drop-shadow(0 7px 8px rgba(88, 20, 10, 0.2));
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 16px, 1240px);
    padding-top: 12px;
  }

  .app-header {
    margin-bottom: 10px;
  }

  h1 {
    font-size: clamp(1.25rem, 5.25vw, 1.47rem);
  }

  .game-panel {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    min-height: 194px;
    padding: 14px;
    border-radius: 20px 20px 0 0;
  }

  .controls {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(78px, 0.8fr) 68px;
  }

  .start-button {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
  }

  .countdown {
    top: 18px;
    width: 1.2em;
    height: 1.2em;
    font-size: 4.5rem;
  }

  .map-panel {
    border-radius: 0 0 20px 20px;
  }

  #map {
    height: 64vh;
    min-height: 430px;
  }

  .round-progress {
    right: 10px;
    bottom: 10px;
  }
}

@media (min-width: 721px) and (max-width: 1040px) {
  .game-panel {
    grid-template-columns: minmax(0, 1fr);
  }

  .controls {
    grid-column: 1 / -1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
