:root {
  --green: #2f7d3c;
  --green-mid: #3f9d4e;
  --green-dark: #256a31;
  --paper: #f4f2ec;
  --ink: #333a35;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Segoe UI', 'PT Sans', system-ui, -apple-system, Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

.app {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-header {
  flex: 0 0 auto;
  background: linear-gradient(135deg, var(--green) 0%, var(--green-mid) 100%);
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(31, 74, 40, 0.25);
  z-index: 10;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-leaf {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  filter: drop-shadow(0 1px 2px rgba(0, 40, 10, 0.35));
}

.brand h1 {
  margin: 0;
  font-size: clamp(1.02rem, 2.2vw, 1.3rem);
  font-weight: 700;
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand p {
  margin: 2px 0 0;
  font-size: 0.8rem;
  opacity: 0.92;
}

.header-note {
  flex: 0 0 auto;
  font-size: 0.75rem;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.35);
  white-space: nowrap;
}

.map-wrap {
  flex: 1 1 auto;
  position: relative;
  min-height: 0;
  background: #eef0e8;
}

#map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}

#map.dragging { cursor: grabbing; }

.building {
  fill: #d9d2c7;
  stroke: #b7ada0;
}

.waterline {
  fill: none;
  stroke: #a9cfe3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.rail {
  fill: none;
  stroke: #a09a8e;
}

.rail-dash {
  fill: none;
  stroke: #f6f4ec;
}

.road {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#g-road-major-casing { stroke: #cfc3a6; }
#g-road-major { stroke: #fdfcf5; }
#g-road-secondary-casing { stroke: #d3cab1; }
#g-road-secondary { stroke: #fefdf8; }
#g-road-minor-casing { stroke: #d6cdb5; }
#g-road-minor { stroke: #ffffff; }
#g-road-service-casing { stroke: #d8d0ba; }
#g-road-service { stroke: #f8f6ef; }
#g-road-path { stroke: #c9bd9e; }

.label {
  fill: #6b665a;
  paint-order: stroke;
  stroke: rgba(252, 251, 246, 0.88);
  stroke-linejoin: round;
  font-family: inherit;
  pointer-events: none;
}

.label-road { fill: #7a7466; }

.label-area {
  fill: #44713f;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.label-poi {
  fill: #5f6a61;
  font-weight: 600;
}

.label-school {
  fill: #a04b32;
  font-weight: 700;
}

.poi-dot {
  fill: #8a8375;
  pointer-events: none;
}

.marker { cursor: pointer; }

.marker-halo {
  fill: var(--green-mid);
  opacity: 0.16;
}

.marker-ring {
  fill: rgba(255, 255, 255, 0.93);
  stroke: var(--green);
  stroke-width: 1.2;
}

.marker.flash .marker-ring { animation: ring-flash 0.7s ease-out 3; }

@keyframes ring-flash {
  0% { stroke-width: 1.2; }
  50% { stroke-width: 3.2; }
  100% { stroke-width: 1.2; }
}

.map-controls {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 5;
}

.map-controls button {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(60, 80, 60, 0.18);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--green-dark);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(30, 50, 30, 0.18);
}

.map-controls button:hover { background: #ffffff; }

.map-controls button:focus-visible {
  outline: 2px solid var(--green-mid);
  outline-offset: 1px;
}

.legend {
  position: absolute;
  left: 14px;
  bottom: 40px;
  z-index: 5;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.93);
  border: 1px solid rgba(60, 80, 60, 0.12);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.75rem;
  color: #4a544c;
  box-shadow: 0 1px 5px rgba(30, 50, 30, 0.12);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1;
}

.chip {
  width: 15px;
  height: 15px;
  border-radius: 4px;
  display: inline-block;
  border: 1px solid rgba(0, 0, 0, 0.16);
}

.chip-clover {
  width: 17px;
  height: 17px;
  display: inline-block;
}

.hint {
  position: absolute;
  left: 50%;
  bottom: 42px;
  transform: translateX(-50%);
  z-index: 5;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(60, 80, 60, 0.14);
  color: #38543e;
  font-size: 0.8rem;
  padding: 8px 16px;
  border-radius: 999px;
  box-shadow: 0 1px 5px rgba(30, 50, 30, 0.15);
  white-space: nowrap;
  transition: opacity 0.5s;
  pointer-events: none;
}

.hint.hide { opacity: 0; }

.attribution {
  position: absolute;
  right: 14px;
  bottom: 36px;
  z-index: 5;
  pointer-events: none;
  font-size: 0.66rem;
  color: #6a7269;
  background: rgba(255, 255, 255, 0.82);
  padding: 3px 8px;
  border-radius: 8px;
}

.coord-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  height: 28px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  background: rgba(37, 48, 38, 0.88);
  color: #e8efe6;
  font-size: 0.76rem;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}

.coord-label {
  color: #b9c9b6;
}

.coord-value {
  font-family: Consolas, 'Courier New', monospace;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(24, 33, 26, 0.55);
  animation: fade-in 0.2s ease-out;
}

.modal-overlay[hidden] { display: none; }

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  position: relative;
  background: #ffffff;
  border-radius: 16px;
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  overflow: auto;
  box-shadow: 0 18px 50px rgba(10, 30, 15, 0.35);
  animation: pop 0.24s ease-out;
}

@keyframes pop {
  from { transform: translateY(14px) scale(0.98); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.93);
  color: #33413a;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  z-index: 2;
}

.modal-close:hover { background: #ffffff; }

.modal-photo {
  width: 100%;
  height: 250px;
  object-fit: cover;
  display: block;
  background: #e7eae2;
}

.modal-body { padding: 18px 22px 6px; }

.modal-body h2 {
  margin: 0;
  color: var(--green-dark);
  font-size: 1.35rem;
}

.latin {
  margin: 2px 0 12px;
  color: #7b847c;
  font-style: italic;
  font-size: 0.92rem;
}

.facts {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  border: 1px solid #e4e7df;
  border-radius: 10px;
  overflow: hidden;
}

.facts li {
  display: flex;
  gap: 12px;
  padding: 8px 12px;
  font-size: 0.9rem;
}

.facts li + li { border-top: 1px solid #eef0ea; }

.fact-label {
  flex: 0 0 118px;
  color: #5f6a61;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-top: 3px;
}

.fact-value { flex: 1; color: #333a35; }

.desc {
  margin: 0;
  font-size: 0.94rem;
  line-height: 1.55;
  color: #3c4440;
}

.modal-actions {
  display: flex;
  gap: 10px;
  padding: 16px 22px 20px;
}

.btn {
  border: 0;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
}

.btn-primary {
  background: var(--green-mid);
  color: #ffffff;
}

.btn-primary:hover { background: #379047; }

.btn-ghost {
  background: #eef1ea;
  color: #2f4a35;
}

.btn-ghost:hover { background: #e3e8df; }

.btn:focus-visible {
  outline: 2px solid var(--green-dark);
  outline-offset: 1px;
}

@media (max-width: 640px) {
  .header-inner { padding: 8px 12px; }
  .header-note { display: none; }
  .legend { display: none; }
  .hint { display: none; }
  .modal-photo { height: 190px; }
  .modal-body { padding: 14px 16px 4px; }
  .modal-actions { padding: 12px 16px 16px; flex-wrap: wrap; }
}
