:root {
  --bg: #f3efe6;
  --ink: #1c1914;
  --muted: #6b6458;
  --panel: #fffaf2;
  --line: #d9d0c0;
  --accent: #0f6b5c;
  --accent-soft: #d8efe9;
  --warn: #9a3412;
  --map-shade: #e7e1d4;
  --shadow: 0 18px 40px rgba(28, 25, 20, 0.08);
  --radius: 18px;
  --font: "IBM Plex Sans JP", sans-serif;
  --display: "Syne", "IBM Plex Sans JP", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(15, 107, 92, 0.08), transparent 32%),
    linear-gradient(160deg, #f7f3ea 0%, #efe7d8 48%, #e8e0d1 100%);
  color: var(--ink);
  font-family: var(--font);
}

body {
  min-height: 100vh;
}

button,
input,
select {
  font: inherit;
}

.app {
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr;
  min-height: 100vh;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.25rem;
  background: color-mix(in srgb, var(--panel) 92%, white);
  border-right: 1px solid var(--line);
  max-height: 100vh;
  overflow: auto;
}

.panel-header h1 {
  margin: 0.2rem 0 0.6rem;
  font-family: var(--display);
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lede,
.hint,
.panel-footer {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.55;
}

.controls,
.brands-section,
.import-section,
.ranking {
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem;
}

.field {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem 0.75rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.field span {
  grid-column: 1 / -1;
  font-size: 0.82rem;
  color: var(--muted);
}

.field input[type="range"] {
  width: 100%;
}

.button-row {
  display: flex;
  gap: 0.5rem;
}

.ghost {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  cursor: pointer;
}

.ghost:hover {
  background: var(--accent-soft);
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.6rem;
}

.section-title h2,
.ranking-head h2,
.import-section h2 {
  margin: 0;
  font-size: 0.95rem;
}

.brand-list {
  display: grid;
  gap: 0.35rem;
  max-height: 42vh;
  overflow: auto;
  padding-right: 0.2rem;
}

.brand-item {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  padding: 0.35rem 0.2rem;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  font-size: 0.88rem;
}

.brand-item input {
  margin-top: 0.2rem;
}

.brand-meta {
  color: var(--muted);
  font-size: 0.75rem;
}

.brand-meta--muted {
  font-style: italic;
}

.main {
  position: relative;
  min-height: 100vh;
}

#map {
  position: absolute;
  inset: 0;
  background: var(--map-shade);
}

.ranking {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: min(360px, calc(100% - 2rem));
  max-height: calc(100vh - 2rem);
  overflow: auto;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  z-index: 500;
}

.ranking-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.6rem;
}

.ranking-head span,
#brandCount {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.6rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
}

.ranking-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
}

.spot-card {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 14px;
  padding: 0.75rem;
  cursor: pointer;
}

.spot-card:hover,
.spot-card.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.spot-card h3 {
  margin: 0 0 0.25rem;
  font-size: 0.95rem;
}

.spot-card .score {
  color: var(--accent);
  font-weight: 700;
  font-size: 0.82rem;
}

.spot-card .brands {
  margin-top: 0.45rem;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.cluster-icon {
  background: var(--accent);
  color: white;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-weight: 700;
  border: 3px solid white;
  box-shadow: 0 8px 18px rgba(15, 107, 92, 0.28);
}

.empty {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 0.5rem 0.2rem;
}

@media (max-width: 960px) {
  .app {
    grid-template-columns: 1fr;
  }

  .panel {
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .main {
    min-height: 70vh;
  }

  .ranking {
    position: static;
    width: auto;
    max-height: none;
    margin: 0;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }

  #map {
    position: relative;
    height: 55vh;
  }
}
